[git commit] chpst: simple code shrink

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 16 09:52:43 UTC 2011


commit: http://git.busybox.net/busybox/commit/?id=d18ef6c9f6f5c94f2a65a6ab6ae3776711cb2877
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
chpst_main                                           733     718     -15

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 runit/chpst.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/runit/chpst.c b/runit/chpst.c
index 1857060..44c21a2 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -405,19 +405,18 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
 	if (opt & OPT_e)
 		edir(env_dir);
 
-	// FIXME: chrooted jail must have /etc/passwd if we move this after chroot!
-	// OTOH chroot fails for non-roots!
-	// SOLUTION: cache uid/gid before chroot, apply uid/gid after
+	if (opt & (OPT_u|OPT_U)) {
+		xget_uidgid(&ugid, set_user);
+	}
+
 	if (opt & OPT_U) {
-		xget_uidgid(&ugid, env_user);
 		xsetenv("GID", utoa(ugid.gid));
 		xsetenv("UID", utoa(ugid.uid));
 	}
 
-	if (opt & OPT_u) {
-		xget_uidgid(&ugid, set_user);
-	}
-
+	// chrooted jail must have /etc/passwd if we move this after chroot.
+	// OTOH chroot fails for non-roots.
+	// Solution: cache uid/gid before chroot, apply uid/gid after.
 	if (opt & OPT_root) {
 		xchdir(root);
 		xchroot(".");
-- 
1.7.3.4



More information about the busybox-cvs mailing list