]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
Rename option acl2os9mode to acl2uarights
[netatalk.git] / etc / afpd / afp_options.c
1 /*
2  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3  * Copyright (c) 1990,1993 Regents of The University of Michigan.
4  * All Rights Reserved.  See COPYRIGHT.
5  *
6  * modified from main.c. this handles afp options.
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif /* HAVE_CONFIG_H */
12
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 /* STDC check */
17 #if STDC_HEADERS
18 #include <string.h>
19 #else /* STDC_HEADERS */
20 #ifndef HAVE_STRCHR
21 #define strchr index
22 #define strrchr index
23 #endif /* HAVE_STRCHR */
24 char *strchr (), *strrchr ();
25 #ifndef HAVE_MEMCPY
26 #define memcpy(d,s,n) bcopy ((s), (d), (n))
27 #define memmove(d,s,n) bcopy ((s), (d), (n))
28 #endif /* ! HAVE_MEMCPY */
29 #endif /* STDC_HEADERS */
30
31 #include <ctype.h>
32 #ifdef HAVE_UNISTD_H
33 #include <unistd.h>
34 #endif /* HAVE_UNISTD_H */
35 #include <sys/param.h>
36 #include <sys/socket.h>
37 #include <atalk/logger.h>
38
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
41 #ifdef HAVE_NETDB_H
42 #include <netdb.h>
43 #endif /* HAVE_NETDB_H */
44
45 #include <atalk/paths.h>
46 #include <atalk/util.h>
47 #include "globals.h"
48 #include "status.h"
49 #include "auth.h"
50 #include "dircache.h"
51
52 #include <atalk/compat.h>
53
54 #ifdef ADMIN_GRP
55 #include <grp.h>
56 #include <sys/types.h>
57 #endif /* ADMIN_GRP */
58
59 #ifndef MIN
60 #define MIN(a, b)  ((a) < (b) ? (a) : (b))
61 #endif /* MIN */
62
63 /* FIXME CNID */
64 const char *Cnid_srv = "localhost";
65 const char *Cnid_port = "4700";
66
67 #define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:hIvVm:"
68 #define LENGTH 512
69
70 /* return an option. this uses an internal array, so it's necessary
71  * to duplicate it if you want to hold it for long. this is probably
72  * non-optimal. */
73 static char *getoption(char *buf, const char *option)
74 {
75     static char string[LENGTH + 1];
76     char *end;
77     int len;
78
79     if (option && (buf = strstr(buf, option)))
80         buf = strpbrk(buf, " \t");
81
82     while (buf && isspace(*buf))
83         buf++;
84
85     if (!buf)
86         return NULL;
87
88     /* search for any quoted stuff */
89     if (*buf == '"' && (end = strchr(buf + 1, '"'))) {
90         buf++;
91         len = MIN(end - buf, LENGTH);
92     } else if ((end = strpbrk(buf, " \t\n"))) /* option or eoln */
93         len = MIN(end - buf, LENGTH);
94     else
95         len = MIN(strlen(buf), LENGTH);
96
97     strncpy(string, buf, len);
98     string[len] = '\0';
99     return string;
100 }
101
102 /* get rid of any allocated afp_option buffers. */
103 void afp_options_free(struct afp_options *opt,
104                       const struct afp_options *save)
105 {
106     if (opt->defaultvol.name && (opt->defaultvol.name != save->defaultvol.name))
107         free(opt->defaultvol.name);
108     if (opt->defaultvol.full_name && (opt->defaultvol.full_name != save->defaultvol.full_name))
109         free(opt->defaultvol.full_name);
110
111     if (opt->systemvol.name && (opt->systemvol.name != save->systemvol.name))
112         free(opt->systemvol.name);
113     if (opt->systemvol.full_name && (opt->systemvol.full_name != save->systemvol.full_name))
114         free(opt->systemvol.full_name);
115
116     if (opt->uservol.name && (opt->uservol.name != save->uservol.name))
117         free(opt->uservol.name);
118     if (opt->uservol.full_name && (opt->uservol.full_name != save->uservol.full_name))
119         free(opt->uservol.full_name);
120
121     if (opt->loginmesg && (opt->loginmesg != save->loginmesg))
122         free(opt->loginmesg);
123     if (opt->guest && (opt->guest != save->guest))
124         free(opt->guest);
125     if (opt->server && (opt->server != save->server))
126         free(opt->server);
127     if (opt->ipaddr && (opt->ipaddr != save->ipaddr))
128         free(opt->ipaddr);
129     if (opt->port && (opt->port != save->port))
130         free(opt->port);
131     if (opt->fqdn && (opt->fqdn != save->fqdn))
132         free(opt->fqdn);
133     if (opt->uampath && (opt->uampath != save->uampath))
134         free(opt->uampath);
135     if (opt->uamlist && (opt->uamlist != save->uamlist))
136         free(opt->uamlist);
137     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
138         free(opt->passwdfile);
139     if (opt->signatureopt && (opt->signatureopt != save->signatureopt))
140         free(opt->signatureopt);
141     if (opt->k5service && (opt->k5service != save->k5service))
142         free(opt->k5service);
143     if (opt->k5realm && (opt->k5realm != save->k5realm))
144         free(opt->k5realm);
145     if (opt->k5keytab && (opt->k5keytab != save->k5keytab))
146         free(opt->k5keytab);
147     if (opt->unixcodepage && (opt->unixcodepage != save->unixcodepage))
148         free(opt->unixcodepage);
149     if (opt->maccodepage && (opt->maccodepage != save->maccodepage))
150         free(opt->maccodepage);
151
152     if (opt->ntdomain && (opt->ntdomain != save->ntdomain))
153         free(opt->ntdomain);
154     if (opt->ntseparator && (opt->ntseparator != save->ntseparator))
155         free(opt->ntseparator);
156     if (opt->logconfig && (opt->logconfig != save->logconfig))
157         free(opt->logconfig);
158 }
159
160 /* initialize options */
161 void afp_options_init(struct afp_options *options)
162 {
163     memset(options, 0, sizeof(struct afp_options));
164     options->connections = 20;
165     options->pidfile = _PATH_AFPDLOCK;
166     options->defaultvol.name = _PATH_AFPDDEFVOL;
167     options->systemvol.name = _PATH_AFPDSYSVOL;
168     options->configfile = _PATH_AFPDCONF;
169     options->sigconffile = _PATH_AFPDSIGCONF;
170     options->uuidconf = _PATH_AFPDUUIDCONF;
171     options->uampath = _PATH_AFPDUAMPATH;
172     options->uamlist = "uams_dhx.so,uams_dhx2.so";
173     options->guest = "nobody";
174     options->loginmesg = "";
175     options->transports = AFPTRANS_TCP; /*  TCP only */
176     options->passwdfile = _PATH_AFPDPWFILE;
177     options->tickleval = 30;
178     options->timeout = 4;
179     options->sleep = 10* 120; /* 10 h in 30 seconds tick */
180     options->server_notif = 1;
181     options->authprintdir = NULL;
182     options->signatureopt = "auto";
183     options->umask = 0;
184 #ifdef ADMIN_GRP
185     options->admingid = 0;
186 #endif /* ADMIN_GRP */
187     options->k5service = NULL;
188     options->k5realm = NULL;
189     options->k5keytab = NULL;
190     options->unixcharset = CH_UNIX;
191     options->unixcodepage = "LOCALE";
192     options->maccharset = CH_MAC;
193     options->maccodepage = "MAC_ROMAN";
194     options->volnamelen = 80; /* spec: 255, 10.1: 73, 10.4/10.5: 80 */
195     options->ntdomain = NULL;
196     options->ntseparator = NULL;
197 #ifdef USE_SRVLOC
198     /* don't advertize slp by default */
199     options->flags |= OPTION_NOSLP;
200 #endif
201     options->dircachesize = DEFAULT_MAX_DIRCACHE_SIZE;
202 }
203
204 /* parse an afpd.conf line. i'm doing it this way because it's
205  * easy. it is, however, massively hokey. sample afpd.conf:
206  * server:AFPServer@zone -loginmesg "blah blah blah" -nodsi 
207  * "private machine"@zone2 -noguest -port 11012
208  * server2 -nocleartxt -nodsi
209  *
210  * NOTE: this ignores unknown options 
211  */
212 int afp_options_parseline(char *buf, struct afp_options *options)
213 {
214     char *c, *opt;
215
216     /* handle server */
217     if (*buf != '-' && (c = getoption(buf, NULL)) && (opt = strdup(c)))
218         options->server = opt;
219
220     /* parse toggles */
221     if (strstr(buf, " -nodebug"))
222         options->flags &= ~OPTION_DEBUG;
223 #ifdef USE_SRVLOC
224     if (strstr(buf, " -slp"))
225         options->flags &= ~OPTION_NOSLP;
226 #endif
227 #ifdef USE_ZEROCONF
228     if (strstr(buf, " -nozeroconf"))
229         options->flags |= OPTION_NOZEROCONF;
230 #endif
231     if (strstr(buf, " -nouservolfirst"))
232         options->flags &= ~OPTION_USERVOLFIRST;
233     if (strstr(buf, " -uservolfirst"))
234         options->flags |= OPTION_USERVOLFIRST;
235     if (strstr(buf, " -nouservol"))
236         options->flags |= OPTION_NOUSERVOL;
237     if (strstr(buf, " -uservol"))
238         options->flags &= ~OPTION_NOUSERVOL;
239     if (strstr(buf, " -proxy"))
240         options->flags |= OPTION_PROXY;
241     if (strstr(buf, " -noicon"))
242         options->flags &= ~OPTION_CUSTOMICON;
243     if (strstr(buf, " -icon"))
244         options->flags |= OPTION_CUSTOMICON;
245     if (strstr(buf, " -advertise_ssh"))
246         options->flags |= OPTION_ANNOUNCESSH;
247     if (strstr(buf, " -acl2uarights"))
248         options->flags |= OPTION_ACL2UARIGHTS;
249
250     /* passwd bits */
251     if (strstr(buf, " -nosavepassword"))
252         options->passwdbits |= PASSWD_NOSAVE;
253     if (strstr(buf, " -savepassword"))
254         options->passwdbits &= ~PASSWD_NOSAVE;
255     if (strstr(buf, " -nosetpassword"))
256         options->passwdbits &= ~PASSWD_SET;
257     if (strstr(buf, " -setpassword"))
258         options->passwdbits |= PASSWD_SET;
259
260     /* transports */
261     if (strstr(buf, " -transall"))
262         options->transports = AFPTRANS_ALL;
263     if (strstr(buf, " -notransall"))
264         options->transports = AFPTRANS_NONE;
265     if (strstr(buf, " -tcp"))
266         options->transports |= AFPTRANS_TCP;
267     if (strstr(buf, " -notcp"))
268         options->transports &= ~AFPTRANS_TCP;
269     if (strstr(buf, " -ddp"))
270         options->transports |= AFPTRANS_DDP;
271     if (strstr(buf, " -noddp"))
272         options->transports &= ~AFPTRANS_DDP;
273     if (strstr(buf, "-client_polling"))
274         options->server_notif = 0;
275
276     /* figure out options w/ values. currently, this will ignore the setting
277      * if memory is lacking. */
278
279     if ((c = getoption(buf, "-hostname"))) {
280         int len = strlen (c);
281         if (len <= MAXHOSTNAMELEN) {
282             memcpy(options->hostname, c, len);
283             options->hostname[len] = 0;
284         }
285         else
286             LOG(log_info, logtype_afpd, "WARNING: hostname %s is too long (%d)",c,len);
287     }
288
289     if ((c = getoption(buf, "-defaultvol")) && (opt = strdup(c)))
290         options->defaultvol.name = opt;
291     if ((c = getoption(buf, "-systemvol")) && (opt = strdup(c)))
292         options->systemvol.name = opt;
293     if ((c = getoption(buf, "-loginmesg")) && (opt = strdup(c))) {
294         int i = 0, j = 0;
295         while (c[i]) {
296             if (c[i] != '\\') {
297                 opt[j++] = c[i];
298             } else {
299                 i++;
300                 if (c[i] == 'n')
301                     opt[j++] = '\n';
302             }
303             i++;
304         }
305         opt[j] = 0;
306         options->loginmesg = opt;
307         
308     }
309     if ((c = getoption(buf, "-guestname")) && (opt = strdup(c)))
310         options->guest = opt;
311     if ((c = getoption(buf, "-passwdfile")) && (opt = strdup(c)))
312         options->passwdfile = opt;
313     if ((c = getoption(buf, "-passwdminlen")))
314         options->passwdminlen = MIN(1, atoi(c));
315     if ((c = getoption(buf, "-loginmaxfail")))
316         options->loginmaxfail = atoi(c);
317     if ((c = getoption(buf, "-tickleval"))) {
318         options->tickleval = atoi(c);
319         if (options->tickleval <= 0) {
320             options->tickleval = 30;
321         }
322     }
323     if ((c = getoption(buf, "-timeout"))) {
324         options->timeout = atoi(c);
325         if (options->timeout <= 0) {
326             options->timeout = 4;
327         }
328     }
329
330     if ((c = getoption(buf, "-sleep"))) {
331         options->sleep = atoi(c) *120;
332         if (options->sleep <= 4) {
333             options->sleep = 4;
334         }
335     }
336
337     if ((c = getoption(buf, "-server_quantum")))
338         options->server_quantum = strtoul(c, NULL, 0);
339
340     if ((c = getoption(buf, "-volnamelen"))) {
341         options->volnamelen = atoi(c);
342         if (options->volnamelen < 8) {
343             options->volnamelen = 8; /* max mangled volname "???#FFFF" */
344         }
345         if (options->volnamelen > 255) {
346             options->volnamelen = 255; /* AFP3 spec */
347         }
348     }
349
350     /* -[no]setuplog <logtype> <loglevel> [<filename>]*/
351     c = buf;
352     /* Now THIS is hokey! Multiple occurrences are not supported by our current code, */
353     /* so I have to loop myself. */
354     while (NULL != (c = strstr(c, "-setuplog"))) {
355         char *optstr;
356         if ((optstr = getoption(c, "-setuplog"))) {
357             setuplog(optstr);
358             options->logconfig = optstr; /* at least store the last (possibly only) one */
359             c += sizeof("-setuplog");
360         }
361     }
362
363     if ((c = getoption(buf, "-unsetuplog")))
364       unsetuplog(c);
365
366 #ifdef ADMIN_GRP
367     if ((c = getoption(buf, "-admingroup"))) {
368         struct group *gr = getgrnam(c);
369         if (gr != NULL) {
370             options->admingid = gr->gr_gid;
371         }
372     }
373 #endif /* ADMIN_GRP */
374
375     if ((c = getoption(buf, "-k5service")) && (opt = strdup(c)))
376         options->k5service = opt;
377     if ((c = getoption(buf, "-k5realm")) && (opt = strdup(c)))
378         options->k5realm = opt;
379     if ((c = getoption(buf, "-k5keytab"))) {
380         if ( NULL == (options->k5keytab = (char *) malloc(sizeof(char)*(strlen(c)+14)) )) {
381                 LOG(log_error, logtype_afpd, "malloc failed");
382                 exit(-1);
383         }
384         snprintf(options->k5keytab, strlen(c)+14, "KRB5_KTNAME=%s", c);
385         putenv(options->k5keytab);
386         /* setenv( "KRB5_KTNAME", c, 1 ); */
387     }
388     if ((c = getoption(buf, "-authprintdir")) && (opt = strdup(c)))
389         options->authprintdir = opt;
390     if ((c = getoption(buf, "-uampath")) && (opt = strdup(c)))
391         options->uampath = opt;
392     if ((c = getoption(buf, "-uamlist")) && (opt = strdup(c)))
393         options->uamlist = opt;
394
395     if ((c = getoption(buf, "-ipaddr"))) {
396 #if 0
397         struct in_addr inaddr;
398         if (inet_aton(c, &inaddr) && (opt = strdup(c))) {
399             if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET))
400                 LOG(log_info, logtype_afpd, "WARNING: can't find %s", opt);
401             options->ipaddr = opt;
402         }
403         else {
404             LOG(log_error, logtype_afpd, "Error parsing -ipaddr, is %s in numbers-and-dots notation?", c);
405         }
406 #endif
407         options->ipaddr = strdup(c);
408     }
409
410     /* FIXME CNID Cnid_srv is a server attribute */
411     if ((c = getoption(buf, "-cnidserver"))) {
412         char *p = strrchr(c, ':');
413         if (p)
414             *p = 0;
415         Cnid_srv = strdup(c);
416         if (p)
417             Cnid_port = strdup(p + 1);
418         LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", Cnid_srv, Cnid_port);
419     }
420
421     if ((c = getoption(buf, "-port")))
422         options->port = strdup(c);
423     if ((c = getoption(buf, "-ddpaddr")))
424         atalk_aton(c, &options->ddpaddr);
425     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
426         options->signatureopt = opt;
427
428     /* do a little checking for the domain name. */
429     if ((c = getoption(buf, "-fqdn"))) {
430         char *p = strchr(c, ':');
431         if (p)
432             *p = '\0';
433         if (gethostbyname(c)) {
434             if (p)
435                 *p = ':';
436             if ((opt = strdup(c)))
437                 options->fqdn = opt;
438         }
439         else {
440             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
441         }
442     }
443
444     if ((c = getoption(buf, "-unixcodepage"))) {
445         if ((charset_t)-1  == ( options->unixcharset = add_charset(c)) ) {
446             options->unixcharset = CH_UNIX;
447             LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
448         }
449         else {
450             if ((opt = strdup(c)))
451                 options->unixcodepage = opt;
452         }
453     }
454         
455     if ((c = getoption(buf, "-maccodepage"))) {
456         if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
457             options->maccharset = CH_MAC;
458             LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
459         }
460         else {
461             if ((opt = strdup(c)))
462                 options->maccodepage = opt;
463         }
464     }
465     
466     if ((c = strstr(buf, "-closevol"))) {
467         options->closevol= 1;
468     }
469
470     if ((c = getoption(buf, "-ntdomain")) && (opt = strdup(c)))
471        options->ntdomain = opt;
472
473     if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
474        options->ntseparator = opt;
475
476     if ((c = getoption(buf, "-dircachesize")))
477         options->dircachesize = atoi(c);
478      
479     return 1;
480 }
481
482 /*
483  * Show version information about afpd.
484  * Used by "afp -v".
485  */
486 static void show_version( void )
487 {
488         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
489
490         puts( "This program is free software; you can redistribute it and/or modify it under" );
491         puts( "the terms of the GNU General Public License as published by the Free Software" );
492         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
493         puts( "version. Please see the file COPYING for further information and details.\n" );
494
495         puts( "afpd has been compiled with support for these features:\n" );
496
497         printf( "        AFP3.x support:\t" );
498 #ifdef AFP3x
499         puts( "Yes" );
500 #else
501         puts( "No" );
502 #endif
503
504         printf( "        TCP/IP Support:\t" );
505         puts( "Yes" );
506
507         printf( "DDP(AppleTalk) Support:\t" );
508 #ifdef NO_DDP
509         puts( "No" );
510 #else
511         puts( "Yes" );
512 #endif
513
514         printf( "         CNID backends:\t" );
515 #ifdef CNID_BACKEND_CDB
516         printf( "cdb ");
517 #endif
518 #ifdef CNID_BACKEND_DB3
519         printf( "db3 " );
520 #endif
521 #ifdef CNID_BACKEND_DBD
522 #ifdef CNID_BACKEND_DBD_TXN
523         printf( "dbd-txn " );
524 #else
525         printf( "dbd " );
526 #endif
527 #endif
528 #ifdef CNID_BACKEND_HASH
529         printf( "hash " );
530 #endif
531 #ifdef CNID_BACKEND_LAST
532         printf( "last " );
533 #endif
534 #ifdef CNID_BACKEND_MTAB
535         printf( "mtab " );
536 #endif
537 #ifdef CNID_BACKEND_TDB
538         printf( "tdb " );
539 #endif
540         puts( "" );
541 }
542
543 /*
544  * Show extended version information about afpd and Netatalk.
545  * Used by "afp -V".
546  */
547 static void show_version_extended(void )
548 {
549         show_version( );
550
551         printf( "           SLP support:\t" );
552 #ifdef USE_SRVLOC
553         puts( "Yes" );
554 #else
555         puts( "No" );
556 #endif
557
558         printf( "      Zeroconf support:\t" );
559 #ifdef USE_ZEROCONF
560         puts( "Yes" );
561 #else
562         puts( "No" );
563 #endif
564
565         printf( "  TCP wrappers support:\t" );
566 #ifdef TCPWRAP
567         puts( "Yes" );
568 #else
569         puts( "No" );
570 #endif
571
572         printf( "         Quota support:\t" );
573 #ifndef NO_QUOTA_SUPPORT
574         puts( "Yes" );
575 #else
576         puts( "No" );
577 #endif
578
579         printf( "   Admin group support:\t" );
580 #ifdef ADMIN_GRP
581         puts( "Yes" );
582 #else
583         puts( "No" );
584 #endif
585
586         printf( "    Valid shell checks:\t" );
587 #ifndef DISABLE_SHELLCHECK
588         puts( "Yes" );
589 #else
590         puts( "No" );
591 #endif
592
593         printf( "      cracklib support:\t" );
594 #ifdef USE_CRACKLIB
595         puts( "Yes" );
596 #else
597         puts( "No" );
598 #endif
599
600         printf( "        Dropbox kludge:\t" );
601 #ifdef DROPKLUDGE
602         puts( "Yes" );
603 #else
604         puts( "No" );
605 #endif
606
607         printf( "  Force volume uid/gid:\t" );
608 #ifdef FORCE_UIDGID
609         puts( "Yes" );
610 #else
611         puts( "No" );
612 #endif
613 }
614
615 /*
616  * Display compiled-in default paths
617  */
618 static void show_paths( void )
619 {
620         printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
621         printf( "    afp_signature.conf:\t%s\n", _PATH_AFPDSIGCONF );
622         printf( "   AppleVolumes.system:\t%s\n", _PATH_AFPDSYSVOL );
623         printf( "  AppleVolumes.default:\t%s\n", _PATH_AFPDDEFVOL );
624         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
625     printf( "  Server messages path:\t%s\n", SERVERTEXT);
626 }
627
628 /*
629  * Display usage information about afpd.
630  */
631 static void show_usage( char *name )
632 {
633         fprintf( stderr, "Usage:\t%s [-duptDTI] [-f defaultvolumes] [-s systemvolumes] [-n nbpname]\n", name );
634         fprintf( stderr, "\t     [-c maxconnections] [-g guest] [-P pidfile] [-S port] [-L message]\n" );
635         fprintf( stderr, "\t     [-F configfile] [-U uams] [-m umask]\n" );
636         fprintf( stderr, "\t%s -h|-v|-V\n", name );
637 }
638
639 int afp_options_parse(int ac, char **av, struct afp_options *options)
640 {
641     extern char *optarg;
642     extern int optind;
643
644     char *p;
645     char *tmp;  /* Used for error checking the result of strtol */
646     int c, err = 0;
647
648     if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) {
649         perror( "gethostname" );
650         return 0;
651     }
652     if (NULL != ( p = strchr(options->hostname, '.' )) ) {
653         *p = '\0';
654     }
655
656     if (NULL == ( p = strrchr( av[ 0 ], '/' )) ) {
657         p = av[ 0 ];
658     } else {
659         p++;
660     }
661
662     while (EOF != ( c = getopt( ac, av, OPTIONS )) ) {
663         switch ( c ) {
664         case 'd' :
665             options->flags |= OPTION_DEBUG;
666             break;
667         case 'n' :
668             options->server = optarg;
669             break;
670         case 'f' :
671             options->defaultvol.name = optarg;
672             break;
673         case 's' :
674             options->systemvol.name = optarg;
675             break;
676         case 'u' :
677             options->flags |= OPTION_USERVOLFIRST;
678             break;
679         case 'c' :
680             options->connections = atoi( optarg );
681             break;
682         case 'g' :
683             options->guest = optarg;
684             break;
685
686         case 'P' :
687             options->pidfile = optarg;
688             break;
689
690         case 'p':
691             options->passwdbits |= PASSWD_NOSAVE;
692             break;
693         case 't':
694             options->passwdbits |= PASSWD_SET;
695             break;
696
697         case 'D':
698             options->transports &= ~AFPTRANS_DDP;
699             break;
700         case 'S':
701             options->port = optarg;
702             break;
703         case 'T':
704             options->transports &= ~AFPTRANS_TCP;
705             break;
706         case 'L':
707             options->loginmesg = optarg;
708             break;
709         case 'F':
710             options->configfile = optarg;
711             break;
712         case 'U':
713             options->uamlist = optarg;
714             break;
715         case 'v':       /* version */
716             show_version( ); puts( "" );
717             show_paths( ); puts( "" );
718             exit( 0 );
719             break;
720         case 'V':       /* extended version */
721             show_version_extended( ); puts( "" );
722             show_paths( ); puts( "" );
723             exit( 0 );
724             break;
725         case 'h':       /* usage */
726             show_usage( p );
727             exit( 0 );
728             break;
729         case 'I':
730             options->flags |= OPTION_CUSTOMICON;
731             break;
732         case 'm':
733             options->umask = strtoul(optarg, &tmp, 8);
734             if ((options->umask > 0777)) {
735                 fprintf(stderr, "%s: out of range umask setting provided\n", p);
736                 err++;
737             }
738             if (tmp[0] != '\0') {
739                 fprintf(stderr, "%s: invalid characters in umask setting provided\n", p);
740                 err++;
741             }
742             break;
743         default :
744             err++;
745         }
746     }
747     if ( err || optind != ac ) {
748         show_usage( p );
749         exit( 2 );
750     }
751
752 #ifdef ultrix
753     openlog( p, LOG_PID ); /* ultrix only */
754 #else
755     set_processname(p);
756 #endif /* ultrix */
757
758     return 1;
759 }