]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
New AFP signature algorithm, from HAT
[netatalk.git] / etc / afpd / afp_options.c
1 /*
2  * $Id: afp_options.c,v 1.53 2010-03-29 15:22:57 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 const char *Cnid_srv = "localhost";
66 const char *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->port && (opt->port != save->port))
131         free(opt->port);
132     if (opt->fqdn && (opt->fqdn != save->fqdn))
133         free(opt->fqdn);
134     if (opt->uampath && (opt->uampath != save->uampath))
135         free(opt->uampath);
136     if (opt->uamlist && (opt->uamlist != save->uamlist))
137         free(opt->uamlist);
138     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
139         free(opt->passwdfile);
140     if (opt->signature && (opt->signature != save->signature))
141         free(opt->signature);
142     if (opt->k5service && (opt->k5service != save->k5service))
143         free(opt->k5service);
144     if (opt->k5realm && (opt->k5realm != save->k5realm))
145         free(opt->k5realm);
146     if (opt->k5keytab && (opt->k5keytab != save->k5keytab))
147         free(opt->k5keytab);
148     if (opt->unixcodepage && (opt->unixcodepage != save->unixcodepage))
149         free(opt->unixcodepage);
150     if (opt->maccodepage && (opt->maccodepage != save->maccodepage))
151         free(opt->maccodepage);
152
153     if (opt->ntdomain && (opt->ntdomain != save->ntdomain))
154         free(opt->ntdomain);
155     if (opt->ntseparator && (opt->ntseparator != save->ntseparator))
156         free(opt->ntseparator);
157 }
158
159 /* initialize options */
160 void afp_options_init(struct afp_options *options)
161 {
162     memset(options, 0, sizeof(struct afp_options));
163     options->connections = 20;
164     options->pidfile = _PATH_AFPDLOCK;
165     options->defaultvol.name = _PATH_AFPDDEFVOL;
166     options->systemvol.name = _PATH_AFPDSYSVOL;
167     options->configfile = _PATH_AFPDCONF;
168     options->sigconffile = _PATH_AFPDSIGCONF;
169     options->uampath = _PATH_AFPDUAMPATH;
170     options->uamlist = "uams_dhx.so,uams_dhx2.so";
171     options->guest = "nobody";
172     options->loginmesg = "";
173     options->transports = AFPTRANS_TCP; /*  TCP only */
174     options->passwdfile = _PATH_AFPDPWFILE;
175     options->tickleval = 30;
176     options->timeout = 4;
177     options->sleep = 10* 120; /* 10 h in 30 seconds tick */
178     options->server_notif = 1;
179     options->authprintdir = NULL;
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
402     /* do a little checking for the domain name. */
403     if ((c = getoption(buf, "-fqdn"))) {
404         char *p = strchr(c, ':');
405         if (p)
406             *p = '\0';
407         if (gethostbyname(c)) {
408             if (p)
409                 *p = ':';
410             if ((opt = strdup(c)))
411                 options->fqdn = opt;
412         }
413         else {
414             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
415         }
416     }
417
418     if ((c = getoption(buf, "-unixcodepage"))) {
419         if ((charset_t)-1  == ( options->unixcharset = add_charset(c)) ) {
420             options->unixcharset = CH_UNIX;
421             LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
422         }
423         else {
424             if ((opt = strdup(c)))
425                 options->unixcodepage = opt;
426         }
427     }
428         
429     if ((c = getoption(buf, "-maccodepage"))) {
430         if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
431             options->maccharset = CH_MAC;
432             LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
433         }
434         else {
435             if ((opt = strdup(c)))
436                 options->maccodepage = opt;
437         }
438     }
439     
440     if ((c = strstr(buf, "-closevol"))) {
441         options->closevol= 1;
442     }
443
444     if ((c = getoption(buf, "-ntdomain")) && (opt = strdup(c)))
445        options->ntdomain = opt;
446
447     if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
448        options->ntseparator = opt;
449      
450     if ((c = getoption(buf, "-signature")) && (opt = strdup(c))) {
451         set_signature(opt, options);
452     }
453     else {
454         set_signature("auto", options);
455     }
456
457     return 1;
458 }
459
460 /*
461  * Show version information about afpd.
462  * Used by "afp -v".
463  */
464 static void show_version( void )
465 {
466         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
467
468         puts( "This program is free software; you can redistribute it and/or modify it under" );
469         puts( "the terms of the GNU General Public License as published by the Free Software" );
470         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
471         puts( "version. Please see the file COPYING for further information and details.\n" );
472
473         puts( "afpd has been compiled with support for these features:\n" );
474
475         printf( "        AFP3.x support:\t" );
476 #ifdef AFP3x
477         puts( "Yes" );
478 #else
479         puts( "No" );
480 #endif
481
482         printf( "      Transport layers:\t" );
483 #ifdef NO_DDP
484         puts( "TCP/IP" );
485 #else
486         puts( "TCP/IP DDP" );
487 #endif
488
489         printf( "         CNID backends:\t" );
490 #ifdef CNID_BACKEND_CDB
491         printf( "cdb ");
492 #endif
493 #ifdef CNID_BACKEND_DB3
494         printf( "db3 " );
495 #endif
496 #ifdef CNID_BACKEND_DBD
497 #ifdef CNID_BACKEND_DBD_TXN
498         printf( "dbd-txn " );
499 #else
500         printf( "dbd " );
501 #endif
502 #endif
503 #ifdef CNID_BACKEND_HASH
504         printf( "hash " );
505 #endif
506 #ifdef CNID_BACKEND_LAST
507         printf( "last " );
508 #endif
509 #ifdef CNID_BACKEND_MTAB
510         printf( "mtab " );
511 #endif
512 #ifdef CNID_BACKEND_TDB
513         printf( "tdb " );
514 #endif
515         puts( "" );
516 }
517
518 /*
519  * Show extended version information about afpd and Netatalk.
520  * Used by "afp -V".
521  */
522 static void show_version_extended(void )
523 {
524         show_version( );
525
526         printf( "           SLP support:\t" );
527 #ifdef USE_SRVLOC
528         puts( "Yes" );
529 #else
530         puts( "No" );
531 #endif
532
533         printf( "  TCP wrappers support:\t" );
534 #ifdef TCPWRAP
535         puts( "Yes" );
536 #else
537         puts( "No" );
538 #endif
539
540         printf( "         Quota support:\t" );
541 #ifndef NO_QUOTA_SUPPORT
542         puts( "Yes" );
543 #else
544         puts( "No" );
545 #endif
546
547         printf( "   Admin group support:\t" );
548 #ifdef ADMIN_GRP
549         puts( "Yes" );
550 #else
551         puts( "No" );
552 #endif
553
554         printf( "    Valid shell checks:\t" );
555 #ifndef DISABLE_SHELLCHECK
556         puts( "Yes" );
557 #else
558         puts( "No" );
559 #endif
560
561         printf( "      cracklib support:\t" );
562 #ifdef USE_CRACKLIB
563         puts( "Yes" );
564 #else
565         puts( "No" );
566 #endif
567
568         printf( "        Dropbox kludge:\t" );
569 #ifdef DROPKLUDGE
570         puts( "Yes" );
571 #else
572         puts( "No" );
573 #endif
574
575         printf( "  Force volume uid/gid:\t" );
576 #ifdef FORCE_UIDGID
577         puts( "Yes" );
578 #else
579         puts( "No" );
580 #endif
581 }
582
583 /*
584  * Display compiled-in default paths
585  */
586 static void show_paths( void )
587 {
588         printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
589         printf( "    afp_signature.conf:\t%s\n", _PATH_AFPDSIGCONF );
590         printf( "   AppleVolumes.system:\t%s\n", _PATH_AFPDSYSVOL );
591         printf( "  AppleVolumes.default:\t%s\n", _PATH_AFPDDEFVOL );
592         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
593     printf( "  Server messages path:\t%s\n", SERVERTEXT);
594 }
595
596 /*
597  * Display usage information about adpd.
598  */
599 static void show_usage( char *name )
600 {
601         fprintf( stderr, "Usage:\t%s [-dDIptTu] [-c maxconnections] [-f defaultvolumes] [-F config]\n", name );
602         fprintf( stderr, "\t     [-g guest] [-L message] [-m umask][-n nbpname] [-P pidfile]\n" );
603         fprintf( stderr, "\t     [-s systemvolumes] [-S port] [-U uams]\n" );
604         fprintf( stderr, "\t%s -h|-v|-V\n", name );
605 }
606
607 int afp_options_parse(int ac, char **av, struct afp_options *options)
608 {
609     extern char *optarg;
610     extern int optind;
611
612     char *p;
613     char *tmp;  /* Used for error checking the result of strtol */
614     int c, err = 0;
615
616     if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) {
617         perror( "gethostname" );
618         return 0;
619     }
620     if (NULL != ( p = strchr(options->hostname, '.' )) ) {
621         *p = '\0';
622     }
623
624     if (NULL == ( p = strrchr( av[ 0 ], '/' )) ) {
625         p = av[ 0 ];
626     } else {
627         p++;
628     }
629
630     while (EOF != ( c = getopt( ac, av, OPTIONS )) ) {
631         switch ( c ) {
632         case 'd' :
633             options->flags |= OPTION_DEBUG;
634             break;
635         case 'n' :
636             options->server = optarg;
637             break;
638         case 'f' :
639             options->defaultvol.name = optarg;
640             break;
641         case 's' :
642             options->systemvol.name = optarg;
643             break;
644         case 'u' :
645             options->flags |= OPTION_USERVOLFIRST;
646             break;
647         case 'c' :
648             options->connections = atoi( optarg );
649             break;
650         case 'g' :
651             options->guest = optarg;
652             break;
653
654         case 'P' :
655             options->pidfile = optarg;
656             break;
657
658         case 'p':
659             options->passwdbits |= PASSWD_NOSAVE;
660             break;
661         case 't':
662             options->passwdbits |= PASSWD_SET;
663             break;
664
665         case 'D':
666             options->transports &= ~AFPTRANS_DDP;
667             break;
668         case 'S':
669             options->port = optarg;
670             break;
671         case 'T':
672             options->transports &= ~AFPTRANS_TCP;
673             break;
674         case 'L':
675             options->loginmesg = optarg;
676             break;
677         case 'F':
678             options->configfile = optarg;
679             break;
680         case 'U':
681             options->uamlist = optarg;
682             break;
683         case 'v':       /* version */
684             show_version( ); puts( "" );
685             show_paths( ); puts( "" );
686             exit( 0 );
687             break;
688         case 'V':       /* extended version */
689             show_version_extended( ); puts( "" );
690             show_paths( ); puts( "" );
691             exit( 0 );
692             break;
693         case 'h':       /* usage */
694             show_usage( p );
695             exit( 0 );
696             break;
697         case 'I':
698             options->flags |= OPTION_CUSTOMICON;
699             break;
700         case 'm':
701             options->umask = strtoul(optarg, &tmp, 8);
702             if ((options->umask > 0777)) {
703                 fprintf(stderr, "%s: out of range umask setting provided\n", p);
704                 err++;
705             }
706             if (tmp[0] != '\0') {
707                 fprintf(stderr, "%s: invalid characters in umask setting provided\n", p);
708                 err++;
709             }
710             break;
711         default :
712             err++;
713         }
714     }
715     if ( err || optind != ac ) {
716         show_usage( p );
717         exit( 2 );
718     }
719
720 #ifdef ultrix
721     openlog( p, LOG_PID ); /* ultrix only */
722 #else
723     set_processname(p);
724 #endif /* ultrix */
725
726     return 1;
727 }