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