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