From 50505a407d5558883e5242a12ec49d298f4344fe Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Sun, 16 May 2004 14:46:41 +0000 Subject: [PATCH 1/1] @@ -4,6 +4,7 @@ + * really has -R (chroot) option, and usage message improved. --- cprogs/really.c | 17 ++++++++++++----- debian/changelog | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cprogs/really.c b/cprogs/really.c index f4cfa08..4d1f316 100644 --- a/cprogs/really.c +++ b/cprogs/really.c @@ -30,21 +30,24 @@ #include "myopt.h" void usagemessage(void) { - if (fputs("usage: really [] [ ...] [--]" + if (fputs("usage: really [ ...] [--]" " [ [ ...]]\n" - "user-options:\n" + "really-options specifying the user:\n" " if no options given, set the uid to 0;\n" " -u|--user also sets their default group list\n" " -i|--useronly } set the uid\n" " -I|--uidonly } 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 } add this to\n" - " -G|--gid } the group list\n", + " -G|--gid } the group list\n" + "other really-options:\n" + " -h|--help display this message" + " -R|--chroot 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]; @@ -89,6 +92,7 @@ static const struct cmdinfo cmdinfos[]= { { "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 } }; @@ -146,6 +150,9 @@ int main(int argc, const char *const *argv) { 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); } diff --git a/debian/changelog b/debian/changelog index a0ad4e9..5a84e2d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ chiark-utils (4.0.99.0.6) unstable; urgency=low * ngspice2genspic script * gnucap2gnuplot split with new genspic int * gnucap2gnuplot script. + * really has -R (chroot) option, and usage message improved. -- -- 2.30.2