From: Iker Pedrosa Date: Tue, 1 Jul 2025 13:35:35 +0000 (+0200) Subject: src/userdel.c: replace global variable by flags structure X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df2be62b8e9b3b3362ff3675310a76e9ff805a12;p=thirdparty%2Fshadow.git src/userdel.c: replace global variable by flags structure Signed-off-by: Iker Pedrosa --- diff --git a/src/userdel.c b/src/userdel.c index a3805c6e6..0b07b304b 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -73,6 +73,14 @@ #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,