diff -Nuar ./vsftpd-2.0.6-patch/main.c ./vsftpd-2.0.6-ext.2/main.c --- ./vsftpd-2.0.6-patch/main.c 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/main.c 2008-06-25 01:22:10.000000000 +0400 @@ -50,7 +50,7 @@ /* Session state */ 0, /* Userids */ - -1, -1, -1, + -1, -1, -1, -1, /* Pre-chroot() cache */ INIT_MYSTR, INIT_MYSTR, INIT_MYSTR, INIT_MYSTR, 1, /* Logging */ @@ -340,6 +340,10 @@ tunable_chown_username); } p_sess->anon_upload_chown_uid = vsf_sysutil_user_getuid(p_user); + if (tunable_chown_group) + { + p_sess->anon_upload_chown_gid = vsf_sysutil_user_getgid(p_user); + } } } diff -Nuar ./vsftpd-2.0.6-patch/parseconf.c ./vsftpd-2.0.6-ext.2/parseconf.c --- ./vsftpd-2.0.6-patch/parseconf.c 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/parseconf.c 2008-06-25 01:18:54.000000000 +0400 @@ -111,6 +111,7 @@ { "double_377", &tunable_double_377 }, { "anon_rxtx_rate", &tunable_anon_rxtx_rate }, { "local_rxtx_rate", &tunable_local_rxtx_rate }, + { "chown_group", &tunable_chown_group }, { 0, 0 } }; diff -Nuar ./vsftpd-2.0.6-patch/privops.c ./vsftpd-2.0.6-ext.2/privops.c --- ./vsftpd-2.0.6-patch/privops.c 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/privops.c 2008-06-25 20:35:37.000000000 +0400 @@ -70,8 +70,8 @@ static struct vsf_sysutil_statbuf* s_p_statbuf; vsf_sysutil_fstat(fd, &s_p_statbuf); /* Do nothing if it is already owned by the desired user. */ - if (vsf_sysutil_statbuf_get_uid(s_p_statbuf) == - p_sess->anon_upload_chown_uid) + if (vsf_sysutil_statbuf_get_uid(s_p_statbuf) == p_sess->anon_upload_chown_uid && + vsf_sysutil_statbuf_get_gid(s_p_statbuf) == p_sess->anon_upload_chown_gid) { return; } @@ -89,7 +89,7 @@ * otherwise a compromise of the FTP user will lead to compromise of * the "anon_upload_chown_uid" user (think chmod +s). */ - vsf_sysutil_fchown(fd, p_sess->anon_upload_chown_uid, -1); + vsf_sysutil_fchown(fd, p_sess->anon_upload_chown_uid, p_sess->anon_upload_chown_gid); } enum EVSFPrivopLoginResult diff -Nuar ./vsftpd-2.0.6-patch/session.h ./vsftpd-2.0.6-ext.2/session.h --- ./vsftpd-2.0.6-patch/session.h 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/session.h 2008-06-24 23:20:07.000000000 +0400 @@ -55,6 +55,7 @@ int anon_ftp_uid; int guest_user_uid; int anon_upload_chown_uid; + int anon_upload_chown_gid; /* Things we need to cache before we chroot() */ struct mystr banned_email_str; diff -Nuar ./vsftpd-2.0.6-patch/tunables.c ./vsftpd-2.0.6-ext.2/tunables.c --- ./vsftpd-2.0.6-patch/tunables.c 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/tunables.c 2008-06-25 21:03:07.000000000 +0400 @@ -84,6 +84,7 @@ int tunable_double_377 = 1; int tunable_anon_rxtx_rate = 0; int tunable_local_rxtx_rate = 0; +int tunable_chown_group = 0; unsigned int tunable_accept_timeout = 60; unsigned int tunable_connect_timeout = 60; diff -Nuar ./vsftpd-2.0.6-patch/tunables.h ./vsftpd-2.0.6-ext.2/tunables.h --- ./vsftpd-2.0.6-patch/tunables.h 2008-02-27 22:07:32.000000000 +0300 +++ ./vsftpd-2.0.6-ext.2/tunables.h 2008-06-25 01:13:01.000000000 +0400 @@ -80,6 +80,7 @@ extern int tunable_double_377; /* On/off double char \377 */ extern int tunable_anon_rxtx_rate; /* On/off rx and tx rates for anon */ extern int tunable_local_rxtx_rate; /* On/off rx and tx rates for local */ +extern int tunable_chown_group; /* Chown group */ /* Integer/numeric defines */ extern unsigned int tunable_accept_timeout; diff -Nuar ./vsftpd-2.0.6-patch/vsftpver.h ./vsftpd-2.0.6-ext.2/vsftpver.h --- ./vsftpd-2.0.6-patch/vsftpver.h 2008-04-22 23:36:33.000000000 +0400 +++ ./vsftpd-2.0.6-ext.2/vsftpver.h 2008-06-25 02:42:26.000000000 +0400 @@ -1,7 +1,7 @@ #ifndef VSF_VERSION_H #define VSF_VERSION_H -#define VSF_VERSION "2.0.6+ (ext.1-1)" +#define VSF_VERSION "2.0.6+ (ext.1-2)" #endif /* VSF_VERSION_H */