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