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