[Pkg-shadow-devel] Add RLIMIT_<RTPRIO/NICE> [patch]
Justin Bronder
jsbronder at gmail.com
Thu Sep 13 20:26:54 UTC 2007
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
-------------- next part --------------
diff -urN shadow-4.0.15/etc/limits shadow-4.0.15patched/etc/limits
--- shadow-4.0.15/etc/limits 1997-12-14 15:07:18.000000000 -0500
+++ shadow-4.0.15patched/etc/limits 2007-09-13 12:58:48.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.15/libmisc/limits.c shadow-4.0.15patched/libmisc/limits.c
--- shadow-4.0.15/libmisc/limits.c 2005-09-05 13:32:17.000000000 -0400
+++ shadow-4.0.15patched/libmisc/limits.c 2007-09-13 12:56:26.000000000 -0400
@@ -187,7 +187,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
@@ -275,6 +276,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);
@@ -330,7 +345,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.15/man/limits.5 shadow-4.0.15patched/man/limits.5
--- shadow-4.0.15/man/limits.5 2006-03-06 13:57:18.000000000 -0500
+++ shadow-4.0.15patched/man/limits.5 2007-09-13 12:58:37.000000000 -0400
@@ -67,6 +67,12 @@
\(bu
P: process priority, set by
\fBsetpriority\fR(2).
+.TP 3
+\(bu
+I: max nice value (0..39 which translates to 20..-19)
+.TP 3
+\(bu
+O: max real time priority
.PP
For example,
\fIL2D2048N5\fR
-------------- next part --------------
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/attachments/20070913/7c499d53/attachment.pgp
More information about the Pkg-shadow-devel
mailing list