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