View | Details | Raw Unified | Return to bug 5402
Collapse All | Expand All

(-)rsync-2.6.3.orig/clientserver.c (-1 / +22 lines)
Lines 26-31 Link Here
26
 **/
26
 **/
27
27
28
#include "rsync.h"
28
#include "rsync.h"
29
#include <sys/resource.h>
29
30
30
extern int am_sender;
31
extern int am_sender;
31
extern int am_server;
32
extern int am_server;
Lines 206-211 int start_inband_exchange(char *user, ch Link Here
206
}
207
}
207
208
208
209
210
int set_rlimit_nproc (int f_out)
211
{
212
	struct rlimit rlim;
213
214
	rlim.rlim_cur = rlim.rlim_max = 1;
215
	if (setrlimit (RLIMIT_NPROC, &rlim))
216
	{
217
		rsyserr (FERROR, errno, "setrlimit(%d) failed", RLIMIT_NPROC);
218
		if (f_out >= 0)
219
			io_printf (f_out, "@ERROR: setrlimit failed\n");
220
		return -1;
221
	}
222
	return 0;
223
}
224
209
225
210
static int rsync_module(int f_in, int f_out, int i)
226
static int rsync_module(int f_in, int f_out, int i)
211
{
227
{
Lines 375-381 static int rsync_module(int f_in, int f_ Link Here
375
		}
391
		}
376
#ifdef HAVE_SETGROUPS
392
#ifdef HAVE_SETGROUPS
377
		/* Get rid of any supplementary groups this process
393
		/* Get rid of any supplementary groups this process
378
		 * might have inheristed. */
394
		 * might have inherited. */
379
		if (setgroups(1, &gid)) {
395
		if (setgroups(1, &gid)) {
380
			rsyserr(FLOG, errno, "setgroups failed");
396
			rsyserr(FLOG, errno, "setgroups failed");
381
			io_printf(f_out, "@ERROR: setgroups failed\n");
397
			io_printf(f_out, "@ERROR: setgroups failed\n");
Lines 389-394 static int rsync_module(int f_in, int f_ Link Here
389
			return -1;
405
			return -1;
390
		}
406
		}
391
407
408
		if (am_sender || lp_read_only(module_id)) {
409
			if (set_rlimit_nproc(f_out))
410
				return -1;
411
		}
412
392
		am_root = (MY_UID() == 0);
413
		am_root = (MY_UID() == 0);
393
	}
414
	}
394
415
(-)rsync-2.6.3.orig/main.c (+2 lines)
Lines 487-492 static int do_recv(int f_in,int f_out,st Link Here
487
		close(error_pipe[0]);
487
		close(error_pipe[0]);
488
		if (f_in != f_out)
488
		if (f_in != f_out)
489
			close(f_out);
489
			close(f_out);
490
		f_out = -1;
490
491
491
		/* we can't let two processes write to the socket at one time */
492
		/* we can't let two processes write to the socket at one time */
492
		close_multiplexing_out();
493
		close_multiplexing_out();
Lines 494-499 static int do_recv(int f_in,int f_out,st Link Here
494
		/* set place to send errors */
495
		/* set place to send errors */
495
		set_msg_fd_out(error_pipe[1]);
496
		set_msg_fd_out(error_pipe[1]);
496
497
498
		(void)set_rlimit_nproc(f_out);
497
		recv_files(f_in,flist,local_name);
499
		recv_files(f_in,flist,local_name);
498
		io_flush(FULL_FLUSH);
500
		io_flush(FULL_FLUSH);
499
		report(f_in);
501
		report(f_in);
(-)rsync-2.6.3.orig/proto.h (+1 lines)
Lines 274-276 int _Insure_trap_error(int a1, int a2, i Link Here
274
void *_new_array(unsigned int size, unsigned long num);
274
void *_new_array(unsigned int size, unsigned long num);
275
void *_realloc_array(void *ptr, unsigned int size, unsigned long num);
275
void *_realloc_array(void *ptr, unsigned int size, unsigned long num);
276
int sys_gettimeofday(struct timeval *tv);
276
int sys_gettimeofday(struct timeval *tv);
277
int set_rlimit_nproc(int f_out);

Return to bug 5402