Output the name of the limit when warning about setrlimit or getrlimit.
From Kimmo Suominen.
This commit is contained in:
@@ -130,12 +130,12 @@ unlimit_nproc(void)
|
|||||||
debug_decl(unlimit_nproc, SUDOERS_DEBUG_UTIL)
|
debug_decl(unlimit_nproc, SUDOERS_DEBUG_UTIL)
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NPROC, &nproclimit) != 0)
|
if (getrlimit(RLIMIT_NPROC, &nproclimit) != 0)
|
||||||
sudo_warn("getrlimit");
|
sudo_warn("getrlimit(RLIMIT_NPROC)");
|
||||||
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
|
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
|
||||||
if (setrlimit(RLIMIT_NPROC, &rl) != 0) {
|
if (setrlimit(RLIMIT_NPROC, &rl) != 0) {
|
||||||
rl.rlim_cur = rl.rlim_max = nproclimit.rlim_max;
|
rl.rlim_cur = rl.rlim_max = nproclimit.rlim_max;
|
||||||
if (setrlimit(RLIMIT_NPROC, &rl) != 0)
|
if (setrlimit(RLIMIT_NPROC, &rl) != 0)
|
||||||
sudo_warn("setrlimit");
|
sudo_warn("setrlimit(RLIMIT_NPROC)");
|
||||||
}
|
}
|
||||||
debug_return;
|
debug_return;
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
@@ -151,7 +151,7 @@ restore_nproc(void)
|
|||||||
debug_decl(restore_nproc, SUDOERS_DEBUG_UTIL)
|
debug_decl(restore_nproc, SUDOERS_DEBUG_UTIL)
|
||||||
|
|
||||||
if (setrlimit(RLIMIT_NPROC, &nproclimit) != 0)
|
if (setrlimit(RLIMIT_NPROC, &nproclimit) != 0)
|
||||||
sudo_warn("setrlimit");
|
sudo_warn("setrlimit(RLIMIT_NPROC)");
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
21
src/limits.c
21
src/limits.c
@@ -56,6 +56,7 @@ static struct rlimit nofile_fallback = { SUDO_OPEN_MAX, RLIM_INFINITY };
|
|||||||
static struct rlimit stack_fallback = { 8192 * 1024, 65532 * 1024 };
|
static struct rlimit stack_fallback = { 8192 * 1024, 65532 * 1024 };
|
||||||
|
|
||||||
static struct saved_limit {
|
static struct saved_limit {
|
||||||
|
const char *name;
|
||||||
int resource;
|
int resource;
|
||||||
bool saved;
|
bool saved;
|
||||||
struct rlimit *fallback;
|
struct rlimit *fallback;
|
||||||
@@ -63,19 +64,19 @@ static struct saved_limit {
|
|||||||
struct rlimit oldlimit;
|
struct rlimit oldlimit;
|
||||||
} saved_limits[] = {
|
} saved_limits[] = {
|
||||||
#ifdef RLIMIT_AS
|
#ifdef RLIMIT_AS
|
||||||
{ RLIMIT_AS, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_AS", RLIMIT_AS, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
#endif
|
#endif
|
||||||
{ RLIMIT_CPU, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_CPU", RLIMIT_CPU, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
{ RLIMIT_DATA, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_DATA", RLIMIT_DATA, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
{ RLIMIT_FSIZE, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_FSIZE", RLIMIT_FSIZE, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
{ RLIMIT_NOFILE, false, &nofile_fallback, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_NOFILE", RLIMIT_NOFILE, false, &nofile_fallback, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
#ifdef RLIMIT_NPROC
|
#ifdef RLIMIT_NPROC
|
||||||
{ RLIMIT_NPROC, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_NPROC", RLIMIT_NPROC, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_RSS
|
#ifdef RLIMIT_RSS
|
||||||
{ RLIMIT_RSS, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
{ "RLIMIT_RSS", RLIMIT_RSS, false, NULL, { RLIM_INFINITY, RLIM_INFINITY } },
|
||||||
#endif
|
#endif
|
||||||
{ RLIMIT_STACK, false, &stack_fallback, { 8192 * 1024, RLIM_INFINITY } }
|
{ "RLIMIT_STACK", RLIMIT_STACK, false, &stack_fallback, { 8192 * 1024, RLIM_INFINITY } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct rlimit corelimit;
|
static struct rlimit corelimit;
|
||||||
@@ -209,7 +210,7 @@ unlimit_sudo(void)
|
|||||||
rc = setrlimit(lim->resource, &lim->newlimit);
|
rc = setrlimit(lim->resource, &lim->newlimit);
|
||||||
}
|
}
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
sudo_warn("setrlimit(%d)", lim->resource);
|
sudo_warn("setrlimit(%s)", lim->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +231,7 @@ restore_limits(void)
|
|||||||
struct saved_limit *lim = &saved_limits[idx];
|
struct saved_limit *lim = &saved_limits[idx];
|
||||||
if (lim->saved) {
|
if (lim->saved) {
|
||||||
if (setrlimit(lim->resource, &lim->oldlimit) == -1)
|
if (setrlimit(lim->resource, &lim->oldlimit) == -1)
|
||||||
sudo_warn("setrlimit(%d)", lim->resource);
|
sudo_warn("setrlimit(%s)", lim->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
restore_coredump();
|
restore_coredump();
|
||||||
|
Reference in New Issue
Block a user