1 /* 2 * Copyright 2004 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 Copyright (c) 1999,2000 WU-FTPD Development Group. 10 All rights reserved. 11 12 Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 13 The Regents of the University of California. 14 Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. 15 Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. 16 Portions Copyright (c) 1989 Massachusetts Institute of Technology. 17 Portions Copyright (c) 1998 Sendmail, Inc. 18 Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. 19 Portions Copyright (c) 1997 by Stan Barber. 20 Portions Copyright (c) 1997 by Kent Landfield. 21 Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 22 Free Software Foundation, Inc. 23 24 Use and distribution of this software and its source code are governed 25 by the terms and conditions of the WU-FTPD Software License ("LICENSE"). 26 27 If you did not receive a copy of the license, it may be obtained online 28 at http://www.wu-ftpd.org/license.html. 29 30 $Id: proto.h,v 1.10 2000/07/01 18:17:39 wuftpd Exp $ 31 32 ****************************************************************************/ 33 #include <sys/types.h> 34 #include <sys/stat.h> 35 #include <sys/socket.h> 36 #include <ctype.h> 37 #include <stdio.h> 38 #include <stdlib.h> 39 #include <signal.h> 40 #include <pwd.h> 41 #include <grp.h> 42 #include <setjmp.h> 43 #include <netdb.h> 44 #include <errno.h> 45 #include <string.h> 46 #include <stdarg.h> 47 #include <netinet/in.h> 48 49 /* 50 ** access.c 51 */ 52 int parsetime(char *); 53 int validtime(char *); 54 int hostmatch(char *, char *, char *); 55 int acl_guestgroup(struct passwd *); 56 int acl_realgroup(struct passwd *); 57 void acl_autogroup(struct passwd *); 58 void acl_setfunctions(void); 59 int acl_getclass(char *); 60 int acl_getlimit(char *, char *); 61 int acl_getnice(char *); 62 void acl_getdefumask(char *); 63 void acl_tcpwindow(char *); 64 void acl_filelimit(char *); 65 void acl_datalimit(char *); 66 int acl_deny(char *); 67 int acl_countusers(char *); 68 int acl_join(char *, int); 69 void acl_remove(void); 70 void pr_mesg(int, char *); 71 void access_init(void); 72 int access_ok(int); 73 74 /* 75 ** acl.c 76 */ 77 struct aclmember *getaclentry(char *, struct aclmember **); 78 void parseacl(void); 79 int readacl(char *); 80 81 /* 82 ** auth.c 83 */ 84 #ifdef BSD_AUTH 85 char *start_auth(char *, char *, struct passwd *); 86 #endif 87 char *check_auth(char *, char *); 88 89 /* 90 ** authenticate.c 91 */ 92 int wu_authenticate(void); 93 94 /* 95 ** conversions.c 96 */ 97 void conv_init(void); 98 99 /* 100 ** domain.c 101 */ 102 int check_rhost_reverse(void); 103 int check_rhost_matches(void); 104 int rhostlookup(char *); 105 void set_res_options(void); 106 107 /* 108 ** extensions.c 109 */ 110 #ifdef SITE_NEWER 111 int check_newer(const char *, const struct stat *, int); 112 void newer(char *date, char *path, int showlots); 113 #endif 114 long getSize(char *); 115 void msg_massage(const char *, char *, size_t); 116 int cwd_beenhere(int); 117 void show_banner(int); 118 void show_message(int, int); 119 void show_readme(int, int); 120 int deny_badasciixfer(int, char *); 121 int is_shutdown(int, int); 122 int type_match(char *typelist); 123 int path_compare(char *p1, char *p2); 124 void expand_id(void); 125 int fn_check(char *name); 126 int dir_check(char *name, uid_t * uid, gid_t * gid, int *d_mode, int *valid); 127 int upl_check(char *name, uid_t * uid, gid_t * gid, int *f_mode, int *valid); 128 int del_check(char *name); 129 int regexmatch(char *name, char *rgexp); 130 int checknoretrieve(char *name); 131 int path_to_device(char *pathname, char *result); 132 void get_quota(char *fs, int uid); 133 char *time_quota(long curstate, long softlimit, long timelimit, char *timeleft); 134 void fmttime(char *buf, register long time); 135 int file_compare(char *patterns, char *file); 136 int remote_compare(char *patterns); 137 void throughput_calc(char *name, int *bps, double *bpsmult); 138 void throughput_adjust(char *name); 139 void SetCheckMethod(const char *method); 140 void ShowCheckMethod(void); 141 void CheckSum(char *pathname); 142 void CheckSumLastFile(void); 143 144 /* 145 ** ftpcmd.c 146 */ 147 char *wu_getline(char *s, int n, register FILE *iop); 148 int yyparse(void); 149 void upper(char *s); 150 char *copy(char *s); 151 void sizecmd(char *filename); 152 void site_exec(char *cmd); 153 void alias(char *s); 154 void cdpath(void); 155 void print_groups(void); 156 157 /* 158 ** ftpd.c 159 */ 160 161 SIGNAL_TYPE randomsig(int sig); 162 SIGNAL_TYPE lostconn(int sig); 163 char *mapping_getwd(char *path); 164 void do_elem(char *dir); 165 int mapping_chdir(char *orig_path); 166 char *sgetsave(char *s); 167 struct passwd *sgetpwnam(char *name); 168 char *skey_challenge(char *name, struct passwd *pwd, int pwok); 169 void user(char *name); 170 int checkuser(char *name); 171 int uid_match(char *keyword, uid_t uid); 172 int gid_match(char *keyword, gid_t gid, char *username); 173 int denieduid(uid_t uid); 174 int alloweduid(uid_t uid); 175 int deniedgid(gid_t gid); 176 int allowedgid(gid_t gid); 177 void end_login(void); 178 int validate_eaddr(char *eaddr); 179 void pass(char *passwd); 180 int restricteduid(uid_t uid); 181 int unrestricteduid(uid_t uid); 182 int restrictedgid(gid_t gid); 183 int unrestrictedgid(gid_t gid); 184 char *opt_string(int options); 185 void retrieve(char *cmd, char *name); 186 void store(char *name, char *mode, int unique); 187 FILE *getdatasock(char *mode); 188 FILE *dataconn(char *name, off_t size, char *mode); 189 #ifdef THROUGHPUT 190 int send_data(char *name, FILE *instr, FILE *outstr, size_t blksize); 191 #else 192 int send_data(FILE *instr, FILE *outstr, size_t blksize); 193 #endif 194 int receive_data(FILE *instr, FILE *outstr); 195 void statfilecmd(char *filename); 196 void statcmd(void); 197 void fatal(char *s); 198 void vreply(long flags, int n, char *fmt, va_list ap); 199 void reply(int, char *fmt,...); 200 void lreply(int, char *fmt,...); 201 void ack(char *s); 202 void nack(char *s); 203 void yyerror(char *s); 204 void delete(char *name); 205 void cwd(char *path); 206 void makedir(char *name); 207 void removedir(char *name); 208 void pwd(void); 209 char *renamefrom(char *name); 210 void renamecmd(char *from, char *to); 211 void dologout(int status); 212 SIGNAL_TYPE myoob(int sig); 213 void passive(int passive_mode, int proto); 214 char *gunique(char *local); 215 void perror_reply(int code, char *string); 216 void send_file_list(char *whichfiles); 217 void initsetproctitle(int argc, char **argv, char **envp); 218 void setproctitle(const char *fmt,...); 219 void init_krb(void); 220 void end_krb(void); 221 222 #ifdef INTERNAL_LS 223 char *rpad(char *s, unsigned int len); 224 char *ls_file(const char *file, int nameonly, char remove_path, char classify); 225 void ls_dir(char *d, char ls_a, char ls_F, char ls_l, char ls_R, char omit_total, FILE *out); 226 void ls(char *file, char nlst); 227 #endif 228 229 void fixpath(char *path); 230 231 /* 232 ** glob.c 233 */ 234 void blkfree(char **); 235 char **ftpglob(register char *); 236 char *strspl(register char *, register char *); 237 char **copyblk(register char **); 238 239 /* 240 ** hostacc.c 241 */ 242 int rhost_ok(char *pcRuser, char *pcRhost, char *pcRaddr); 243 244 /* 245 ** loadavg.c 246 */ 247 /* 248 ** logwtmp.c 249 */ 250 void wu_logwtmp(char *line, char *name, char *host, int login); 251 252 /* 253 ** paths.c 254 */ 255 void setup_paths(void); 256 257 /* 258 ** popen.c 259 */ 260 FILE *ftpd_popen(char *program, char *type, int closestderr); 261 int ftpd_pclose(FILE *iop); 262 void closefds(int startfd); 263 264 /* 265 ** private.c 266 */ 267 #ifndef NO_PRIVATE 268 void priv_setup(char *path); 269 void priv_group(char *group); 270 void priv_gpass(char *gpass); 271 #endif 272 273 /* 274 ** rdservers.c 275 */ 276 #ifdef VIRTUAL 277 int read_servers_line(FILE *, char *, size_t, char *, size_t); 278 #endif 279 280 /* 281 ** realpath.c 282 */ 283 char *fb_realpath(const char *path, char *resolved); 284 char *wu_realpath(const char *path, char *resolved_path, char *chroot_path); 285 286 /* 287 ** restrict.c 288 */ 289 int restrict_check(char *name); 290 int test_restriction(char *name); 291 int restrict_list_check(char *name); 292 293 /* 294 ** routevector.c 295 */ 296 int routevector(void); 297 298 /* 299 ** timeout.c 300 */ 301 void load_timeouts(void); 302 303 /* 304 ** inet.c 305 */ 306 char *inet_htop(const char *hostname); 307 char *inet_stop(struct SOCKSTORAGE *ss); 308 char *wu_gethostbyname(const char *hostname); 309 int wu_gethostbyaddr(struct SOCKSTORAGE *ss, char *hostname, int hostlen); 310 int sock_cmp_inaddr(struct SOCKSTORAGE *ss, struct in_addr addr); 311 #ifdef INET6 312 void sock_set_inaddr(struct SOCKSTORAGE *ss, struct in_addr addr); 313 int sock_cmp_addr(struct SOCKSTORAGE *ss1, struct SOCKSTORAGE *ss2); 314 void sock_set_scope(struct SOCKSTORAGE *dst, struct SOCKSTORAGE *src); 315 int inet_pton6(char *str, struct in6_addr *addr); 316 const char *inet_ntop_native(int af, const void *addr, char *dst, size_t size); 317 #endif 318 319 /* 320 ** xferlog.c 321 */ 322 void get_xferlog_format(void); 323 324 /* 325 ** privs.c 326 */ 327 void init_privs(const char *); 328 void port_priv_on(uid_t); 329 void port_priv_off(uid_t); 330 void access_priv_on(uid_t); 331 void access_priv_off(uid_t); 332 void setid_priv_on(uid_t); 333 void setid_priv_off(uid_t); 334 void chown_priv_on(uid_t); 335 void chown_priv_off(uid_t); 336 337 /* 338 ** support/getusershell.c 339 */ 340 char *getusershell(void); 341 void endusershell(void); 342 343 /* 344 ** support/strcasestr.c 345 */ 346 char *strcasestr(register char *s, register char *find); 347