chpst: simple code shrink

function                                             old     new   delta
chpst_main                                           733     718     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-09-16 11:52:43 +02:00
parent 585541e8e3
commit d18ef6c9f6

View File

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