From 6a01f488c85957146ca7d2b91dcfbd5775340528 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 14 May 2025 16:15:53 +0200 Subject: [PATCH] os: drop self-limiting resources It's only rarely used and can be easily achieved by generic means, eg. via ulimit or supervisor settings. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xwayland/xwayland.c | 4 ---- man/Xserver.man | 15 ------------- os/osdep.h | 4 ---- os/osinit.c | 50 ------------------------------------------ os/utils.c | 39 -------------------------------- 5 files changed, 112 deletions(-) diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index cc85880af..f9f1c255e 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -153,10 +153,6 @@ try_raising_nofile_limit(void) #ifdef RLIMIT_NOFILE struct rlimit rlim; - /* Only fiddle with the limit if not set explicitly from the command line */ - if (limitNoFile >= 0) - return; - if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { ErrorF("Failed to get the current nofile limit: %s\n", strerror(errno)); return; diff --git a/man/Xserver.man b/man/Xserver.man index e21cc4a25..d722f69a3 100644 --- a/man/Xserver.man +++ b/man/Xserver.man @@ -323,21 +323,6 @@ platform and configuration specific. .SH SERVER DEPENDENT OPTIONS Some X servers accept the following options: .TP 8 -.B \-ld \fIkilobytes\fP -sets the data space limit of the server to the specified number of kilobytes. -A value of zero makes the data size as large as possible. The default value -of \-1 leaves the data space limit unchanged. -.TP 8 -.B \-lf \fIfiles\fP -sets the number-of-open-files limit of the server to the specified number. -A value of zero makes the limit as large as possible. The default value -of \-1 leaves the limit unchanged. -.TP 8 -.B \-ls \fIkilobytes\fP -sets the stack space limit of the server to the specified number of kilobytes. -A value of zero makes the stack size as large as possible. The default value -of \-1 leaves the stack space limit unchanged. -.TP 8 .B \-maxclients .BR 64 | 128 | 256 | 512 Set the maximum number of clients allowed to connect to the X server. diff --git a/os/osdep.h b/os/osdep.h index 3c198a712..0683ca3d9 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -205,10 +205,6 @@ void CloseDownConnection(ClientPtr client); extern int LimitClients; extern Bool PartialNetwork; -extern int limitDataSpace; -extern int limitStackSpace; -extern int limitNoFile; - extern Bool CoreDump; extern Bool NoListenAll; extern Bool AllowByteSwappedClients; diff --git a/os/osinit.c b/os/osinit.c index 3e18b51b0..ab1a89827 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -77,16 +77,6 @@ SOFTWARE. #define ADMPATH "/usr/adm/X%smsgs" #endif -#ifdef RLIMIT_DATA -int limitDataSpace = -1; -#endif -#ifdef RLIMIT_STACK -int limitStackSpace = -1; -#endif -#ifdef RLIMIT_NOFILE -int limitNoFile = -1; -#endif - /* The actual user defined max number of clients */ int LimitClients = LIMITCLIENTS; @@ -266,46 +256,6 @@ OsInit(void) if (getpgrp() == 0) setpgid(0, 0); #endif - -#ifdef RLIMIT_DATA - if (limitDataSpace >= 0) { - struct rlimit rlim; - - if (!getrlimit(RLIMIT_DATA, &rlim)) { - if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max)) - rlim.rlim_cur = limitDataSpace; - else - rlim.rlim_cur = rlim.rlim_max; - (void) setrlimit(RLIMIT_DATA, &rlim); - } - } -#endif -#ifdef RLIMIT_STACK - if (limitStackSpace >= 0) { - struct rlimit rlim; - - if (!getrlimit(RLIMIT_STACK, &rlim)) { - if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max)) - rlim.rlim_cur = limitStackSpace; - else - rlim.rlim_cur = rlim.rlim_max; - (void) setrlimit(RLIMIT_STACK, &rlim); - } - } -#endif -#ifdef RLIMIT_NOFILE - if (limitNoFile >= 0) { - struct rlimit rlim; - - if (!getrlimit(RLIMIT_NOFILE, &rlim)) { - if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max)) - rlim.rlim_cur = limitNoFile; - else - rlim.rlim_cur = rlim.rlim_max; - (void) setrlimit(RLIMIT_NOFILE, &rlim); - } - } -#endif LockServer(); been_here = TRUE; } diff --git a/os/utils.c b/os/utils.c index 99b09e5c9..c223093d9 100644 --- a/os/utils.c +++ b/os/utils.c @@ -302,15 +302,6 @@ UseMsg(void) ErrorF("+iglx Allow creating indirect GLX contexts\n"); ErrorF("-iglx Prohibit creating indirect GLX contexts (default)\n"); ErrorF("-I ignore all remaining arguments\n"); -#ifdef RLIMIT_DATA - ErrorF("-ld int limit data space to N Kb\n"); -#endif -#ifdef RLIMIT_NOFILE - ErrorF("-lf int limit number of open files to N\n"); -#endif -#ifdef RLIMIT_STACK - ErrorF("-ls int limit stack space to N Kb\n"); -#endif LockServerUseMsg(); ErrorF("-maxclients n set maximum number of clients (power of two)\n"); ErrorF("-nolisten string don't listen on protocol\n"); @@ -574,36 +565,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } -#ifdef RLIMIT_DATA - else if (strcmp(argv[i], "-ld") == 0) { - if (++i < argc) { - limitDataSpace = atoi(argv[i]); - if (limitDataSpace > 0) - limitDataSpace *= 1024; - } - else - UseMsg(); - } -#endif -#ifdef RLIMIT_NOFILE - else if (strcmp(argv[i], "-lf") == 0) { - if (++i < argc) - limitNoFile = atoi(argv[i]); - else - UseMsg(); - } -#endif -#ifdef RLIMIT_STACK - else if (strcmp(argv[i], "-ls") == 0) { - if (++i < argc) { - limitStackSpace = atoi(argv[i]); - if (limitStackSpace > 0) - limitStackSpace *= 1024; - } - else - UseMsg(); - } -#endif #ifdef LOCK_SERVER else if (strcmp(argv[i], "-nolock") == 0) { #if !defined(WIN32) && !defined(__CYGWIN__)