From: Michael Vetter Date: Mon, 17 Apr 2023 13:39:47 +0000 (+0200) Subject: prefix: add prefix support X-Git-Tag: 4.14.0-rc1~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ded9cab35d703f21b249d8d534611319f6cf8578;p=thirdparty%2Fshadow.git prefix: add prefix support --- diff --git a/src/passwd.c b/src/passwd.c index 5c5faf6f5..89d173e77 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -51,6 +51,8 @@ static char *name; /* The name of user whose password is being changed */ static char *myname; /* The current user's name */ static bool amroot; /* The caller's real UID was 0 */ +static const char *prefix = ""; + static bool aflg = false, /* -a - show status for all users */ dflg = false, /* -d - delete password */ @@ -149,6 +151,7 @@ usage (int status) (void) fputs (_(" -q, --quiet quiet mode\n"), usageout); (void) fputs (_(" -r, --repository REPOSITORY change password in REPOSITORY repository\n"), usageout); (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); + (void) fputs (_(" -P, --prefix PREFIX_DIR directory prefix\n"), usageout); (void) fputs (_(" -S, --status report password status on the named account\n"), usageout); (void) fputs (_(" -u, --unlock unlock the password of the named account\n"), usageout); (void) fputs (_(" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"), usageout); @@ -743,6 +746,7 @@ int main (int argc, char **argv) (void) textdomain (PACKAGE); process_root_flag ("-R", argc, argv); + prefix = process_prefix_flag ("-P", argc, argv); /* * The program behaves differently when executed by root than when @@ -769,6 +773,7 @@ int main (int argc, char **argv) {"quiet", no_argument, NULL, 'q'}, {"repository", required_argument, NULL, 'r'}, {"root", required_argument, NULL, 'R'}, + {"prefix", required_argument, NULL, 'P'}, {"status", no_argument, NULL, 'S'}, {"unlock", no_argument, NULL, 'u'}, {"warndays", required_argument, NULL, 'w'}, @@ -838,6 +843,8 @@ int main (int argc, char **argv) break; case 'R': /* no-op, handled in process_root_flag () */ break; + case 'P': /* no-op, handled in process_prefix_flag () */ + break; case 'S': Sflg = true; /* ok for users */ break;