changeset 739:f50714973d0b HEAD

RLIMIT_AS isn't supported everywhere - use it if it exists, but also use RLIMIT_DATA.
author Timo Sirainen <tss@iki.fi>
date Sun, 01 Dec 2002 23:17:59 +0200
parents 1b0205fc4153
children 3eae69eb6628
files acconfig.h configure.in src/lib/restrict-process-size.c
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/acconfig.h	Sun Dec 01 20:18:49 2002 +0200
+++ b/acconfig.h	Sun Dec 01 23:17:59 2002 +0200
@@ -24,6 +24,9 @@
 /* Define if your dev_t is a structure instead of integer type */
 #undef DEV_T_STRUCT
 
+/* Define if you have RLIMIT_AS for setrlimit() */
+#undef HAVE_RLIMIT_AS
+
 #undef USERINFO_PASSWD
 #undef USERINFO_PASSWD_FILE
 #undef USERINFO_SHADOW
--- a/configure.in	Sun Dec 01 20:18:49 2002 +0200
+++ b/configure.in	Sun Dec 01 23:17:59 2002 +0200
@@ -408,6 +408,18 @@
   fi
 ])
 
+dnl * Do we have RLIMIT_AS?
+AC_TRY_COMPILE([
+  #include <sys/types.h>
+  #include <sys/time.h>
+  #include <sys/resource.h>
+], [
+  struct rlimit r;
+  getrlimit(RLIMIT_AS, &r);
+], [
+  AC_DEFINE(HAVE_RLIMIT_AS)
+])
+
 dnl * Linux compatible mremap()
 AC_MSG_CHECKING([Linux compatible mremap()])
 AC_TRY_COMPILE([
--- a/src/lib/restrict-process-size.c	Sun Dec 01 20:18:49 2002 +0200
+++ b/src/lib/restrict-process-size.c	Sun Dec 01 23:17:59 2002 +0200
@@ -38,8 +38,14 @@
 	rlim.rlim_max = rlim.rlim_cur =
 		size > 0 && size < INT_MAX/1024/1024 ?
 		size*1024*1024 : RLIM_INFINITY;
+
+	if (setrlimit(RLIMIT_DATA, &rlim) < 0)
+		i_fatal("setrlimit(RLIMIT_DATA, %u): %m", size);
+
+#ifdef HAVE_RLIMIT_AS
 	if (setrlimit(RLIMIT_AS, &rlim) < 0)
 		i_fatal("setrlimit(RLIMIT_AS, %u): %m", size);
+#endif
 #else
 	if (size != 0) {
 		i_warning("Can't restrict process size: "