]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
Show msg dir in afpd -V
[netatalk.git] / etc / afpd / afp_options.c
1 /*
2  * $Id: afp_options.c,v 1.52 2010-02-03 11:35:58 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 }
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     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
402         options->signature = opt;
403
404     /* do a little checking for the domain name. */
405     if ((c = getoption(buf, "-fqdn"))) {
406         char *p = strchr(c, ':');
407         if (p)
408             *p = '\0';
409         if (gethostbyname(c)) {
410             if (p)
411                 *p = ':';
412             if ((opt = strdup(c)))
413                 options->fqdn = opt;
414         }
415         else {
416             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
417         }
418     }
419
420     if ((c = getoption(buf, "-unixcodepage"))) {
421         if ((charset_t)-1  == ( options->unixcharset = add_charset(c)) ) {
422             options->unixcharset = CH_UNIX;
423             LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
424         }
425         else {
426             if ((opt = strdup(c)))
427                 options->unixcodepage = opt;
428         }
429     }
430         
431     if ((c = getoption(buf, "-maccodepage"))) {
432         if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
433             options->maccharset = CH_MAC;
434             LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
435         }
436         else {
437             if ((opt = strdup(c)))
438                 options->maccodepage = opt;
439         }
440     }
441     
442     if ((c = strstr(buf, "-closevol"))) {
443         options->closevol= 1;
444     }
445
446     if ((c = getoption(buf, "-ntdomain")) && (opt = strdup(c)))
447        options->ntdomain = opt;
448
449     if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
450        options->ntseparator = opt;
451      
452     return 1;
453 }
454
455 /*
456  * Show version information about afpd.
457  * Used by "afp -v".
458  */
459 static void show_version( void )
460 {
461         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
462
463         puts( "This program is free software; you can redistribute it and/or modify it under" );
464         puts( "the terms of the GNU General Public License as published by the Free Software" );
465         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
466         puts( "version. Please see the file COPYING for further information and details.\n" );
467
468         puts( "afpd has been compiled with support for these features:\n" );
469
470         printf( "        AFP3.x support:\t" );
471 #ifdef AFP3x
472         puts( "Yes" );
473 #else
474         puts( "No" );
475 #endif
476
477         printf( "      Transport layers:\t" );
478 #ifdef NO_DDP
479         puts( "TCP/IP" );
480 #else
481         puts( "TCP/IP DDP" );
482 #endif
483
484         printf( "         CNID backends:\t" );
485 #ifdef CNID_BACKEND_CDB
486         printf( "cdb ");
487 #endif
488 #ifdef CNID_BACKEND_DB3
489         printf( "db3 " );
490 #endif
491 #ifdef CNID_BACKEND_DBD
492 #ifdef CNID_BACKEND_DBD_TXN
493         printf( "dbd-txn " );
494 #else
495         printf( "dbd " );
496 #endif
497 #endif
498 #ifdef CNID_BACKEND_HASH
499         printf( "hash " );
500 #endif
501 #ifdef CNID_BACKEND_LAST
502         printf( "last " );
503 #endif
504 #ifdef CNID_BACKEND_MTAB
505         printf( "mtab " );
506 #endif
507 #ifdef CNID_BACKEND_TDB
508         printf( "tdb " );
509 #endif
510         puts( "" );
511 }
512
513 /*
514  * Show extended version information about afpd and Netatalk.
515  * Used by "afp -V".
516  */
517 static void show_version_extended(void )
518 {
519         show_version( );
520
521         printf( "           SLP support:\t" );
522 #ifdef USE_SRVLOC
523         puts( "Yes" );
524 #else
525         puts( "No" );
526 #endif
527
528         printf( "  TCP wrappers support:\t" );
529 #ifdef TCPWRAP
530         puts( "Yes" );
531 #else
532         puts( "No" );
533 #endif
534
535         printf( "         Quota support:\t" );
536 #ifndef NO_QUOTA_SUPPORT
537         puts( "Yes" );
538 #else
539         puts( "No" );
540 #endif
541
542         printf( "   Admin group support:\t" );
543 #ifdef ADMIN_GRP
544         puts( "Yes" );
545 #else
546         puts( "No" );
547 #endif
548
549         printf( "    Valid shell checks:\t" );
550 #ifndef DISABLE_SHELLCHECK
551         puts( "Yes" );
552 #else
553         puts( "No" );
554 #endif
555
556         printf( "      cracklib support:\t" );
557 #ifdef USE_CRACKLIB
558         puts( "Yes" );
559 #else
560         puts( "No" );
561 #endif
562
563         printf( "        Dropbox kludge:\t" );
564 #ifdef DROPKLUDGE
565         puts( "Yes" );
566 #else
567         puts( "No" );
568 #endif
569
570         printf( "  Force volume uid/gid:\t" );
571 #ifdef FORCE_UIDGID
572         puts( "Yes" );
573 #else
574         puts( "No" );
575 #endif
576 }
577
578 /*
579  * Display compiled-in default paths
580  */
581 static void show_paths( void )
582 {
583         printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
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 adpd.
592  */
593 static void show_usage( char *name )
594 {
595         fprintf( stderr, "Usage:\t%s [-dDIptTu] [-c maxconnections] [-f defaultvolumes] [-F config]\n", name );
596         fprintf( stderr, "\t     [-g guest] [-L message] [-m umask][-n nbpname] [-P pidfile]\n" );
597         fprintf( stderr, "\t     [-s systemvolumes] [-S port] [-U uams]\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 }