aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-03-13 22:32:05 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2017-03-13 22:35:30 +0100
commit018804204f41e6e60cec536843275f8fdd4d3620 (patch)
tree8d1adfc3acba1cbfb24e952e12f1a329a3a15a21
parente88608eae24ae5934034e1ecb6c494fefbf1b9ae (diff)
downloadbusybox-w32-018804204f41e6e60cec536843275f8fdd4d3620.tar.gz
busybox-w32-018804204f41e6e60cec536843275f8fdd4d3620.tar.bz2
busybox-w32-018804204f41e6e60cec536843275f8fdd4d3620.zip
runit: fix chpst -n -N -u USER
busybox's chpst first switches user/group and then tries to call nice(). Once the root priviledges are dropped, process priority can only be lowered. So negative nice values don't work anymore. Upstream version of chpst correctly calls nice() before switching user. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--runit/chpst.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/runit/chpst.c b/runit/chpst.c
index 846c846d3..ee3a33153 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -463,6 +463,13 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
463 xchroot(root); 463 xchroot(root);
464 } 464 }
465 465
466 /* nice should be done before xsetuid */
467 if (opt & OPT_n) {
468 errno = 0;
469 if (nice(xatoi(nicestr)) == -1)
470 bb_perror_msg_and_die("nice");
471 }
472
466 if (opt & OPT_u) { 473 if (opt & OPT_u) {
467 if (setgroups(1, &ugid.gid) == -1) 474 if (setgroups(1, &ugid.gid) == -1)
468 bb_perror_msg_and_die("setgroups"); 475 bb_perror_msg_and_die("setgroups");
@@ -470,12 +477,6 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
470 xsetuid(ugid.uid); 477 xsetuid(ugid.uid);
471 } 478 }
472 479
473 if (opt & OPT_n) {
474 errno = 0;
475 if (nice(xatoi(nicestr)) == -1)
476 bb_perror_msg_and_die("nice");
477 }
478
479 if (opt & OPT_0) 480 if (opt & OPT_0)
480 close(STDIN_FILENO); 481 close(STDIN_FILENO);
481 if (opt & OPT_1) 482 if (opt & OPT_1)