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>
xchroot(root);
}
+ /* nice should be done before xsetuid */
+ if (opt & OPT_n) {
+ errno = 0;
+ if (nice(xatoi(nicestr)) == -1)
+ bb_perror_msg_and_die("nice");
+ }
+
if (opt & OPT_u) {
if (setgroups(1, &ugid.gid) == -1)
bb_perror_msg_and_die("setgroups");
xsetuid(ugid.uid);
}
- if (opt & OPT_n) {
- errno = 0;
- if (nice(xatoi(nicestr)) == -1)
- bb_perror_msg_and_die("nice");
- }
-
if (opt & OPT_0)
close(STDIN_FILENO);
if (opt & OPT_1)