//usage: "\n a SIGXCPU after N seconds"
#include "libbb.h"
+#include <sys/resource.h> /* getrlimit */
/*
Five applets here: chpst, envdir, envuidgid, setuidgid, softlimit.
{
struct bb_uidgid_t ugid;
char *set_user = set_user; /* for compiler */
- char *env_user = env_user;
char *env_dir = env_dir;
char *root;
char *nicestr;
IF_CHPST("/:n:vP012"),
&limita, &limitc, &limitd, &limitf, &limitl,
&limitm, &limito, &limitp, &limitr, &limits, &limitt,
- &set_user, &env_user, &env_dir
+ &set_user, &set_user, &env_dir
IF_CHPST(, &root, &nicestr));
argv += optind;
if (opt & OPT_m) { // -m means -asld
// envuidgid?
if (ENABLE_ENVUIDGID && applet_name[0] == 'e' && applet_name[3] == 'u') {
- env_user = *argv++;
+ set_user = *argv++;
opt |= OPT_U;
}
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);
+
+ // 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) {
- xget_uidgid(&ugid, env_user);
xsetenv("GID", utoa(ugid.gid));
xsetenv("UID", utoa(ugid.uid));
}
- if (opt & OPT_u) {
- xget_uidgid(&ugid, set_user);
- }
-
if (opt & OPT_root) {
- xchdir(root);
- xchroot(".");
+ xchroot(root);
}
if (opt & OPT_u) {