From 0530588266ab223555acae35925f3bcc91af3be6 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 6 Nov 2011 18:39:24 +0000 Subject: [PATCH] * NEWS, src/chfn.c, man/chfn.1.xml: Add --root option. --- ChangeLog | 1 + NEWS | 2 ++ man/chfn.1.xml | 13 +++++++++++++ src/chfn.c | 20 +++++++++++++------- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43eb13c2..7cd4dd04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * src/chfn.c, man/chfn.1.xml: Add support for long options. * src/chfn.c, man/chfn.1.xml: Add -u/--help option + * NEWS, src/chfn.c, man/chfn.1.xml: Add --root option. 2011-10-30 Nicolas François diff --git a/NEWS b/NEWS index 5ddffa89..fd0f1c9c 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED - chage * Add --root option. +- chfn + * Add --root option. - chgpasswd * When the gshadow file exists but there are no gshadow entries, an entry is created if the password is changed and group requires a diff --git a/man/chfn.1.xml b/man/chfn.1.xml index 0b568900..3a3b1f74 100644 --- a/man/chfn.1.xml +++ b/man/chfn.1.xml @@ -130,6 +130,19 @@ Change the user's room number. + + + , + CHROOT_DIR + + + + Apply changes in the CHROOT_DIR + directory and use the configuration files from the + CHROOT_DIR directory. + + + , diff --git a/src/chfn.c b/src/chfn.c index 70cb0f39..40d6750b 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -123,6 +123,7 @@ static /*@noreturn@*/void usage (int status) (void) fputs (_(" -h, --home-phone HOME_PHONE change user's home phone number\n"), usageout); (void) fputs (_(" -o, --other OTHER_INFO change user's other GECOS information\n"), usageout); (void) fputs (_(" -r, --room ROOM_NUMBER change user's room number\n"), usageout); + (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); (void) fputs (_(" -u, --help display this help message and exit\n"), usageout); (void) fputs (_(" -w, --work-phone WORK_PHONE change user's office phone number\n"), usageout); (void) fputs ("\n", usageout); @@ -272,6 +273,7 @@ static void process_flags (int argc, char **argv) {"home-phone", required_argument, NULL, 'h'}, {"other", required_argument, NULL, 'o'}, {"room", required_argument, NULL, 'r'}, + {"root", required_argument, NULL, 'R'}, {"help", no_argument, NULL, 'u'}, {"work-phone", required_argument, NULL, 'w'}, {NULL, 0, NULL, '\0'} @@ -284,7 +286,7 @@ static void process_flags (int argc, char **argv) * environment and must agree with the real UID. Also, the UID will * be checked for any commands which are restricted to root only. */ - while ((c = getopt_long (argc, argv, "f:h:o:r:uw:", + while ((c = getopt_long (argc, argv, "f:h:o:r:R:uw:", long_options, NULL)) != -1) { switch (c) { case 'f': @@ -323,6 +325,8 @@ static void process_flags (int argc, char **argv) rflg = true; STRFCPY (roomno, optarg); break; + case 'R': /* no-op, handled in process_root_flag () */ + break; case 'u': usage (E_SUCCESS); /*@notreached@*/break; @@ -626,23 +630,25 @@ int main (int argc, char **argv) char new_gecos[BUFSIZ]; /* buffer for new GECOS fields */ char *user; + /* + * Get the program name. The program name is used as a + * prefix to most error messages. + */ + Prog = Basename (argv[0]); + sanitize_env (); (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); + process_root_flag ("-R", argc, argv); + /* * This command behaves different for root and non-root * users. */ amroot = (getuid () == 0); - /* - * Get the program name. The program name is used as a - * prefix to most error messages. - */ - Prog = Basename (argv[0]); - OPENLOG ("chfn"); /* parse the command line options */