Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37743486
en ru br
Репозитории ALT
S:3.2.7-alt1
5.1: 3.0.8-alt0.M51.1
4.1: 3.0.2-alt2
4.0: 3.0.2-alt0.2.M40.1
+updates:2.6.9-alt3
3.0: 2.6.5-alt1
+backports:2.6.9-alt0.M30.1
www.altlinux.org/Changes

Группа :: Сети/Передача файлов
Пакет: rsync

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: rsync-2.6.4-alt-setrlimit.patch
Скачать


--- rsync-2.6.4/clientserver.c.orig	2005-03-31 04:21:15 +0400
+++ rsync-2.6.4/clientserver.c	2005-03-31 18:27:43 +0400
@@ -26,6 +26,7 @@
  **/
 
 #include "rsync.h"
+#include <sys/resource.h>
 
 extern int verbose;
 extern int list_only;
@@ -217,6 +218,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)
 {
@@ -407,7 +423,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");
@@ -421,6 +437,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);
 	}
 
--- rsync-2.6.4/main.c.orig	2005-03-30 20:55:11 +0400
+++ rsync-2.6.4/main.c	2005-03-31 18:30:39 +0400
@@ -554,6 +554,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();
@@ -561,6 +562,8 @@ 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);
 		handle_stats(f_in);
--- rsync-2.6.4/proto.h.orig	2005-03-31 04:19:27 +0400
+++ rsync-2.6.4/proto.h	2005-03-31 18:27:43 +0400
@@ -296,3 +296,4 @@ void *_realloc_array(void *ptr, unsigned
 const char *find_filename_suffix(const char *fn, int fn_len, int *len_ptr);
 uint32 fuzzy_distance(const char *s1, int len1, const char *s2, int len2);
 int sys_gettimeofday(struct timeval *tv);
+int set_rlimit_nproc(int f_out);
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin