10Sstevel@tonic-gate /* 2*12333SMilan.Jurik@Sun.COM * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate */ 40Sstevel@tonic-gate 50Sstevel@tonic-gate /**************************************************************************** 60Sstevel@tonic-gate Copyright (c) 1999,2000 WU-FTPD Development Group. 70Sstevel@tonic-gate All rights reserved. 80Sstevel@tonic-gate 90Sstevel@tonic-gate Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 100Sstevel@tonic-gate The Regents of the University of California. 110Sstevel@tonic-gate Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. 120Sstevel@tonic-gate Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. 130Sstevel@tonic-gate Portions Copyright (c) 1989 Massachusetts Institute of Technology. 140Sstevel@tonic-gate Portions Copyright (c) 1998 Sendmail, Inc. 150Sstevel@tonic-gate Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. 160Sstevel@tonic-gate Portions Copyright (c) 1997 by Stan Barber. 170Sstevel@tonic-gate Portions Copyright (c) 1997 by Kent Landfield. 180Sstevel@tonic-gate Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 190Sstevel@tonic-gate Free Software Foundation, Inc. 200Sstevel@tonic-gate 210Sstevel@tonic-gate Use and distribution of this software and its source code are governed 220Sstevel@tonic-gate by the terms and conditions of the WU-FTPD Software License ("LICENSE"). 230Sstevel@tonic-gate 240Sstevel@tonic-gate If you did not receive a copy of the license, it may be obtained online 250Sstevel@tonic-gate at http://www.wu-ftpd.org/license.html. 260Sstevel@tonic-gate 270Sstevel@tonic-gate $Id: proto.h,v 1.10 2000/07/01 18:17:39 wuftpd Exp $ 280Sstevel@tonic-gate 290Sstevel@tonic-gate ****************************************************************************/ 300Sstevel@tonic-gate #include <sys/types.h> 310Sstevel@tonic-gate #include <sys/stat.h> 320Sstevel@tonic-gate #include <sys/socket.h> 330Sstevel@tonic-gate #include <ctype.h> 340Sstevel@tonic-gate #include <stdio.h> 350Sstevel@tonic-gate #include <stdlib.h> 360Sstevel@tonic-gate #include <signal.h> 370Sstevel@tonic-gate #include <pwd.h> 380Sstevel@tonic-gate #include <grp.h> 390Sstevel@tonic-gate #include <setjmp.h> 400Sstevel@tonic-gate #include <netdb.h> 410Sstevel@tonic-gate #include <errno.h> 420Sstevel@tonic-gate #include <string.h> 430Sstevel@tonic-gate #include <stdarg.h> 440Sstevel@tonic-gate #include <netinet/in.h> 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate ** access.c 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate int parsetime(char *); 500Sstevel@tonic-gate int validtime(char *); 510Sstevel@tonic-gate int hostmatch(char *, char *, char *); 520Sstevel@tonic-gate int acl_guestgroup(struct passwd *); 530Sstevel@tonic-gate int acl_realgroup(struct passwd *); 540Sstevel@tonic-gate void acl_autogroup(struct passwd *); 550Sstevel@tonic-gate void acl_setfunctions(void); 560Sstevel@tonic-gate int acl_getclass(char *); 570Sstevel@tonic-gate int acl_getlimit(char *, char *); 580Sstevel@tonic-gate int acl_getnice(char *); 590Sstevel@tonic-gate void acl_getdefumask(char *); 600Sstevel@tonic-gate void acl_tcpwindow(char *); 610Sstevel@tonic-gate void acl_filelimit(char *); 620Sstevel@tonic-gate void acl_datalimit(char *); 630Sstevel@tonic-gate int acl_deny(char *); 640Sstevel@tonic-gate int acl_countusers(char *); 650Sstevel@tonic-gate int acl_join(char *, int); 660Sstevel@tonic-gate void acl_remove(void); 670Sstevel@tonic-gate void pr_mesg(int, char *); 680Sstevel@tonic-gate void access_init(void); 690Sstevel@tonic-gate int access_ok(int); 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate ** acl.c 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate struct aclmember *getaclentry(char *, struct aclmember **); 750Sstevel@tonic-gate void parseacl(void); 760Sstevel@tonic-gate int readacl(char *); 770Sstevel@tonic-gate 780Sstevel@tonic-gate /* 790Sstevel@tonic-gate ** auth.c 800Sstevel@tonic-gate */ 810Sstevel@tonic-gate #ifdef BSD_AUTH 820Sstevel@tonic-gate char *start_auth(char *, char *, struct passwd *); 830Sstevel@tonic-gate #endif 840Sstevel@tonic-gate char *check_auth(char *, char *); 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 870Sstevel@tonic-gate ** authenticate.c 880Sstevel@tonic-gate */ 890Sstevel@tonic-gate int wu_authenticate(void); 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* 920Sstevel@tonic-gate ** conversions.c 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate void conv_init(void); 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate ** domain.c 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate int check_rhost_reverse(void); 1000Sstevel@tonic-gate int check_rhost_matches(void); 1010Sstevel@tonic-gate int rhostlookup(char *); 1020Sstevel@tonic-gate void set_res_options(void); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 1050Sstevel@tonic-gate ** extensions.c 1060Sstevel@tonic-gate */ 1070Sstevel@tonic-gate #ifdef SITE_NEWER 1080Sstevel@tonic-gate int check_newer(const char *, const struct stat *, int); 1090Sstevel@tonic-gate void newer(char *date, char *path, int showlots); 1100Sstevel@tonic-gate #endif 1110Sstevel@tonic-gate long getSize(char *); 1120Sstevel@tonic-gate void msg_massage(const char *, char *, size_t); 1130Sstevel@tonic-gate int cwd_beenhere(int); 1140Sstevel@tonic-gate void show_banner(int); 1150Sstevel@tonic-gate void show_message(int, int); 1160Sstevel@tonic-gate void show_readme(int, int); 1170Sstevel@tonic-gate int deny_badasciixfer(int, char *); 1180Sstevel@tonic-gate int is_shutdown(int, int); 1190Sstevel@tonic-gate int type_match(char *typelist); 1200Sstevel@tonic-gate int path_compare(char *p1, char *p2); 1210Sstevel@tonic-gate void expand_id(void); 1220Sstevel@tonic-gate int fn_check(char *name); 1230Sstevel@tonic-gate int dir_check(char *name, uid_t * uid, gid_t * gid, int *d_mode, int *valid); 1240Sstevel@tonic-gate int upl_check(char *name, uid_t * uid, gid_t * gid, int *f_mode, int *valid); 1250Sstevel@tonic-gate int del_check(char *name); 1260Sstevel@tonic-gate int regexmatch(char *name, char *rgexp); 1270Sstevel@tonic-gate int checknoretrieve(char *name); 1280Sstevel@tonic-gate int path_to_device(char *pathname, char *result); 1290Sstevel@tonic-gate void get_quota(char *fs, int uid); 1300Sstevel@tonic-gate char *time_quota(long curstate, long softlimit, long timelimit, char *timeleft); 1310Sstevel@tonic-gate void fmttime(char *buf, register long time); 1320Sstevel@tonic-gate int file_compare(char *patterns, char *file); 1330Sstevel@tonic-gate int remote_compare(char *patterns); 1340Sstevel@tonic-gate void throughput_calc(char *name, int *bps, double *bpsmult); 1350Sstevel@tonic-gate void throughput_adjust(char *name); 1360Sstevel@tonic-gate void SetCheckMethod(const char *method); 1370Sstevel@tonic-gate void ShowCheckMethod(void); 1380Sstevel@tonic-gate void CheckSum(char *pathname); 1390Sstevel@tonic-gate void CheckSumLastFile(void); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate ** ftpcmd.c 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate char *wu_getline(char *s, int n, register FILE *iop); 1450Sstevel@tonic-gate int yyparse(void); 1460Sstevel@tonic-gate void upper(char *s); 1470Sstevel@tonic-gate char *copy(char *s); 1480Sstevel@tonic-gate void sizecmd(char *filename); 1490Sstevel@tonic-gate void site_exec(char *cmd); 1500Sstevel@tonic-gate void alias(char *s); 1510Sstevel@tonic-gate void cdpath(void); 1520Sstevel@tonic-gate void print_groups(void); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate /* 1550Sstevel@tonic-gate ** ftpd.c 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate SIGNAL_TYPE randomsig(int sig); 1590Sstevel@tonic-gate SIGNAL_TYPE lostconn(int sig); 1600Sstevel@tonic-gate char *mapping_getwd(char *path); 1610Sstevel@tonic-gate void do_elem(char *dir); 1620Sstevel@tonic-gate int mapping_chdir(char *orig_path); 1630Sstevel@tonic-gate char *sgetsave(char *s); 1640Sstevel@tonic-gate struct passwd *sgetpwnam(char *name); 1650Sstevel@tonic-gate char *skey_challenge(char *name, struct passwd *pwd, int pwok); 1660Sstevel@tonic-gate void user(char *name); 1670Sstevel@tonic-gate int checkuser(char *name); 1680Sstevel@tonic-gate int uid_match(char *keyword, uid_t uid); 1690Sstevel@tonic-gate int gid_match(char *keyword, gid_t gid, char *username); 1700Sstevel@tonic-gate int denieduid(uid_t uid); 1710Sstevel@tonic-gate int alloweduid(uid_t uid); 1720Sstevel@tonic-gate int deniedgid(gid_t gid); 1730Sstevel@tonic-gate int allowedgid(gid_t gid); 1740Sstevel@tonic-gate void end_login(void); 1750Sstevel@tonic-gate int validate_eaddr(char *eaddr); 1760Sstevel@tonic-gate void pass(char *passwd); 1770Sstevel@tonic-gate int restricteduid(uid_t uid); 1780Sstevel@tonic-gate int unrestricteduid(uid_t uid); 1790Sstevel@tonic-gate int restrictedgid(gid_t gid); 1800Sstevel@tonic-gate int unrestrictedgid(gid_t gid); 1810Sstevel@tonic-gate char *opt_string(int options); 1820Sstevel@tonic-gate void retrieve(char *cmd, char *name); 1830Sstevel@tonic-gate void store(char *name, char *mode, int unique); 1840Sstevel@tonic-gate FILE *getdatasock(char *mode); 1850Sstevel@tonic-gate FILE *dataconn(char *name, off_t size, char *mode); 1860Sstevel@tonic-gate #ifdef THROUGHPUT 1870Sstevel@tonic-gate int send_data(char *name, FILE *instr, FILE *outstr, size_t blksize); 1880Sstevel@tonic-gate #else 1890Sstevel@tonic-gate int send_data(FILE *instr, FILE *outstr, size_t blksize); 1900Sstevel@tonic-gate #endif 1910Sstevel@tonic-gate int receive_data(FILE *instr, FILE *outstr); 1920Sstevel@tonic-gate void statfilecmd(char *filename); 1930Sstevel@tonic-gate void statcmd(void); 1940Sstevel@tonic-gate void fatal(char *s); 1950Sstevel@tonic-gate void vreply(long flags, int n, char *fmt, va_list ap); 1960Sstevel@tonic-gate void reply(int, char *fmt,...); 1970Sstevel@tonic-gate void lreply(int, char *fmt,...); 1980Sstevel@tonic-gate void ack(char *s); 1990Sstevel@tonic-gate void nack(char *s); 2000Sstevel@tonic-gate void yyerror(char *s); 2010Sstevel@tonic-gate void delete(char *name); 2020Sstevel@tonic-gate void cwd(char *path); 2030Sstevel@tonic-gate void makedir(char *name); 2040Sstevel@tonic-gate void removedir(char *name); 2050Sstevel@tonic-gate void pwd(void); 2060Sstevel@tonic-gate char *renamefrom(char *name); 2070Sstevel@tonic-gate void renamecmd(char *from, char *to); 2080Sstevel@tonic-gate void dologout(int status); 2090Sstevel@tonic-gate SIGNAL_TYPE myoob(int sig); 2100Sstevel@tonic-gate void passive(int passive_mode, int proto); 2110Sstevel@tonic-gate char *gunique(char *local); 2120Sstevel@tonic-gate void perror_reply(int code, char *string); 2130Sstevel@tonic-gate void send_file_list(char *whichfiles); 2140Sstevel@tonic-gate void initsetproctitle(int argc, char **argv, char **envp); 2150Sstevel@tonic-gate void setproctitle(const char *fmt,...); 2160Sstevel@tonic-gate void init_krb(void); 2170Sstevel@tonic-gate void end_krb(void); 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate #ifdef INTERNAL_LS 2200Sstevel@tonic-gate char *rpad(char *s, unsigned int len); 2210Sstevel@tonic-gate char *ls_file(const char *file, int nameonly, char remove_path, char classify); 2220Sstevel@tonic-gate void ls_dir(char *d, char ls_a, char ls_F, char ls_l, char ls_R, char omit_total, FILE *out); 2230Sstevel@tonic-gate void ls(char *file, char nlst); 2240Sstevel@tonic-gate #endif 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate void fixpath(char *path); 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate ** glob.c 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate void blkfree(char **); 232*12333SMilan.Jurik@Sun.COM char **ftpglob(register char *, boolean_t check_ncargs); 2330Sstevel@tonic-gate char *strspl(register char *, register char *); 2340Sstevel@tonic-gate char **copyblk(register char **); 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate /* 2370Sstevel@tonic-gate ** hostacc.c 2380Sstevel@tonic-gate */ 2390Sstevel@tonic-gate int rhost_ok(char *pcRuser, char *pcRhost, char *pcRaddr); 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate /* 2420Sstevel@tonic-gate ** loadavg.c 2430Sstevel@tonic-gate */ 2440Sstevel@tonic-gate /* 2450Sstevel@tonic-gate ** logwtmp.c 2460Sstevel@tonic-gate */ 2470Sstevel@tonic-gate void wu_logwtmp(char *line, char *name, char *host, int login); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* 2500Sstevel@tonic-gate ** paths.c 2510Sstevel@tonic-gate */ 2520Sstevel@tonic-gate void setup_paths(void); 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate ** popen.c 2560Sstevel@tonic-gate */ 2570Sstevel@tonic-gate FILE *ftpd_popen(char *program, char *type, int closestderr); 2580Sstevel@tonic-gate int ftpd_pclose(FILE *iop); 2590Sstevel@tonic-gate void closefds(int startfd); 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate /* 2620Sstevel@tonic-gate ** private.c 2630Sstevel@tonic-gate */ 2640Sstevel@tonic-gate #ifndef NO_PRIVATE 2650Sstevel@tonic-gate void priv_setup(char *path); 2660Sstevel@tonic-gate void priv_group(char *group); 2670Sstevel@tonic-gate void priv_gpass(char *gpass); 2680Sstevel@tonic-gate #endif 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate /* 2710Sstevel@tonic-gate ** rdservers.c 2720Sstevel@tonic-gate */ 2730Sstevel@tonic-gate #ifdef VIRTUAL 2740Sstevel@tonic-gate int read_servers_line(FILE *, char *, size_t, char *, size_t); 2750Sstevel@tonic-gate #endif 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate /* 2780Sstevel@tonic-gate ** realpath.c 2790Sstevel@tonic-gate */ 2800Sstevel@tonic-gate char *fb_realpath(const char *path, char *resolved); 2810Sstevel@tonic-gate char *wu_realpath(const char *path, char *resolved_path, char *chroot_path); 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate /* 2840Sstevel@tonic-gate ** restrict.c 2850Sstevel@tonic-gate */ 2860Sstevel@tonic-gate int restrict_check(char *name); 2870Sstevel@tonic-gate int test_restriction(char *name); 2880Sstevel@tonic-gate int restrict_list_check(char *name); 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate ** routevector.c 2920Sstevel@tonic-gate */ 2930Sstevel@tonic-gate int routevector(void); 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate ** timeout.c 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate void load_timeouts(void); 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate /* 3010Sstevel@tonic-gate ** inet.c 3020Sstevel@tonic-gate */ 3030Sstevel@tonic-gate char *inet_htop(const char *hostname); 3040Sstevel@tonic-gate char *inet_stop(struct SOCKSTORAGE *ss); 3050Sstevel@tonic-gate char *wu_gethostbyname(const char *hostname); 3060Sstevel@tonic-gate int wu_gethostbyaddr(struct SOCKSTORAGE *ss, char *hostname, int hostlen); 3070Sstevel@tonic-gate int sock_cmp_inaddr(struct SOCKSTORAGE *ss, struct in_addr addr); 3080Sstevel@tonic-gate #ifdef INET6 3090Sstevel@tonic-gate void sock_set_inaddr(struct SOCKSTORAGE *ss, struct in_addr addr); 3100Sstevel@tonic-gate int sock_cmp_addr(struct SOCKSTORAGE *ss1, struct SOCKSTORAGE *ss2); 3110Sstevel@tonic-gate void sock_set_scope(struct SOCKSTORAGE *dst, struct SOCKSTORAGE *src); 3120Sstevel@tonic-gate int inet_pton6(char *str, struct in6_addr *addr); 3130Sstevel@tonic-gate const char *inet_ntop_native(int af, const void *addr, char *dst, size_t size); 3140Sstevel@tonic-gate #endif 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate /* 3170Sstevel@tonic-gate ** xferlog.c 3180Sstevel@tonic-gate */ 3190Sstevel@tonic-gate void get_xferlog_format(void); 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /* 3220Sstevel@tonic-gate ** privs.c 3230Sstevel@tonic-gate */ 3240Sstevel@tonic-gate void init_privs(const char *); 3250Sstevel@tonic-gate void port_priv_on(uid_t); 3260Sstevel@tonic-gate void port_priv_off(uid_t); 3270Sstevel@tonic-gate void access_priv_on(uid_t); 3280Sstevel@tonic-gate void access_priv_off(uid_t); 3290Sstevel@tonic-gate void setid_priv_on(uid_t); 3300Sstevel@tonic-gate void setid_priv_off(uid_t); 3310Sstevel@tonic-gate void chown_priv_on(uid_t); 3320Sstevel@tonic-gate void chown_priv_off(uid_t); 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate /* 3350Sstevel@tonic-gate ** support/getusershell.c 3360Sstevel@tonic-gate */ 3370Sstevel@tonic-gate char *getusershell(void); 3380Sstevel@tonic-gate void endusershell(void); 339