]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
chage: add --prefix/-P options
authorJaroslav Jindrak <dzejrou@gmail.com>
Fri, 21 Apr 2023 20:24:36 +0000 (22:24 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 9 Jun 2023 14:22:24 +0000 (16:22 +0200)
src/chage.c

index 30d058eaf590e9ec8c5ec2f5dea1f541870e7095..b11ed3d8985bdc2772983fb8cb42ab7044c067ab 100644 (file)
@@ -54,6 +54,8 @@ static bool
     Wflg = false;              /* set expiration warning days */
 static bool amroot = false;
 
+static const char *prefix = "";
+
 static bool pw_locked  = false;        /* Indicate if the password file is locked */
 static bool spw_locked = false;        /* Indicate if the shadow file is locked */
 /* The name and UID of the user being worked on */
@@ -137,6 +139,7 @@ usage (int status)
        (void) fputs (_("  -M, --maxdays MAX_DAYS        set maximum number of days before password\n"
                        "                                change to MAX_DAYS\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 (_("  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS\n"), usageout);
        (void) fputs ("\n", usageout);
        exit (status);
@@ -349,12 +352,13 @@ static void process_flags (int argc, char **argv)
                {"mindays",    required_argument, NULL, 'm'},
                {"maxdays",    required_argument, NULL, 'M'},
                {"root",       required_argument, NULL, 'R'},
+               {"prefix",     required_argument, NULL, 'P'},
                {"warndays",   required_argument, NULL, 'W'},
                {"iso8601",    no_argument,       NULL, 'i'},
                {NULL, 0, NULL, '\0'}
        };
 
-       while ((c = getopt_long (argc, argv, "d:E:hiI:lm:M:R:W:",
+       while ((c = getopt_long (argc, argv, "d:E:hiI:lm:M:R:P:W:",
                                 long_options, NULL)) != -1) {
                switch (c) {
                case 'd':
@@ -418,6 +422,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;
                case 'W':
                        Wflg = true;
                        if (   (getlong (optarg, &warndays) == 0)
@@ -769,6 +775,7 @@ int main (int argc, char **argv)
        (void) textdomain (PACKAGE);
 
        process_root_flag ("-R", argc, argv);
+       prefix = process_prefix_flag ("-P", argc, argv);
 
 #ifdef WITH_AUDIT
        audit_help_open ();