]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
d6566dfdd0096f5943d63231db3fbb6046bd0f7d
[netatalk.git] / etc / afpd / afp_options.c
1 /*
2  * $Id: afp_options.c,v 1.35 2005-04-28 20:49:39 bfernhomberg 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_clrtxt.so,uams_dhx.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
256     if ((c = getoption(buf, "-hostname"))) {
257         int len = strlen (c);
258         if (len <= MAXHOSTNAMELEN) {
259             memcpy(options->hostname, c, len);
260             options->hostname[len] = 0;
261         }
262         else
263             LOG(log_info, logtype_afpd, "WARNING: hostname %s is too long (%d)",c,len);
264     }
265
266     if ((c = getoption(buf, "-defaultvol")) && (opt = strdup(c)))
267         options->defaultvol.name = opt;
268     if ((c = getoption(buf, "-systemvol")) && (opt = strdup(c)))
269         options->systemvol.name = opt;
270     if ((c = getoption(buf, "-loginmesg")) && (opt = strdup(c)))
271         options->loginmesg = opt;
272     if ((c = getoption(buf, "-guestname")) && (opt = strdup(c)))
273         options->guest = opt;
274     if ((c = getoption(buf, "-passwdfile")) && (opt = strdup(c)))
275         options->passwdfile = opt;
276     if ((c = getoption(buf, "-passwdminlen")))
277         options->passwdminlen = MIN(1, atoi(c));
278     if ((c = getoption(buf, "-loginmaxfail")))
279         options->loginmaxfail = atoi(c);
280     if ((c = getoption(buf, "-tickleval"))) {
281         options->tickleval = atoi(c);
282         if (options->tickleval <= 0) {
283             options->tickleval = 30;
284         }
285     }
286     if ((c = getoption(buf, "-timeout"))) {
287         options->timeout = atoi(c);
288         if (options->timeout <= 0) {
289             options->timeout = 4;
290         }
291     }
292
293     if ((c = getoption(buf, "-sleep"))) {
294         options->sleep = atoi(c) *120;
295         if (options->sleep <= 4) {
296             options->sleep = 4;
297         }
298     }
299
300     if ((c = getoption(buf, "-server_quantum")))
301         options->server_quantum = strtoul(c, NULL, 0);
302
303 #ifndef DISABLE_LOGGER
304     /* -setuplogtype <syslog|filelog> <logtype> <loglevel> <filename>*/
305     /* -[no]setuplog <logtype> <loglevel> [<filename>]*/
306     if ((c = getoption(buf, "-setuplog")))
307     {
308       char *ptr, *logsource, *logtype, *loglevel, *filename;
309
310       LOG(log_debug6, logtype_afpd, "setting up logtype, c is %s", c);
311       ptr = c;
312       
313       /* 
314       logsource = ptr = c;
315       if (ptr)
316       {
317         ptr = strpbrk(ptr, " \t");
318         if (ptr) 
319         {
320           *ptr++ = 0;
321           while (*ptr && isspace(*ptr))
322             ptr++;
323         }
324       }
325       */
326
327       logtype = ptr; 
328       if (ptr)
329       {
330         ptr = strpbrk(ptr, " \t");
331         if (ptr) 
332         {
333           *ptr++ = 0;
334           while (*ptr && isspace(*ptr))
335             ptr++;
336         }
337       }
338
339       loglevel = ptr;
340       if (ptr)
341       {
342         ptr = strpbrk(ptr, " \t");
343         if (ptr) 
344         {
345           *ptr++ = 0;
346           while (*ptr && isspace(*ptr))
347             ptr++;
348         }
349       }
350
351       filename = ptr;
352       if (ptr)
353       {
354         ptr = strpbrk(ptr, " \t");
355         if (ptr) 
356         {
357           *ptr++ = 0;
358           while (*ptr && isspace(*ptr))
359             ptr++;
360         }
361       }
362
363       LOG(log_debug7, logtype_afpd, "calling setuplog %s %s %s", 
364           logtype, loglevel, filename);
365
366       setuplog(logtype, loglevel, filename);
367     }
368
369     if ((c = getoption(buf, "-unsetuplog")))
370     {
371       char *ptr, *logtype, *loglevel, *filename;
372
373       LOG(log_debug6, logtype_afpd, "unsetting up logtype, c is %s", c);
374
375       ptr = c;
376       logtype = ptr;
377       if (ptr)
378       {
379         ptr = strpbrk(ptr, " \t");
380         if (ptr)
381         {
382           *ptr++ = 0;
383           while (*ptr && isspace(*ptr))
384             ptr++;
385         }
386       }
387
388       loglevel = ptr;
389       if (ptr)
390       {
391         ptr = strpbrk(ptr, " \t");
392         if (ptr)
393         {
394           *ptr++ = 0;
395            while (*ptr && isspace(*ptr))
396              ptr++;
397         }
398       }
399
400       filename = ptr;
401       if (ptr)
402       {
403         ptr = strpbrk(ptr, " \t");
404         if (ptr)
405         {
406           *ptr++ = 0;
407           while (*ptr && isspace(*ptr))
408             ptr++;
409         }
410       }
411       
412       LOG(log_debug7, logtype_afpd, "calling setuplog %s %s %s",
413               logtype, NULL, filename);
414
415       setuplog(logtype, NULL, filename);
416     }
417 #endif /* DISABLE_LOGGER */
418 #ifdef ADMIN_GRP
419     if ((c = getoption(buf, "-admingroup"))) {
420         struct group *gr = getgrnam(c);
421         if (gr != NULL) {
422             options->admingid = gr->gr_gid;
423         }
424     }
425 #endif /* ADMIN_GRP */
426
427     if ((c = getoption(buf, "-k5service")) && (opt = strdup(c)))
428         options->k5service = opt;
429     if ((c = getoption(buf, "-k5realm")) && (opt = strdup(c)))
430         options->k5realm = opt;
431     if ((c = getoption(buf, "-k5keytab"))) {
432         if ( NULL == (options->k5keytab = (char *) malloc(sizeof(char)*(strlen(c)+14)) )) {
433                 LOG(log_error, logtype_afpd, "malloc failed");
434                 exit(-1);
435         }
436         snprintf(options->k5keytab, strlen(c)+14, "KRB5_KTNAME=%s", c);
437         putenv(options->k5keytab);
438         /* setenv( "KRB5_KTNAME", c, 1 ); */
439     }
440     if ((c = getoption(buf, "-authprintdir")) && (opt = strdup(c)))
441         options->authprintdir = opt;
442     if ((c = getoption(buf, "-uampath")) && (opt = strdup(c)))
443         options->uampath = opt;
444     if ((c = getoption(buf, "-uamlist")) && (opt = strdup(c)))
445         options->uamlist = opt;
446
447     if ((c = getoption(buf, "-ipaddr"))) {
448         struct in_addr inaddr;
449         if (inet_aton(c, &inaddr) && (opt = strdup(c))) {
450             if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET))
451                 LOG(log_info, logtype_afpd, "WARNING: can't find %s", opt);
452             options->ipaddr = opt;
453         }
454         else {
455             LOG(log_error, logtype_afpd, "Error parsing -ipaddr, is %s in numbers-and-dots notation?", c);
456         }
457     }
458
459     /* FIXME CNID Cnid_srv is a server attribute */
460     if ((c = getoption(buf, "-cnidserver"))) {
461         char *p;
462         int len;        
463         p = strchr(c, ':');
464         if (p != NULL && (len = p - c) <= MAXHOSTNAMELEN) {
465             memcpy(Cnid_srv, c, len);
466             Cnid_srv[len] = 0;
467             Cnid_port = atoi(p +1);
468         }
469     }
470
471     if ((c = getoption(buf, "-port")))
472         options->port = atoi(c);
473     if ((c = getoption(buf, "-ddpaddr")))
474         atalk_aton(c, &options->ddpaddr);
475     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
476         options->signature = opt;
477
478     /* do a little checking for the domain name. */
479     if ((c = getoption(buf, "-fqdn"))) {
480         char *p = strchr(c, ':');
481         if (p)
482             *p = '\0';
483         if (gethostbyname(c)) {
484             if (p)
485                 *p = ':';
486             if ((opt = strdup(c)))
487                 options->fqdn = opt;
488         }
489         else {
490             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
491         }
492     }
493
494     if ((c = getoption(buf, "-unixcodepage"))) {
495         if ((charset_t)-1  == ( options->unixcharset = add_charset(c)) ) {
496             options->unixcharset = CH_UNIX;
497             LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
498         }
499         else {
500             if ((opt = strdup(c)))
501                 options->unixcodepage = opt;
502         }
503     }
504         
505     if ((c = getoption(buf, "-maccodepage"))) {
506         if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
507             options->maccharset = CH_MAC;
508             LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
509         }
510         else {
511             if ((opt = strdup(c)))
512                 options->maccodepage = opt;
513         }
514     }
515     
516     if ((c = strstr(buf, "-closevol"))) {
517         options->closevol= 1;
518     }
519
520     return 1;
521 }
522
523 /*
524  * Show version information about afpd.
525  * Used by "afp -v".
526  */
527 void show_version( )
528 {
529         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
530
531         puts( "This program is free software; you can redistribute it and/or modify it under" );
532         puts( "the terms of the GNU General Public License as published by the Free Software" );
533         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
534         puts( "version. Please see the file COPYING for further information and details.\n" );
535
536         puts( "afpd has been compiled with support for these features:\n" );
537
538         printf( "        AFP3.1 support:\t" );
539 #ifdef AFP3x
540         puts( "Yes" );
541 #else
542         puts( "No" );
543 #endif
544
545         printf( "      Transport layers:\t" );
546 #ifdef NO_DDP
547         puts( "TCP/IP" );
548 #else
549         puts( "TCP/IP DDP" );
550 #endif
551
552         printf( "         CNID backends:\t" );
553 #ifdef CNID_BACKEND_CDB
554         printf( "cdb ");
555 #endif
556 #ifdef CNID_BACKEND_DB3
557         printf( "db3 " );
558 #endif
559 #ifdef CNID_BACKEND_DBD
560 #ifdef CNID_BACKEND_DBD_TXN
561         printf( "dbd-txn " );
562 #else
563         printf( "dbd " );
564 #endif
565 #endif
566 #ifdef CNID_BACKEND_HASH
567         printf( "hash " );
568 #endif
569 #ifdef CNID_BACKEND_LAST
570         printf( "last " );
571 #endif
572 #ifdef CNID_BACKEND_MTAB
573         printf( "mtab " );
574 #endif
575 #ifdef CNID_BACKEND_TDB
576         printf( "tdb " );
577 #endif
578         puts( "" );
579 }
580
581 /*
582  * Show extended version information about afpd and Netatalk.
583  * Used by "afp -V".
584  */
585 void show_version_extended( )
586 {
587         show_version( );
588
589         printf( "           SLP support:\t" );
590 #ifdef USE_SRVLOC
591         puts( "Yes" );
592 #else
593         puts( "No" );
594 #endif
595
596         printf( "  TCP wrappers support:\t" );
597 #ifdef TCPWRAP
598         puts( "Yes" );
599 #else
600         puts( "No" );
601 #endif
602
603         printf( "         Quota support:\t" );
604 #ifndef NO_QUOTA_SUPPORT
605         puts( "Yes" );
606 #else
607         puts( "No" );
608 #endif
609
610         printf( "   Admin group support:\t" );
611 #ifdef ADMIN_GRP
612         puts( "Yes" );
613 #else
614         puts( "No" );
615 #endif
616
617         printf( "    Valid shell checks:\t" );
618 #ifndef DISABLE_SHELLCHECK
619         puts( "Yes" );
620 #else
621         puts( "No" );
622 #endif
623
624         printf( "      cracklib support:\t" );
625 #ifdef USE_CRACKLIB
626         puts( "Yes" );
627 #else
628         puts( "No" );
629 #endif
630
631         printf( "        Dropbox kludge:\t" );
632 #ifdef DROPKLUDGE
633         puts( "Yes" );
634 #else
635         puts( "No" );
636 #endif
637
638         printf( "  Force volume uid/gid:\t" );
639 #ifdef FORCE_UIDGID
640         puts( "Yes" );
641 #else
642         puts( "No" );
643 #endif
644 }
645
646 /*
647  * Display compiled-in default paths
648  */
649 void show_paths( void )
650 {
651         printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
652         printf( "   AppleVolumes.system:\t%s\n", _PATH_AFPDSYSVOL );
653         printf( "  AppleVolumes.default:\t%s\n", _PATH_AFPDDEFVOL );
654         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
655 }
656
657 /*
658  * Display usage information about adpd.
659  */
660 void show_usage( char *name )
661 {
662         fprintf( stderr, "Usage:\t%s [-dDIptTu] [-c maxconnections] [-f defaultvolumes] [-F config]\n", name );
663         fprintf( stderr, "\t     [-g guest] [-L message] [-m umask][-n nbpname] [-P pidfile]\n" );
664         fprintf( stderr, "\t     [-s systemvolumes] [-S port] [-U uams]\n" );
665         fprintf( stderr, "\t%s -h|-v|-V\n", name );
666 }
667
668 int afp_options_parse(int ac, char **av, struct afp_options *options)
669 {
670     extern char *optarg;
671     extern int optind;
672
673     char *p;
674     char *tmp;  /* Used for error checking the result of strtol */
675     int c, err = 0;
676
677     if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) {
678         perror( "gethostname" );
679         return 0;
680     }
681     if (NULL != ( p = strchr(options->hostname, '.' )) ) {
682         *p = '\0';
683     }
684
685     if (NULL == ( p = strrchr( av[ 0 ], '/' )) ) {
686         p = av[ 0 ];
687     } else {
688         p++;
689     }
690
691     while (EOF != ( c = getopt( ac, av, OPTIONS )) ) {
692         switch ( c ) {
693         case 'd' :
694             options->flags |= OPTION_DEBUG;
695             break;
696         case 'n' :
697             options->server = optarg;
698             break;
699         case 'f' :
700             options->defaultvol.name = optarg;
701             break;
702         case 's' :
703             options->systemvol.name = optarg;
704             break;
705         case 'u' :
706             options->flags |= OPTION_USERVOLFIRST;
707             break;
708         case 'c' :
709             options->connections = atoi( optarg );
710             break;
711         case 'g' :
712             options->guest = optarg;
713             break;
714
715         case 'P' :
716             options->pidfile = optarg;
717             break;
718
719         case 'p':
720             options->passwdbits |= PASSWD_NOSAVE;
721             break;
722         case 't':
723             options->passwdbits |= PASSWD_SET;
724             break;
725
726         case 'D':
727             options->transports &= ~AFPTRANS_DDP;
728             break;
729         case 'S':
730             options->port = atoi(optarg);
731             break;
732         case 'T':
733             options->transports &= ~AFPTRANS_TCP;
734             break;
735         case 'L':
736             options->loginmesg = optarg;
737             break;
738         case 'F':
739             options->configfile = optarg;
740             break;
741         case 'U':
742             options->uamlist = optarg;
743             break;
744         case 'v':       /* version */
745             show_version( ); puts( "" );
746             show_paths( ); puts( "" );
747             exit( 0 );
748             break;
749         case 'V':       /* extended version */
750             show_version_extended( ); puts( "" );
751             show_paths( ); puts( "" );
752             exit( 0 );
753             break;
754         case 'h':       /* usage */
755             show_usage( p );
756             exit( 0 );
757             break;
758         case 'I':
759             options->flags |= OPTION_CUSTOMICON;
760             break;
761         case 'm':
762             options->umask = strtoul(optarg, &tmp, 8);
763             if ((options->umask > 0777)) {
764                 fprintf(stderr, "%s: out of range umask setting provided\n", p);
765                 err++;
766             }
767             if (tmp[0] != '\0') {
768                 fprintf(stderr, "%s: invalid characters in umask setting provided\n", p);
769                 err++;
770             }
771             break;
772         default :
773             err++;
774         }
775     }
776     if ( err || optind != ac ) {
777         show_usage( p );
778         exit( 2 );
779     }
780
781 #ifdef ultrix
782     openlog( p, LOG_PID ); /* ultrix only */
783 #else /* ultrix */
784     set_processname(p);
785     syslog_setup(log_debug, logtype_default, logoption_ndelay|logoption_pid, logfacility_daemon);
786 #endif /* ultrix */
787
788     return 1;
789 }