summaryrefslogtreecommitdiff
path: root/modules/pam_limits
diff options
context:
space:
mode:
authorTomas Mraz <tm@t8m.info>2005-07-04 13:47:33 +0000
committerTomas Mraz <tm@t8m.info>2005-07-04 13:47:33 +0000
commit062a7cbb1b285b99411f7297bb89f11fe2d745ab (patch)
tree3d5bf8b38ebc8a043a6f9d1e030384a07ac5bab6 /modules/pam_limits
parent32a1ca40a3303791cc91919b9ef206bb986dbff9 (diff)
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
Diffstat (limited to 'modules/pam_limits')
-rw-r--r--modules/pam_limits/README3
-rw-r--r--modules/pam_limits/pam_limits.c15
2 files changed, 15 insertions, 3 deletions
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;
}