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