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