diff -rup vsftpd-1.1.3.orig/Makefile vsftpd-1.1.3/Makefile --- vsftpd-1.1.3.orig/Makefile 2002-10-21 19:15:16.000000000 -0400 +++ vsftpd-1.1.3/Makefile 2003-01-13 07:56:22.000000000 -0500 @@ -22,6 +22,8 @@ OBJS = main.o utility.o prelogin.o ftpcm vsftpd: $(OBJS) $(CC) -o vsftpd $(OBJS) $(LINK) $(LIBS) +.PHONY: install + install: if [ -x /usr/local/sbin ]; then \ $(INSTALL) -m 755 vsftpd /usr/local/sbin/vsftpd; \ diff -rup vsftpd-1.1.3.orig/port/porting_junk.h vsftpd-1.1.3/port/porting_junk.h --- vsftpd-1.1.3.orig/port/porting_junk.h 2002-09-25 14:16:24.000000000 -0400 +++ vsftpd-1.1.3/port/porting_junk.h 2003-01-13 08:12:35.000000000 -0500 @@ -21,6 +21,10 @@ #include "tru64_bogons.h" #endif +#ifdef __CYGWIN__ +#include "cygwin_bogons.h" +#endif + /* So many older systems lack these, that it's too much hassle to list all * the errant systems */ diff -rup vsftpd-1.1.3.orig/secbuf.c vsftpd-1.1.3/secbuf.c --- vsftpd-1.1.3.orig/secbuf.c 2001-04-22 18:15:37.000000000 -0400 +++ vsftpd-1.1.3/secbuf.c 2003-01-10 14:51:41.000000000 -0500 @@ -14,6 +14,21 @@ #include "sysutil.h" #include "sysdeputil.h" +#ifdef __CYGWIN__ +#include + +void +vsf_secbuf_alloc(char** p_ptr, unsigned int size) +{ + *p_ptr = (char*) malloc(size); +} + +void +vsf_secbuf_free(char** p_ptr) +{ + free(*p_ptr); +} +#else void vsf_secbuf_alloc(char** p_ptr, unsigned int size) { @@ -86,4 +101,4 @@ vsf_secbuf_free(char** p_ptr) /* Lose the mapping */ vsf_sysutil_memunmap(p_mmap, map_size); } - +#endif diff -rup vsftpd-1.1.3.orig/sysdeputil.c vsftpd-1.1.3/sysdeputil.c --- vsftpd-1.1.3.orig/sysdeputil.c 2002-10-29 20:06:41.000000000 -0500 +++ vsftpd-1.1.3/sysdeputil.c 2003-01-13 08:25:39.000000000 -0500 @@ -99,6 +99,14 @@ #ifdef __sun #define VSF_SYSDEP_HAVE_SOLARIS_SENDFILE #endif + +#ifdef __CYGWIN__ + #define VSF_SYSDEP_NEED_OLD_FD_PASSING + #undef VSF_SYSDEP_HAVE_PAM + #undef VSF_SYSDEP_HAVE_SHADOW + #undef VSF_SYSDEP_HAVE_USERSHELL + #include +#endif /* END config */ /* PAM support - we include our own dummy version if the system lacks this */ @@ -220,6 +228,14 @@ vsf_sysdep_check_auth(const struct mystr } } #endif /* VSF_SYSDEP_HAVE_SHADOW */ +#ifdef __CYGWIN__ + if (is_winnt) + { + HANDLE token = cygwin_logon_user (p_pwd, str_getbuf(p_pass_str)); + cygwin_set_impersonation_token (token); + return token != INVALID_HANDLE_VALUE; + } +#endif p_crypted = crypt(str_getbuf(p_pass_str), p_pwd->pw_passwd); if (!vsf_sysutil_strcmp(p_crypted, p_pwd->pw_passwd)) { diff -rup vsftpd-1.1.3.orig/sysutil.c vsftpd-1.1.3/sysutil.c --- vsftpd-1.1.3.orig/sysutil.c 2002-10-25 13:32:52.000000000 -0400 +++ vsftpd-1.1.3/sysutil.c 2003-01-13 08:18:34.000000000 -0500 @@ -15,6 +15,7 @@ #include "sysutil.h" #include "utility.h" #include "tunables.h" +#include "defs.h" /* Activate 64-bit file support on Linux/32bit */ #define _FILE_OFFSET_BITS 64 @@ -1806,7 +1807,7 @@ vsf_sysutil_get_random_byte(void) int vsf_sysutil_running_as_root(void) { - return (getuid() == 0); + return (getuid() == VSFTP_ROOT_UID); } void @@ -2021,10 +2022,13 @@ vsf_sysutil_qsort(void* p_base, unsigned { qsort(p_base, num_elem, elem_size, p_compar); } - void vsf_sysutil_sleep(double seconds) { +#ifdef __CYGWIN__ + sleep(seconds); + vsf_sysutil_check_pending_actions(kVSFSysUtilUnknown, 0, 0); +#else int retval; double fractional; time_t secs; @@ -2038,6 +2042,7 @@ vsf_sysutil_sleep(double seconds) retval = nanosleep(&ts, &ts); vsf_sysutil_check_pending_actions(kVSFSysUtilUnknown, 0, 0); } while (retval == -1 && errno == EINTR); +#endif } char* diff -rup vsftpd-1.1.3.orig/twoprocess.c vsftpd-1.1.3/twoprocess.c --- vsftpd-1.1.3.orig/twoprocess.c 2002-10-25 13:28:25.000000000 -0400 +++ vsftpd-1.1.3/twoprocess.c 2003-01-13 08:15:02.000000000 -0500 @@ -24,6 +24,9 @@ #include "defs.h" #include "parseconf.h" +/* For Linux, this adds nothing :-) */ +#include "port/porting_junk.h" + static void drop_all_privs(void); static void handle_sigchld(int duff); static void process_login_req(struct vsf_session* p_sess); diff -rup vsftpd-1.1.3.orig/vsf_findlibs.sh vsftpd-1.1.3/vsf_findlibs.sh --- vsftpd-1.1.3.orig/vsf_findlibs.sh 2002-10-27 19:12:53.000000000 -0500 +++ vsftpd-1.1.3/vsf_findlibs.sh 2003-01-13 07:55:44.000000000 -0500 @@ -35,6 +35,8 @@ elif [ -r /etc/redhat-release ]; then echo "-lcap"; fi exit +elif [ -x /usr/bin/cygwin1.dll ]; then + echo "-lcrypt" fi # Look for PAM (done weirdly due to distribution bugs (e.g. Debian) diff -rupN vsftpd-1.1.3.orig/port/cygwin_bogons.h vsftpd-1.1.3/port/cygwin_bogons.h --- vsftpd-1.1.3.orig/port/cygwin_bogons.h 1969-12-31 19:00:00.000000000 -0500 +++ vsftpd-1.1.3/port/cygwin_bogons.h 2003-01-13 08:26:25.000000000 -0500 @@ -0,0 +1,16 @@ +#ifndef VSF_CYGWIN_BOGONS_H +#define VSF_CYGWIN_BOGONS_H + +#include +#include +#include + +#undef VSFTP_ROOT_UID +#define VSFTP_ROOT_UID 18 + +#define setreuid(dummy, uid) seteuid(uid) +#define setregid(dummy, gid) setegid(gid) + +#define is_winnt (GetVersion() < 0x80000000) + +#endif /* VSF_CYGWIN_BOGONS_H */