]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/userdel.c: replace global variable by flags structure
authorIker Pedrosa <ipedrosa@redhat.com>
Tue, 1 Jul 2025 13:35:35 +0000 (15:35 +0200)
committerIker Pedrosa <ipedrosa@redhat.com>
Tue, 7 Oct 2025 09:04:39 +0000 (11:04 +0200)
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
src/userdel.c

index a3805c6e6c29c57a809d3d8e741cb66ac73fa608..0b07b304beed18037b9f9e4e97041bd8e0be430b 100644 (file)
 #define E_SUB_GID_UPDATE 18    /* can't update the subordinate gid file */
 #endif                         /* ENABLE_SUBIDS */
 
+/*
+ * Structures
+ */
+struct option_flags {
+       bool chroot;
+       bool prefix;
+};
+
 /*
  * Global variables
  */
@@ -88,7 +96,6 @@ static bool rflg = false;
 #ifdef WITH_SELINUX
 static bool Zflg = false;
 #endif
-static bool Rflg = false;
 
 static bool is_shadow_pwd;
 
@@ -906,6 +913,7 @@ int main (int argc, char **argv)
        int retval;
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
+       struct option_flags  flags;
 
        log_set_progname(Prog);
        log_set_logfd(stderr);
@@ -955,9 +963,10 @@ int main (int argc, char **argv)
                                rflg = true;
                                break;
                        case 'R': /* no-op, handled in process_root_flag () */
-                               Rflg = true;
+                               flags.chroot = true;
                                break;
                        case 'P': /* no-op, handled in process_prefix_flag () */
+                               flags.prefix = true;
                                break;
 #ifdef WITH_SELINUX
                        case 'Z':
@@ -1078,7 +1087,7 @@ int main (int argc, char **argv)
         * Note: This is a best effort basis. The user may log in between,
         * a cron job may be started on her behalf, etc.
         */
-       if (streq(prefix, "") && !Rflg && user_busy(user_name, user_id) != 0) {
+       if (streq(prefix, "") && !flags.chroot && user_busy(user_name, user_id) != 0) {
                if (!fflg) {
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,