From cdaa04e4601b91b4b13979ebb3865bc9db2e5467 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 2 Dec 2022 22:10:18 +0100 Subject: [PATCH] Remove uses of ulimit(3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function is obsolete. It is recommended to use getrlimit(2) instead (see the manual page for ulimit(3) or the POSIX manual for it). Since getrlimit(2) is required by POSIX.1-2001, we can rely on it. Cc: Christian Göttsche Signed-off-by: Alejandro Colomar --- configure.ac | 2 +- libmisc/ulimit.c | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index fd6c8207..4a63abcd 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ dnl Checks for libraries. dnl Checks for header files. AC_CHECK_HEADERS(crypt.h utmp.h \ termio.h sgtty.h sys/ioctl.h paths.h \ - ulimit.h sys/capability.h sys/random.h sys/resource.h \ + sys/capability.h sys/random.h sys/resource.h \ gshadow.h lastlog.h rpc/key_prot.h netdb.h acl/libacl.h \ attr/libattr.h attr/error_context.h) diff --git a/libmisc/ulimit.c b/libmisc/ulimit.c index f835f6a8..6597cdb0 100644 --- a/libmisc/ulimit.c +++ b/libmisc/ulimit.c @@ -11,16 +11,7 @@ #ident "$Id$" -#if HAVE_ULIMIT_H -# include -# ifndef UL_SETFSIZE -# ifdef UL_SFILLIM -# define UL_SETFSIZE UL_SFILLIM -# else -# define UL_SETFSIZE 2 -# endif -# endif -#elif HAVE_SYS_RESOURCE_H +#if HAVE_SYS_RESOURCE_H # include /* for struct timeval on sunos4 */ /* XXX - is the above ok or should it be on ultrix? */ # include @@ -30,11 +21,7 @@ int set_filesize_limit (int blocks) { int ret = -1; -#if HAVE_ULIMIT_H - if (ulimit (UL_SETFSIZE, blocks) != -1) { - ret = 0; - } -#elif defined(RLIMIT_FSIZE) +#if defined(RLIMIT_FSIZE) struct rlimit rlimit_fsize; rlimit_fsize.rlim_cur = 512L * blocks;