extern.h revision 1.23 1 1.23 lukem /* $NetBSD: extern.h,v 1.23 2000/01/12 22:39:28 lukem Exp $ */
2 1.19 itojun
3 1.21 lukem /*-
4 1.21 lukem * Copyright (c) 1992, 1993
5 1.21 lukem * The Regents of the University of California. All rights reserved.
6 1.21 lukem *
7 1.19 itojun * Redistribution and use in source and binary forms, with or without
8 1.19 itojun * modification, are permitted provided that the following conditions
9 1.19 itojun * are met:
10 1.19 itojun * 1. Redistributions of source code must retain the above copyright
11 1.19 itojun * notice, this list of conditions and the following disclaimer.
12 1.19 itojun * 2. Redistributions in binary form must reproduce the above copyright
13 1.19 itojun * notice, this list of conditions and the following disclaimer in the
14 1.19 itojun * documentation and/or other materials provided with the distribution.
15 1.21 lukem * 3. All advertising materials mentioning features or use of this software
16 1.21 lukem * must display the following acknowledgement:
17 1.21 lukem * This product includes software developed by the University of
18 1.21 lukem * California, Berkeley and its contributors.
19 1.21 lukem * 4. Neither the name of the University nor the names of its contributors
20 1.19 itojun * may be used to endorse or promote products derived from this software
21 1.19 itojun * without specific prior written permission.
22 1.21 lukem *
23 1.21 lukem * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.19 itojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.19 itojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.21 lukem * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.19 itojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.19 itojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.19 itojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.19 itojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.19 itojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.19 itojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.19 itojun * SUCH DAMAGE.
34 1.21 lukem *
35 1.21 lukem * @(#)extern.h 8.2 (Berkeley) 4/4/94
36 1.19 itojun */
37 1.2 cgd
38 1.1 deraadt /*-
39 1.22 lukem * Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
40 1.21 lukem * All rights reserved.
41 1.21 lukem *
42 1.21 lukem * This code is derived from software contributed to The NetBSD Foundation
43 1.21 lukem * by Luke Mewburn.
44 1.1 deraadt *
45 1.1 deraadt * Redistribution and use in source and binary forms, with or without
46 1.1 deraadt * modification, are permitted provided that the following conditions
47 1.1 deraadt * are met:
48 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
49 1.1 deraadt * notice, this list of conditions and the following disclaimer.
50 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
51 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
52 1.1 deraadt * documentation and/or other materials provided with the distribution.
53 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
54 1.1 deraadt * must display the following acknowledgement:
55 1.21 lukem * This product includes software developed by the NetBSD
56 1.21 lukem * Foundation, Inc. and its contributors.
57 1.21 lukem * 4. Neither the name of The NetBSD Foundation nor the names of its
58 1.21 lukem * contributors may be used to endorse or promote products derived
59 1.21 lukem * from this software without specific prior written permission.
60 1.21 lukem *
61 1.21 lukem * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
62 1.21 lukem * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
63 1.21 lukem * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64 1.21 lukem * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
65 1.21 lukem * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
66 1.21 lukem * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
67 1.21 lukem * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
68 1.21 lukem * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
69 1.21 lukem * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
70 1.21 lukem * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
71 1.21 lukem * POSSIBILITY OF SUCH DAMAGE.
72 1.21 lukem */
73 1.21 lukem
74 1.21 lukem /*
75 1.21 lukem * Copyright (C) 1997 and 1998 WIDE Project.
76 1.21 lukem * All rights reserved.
77 1.21 lukem *
78 1.21 lukem * Redistribution and use in source and binary forms, with or without
79 1.21 lukem * modification, are permitted provided that the following conditions
80 1.21 lukem * are met:
81 1.21 lukem * 1. Redistributions of source code must retain the above copyright
82 1.21 lukem * notice, this list of conditions and the following disclaimer.
83 1.21 lukem * 2. Redistributions in binary form must reproduce the above copyright
84 1.21 lukem * notice, this list of conditions and the following disclaimer in the
85 1.21 lukem * documentation and/or other materials provided with the distribution.
86 1.21 lukem * 3. Neither the name of the project nor the names of its contributors
87 1.1 deraadt * may be used to endorse or promote products derived from this software
88 1.1 deraadt * without specific prior written permission.
89 1.21 lukem *
90 1.21 lukem * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
91 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 1.21 lukem * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
94 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 1.1 deraadt * SUCH DAMAGE.
101 1.1 deraadt */
102 1.1 deraadt
103 1.1 deraadt void blkfree __P((char **));
104 1.5 lukem char *conffilename __P((const char *));
105 1.1 deraadt char **copyblk __P((char **));
106 1.22 lukem void count_users __P((void));
107 1.10 mycroft void cwd __P((const char *));
108 1.16 lukem void delete __P((const char *));
109 1.20 lukem char **do_conversion __P((const char *));
110 1.1 deraadt void dologout __P((int));
111 1.16 lukem void fatal __P((const char *));
112 1.21 lukem int format_file __P((const char *, int));
113 1.1 deraadt int ftpd_pclose __P((FILE *));
114 1.20 lukem FILE *ftpd_popen __P((char *[], const char *, int));
115 1.1 deraadt char *getline __P((char *, int, FILE *));
116 1.22 lukem void init_curclass __P((void));
117 1.16 lukem void logcmd __P((const char *, off_t, const char *, const char *,
118 1.16 lukem const struct timeval *, const char *));
119 1.9 mycroft void logwtmp __P((const char *, const char *, const char *));
120 1.1 deraadt void lreply __P((int, const char *, ...));
121 1.16 lukem void makedir __P((const char *));
122 1.4 christos void parse_conf __P((char *));
123 1.16 lukem void pass __P((const char *));
124 1.1 deraadt void passive __P((void));
125 1.19 itojun void long_passive __P((char *, int));
126 1.10 mycroft void perror_reply __P((int, const char *));
127 1.1 deraadt void pwd __P((void));
128 1.16 lukem void removedir __P((const char *));
129 1.16 lukem void renamecmd __P((const char *, const char *));
130 1.1 deraadt char *renamefrom __P((char *));
131 1.1 deraadt void reply __P((int, const char *, ...));
132 1.20 lukem void retrieve __P((char *[], const char *));
133 1.16 lukem void send_file_list __P((const char *));
134 1.3 lukem void show_chdir_messages __P((int));
135 1.1 deraadt void statcmd __P((void));
136 1.16 lukem void statfilecmd __P((const char *));
137 1.16 lukem void store __P((const char *, const char *, int));
138 1.21 lukem int strsuftoi __P((const char *));
139 1.16 lukem void user __P((const char *));
140 1.12 lukem char *xstrdup __P((const char *));
141 1.1 deraadt void yyerror __P((char *));
142 1.18 ross
143 1.18 ross typedef long long qdfmt_t;
144 1.18 ross typedef unsigned long long qufmt_t;
145 1.3 lukem
146 1.21 lukem typedef enum {
147 1.21 lukem CLASS_GUEST,
148 1.21 lukem CLASS_CHROOT,
149 1.21 lukem CLASS_REAL
150 1.21 lukem } class_t;
151 1.3 lukem
152 1.3 lukem struct ftpconv {
153 1.3 lukem struct ftpconv *next;
154 1.4 christos char *suffix; /* Suffix of requested name */
155 1.4 christos char *types; /* Valid file types */
156 1.4 christos char *disable; /* File to disable conversions */
157 1.4 christos char *command; /* Command to do the conversion */
158 1.3 lukem };
159 1.3 lukem
160 1.3 lukem struct ftpclass {
161 1.7 lukem int checkportcmd; /* Check PORT commands are valid */
162 1.4 christos char *classname; /* Current class */
163 1.20 lukem struct ftpconv *conversions; /* List of conversions */
164 1.4 christos char *display; /* Files to display upon chdir */
165 1.22 lukem int limit; /* Max connections (-1 = unlimited) */
166 1.22 lukem char *limitfile; /* File to display if limit reached */
167 1.21 lukem int maxrateget; /* Maximum get transfer rate throttle */
168 1.21 lukem int maxrateput; /* Maximum put transfer rate throttle */
169 1.3 lukem unsigned int maxtimeout; /* Maximum permitted timeout */
170 1.21 lukem int modify; /* Allow CHMOD, DELE, MKD, RMD, RNFR,
171 1.21 lukem UMASK */
172 1.21 lukem char *motd; /* MotD file to display after login */
173 1.4 christos char *notify; /* Files to notify about upon chdir */
174 1.23 lukem int passive; /* Allow PASV mode */
175 1.23 lukem int portmin; /* Minumum port for passive mode */
176 1.23 lukem int portmax; /* Maximum port for passive mode */
177 1.21 lukem int rateget; /* Get (RETR) transfer rate throttle */
178 1.21 lukem int rateput; /* Put (STOR) transfer rate throttle */
179 1.3 lukem unsigned int timeout; /* Default timeout */
180 1.21 lukem class_t type; /* Class type */
181 1.3 lukem mode_t umask; /* Umask to use */
182 1.21 lukem int upload; /* As per modify, but also allow
183 1.21 lukem APPE, STOR, STOU */
184 1.3 lukem };
185 1.11 lukem
186 1.19 itojun #include <netinet/in.h>
187 1.19 itojun
188 1.19 itojun union sockunion {
189 1.19 itojun struct sockinet {
190 1.19 itojun u_char si_len;
191 1.19 itojun u_char si_family;
192 1.19 itojun u_short si_port;
193 1.19 itojun } su_si;
194 1.19 itojun struct sockaddr_in su_sin;
195 1.19 itojun struct sockaddr_in6 su_sin6;
196 1.19 itojun };
197 1.19 itojun #define su_len su_si.si_len
198 1.19 itojun #define su_family su_si.si_family
199 1.19 itojun #define su_port su_si.si_port
200 1.19 itojun
201 1.23 lukem extern int yyparse __P((void));
202 1.11 lukem
203 1.23 lukem #ifndef GLOBAL
204 1.23 lukem #define GLOBAL extern
205 1.23 lukem #endif
206 1.23 lukem
207 1.23 lukem GLOBAL int connections;
208 1.23 lukem GLOBAL struct ftpclass curclass;
209 1.23 lukem GLOBAL union sockunion data_dest;
210 1.23 lukem GLOBAL int debug;
211 1.23 lukem GLOBAL jmp_buf errcatch;
212 1.23 lukem GLOBAL int form;
213 1.23 lukem GLOBAL int hasyyerrored;
214 1.23 lukem GLOBAL union sockunion his_addr;
215 1.23 lukem GLOBAL char hostname[];
216 1.11 lukem #ifdef KERBEROS5
217 1.23 lukem GLOBAL krb5_context kcontext;
218 1.11 lukem #endif
219 1.23 lukem GLOBAL int logged_in;
220 1.23 lukem GLOBAL int logging;
221 1.23 lukem GLOBAL int pdata;
222 1.23 lukem GLOBAL char proctitle[];
223 1.23 lukem GLOBAL struct passwd *pw;
224 1.23 lukem GLOBAL char remotehost[];
225 1.23 lukem GLOBAL off_t restart_point;
226 1.23 lukem GLOBAL char tmpline[];
227 1.23 lukem GLOBAL sig_atomic_t transflag;
228 1.23 lukem GLOBAL int type;
229 1.23 lukem GLOBAL int usedefault;
230 1.23 lukem GLOBAL const char version[];
231 1.23 lukem
232 1.23 lukem GLOBAL off_t total_data_in, total_data_out, total_data;
233 1.23 lukem GLOBAL off_t total_files_in, total_files_out, total_files;
234 1.23 lukem GLOBAL off_t total_bytes_in, total_bytes_out, total_bytes;
235 1.23 lukem GLOBAL off_t total_xfers_in, total_xfers_out, total_xfers;
236 1.16 lukem
237 1.16 lukem
238 1.21 lukem #define EMPTYSTR(p) ((p) == NULL || *(p) == '\0')
239 1.21 lukem #define NEXTWORD(P, W) do { \
240 1.21 lukem (W) = strsep(&(P), " \t"); \
241 1.21 lukem } while ((W) != NULL && *(W) == '\0')
242 1.16 lukem #define PLURAL(s) ((s) == 1 ? "" : "s")
243 1.21 lukem #define REASSIGN(X,Y) do { if (X) free(X); (X)=(Y); } while (0)
244 1.21 lukem
245 1.17 lukem #define INTERNAL_LS "/bin/ls"
246