]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
Fix SIGHUP config reloading
[netatalk.git] / etc / afpd / afp_options.c
1 /*
2  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3  * Copyright (c) 1990,1993 Regents of The University of Michigan.
4  * All Rights Reserved.  See COPYRIGHT.
5  *
6  * modified from main.c. this handles afp options.
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif /* HAVE_CONFIG_H */
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <ctype.h>
17 #include <unistd.h>
18 #include <sys/param.h>
19 #include <sys/socket.h>
20 #include <atalk/logger.h>
21
22 #include <netinet/in.h>
23 #include <arpa/inet.h>
24
25 #ifdef HAVE_NETDB_H
26 #include <netdb.h>
27 #endif /* HAVE_NETDB_H */
28
29 #ifdef ADMIN_GRP
30 #include <grp.h>
31 #include <sys/types.h>
32 #endif /* ADMIN_GRP */
33
34 #include <atalk/paths.h>
35 #include <atalk/util.h>
36 #include <atalk/compat.h>
37 #include <atalk/globals.h>
38 #include <atalk/fce_api.h>
39 #include <atalk/errchk.h>
40
41 #include "status.h"
42 #include "auth.h"
43 #include "dircache.h"
44
45 #define LENGTH 512
46
47 /*
48  * Show version information about afpd.
49  * Used by "afp -v".
50  */
51 static void show_version( void )
52 {
53         int num, i;
54
55         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
56
57         puts( "This program is free software; you can redistribute it and/or modify it under" );
58         puts( "the terms of the GNU General Public License as published by the Free Software" );
59         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
60         puts( "version. Please see the file COPYING for further information and details.\n" );
61
62         puts( "afpd has been compiled with support for these features:\n" );
63
64         num = sizeof( afp_versions ) / sizeof( afp_versions[ 0 ] );
65         printf( "          AFP versions:\t" );
66         for ( i = 0; i < num; i++ ) {
67                 printf( "%d.%d ", afp_versions[ i ].av_number/10, afp_versions[ i ].av_number%10);
68         }
69         puts( "" );
70
71         printf( "         CNID backends:\t" );
72 #ifdef CNID_BACKEND_CDB
73         printf( "cdb ");
74 #endif
75 #ifdef CNID_BACKEND_DB3
76         printf( "db3 " );
77 #endif
78 #ifdef CNID_BACKEND_DBD
79 #ifdef CNID_BACKEND_DBD_TXN
80         printf( "dbd-txn " );
81 #else
82         printf( "dbd " );
83 #endif
84 #endif
85 #ifdef CNID_BACKEND_HASH
86         printf( "hash " );
87 #endif
88 #ifdef CNID_BACKEND_LAST
89         printf( "last " );
90 #endif
91 #ifdef CNID_BACKEND_MTAB
92         printf( "mtab " );
93 #endif
94 #ifdef CNID_BACKEND_TDB
95         printf( "tdb " );
96 #endif
97         puts( "" );
98 }
99
100 /*
101  * Show extended version information about afpd and Netatalk.
102  * Used by "afp -V".
103  */
104 static void show_version_extended(void )
105 {
106         show_version( );
107
108         printf( "      Zeroconf support:\t" );
109 #if defined (HAVE_MDNS)
110         puts( "mDNSResponder" );
111 #elif defined (HAVE_AVAHI)
112         puts( "Avahi" );
113 #else
114         puts( "No" );
115 #endif
116
117         printf( "  TCP wrappers support:\t" );
118 #ifdef TCPWRAP
119         puts( "Yes" );
120 #else
121         puts( "No" );
122 #endif
123
124         printf( "         Quota support:\t" );
125 #ifndef NO_QUOTA_SUPPORT
126         puts( "Yes" );
127 #else
128         puts( "No" );
129 #endif
130
131         printf( "   Admin group support:\t" );
132 #ifdef ADMIN_GRP
133         puts( "Yes" );
134 #else
135         puts( "No" );
136 #endif
137
138         printf( "    Valid shell checks:\t" );
139 #ifndef DISABLE_SHELLCHECK
140         puts( "Yes" );
141 #else
142         puts( "No" );
143 #endif
144
145         printf( "      cracklib support:\t" );
146 #ifdef USE_CRACKLIB
147         puts( "Yes" );
148 #else
149         puts( "No" );
150 #endif
151
152         printf( "            EA support:\t" );
153         puts( EA_MODULES );
154
155         printf( "           ACL support:\t" );
156 #ifdef HAVE_ACLS
157         puts( "Yes" );
158 #else
159         puts( "No" );
160 #endif
161
162         printf( "          LDAP support:\t" );
163 #ifdef HAVE_LDAP
164         puts( "Yes" );
165 #else
166         puts( "No" );
167 #endif
168 }
169
170 /*
171  * Display compiled-in default paths
172  */
173 static void show_paths( void )
174 {
175         printf( "              afp.conf:\t%s\n", _PATH_CONFDIR "afp.conf");
176         printf( "           extmap.conf:\t%s\n", _PATH_CONFDIR "extmap.conf");
177         printf( "       state directory:\t%s\n", _PATH_STATEDIR);
178         printf( "    afp_signature.conf:\t%s\n", _PATH_STATEDIR "afp_signature.conf");
179         printf( "      afp_voluuid.conf:\t%s\n", _PATH_STATEDIR "afp_voluuid.conf");
180         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
181         printf( "  Server messages path:\t%s\n", SERVERTEXT);
182 }
183
184 /*
185  * Display usage information about afpd.
186  */
187 static void show_usage(void)
188 {
189         fprintf( stderr, "Usage:\tafpd [-d] [-F configfile]\n");
190         fprintf( stderr, "\tafpd -h|-v|-V\n");
191 }
192
193 void afp_options_parse_cmdline(AFPObj *obj, int ac, char **av)
194 {
195     int c, err = 0;
196
197     while (EOF != ( c = getopt( ac, av, "dF:vVh" )) ) {
198         switch ( c ) {
199         case 'd':
200             obj->cmdlineflags |= OPTION_DEBUG;
201             break;
202         case 'F':
203             obj->cmdlineconfigfile = strdup(optarg);
204             break;
205         case 'v':       /* version */
206             show_version( ); puts( "" );
207             show_paths( ); puts( "" );
208             exit( 0 );
209             break;
210         case 'V':       /* extended version */
211             show_version_extended( ); puts( "" );
212             show_paths( ); puts( "" );
213             exit( 0 );
214             break;
215         case 'h':       /* usage */
216             show_usage();
217             exit( 0 );
218             break;
219         default :
220             err++;
221         }
222     }
223     if ( err || optind != ac ) {
224         show_usage();
225         exit( 2 );
226     }
227
228     return;
229 }