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