Package: shadow
Tags: patch
Severity: wishlist

Adds the following when we're not using PAM:
[Ii]: i = RLIMIT_NICE    max nice value (0..39 translates to 20..-19)
[Oo]: o = RLIMIT_RTPRIO  max real time priority

Patches cleanly against 4.0.15 and 4.1.18.  The only difference between the
patches is dealing with man/limits.5.

Thanks,
-- 
Justin Bronder


diff -urN shadow-4.0.18.1/etc/limits shadow-4.0.18.1_patched/etc/limits
--- shadow-4.0.18.1/etc/limits	1997-12-14 15:07:18.000000000 -0500
+++ shadow-4.0.18.1_patched/etc/limits	2007-09-13 14:54:22.000000000 -0400
@@ -18,10 +18,12 @@
 # T: max CPU time (MIN)
 # U: max number of processes
 # L: max number of logins for this user
+# I: max nice value (0..39 translates to 20..-19)
+# O: max real time priority (0..MAX_RT_PRIO)
 #
 # Examples:
 # the default entry
-#* L2 D6144 R2048 S2048 U32 N32 F16384 T5 C0
+#* L2 D6144 R2048 S2048 U32 N32 F16384 T5 C0 I20 O0
 # another way of suspending a user login
 #guest   L0
 # this account has no limits
diff -urN shadow-4.0.18.1/libmisc/limits.c shadow-4.0.18.1_patched/libmisc/limits.c
--- shadow-4.0.18.1/libmisc/limits.c	2006-07-10 00:11:31.000000000 -0400
+++ shadow-4.0.18.1_patched/libmisc/limits.c	2007-09-13 14:54:22.000000000 -0400
@@ -185,7 +185,8 @@
  * [Kk]: k = file creation masK (umask)
  * [Ll]: l = max number of logins for this user
  * [Pp]: p = process priority -20..20 (negative = high, positive = low)
- *
+ * [Ii]: i = RLIMIT_NICE    max nice value (0..39 translates to 20..-19)
+ * [Oo]: o = RLIMIT_RTPRIO  max real time priority (linux/sched.h 0..MAX_RT_PRIO)
  * Return value:
  *		0 = okay, of course
  *		LOGIN_ERROR_RLIMIT = error setting some RLIMIT
@@ -273,6 +274,20 @@
 			retval |= setrlimit_value (RLIMIT_STACK, pp, 1024);
 			break;
 #endif
+#ifdef RLIMIT_NICE
+        case 'i':
+        case 'I':
+            /* RLIMIT_NICE - max scheduling priority (0..39) */
+            retval |= setrlimit_value (RLIMIT_NICE, pp, 1);
+            break;
+#endif
+#ifdef RLIMIT_RTPRIO
+        case 'o':
+        case 'O':
+            /* RLIMIT_RTPRIO - max real time priority (0..MAX_RT_PRIO) */
+            retval |= setrlimit_value (RLIMIT_RTPRIO, pp, 1);
+            break;
+#endif
 		case 'k':
 		case 'K':
 			retval |= set_umask (pp);
@@ -328,7 +343,7 @@
 		 * Imposing a limit should be done with care, so a wrong
 		 * entry means no care anyway :-). A '-' as a limits
 		 * strings means no limits --cristiang */
-		if (sscanf (buf, "%s%[ACDFMNRSTULPacdfmnrstulp0-9 \t-]",
+		if (sscanf (buf, "%s%[ACDFMNRSTULPIOacdfmnrstulpio0-9 \t-]",
 			    name, tempbuf) == 2) {
 			if (strcmp (name, uname) == 0) {
 				strcpy (limits, tempbuf);
diff -urN shadow-4.0.18.1/man/limits.5 shadow-4.0.18.1_patched/man/limits.5
--- shadow-4.0.18.1/man/limits.5	2006-07-30 16:54:00.000000000 -0400
+++ shadow-4.0.18.1_patched/man/limits.5	2007-09-13 14:55:59.000000000 -0400
@@ -73,6 +73,12 @@
 \(bu
 P: process priority, set by
 \fBsetpriority\fR(2).
+.TP 3n
+\(bu
+I: max nice value (0..39 which translates to 20..-19)
+.TP 3n
+\(bu
+O: max real time priority
 .sp
 .RE
 .PP

Attachment: signature.asc
Description: Digital signature

Reply via email to