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