⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftpd.h

📁 功能强大的ftp服务器源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
void donlist(char *arg, const int on_ctrlconn, const int opt_l_,             const int split_args);void opendata(void);void closedata(void);void addreply(const int code, const char * const line, ...)	__attribute__ ((format(printf, 2, 3)));void addreply_noformat(const int code, const char * const line);void doreply(void);void sighandler(int sig);void prevent(char *arg);unsigned int daemons(unsigned short server_port);void logfile(const int facility, const char *format, ...) 	__attribute__ ((format(printf, 2, 3)));void die(const int err, const int priority, const char * const format, ...)	__attribute__ ((format(printf, 3, 4)));void die_mem(void);void setprogname(const char * const title);int modernformat(const char *file,                 char *target, size_t target_size);int sfgets(void);const char *getgroup(const gid_t gid);const char *getname(const uid_t uid);unsigned int zrand(void);void simplify(char *subdir);int checkprintable(register const char *s);void delete_atomic_file(void);#ifdef HAVE_SYS_FSUID_H# define usleep2 usleep#elsevoid usleep2(const unsigned long microsec);#endifint mysnprintf(char *str, size_t size, const char *format, ...);extern int opt_a, opt_C, opt_d, opt_F, opt_l, opt_R;#ifndef CONFDIR# define CONFDIR "/etc"#endif#ifndef VHOST_PATH# define VHOST_PATH CONFDIR "/pure-ftpd"#endif#ifdef WITH_TLS# ifndef TLS_CERTIFICATE_FILE#  define TLS_CERTIFICATE_FILE "/etc/ssl/private/pure-ftpd.pem"# endif#endif#define FAKE_SHELL "ftp"#ifndef PID_FILE# ifdef NON_ROOT_FTP#  define PID_FILE CONFDIR "/pure-ftpd.pid"# else#  define PID_FILE "/var/run/pure-ftpd.pid"# endif#endif#ifndef UPLOADSCRIPT_PID_FILE# ifdef NON_ROOT_FTP#  define UPLOADSCRIPT_PID_FILE CONFDIR "/pure-uploadscript.pid"# else#  define UPLOADSCRIPT_PID_FILE "/var/run/pure-uploadscript.pid"# endif#endif#ifndef AUTHD_PID_FILE# ifdef NON_ROOT_FTP#  define AUTHD_PID_FILE CONFDIR "/pure-authd.pid"# else#  define AUTHD_PID_FILE "/var/run/pure-authd.pid"# endif#endif#ifndef NON_ROOT_FTP# define DEFAULT_FTP_PORT_S "21"#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)# define DEFAULT_FTP_PORT_S "21"#else# define DEFAULT_FTP_PORT_S "2121"#endif/* * Some operating systems (at least Solaris > 2.7 and FreeBSD) have strange * troubles with reusing TCP ports, even when SO_REUSEADDR is enabled.  * As a workaround, we try several unassigned privileged ports. * The last way is to let the OS assign a port. * For egress filtering, you can accept connections from ports <= 20 * to ports >= 1024. */#define FTP_ACTIVE_SOURCE_PORTS { \    DEFAULT_FTP_DATA_PORT, 2U, 3U, 4U, 5U, 6U, 10U, 14U, 16U, 0U \}#ifndef MAXPATHLEN# ifdef PATH_MAX#  define MAXPATHLEN PATH_MAX# else#  define MAXPATHLEN 65536UWarning: neither PATH_MAX nor MAXPATHLEN were found.Remove these lines if you really want to compile the server, butthe server may be insecure if a wrong value is set here.    # endif#endif#if (MAXPATHLEN) >= (INT_MAX)Your platform has a very large MAXPATHLEN, we should not trust it.#endif#define DEFAULT_MAX_USERS 50#define DEFAULT_FTP_DATA_PORT 20 #define MAX_SYSLOG_LINE (MAXPATHLEN + 512U)#define DEFAULT_IDLE (15UL * 60UL)#define MAX_SITE_IDLE (42UL * 60UL)#define DEFAULT_MAX_LS_FILES 2000U#define DEFAULT_MAX_LS_DEPTH 5U#define GLOB_TIMEOUT 17                   /* Max user time for a 'ls' to complete */#define MAX_CPU_TIME (17 * 60)           /* Max allowed CPU time per session */#define MAX_SESSION_XFER_IDLE (24 * 60 * 60)   /* Max duration of a transfer */#define MAX_USER_LENGTH 32U#ifdef LOG_FTP# define DEFAULT_FACILITY LOG_FTP#else# define DEFAULT_FACILITY LOG_LOCAL2#endif#if defined(WITH_LDAP) || defined(WITH_MYSQL) || defined(WITH_PGSQL)# define MAX_DATA_SIZE (16 * 1024 * 1024)       /* Max memory usage - SQL/LDAP need more */#else# define MAX_DATA_SIZE (8 * 1024 * 1024)       /* Max memory usage */#endif#if CONF_TCP_SO_RCVBUF < 65536# undef CONF_TCP_SO_RCVBUF# define CONF_TCP_SO_RCVBUF 65536#endif#if CONF_TCP_SO_SNDBUF < 65536# undef CONF_TCP_SO_SNDBUF# define CONF_TCP_SO_SNDBUF 65536#endif    #define DEFAULT_DL_CHUNK_SIZE (1 << 18)#define DEFAULT_UL_CHUNK_SIZE (CONF_TCP_SO_RCVBUF)#define MAX_UL_CHUNK_SIZE (CONF_TCP_SO_RCVBUF)#define MAX_THROTTLING_DELAY 42           /* Maximum throttling compensation */#define VHOST_PREFIX_MAX_LEN 64    #define PUREFTPD_TMPFILE_PREFIX ".pureftpd-"    #define ATOMIC_PREFIX_PREFIX PUREFTPD_TMPFILE_PREFIX "upload."    /* * Some users reported that something was wrong with TCP_CORK. * Better disable it for now, but we have to investigate. */#ifdef TCP_CORK# undef TCP_CORK#endif#ifdef TCP_CORK# define CORK_ON(SK) do { int optval = 1; setsockopt(SK, SOL_TCP, TCP_CORK, \  &optval, sizeof optval); } while(0)# define CORK_OFF(SK) do { int optval = 0; setsockopt(SK, SOL_TCP, TCP_CORK, \  &optval, sizeof optval); } while(0)#else# define CORK_ON(SK) do { } while(0)# define CORK_OFF(SK) do { } while(0)#endif#define STORAGE_PORT(X) (((struct sockaddr_in *) &(X))->sin_port)#define STORAGE_PORT6(X) (((struct sockaddr_in6 *) &(X))->sin6_port)#define STORAGE_SIN_ADDR(X) ((((struct sockaddr_in *) &(X))->sin_addr).s_addr)#define STORAGE_SIN_ADDR6(X) ((((struct sockaddr_in6 *) &(X))->sin6_addr).s6_addr)#define STORAGE_SIN_ADDR6_NF(X) (((struct sockaddr_in6 *) &(X))->sin6_addr)#ifdef HAVE_SS_LEN# define STORAGE_LEN(X) ((X).ss_len)# define SET_STORAGE_LEN(X, Y) do { STORAGE_LEN(X) = (Y); } while(0)#elif defined(HAVE___SS_LEN)# define STORAGE_LEN(X) ((X).__ss_len)# define SET_STORAGE_LEN(X, Y) do { STORAGE_LEN(X) = (Y); } while(0)#else# define STORAGE_LEN(X) (STORAGE_FAMILY(X) == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))# define SET_STORAGE_LEN(X, Y) (void) 0#endif#ifdef HAVE___SS_FAMILY# define STORAGE_FAMILY(X) ((X).__ss_family)#else# define STORAGE_FAMILY(X) ((X).ss_family)#endif#ifndef SOL_IP# define SOL_IP IPPROTO_IP#endif#ifndef SOL_TCP# define SOL_TCP IPPROTO_TCP#endif#ifndef INADDR_NONE# define INADDR_NONE 0#endif#if !defined(O_NDELAY) && defined(O_NONBLOCK)# define O_NDELAY O_NONBLOCK#endif#ifndef FNDELAY# define FNDELAY O_NDELAY#endif#ifndef MAP_FAILED# define MAP_FAILED ((void *) -1)#endif#ifndef HAVE_STRTOULL# ifdef HAVE_STRTOQ#  define strtoull(X, Y, Z) strtoq(X, Y, Z)# else#  define strtoull(X, Y, Z) strtoul(X, Y, Z)# endif#endif#ifndef ULONG_LONG_MAX# define ULONG_LONG_MAX (1ULL << 63)#endif#ifdef HAVE_DIRENT_H# include <dirent.h>#endif#ifdef HAVE_SYS_NDIR_H# include <sys/ndir.h>#endif#ifdef HAVE_NDIR_H# include <ndir.h>#endif       #ifdef STAT_MACROS_BROKEN# undef S_ISBLK# undef S_ISCHR# undef S_ISDIR# undef S_ISFIFO# undef S_ISLNK# undef S_ISMPB# undef S_ISMPC# undef S_ISNWK# undef S_ISREG# undef S_ISSOCK#endif                            /* STAT_MACROS_BROKEN.  */    #ifndef S_IFMT# define S_IFMT 0170000#endif#if !defined(S_ISBLK) && defined(S_IFBLK)# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)#endif#if !defined(S_ISCHR) && defined(S_IFCHR)# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)#endif#if !defined(S_ISDIR) && defined(S_IFDIR)# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)#endif#if !defined(S_ISREG) && defined(S_IFREG)# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)#endif#if !defined(S_ISFIFO) && defined(S_IFIFO)# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)#endif#if !defined(S_ISLNK) && defined(S_IFLNK)# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)#endif#if !defined(S_ISSOCK) && defined(S_IFSOCK)# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)#endif#if !defined(S_ISMPB) && defined(S_IFMPB)    /* V7 */# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)#endif#if !defined(S_ISNWK) && defined(S_IFNWK)    /* HP/UX */# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)#endif    #ifndef S_IEXEC# define S_IEXEC S_IXUSR#endif    #ifndef S_IXUSR# define S_IXUSR S_IEXEC#endif#ifndef S_IXGRP# define S_IXGRP (S_IEXEC >> 3)#endif#ifndef S_IXOTH# define S_IXOTH (S_IEXEC >> 6)#endif#ifndef S_IXUGO# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)#endif#ifdef ACCEPT_UNICODE_CONTROL_CHARS# define ISCTRLCODE(X) ((X) == 0x7f || ((unsigned char) (X)) < 32U)#else# define ISCTRLCODE(X) ((X) == 0x7f || !(((unsigned char) (X)) & 0x60))#endif    #ifndef HAVE_MUNMAP# define munmap(A, B) (0)#endif#ifndef HAVE_GETHOSTNAME# define gethostname(A, B) (-1)#endif#ifndef HAVE_SETEUID# ifdef HAVE_SETREUID#  define seteuid(X) setreuid(-1, (X))# elif defined(HAVE_SETRESUID)#  define seteuid(X) setresuid(-1, (X), -1)# else#  define seteuid(X) (-1)# endif#endif#ifndef HAVE_SETEGID# ifdef HAVE_SETREGID#  define setegid(X) setregid(-1, (X))# elif defined(HAVE_SETRESGID)#  define setegid(X) setresgid(-1, (X), -1)# else#  define setegid(X) (-1)# endif#endif    #define CRLF "\r\n"#ifdef WITH_DMALLOC# define _exit(X) exit(X)#endif#ifdef FTPWHO# define _EXIT(X) do { delete_atomic_file(); ftpwho_exit(X); } while(0)#else# define _EXIT(X) do { delete_atomic_file(); _exit(X); } while(0)#endif#include "bsd-realpath.h"    #include "fakechroot.h"        #endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -