]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/afp_options.c
3b37538b642c312f212f6e1821dc601d6da34a84
[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 #ifdef USE_ZEROCONF
159         puts( "Yes" );
160 #else
161         puts( "No" );
162 #endif
163
164         printf( "  TCP wrappers support:\t" );
165 #ifdef TCPWRAP
166         puts( "Yes" );
167 #else
168         puts( "No" );
169 #endif
170
171         printf( "         Quota support:\t" );
172 #ifndef NO_QUOTA_SUPPORT
173         puts( "Yes" );
174 #else
175         puts( "No" );
176 #endif
177
178         printf( "   Admin group support:\t" );
179 #ifdef ADMIN_GRP
180         puts( "Yes" );
181 #else
182         puts( "No" );
183 #endif
184
185         printf( "    Valid shell checks:\t" );
186 #ifndef DISABLE_SHELLCHECK
187         puts( "Yes" );
188 #else
189         puts( "No" );
190 #endif
191
192         printf( "      cracklib support:\t" );
193 #ifdef USE_CRACKLIB
194         puts( "Yes" );
195 #else
196         puts( "No" );
197 #endif
198
199         printf( "            EA support:\t" );
200         puts( EA_MODULES );
201
202         printf( "           ACL support:\t" );
203 #ifdef HAVE_ACLS
204         puts( "Yes" );
205 #else
206         puts( "No" );
207 #endif
208
209         printf( "          LDAP support:\t" );
210 #ifdef HAVE_LDAP
211         puts( "Yes" );
212 #else
213         puts( "No" );
214 #endif
215 }
216
217 /*
218  * Display compiled-in default paths
219  */
220 static void show_paths( void )
221 {
222         printf( "              afp.conf:\t%s\n", _PATH_CONFDIR "afp.conf");
223         printf( "    afp_signature.conf:\t%s\n", _PATH_CONFDIR "afp_signature.conf");
224         printf( "      afp_voluuid.conf:\t%s\n", _PATH_CONFDIR "afp_voluuid.conf");
225         printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
226         printf( "  Server messages path:\t%s\n", SERVERTEXT);
227         printf( "              lockfile:\t%s\n", _PATH_AFPDLOCK);
228 }
229
230 /*
231  * Display usage information about afpd.
232  */
233 static void show_usage(void)
234 {
235         fprintf( stderr, "Usage:\tafpd [-d] [-F configfile]\n");
236         fprintf( stderr, "\tafpd -h|-v|-V\n");
237 }
238
239 void afp_options_parse_cmdline(AFPObj *obj, int ac, char **av)
240 {
241     int c, err = 0;
242
243     while (EOF != ( c = getopt( ac, av, "dFvVh" )) ) {
244         switch ( c ) {
245         case 'd':
246             obj->cmdlineflags |= OPTION_DEBUG;
247             break;
248         case 'F':
249             obj->cmdlineconfigfile = strdup(optarg);
250             break;
251         case 'v':       /* version */
252             show_version( ); puts( "" );
253             show_paths( ); puts( "" );
254             exit( 0 );
255             break;
256         case 'V':       /* extended version */
257             show_version_extended( ); puts( "" );
258             show_paths( ); puts( "" );
259             exit( 0 );
260             break;
261         case 'h':       /* usage */
262             show_usage();
263             exit( 0 );
264             break;
265         default :
266             err++;
267         }
268     }
269     if ( err || optind != ac ) {
270         show_usage();
271         exit( 2 );
272     }
273
274     return;
275 }