]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
6361d18fe538dbb16f55a55465aad855ef5ee826
[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 /* get rid of any allocated afp_option buffers. */
48 void afp_options_free(struct afp_options *opt)
49 {
50         if (opt->hostname)
51         free(opt->hostname);
52         if (opt->adminauthuser)
53         free(opt->adminauthuser);
54         if (opt->configfile)
55         free(opt->configfile);
56     if (opt->fqdn)
57         free(opt->fqdn);
58     if (opt->guest)
59         free(opt->guest);
60     if (opt->listen)
61         free(opt->listen);
62     if (opt->k5realm)
63         free(opt->k5realm);
64     if (opt->k5keytab)
65         free(opt->k5keytab);
66     if (opt->k5service)
67         free(opt->k5service);
68     if (opt->logconfig)
69         free(opt->logconfig);
70     if (opt->logfile)
71         free(opt->logfile);
72     if (opt->loginmesg)
73         free(opt->loginmesg);
74     if (opt->maccodepage)
75         free(opt->maccodepage);
76         if (opt->mimicmodel)
77         free(opt->mimicmodel);
78     if (opt->ntdomain)
79         free(opt->ntdomain);
80     if (opt->ntseparator)
81         free(opt->ntseparator);
82     if (opt->passwdfile)
83         free(opt->passwdfile);
84     if (opt->port)
85         free(opt->port);
86     if (opt->signatureopt)
87         free(opt->signatureopt);
88     if (opt->uamlist)
89         free(opt->uamlist);
90     if (opt->uampath)
91         free(opt->uampath);
92     if (opt->unixcodepage)
93         free(opt->unixcodepage);
94 }
95
96 /*
97  * Show version information about afpd.
98  * Used by "afp -v".
99  */
100 static void show_version( void )
101 {
102         int num, i;
103
104         printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
105
106         puts( "This program is free software; you can redistribute it and/or modify it under" );
107         puts( "the terms of the GNU General Public License as published by the Free Software" );
108         puts( "Foundation; either version 2 of the License, or (at your option) any later" );
109         puts( "version. Please see the file COPYING for further information and details.\n" );
110
111         puts( "afpd has been compiled with support for these features:\n" );
112
113         num = sizeof( afp_versions ) / sizeof( afp_versions[ 0 ] );
114         printf( "          AFP versions:\t" );
115         for ( i = 0; i < num; i++ ) {
116                 printf( "%d.%d ", afp_versions[ i ].av_number/10, afp_versions[ i ].av_number%10);
117         }
118         puts( "" );
119
120         printf( "         CNID backends:\t" );
121 #ifdef CNID_BACKEND_CDB
122         printf( "cdb ");
123 #endif
124 #ifdef CNID_BACKEND_DB3
125         printf( "db3 " );
126 #endif
127 #ifdef CNID_BACKEND_DBD
128 #ifdef CNID_BACKEND_DBD_TXN
129         printf( "dbd-txn " );
130 #else
131         printf( "dbd " );
132 #endif
133 #endif
134 #ifdef CNID_BACKEND_HASH
135         printf( "hash " );
136 #endif
137 #ifdef CNID_BACKEND_LAST
138         printf( "last " );
139 #endif
140 #ifdef CNID_BACKEND_MTAB
141         printf( "mtab " );
142 #endif
143 #ifdef CNID_BACKEND_TDB
144         printf( "tdb " );
145 #endif
146         puts( "" );
147 }
148
149 /*
150  * Show extended version information about afpd and Netatalk.
151  * Used by "afp -V".
152  */
153 static void show_version_extended(void )
154 {
155         show_version( );
156
157         printf( "      Zeroconf support:\t" );
158 #if defined (HAVE_MDNS)
159         puts( "mDNSResponder" );
160 #elif defined (HAVE_AVAHI)
161         puts( "Avahi" );
162 #else
163         puts( "No" );
164 #endif
165
166         printf( "  TCP wrappers support:\t" );
167 #ifdef TCPWRAP
168         puts( "Yes" );
169 #else
170         puts( "No" );
171 #endif
172
173         printf( "         Quota support:\t" );
174 #ifndef NO_QUOTA_SUPPORT
175         puts( "Yes" );
176 #else
177         puts( "No" );
178 #endif
179
180         printf( "   Admin group support:\t" );
181 #ifdef ADMIN_GRP
182         puts( "Yes" );
183 #else
184         puts( "No" );
185 #endif
186
187         printf( "    Valid shell checks:\t" );
188 #ifndef DISABLE_SHELLCHECK
189         puts( "Yes" );
190 #else
191         puts( "No" );
192 #endif
193
194         printf( "      cracklib support:\t" );
195 #ifdef USE_CRACKLIB
196         puts( "Yes" );
197 #else
198         puts( "No" );
199 #endif
200
201         printf( "            EA support:\t" );
202         puts( EA_MODULES );
203
204         printf( "           ACL support:\t" );
205 #ifdef HAVE_ACLS
206         puts( "Yes" );
207 #else
208         puts( "No" );
209 #endif
210
211         printf( "          LDAP support:\t" );
212 #ifdef HAVE_LDAP
213         puts( "Yes" );
214 #else
215         puts( "No" );
216 #endif
217 }
218
219 /*
220  * Display compiled-in default paths
221  */
222 static void show_paths( void )
223 {
224         printf( "              afp.conf:\t%s\n", _PATH_CONFDIR "afp.conf");
225         printf( "           extmap.conf:\t%s\n", _PATH_CONFDIR "extmap.conf");
226         printf( "       state directory:\t%s\n", _PATH_STATEDIR);
227         printf( "    afp_signature.conf:\t%s\n", _PATH_STATEDIR "afp_signature.conf");
228         printf( "      afp_voluuid.conf:\t%s\n", _PATH_STATEDIR "afp_voluuid.conf");
229         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
230         printf( "  Server messages path:\t%s\n", SERVERTEXT);
231 }
232
233 /*
234  * Display usage information about afpd.
235  */
236 static void show_usage(void)
237 {
238         fprintf( stderr, "Usage:\tafpd [-d] [-F configfile]\n");
239         fprintf( stderr, "\tafpd -h|-v|-V\n");
240 }
241
242 void afp_options_parse_cmdline(AFPObj *obj, int ac, char **av)
243 {
244     int c, err = 0;
245
246     while (EOF != ( c = getopt( ac, av, "dF:vVh" )) ) {
247         switch ( c ) {
248         case 'd':
249             obj->cmdlineflags |= OPTION_DEBUG;
250             break;
251         case 'F':
252             obj->cmdlineconfigfile = strdup(optarg);
253             break;
254         case 'v':       /* version */
255             show_version( ); puts( "" );
256             show_paths( ); puts( "" );
257             exit( 0 );
258             break;
259         case 'V':       /* extended version */
260             show_version_extended( ); puts( "" );
261             show_paths( ); puts( "" );
262             exit( 0 );
263             break;
264         case 'h':       /* usage */
265             show_usage();
266             exit( 0 );
267             break;
268         default :
269             err++;
270         }
271     }
272     if ( err || optind != ac ) {
273         show_usage();
274         exit( 2 );
275     }
276
277     return;
278 }