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