From: Jaroslav Jindrak Date: Fri, 28 Apr 2023 18:30:18 +0000 (+0200) Subject: chpasswd: add --prefix/-P options X-Git-Tag: 4.14.0-rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13b0a2bf3bcf108f550100aa04d962754f2a3476;p=thirdparty%2Fshadow.git chpasswd: add --prefix/-P options --- diff --git a/src/chpasswd.c b/src/chpasswd.c index 3cfd611eb..3dec07966 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -54,6 +54,8 @@ static long bcrypt_rounds = 13; static long yescrypt_cost = 5; #endif +static const char *prefix = ""; + static bool is_shadow_pwd; static bool pw_locked = false; static bool spw_locked = false; @@ -123,6 +125,7 @@ usage (int status) " the MD5 algorithm\n"), usageout); (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout); + (void) fputs (_(" -P, --prefix PREFIX_DIR directory prefix\n"), usageout); #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) (void) fputs (_(" -s, --sha-rounds number of rounds for the SHA, BCRYPT\n" " or YESCRYPT crypt algorithms\n"), @@ -150,6 +153,7 @@ static void process_flags (int argc, char **argv) {"help", no_argument, NULL, 'h'}, {"md5", no_argument, NULL, 'm'}, {"root", required_argument, NULL, 'R'}, + {"prefix", required_argument, NULL, 'P'}, #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) {"sha-rounds", required_argument, NULL, 's'}, #endif /* USE_SHA_CRYPT || USE_BCRYPT || USE_YESCRYPT */ @@ -158,9 +162,9 @@ static void process_flags (int argc, char **argv) while ((c = getopt_long (argc, argv, #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) - "c:ehmR:s:", + "c:ehmR:P:s:", #else - "c:ehmR:", + "c:ehmR:P:", #endif long_options, NULL)) != -1) { switch (c) { @@ -178,6 +182,8 @@ static void process_flags (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; #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT) case 's': sflg = true; @@ -462,6 +468,7 @@ int main (int argc, char **argv) salt = get_salt(); process_root_flag ("-R", argc, argv); + prefix = process_prefix_flag ("-P", argc, argv); #ifdef USE_PAM if (md5flg || eflg || cflg) {