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