xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/ckconfig.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate  * Use is subject to license terms.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*0Sstevel@tonic-gate 
8*0Sstevel@tonic-gate /****************************************************************************
9*0Sstevel@tonic-gate 
10*0Sstevel@tonic-gate   Copyright (c) 1999,2000 WU-FTPD Development Group.
11*0Sstevel@tonic-gate   All rights reserved.
12*0Sstevel@tonic-gate 
13*0Sstevel@tonic-gate   Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
14*0Sstevel@tonic-gate     The Regents of the University of California.
15*0Sstevel@tonic-gate   Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
16*0Sstevel@tonic-gate   Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
17*0Sstevel@tonic-gate   Portions Copyright (c) 1989 Massachusetts Institute of Technology.
18*0Sstevel@tonic-gate   Portions Copyright (c) 1998 Sendmail, Inc.
19*0Sstevel@tonic-gate   Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P.  Allman.
20*0Sstevel@tonic-gate   Portions Copyright (c) 1997 by Stan Barber.
21*0Sstevel@tonic-gate   Portions Copyright (c) 1997 by Kent Landfield.
22*0Sstevel@tonic-gate   Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
23*0Sstevel@tonic-gate     Free Software Foundation, Inc.
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate   Use and distribution of this software and its source code are governed
26*0Sstevel@tonic-gate   by the terms and conditions of the WU-FTPD Software License ("LICENSE").
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate   If you did not receive a copy of the license, it may be obtained online
29*0Sstevel@tonic-gate   at http://www.wu-ftpd.org/license.html.
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate   $Id: ckconfig.c,v 1.10 2000/07/01 18:17:38 wuftpd Exp $
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate ****************************************************************************/
34*0Sstevel@tonic-gate #include "config.h"
35*0Sstevel@tonic-gate #ifndef HOST_ACCESS
36*0Sstevel@tonic-gate #define  HOST_ACCESS  1
37*0Sstevel@tonic-gate #endif
38*0Sstevel@tonic-gate #include <stdio.h>
39*0Sstevel@tonic-gate #include <string.h>
40*0Sstevel@tonic-gate #include <sys/types.h>
41*0Sstevel@tonic-gate #include <sys/param.h>
42*0Sstevel@tonic-gate #include <sys/stat.h>
43*0Sstevel@tonic-gate #include "pathnames.h"
44*0Sstevel@tonic-gate #if defined(VIRTUAL) && defined(INET6)
45*0Sstevel@tonic-gate #include <netinet/in.h>
46*0Sstevel@tonic-gate #endif
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate /* Prototypes */
49*0Sstevel@tonic-gate #ifdef VIRTUAL
50*0Sstevel@tonic-gate extern int read_servers_line(FILE *, char *, size_t, char *, size_t);
51*0Sstevel@tonic-gate #endif
52*0Sstevel@tonic-gate void print_copyright(void);
53*0Sstevel@tonic-gate 
main(int argc,char ** argv)54*0Sstevel@tonic-gate int main(int argc, char **argv)
55*0Sstevel@tonic-gate {
56*0Sstevel@tonic-gate     struct stat sbuf;
57*0Sstevel@tonic-gate     char *sp;
58*0Sstevel@tonic-gate     char buf[1024];
59*0Sstevel@tonic-gate     int c;
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate #ifdef VIRTUAL
62*0Sstevel@tonic-gate     FILE *svrfp;
63*0Sstevel@tonic-gate     char accesspath[MAXPATHLEN];
64*0Sstevel@tonic-gate #ifdef INET6
65*0Sstevel@tonic-gate     char hostaddress[INET6_ADDRSTRLEN];
66*0Sstevel@tonic-gate #else
67*0Sstevel@tonic-gate     char hostaddress[32];
68*0Sstevel@tonic-gate #endif
69*0Sstevel@tonic-gate #endif
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate     if (argc > 1) {
72*0Sstevel@tonic-gate 	while ((c = getopt(argc, argv, "V")) != EOF) {
73*0Sstevel@tonic-gate 	    switch (c) {
74*0Sstevel@tonic-gate 	    case 'V':
75*0Sstevel@tonic-gate 		print_copyright();
76*0Sstevel@tonic-gate 		exit(0);
77*0Sstevel@tonic-gate 	    default:
78*0Sstevel@tonic-gate 		fprintf(stderr, "usage: %s [-V]\n", argv[0]);
79*0Sstevel@tonic-gate 		exit(1);
80*0Sstevel@tonic-gate 	    }
81*0Sstevel@tonic-gate 	}
82*0Sstevel@tonic-gate     }
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate     /* _PATH_FTPUSERS   */
85*0Sstevel@tonic-gate     fprintf(stdout, "Checking _PATH_FTPUSERS :: %s\n", _PATH_FTPUSERS);
86*0Sstevel@tonic-gate     if ((stat(_PATH_FTPUSERS, &sbuf)) < 0)
87*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
88*0Sstevel@tonic-gate     else
89*0Sstevel@tonic-gate 	printf("ok.\n");
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate #ifdef VIRTUAL
92*0Sstevel@tonic-gate 
93*0Sstevel@tonic-gate     /* _PATH_FTPSERVERS  */
94*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_FTPSERVERS :: %s\n", _PATH_FTPSERVERS);
95*0Sstevel@tonic-gate     if ((stat(_PATH_FTPSERVERS, &sbuf)) < 0)
96*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
97*0Sstevel@tonic-gate     else {
98*0Sstevel@tonic-gate 	printf("ok.\n");
99*0Sstevel@tonic-gate 	/* Need to check the access files specified in the ftpservers file. */
100*0Sstevel@tonic-gate 	if ((svrfp = fopen(_PATH_FTPSERVERS, "r")) == NULL)
101*0Sstevel@tonic-gate 	    printf("I can't open it! check permissions and run ckconfig again.\n");
102*0Sstevel@tonic-gate 	else {
103*0Sstevel@tonic-gate 	    while (read_servers_line(svrfp, hostaddress, sizeof(hostaddress),
104*0Sstevel@tonic-gate 		   accesspath, sizeof(accesspath)) == 1) {
105*0Sstevel@tonic-gate 		fprintf(stderr, "\nChecking accessfile for %s :: %s\n", hostaddress, accesspath);
106*0Sstevel@tonic-gate 		/*
107*0Sstevel@tonic-gate 		   ** check to see that a valid directory value was
108*0Sstevel@tonic-gate 		   ** supplied and not something such as "INTERNAL"
109*0Sstevel@tonic-gate 		   **
110*0Sstevel@tonic-gate 		   ** It is valid to have a string such as "INTERNAL" in the
111*0Sstevel@tonic-gate 		   ** ftpservers entry. This is not an error. Silently ignore it.
112*0Sstevel@tonic-gate 		 */
113*0Sstevel@tonic-gate 		if (stat(accesspath, &sbuf) == 0) {
114*0Sstevel@tonic-gate 		    if ((sbuf.st_mode & S_IFMT) == S_IFDIR)
115*0Sstevel@tonic-gate 			printf("ok.\n");
116*0Sstevel@tonic-gate 		    else {
117*0Sstevel@tonic-gate 			printf("Check servers file and make sure only directories are listed...\n");
118*0Sstevel@tonic-gate 			printf("look in doc/examples for an example.\n");
119*0Sstevel@tonic-gate 		    }
120*0Sstevel@tonic-gate 		}
121*0Sstevel@tonic-gate 		else
122*0Sstevel@tonic-gate 		    printf("Internal ftpaccess usage specified... ok.\n");
123*0Sstevel@tonic-gate 	    }
124*0Sstevel@tonic-gate 	    fclose(svrfp);
125*0Sstevel@tonic-gate 	}
126*0Sstevel@tonic-gate     }
127*0Sstevel@tonic-gate #endif
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate     /* _PATH_FTPACCESS  */
130*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_FTPACCESS :: %s\n", _PATH_FTPACCESS);
131*0Sstevel@tonic-gate     if ((stat(_PATH_FTPACCESS, &sbuf)) < 0)
132*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
133*0Sstevel@tonic-gate     else
134*0Sstevel@tonic-gate 	printf("ok.\n");
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate     /* _PATH_PIDNAMES   */
137*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_PIDNAMES :: %s\n", _PATH_PIDNAMES);
138*0Sstevel@tonic-gate     (void) strlcpy(buf, _PATH_PIDNAMES, sizeof(buf));
139*0Sstevel@tonic-gate     sp = (char *) strrchr(buf, '/');
140*0Sstevel@tonic-gate     *sp = '\0';
141*0Sstevel@tonic-gate     if ((stat(buf, &sbuf)) < 0) {
142*0Sstevel@tonic-gate 	printf("I can't find it...\n");
143*0Sstevel@tonic-gate 	printf("You need to make this directory [%s] in order for\n", buf);
144*0Sstevel@tonic-gate 	printf("the limit and user count functions to work.\n");
145*0Sstevel@tonic-gate     }
146*0Sstevel@tonic-gate     else
147*0Sstevel@tonic-gate 	printf("ok.\n");
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate     /* _PATH_CVT        */
150*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_CVT :: %s\n", _PATH_CVT);
151*0Sstevel@tonic-gate     if ((stat(_PATH_CVT, &sbuf)) < 0)
152*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
153*0Sstevel@tonic-gate     else
154*0Sstevel@tonic-gate 	printf("ok.\n");
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate     /* _PATH_XFERLOG    */
157*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_XFERLOG :: %s\n", _PATH_XFERLOG);
158*0Sstevel@tonic-gate     if ((stat(_PATH_XFERLOG, &sbuf)) < 0) {
159*0Sstevel@tonic-gate 	printf("I can't find it... \n");
160*0Sstevel@tonic-gate 	printf("Don't worry, it will be created automatically by the\n");
161*0Sstevel@tonic-gate 	printf("server if you do transfer logging.\n");
162*0Sstevel@tonic-gate     }
163*0Sstevel@tonic-gate     else
164*0Sstevel@tonic-gate 	printf("ok.\n");
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate     /* _PATH_PRIVATE    */
167*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_PRIVATE :: %s\n", _PATH_PRIVATE);
168*0Sstevel@tonic-gate     if ((stat(_PATH_PRIVATE, &sbuf)) < 0) {
169*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
170*0Sstevel@tonic-gate 	printf("You only need this if you want SITE GROUP and SITE GPASS\n");
171*0Sstevel@tonic-gate 	printf("functionality. If you do, you will need to edit the example.\n");
172*0Sstevel@tonic-gate     }
173*0Sstevel@tonic-gate     else
174*0Sstevel@tonic-gate 	printf("ok.\n");
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate     /* _PATH_FTPHOSTS   */
177*0Sstevel@tonic-gate     fprintf(stdout, "\nChecking _PATH_FTPHOSTS :: %s\n", _PATH_FTPHOSTS);
178*0Sstevel@tonic-gate     if ((stat(_PATH_FTPHOSTS, &sbuf)) < 0) {
179*0Sstevel@tonic-gate 	printf("I can't find it... look in doc/examples for an example.\n");
180*0Sstevel@tonic-gate 	printf("You only need this if you are using the HOST ACCESS features\n");
181*0Sstevel@tonic-gate 	printf("of the server.\n");
182*0Sstevel@tonic-gate     }
183*0Sstevel@tonic-gate     else
184*0Sstevel@tonic-gate 	printf("ok.\n");
185*0Sstevel@tonic-gate     return (0);
186*0Sstevel@tonic-gate }
187