From 062a7cbb1b285b99411f7297bb89f11fe2d745ab Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Mon, 4 Jul 2005 13:47:33 +0000 Subject: Relevant BUGIDs: Purpose of commit: new feature Commit summary: --------------- Improve the RLIMIT_NICE support so the input values are in the nice range -20..19 --- modules/pam_limits/README | 3 +-- modules/pam_limits/pam_limits.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/pam_limits/README b/modules/pam_limits/README index ab2b6545..a4f07e32 100644 --- a/modules/pam_limits/README +++ b/modules/pam_limits/README @@ -42,8 +42,7 @@ Where: - sigpending - max number of pending signals (Linux 2.6 and higher) - msgqueue - max memory used by POSIX message queues (bytes) (Linux 2.6 and higher) - - nice - max nice priority allowed to raise to. Nice levels 19..-20 - correspond to 0..39 values of this limit (Linux 2.6.12 and higher) + - nice - max nice priority allowed to raise to (Linux 2.6.12 and higher) - rtprio - max realtime priority allowed for non-priviledged processes (Linux 2.6.12 and higher) diff --git a/modules/pam_limits/pam_limits.c b/modules/pam_limits/pam_limits.c index 5909cb28..520f2479 100644 --- a/modules/pam_limits/pam_limits.c +++ b/modules/pam_limits/pam_limits.c @@ -337,12 +337,19 @@ static void process_limit(int source, const char *lim_type, _pam_log(LOG_DEBUG,"unknown limit type '%s'", lim_type); return; } - if (limit_item != LIMIT_PRI && (strcmp(lim_value, "-1") == 0 + if (limit_item != LIMIT_PRI +#ifdef RLIMIT_NICE + && limit_item != RLIMIT_NICE +#endif + && (strcmp(lim_value, "-1") == 0 || strcmp(lim_value, "-") == 0 || strcmp(lim_value, "unlimited") == 0 || strcmp(lim_value, "infinity") == 0)) { int_value = -1; rlimit_value = RLIM_INFINITY; } else if (limit_item == LIMIT_PRI || limit_item == LIMIT_LOGIN || +#ifdef RLIMIT_NICE + limit_item == RLIMIT_NICE || +#endif limit_item == LIMIT_NUMSYSLOGINS) { long temp; temp = strtol (lim_value, &endptr, 10); @@ -385,6 +392,12 @@ static void process_limit(int source, const char *lim_type, case RLIMIT_AS: if (rlimit_value != RLIM_INFINITY) rlimit_value *= 1024; +#ifdef RLIMIT_NICE + case RLIMIT_NICE: + if (int_value > 19) + int_value = 19; + rlimit_value = 19 - int_value; +#endif break; } -- cgit v1.2.3