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