diff -uprk.orig rsync-2.6.3.orig/clientserver.c rsync-2.6.3/clientserver.c --- rsync-2.6.3.orig/clientserver.c 2004-07-31 23:55:42 +0400 +++ rsync-2.6.3/clientserver.c 2004-10-27 15:53:18 +0400 @@ -26,6 +26,7 @@ **/ #include "rsync.h" +#include extern int am_sender; extern int am_server; @@ -206,6 +207,21 @@ int start_inband_exchange(char *user, ch } +int set_rlimit_nproc (int f_out) +{ + struct rlimit rlim; + + rlim.rlim_cur = rlim.rlim_max = 1; + if (setrlimit (RLIMIT_NPROC, &rlim)) + { + rsyserr (FERROR, errno, "setrlimit(%d) failed", RLIMIT_NPROC); + if (f_out >= 0) + io_printf (f_out, "@ERROR: setrlimit failed\n"); + return -1; + } + return 0; +} + static int rsync_module(int f_in, int f_out, int i) { @@ -375,7 +391,7 @@ static int rsync_module(int f_in, int f_ } #ifdef HAVE_SETGROUPS /* Get rid of any supplementary groups this process - * might have inheristed. */ + * might have inherited. */ if (setgroups(1, &gid)) { rsyserr(FLOG, errno, "setgroups failed"); io_printf(f_out, "@ERROR: setgroups failed\n"); @@ -389,6 +405,11 @@ static int rsync_module(int f_in, int f_ return -1; } + if (am_sender || lp_read_only(module_id)) { + if (set_rlimit_nproc(f_out)) + return -1; + } + am_root = (MY_UID() == 0); } diff -uprk.orig rsync-2.6.3.orig/main.c rsync-2.6.3/main.c --- rsync-2.6.3.orig/main.c 2004-09-29 21:58:07 +0400 +++ rsync-2.6.3/main.c 2004-10-27 15:53:18 +0400 @@ -487,6 +487,7 @@ static int do_recv(int f_in,int f_out,st close(error_pipe[0]); if (f_in != f_out) close(f_out); + f_out = -1; /* we can't let two processes write to the socket at one time */ close_multiplexing_out(); @@ -494,6 +495,7 @@ static int do_recv(int f_in,int f_out,st /* set place to send errors */ set_msg_fd_out(error_pipe[1]); + (void)set_rlimit_nproc(f_out); recv_files(f_in,flist,local_name); io_flush(FULL_FLUSH); report(f_in); diff -uprk.orig rsync-2.6.3.orig/proto.h rsync-2.6.3/proto.h --- rsync-2.6.3.orig/proto.h 2004-09-21 13:15:56 +0400 +++ rsync-2.6.3/proto.h 2004-10-27 15:54:08 +0400 @@ -274,3 +274,4 @@ int _Insure_trap_error(int a1, int a2, i void *_new_array(unsigned int size, unsigned long num); void *_realloc_array(void *ptr, unsigned int size, unsigned long num); int sys_gettimeofday(struct timeval *tv); +int set_rlimit_nproc(int f_out);