#include "myopt.h"
void usagemessage(void) {
- if (fputs("usage: really [<user-option>] [<group-option> ...] [--]"
+ if (fputs("usage: really [<really-option> ...] [--]"
" [<command> [<argument/option> ...]]\n"
- "user-options:\n"
+ "really-options specifying the user:\n"
" if no options given, set the uid to 0;\n"
" -u|--user <username> also sets their default group list\n"
" -i|--useronly <username> } set the uid\n"
" -I|--uidonly <uid> } but inherits the group list\n"
- "group-options:\n"
+ "really-options specifying the group:\n"
" -z|--groupsclear only groups specified are to be used\n"
" -g|--group <groupname> } add this to\n"
- " -G|--gid <gid> } the group list\n",
+ " -G|--gid <gid> } the group list\n"
+ "other really-options:\n"
+ " -h|--help display this message"
+ " -R|--chroot <dir> chroot (but *not* chdir)",
stderr) == EOF) { perror("write usage"); exit(-1); }
}
-static const char *opt_user, *opt_useronly;
+static const char *opt_user, *opt_useronly, *opt_chroot;
static int opt_groupsclear= 0, opt_ngids= 0, opt_uidonly= -1;
static int opt_gids[512];
{ "groupsclear", 'z', 0, &opt_groupsclear, 0, 0, 1 },
{ "group", 'g', 1, 0, 0, af_group },
{ "gid", 'G', 1, 0, 0, af_gid },
+ { "chroot", 'R', 1, 0, &opt_chroot, 0 },
{ "help", 'h', 0, 0, 0, af_help },
{ 0, 0 }
};
if (!pw) { fprintf(stderr,"unknown user `%s'\n",cp); exit(-1); }
opt_uidonly= pw->pw_uid;
}
+ if (opt_chroot) {
+ if (chroot(opt_chroot)) { perror("chroot failed"); exit(-1); }
+ }
orgmaingid= getgid();
orgmainuid= getuid();
if (orgmaingid<0) { perror("getgid failed"); exit(-1); }