]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs:
authorTomas Mraz <tm@t8m.info>
Mon, 4 Jul 2005 13:47:33 +0000 (13:47 +0000)
committerTomas Mraz <tm@t8m.info>
Mon, 4 Jul 2005 13:47:33 +0000 (13:47 +0000)
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
modules/pam_limits/pam_limits.c

index ab2b65457c334f824c943c7c02c1060a82bfa4f9..a4f07e32e5d3be1eb20a0b2c390a70514b1d0c3b 100644 (file)
@@ -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)
 
index 5909cb2812a7c5e5116e21875004dc061545ee2b..520f24790c145e95d4f78289c402ad8d6588b5ac 100644 (file)
@@ -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;
     }