From: Iker Pedrosa Date: Tue, 1 Jul 2025 14:32:27 +0000 (+0200) Subject: src/grpunconv.c: SELinux file context for fail_exit() X-Git-Tag: 4.19.0-rc1~128^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4946b027bbf965061307af4e8b6bd1575211d943;p=thirdparty%2Fshadow.git src/grpunconv.c: SELinux file context for fail_exit() Do not process SELinux file context when running fail_exit() when chroot or prefix options are selected. Signed-off-by: Iker Pedrosa --- diff --git a/src/grpunconv.c b/src/grpunconv.c index a73a08f59..d66cf52e0 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -55,14 +55,14 @@ static bool gr_locked = false; static bool sgr_locked = false; /* local function prototypes */ -static void fail_exit (int status); +static void fail_exit (int status, bool process_selinux); static void usage (int status); static void process_flags (int argc, char **argv, struct option_flags *flags); -static void fail_exit (int status) +static void fail_exit (int status, bool process_selinux) { if (gr_locked) { - if (gr_unlock (true) == 0) { + if (gr_unlock (process_selinux) == 0) { fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ())); /* continue */ @@ -70,7 +70,7 @@ static void fail_exit (int status) } if (sgr_locked) { - if (sgr_unlock (true) == 0) { + if (sgr_unlock (process_selinux) == 0) { fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ())); /* continue */ @@ -160,26 +160,26 @@ int main (int argc, char **argv) fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); - fail_exit (5); + fail_exit (5, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); - fail_exit (1); + fail_exit (1, process_selinux); } if (sgr_lock () == 0) { fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); - fail_exit (5); + fail_exit (5, process_selinux); } sgr_locked = true; if (sgr_open (O_RDONLY) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ()); - fail_exit (1); + fail_exit (1, process_selinux); } /* @@ -197,7 +197,7 @@ int main (int argc, char **argv) fprintf (stderr, _("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grent.gr_name); - fail_exit (3); + fail_exit (3, process_selinux); } } } @@ -209,7 +209,7 @@ int main (int argc, char **argv) _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ())); - fail_exit (3); + fail_exit (3, process_selinux); } if (unlink(_PATH_GSHADOW) != 0) { @@ -217,7 +217,7 @@ int main (int argc, char **argv) _("%s: cannot delete %s\n"), Prog, _PATH_GSHADOW); SYSLOG((LOG_ERR, "cannot delete %s", _PATH_GSHADOW)); - fail_exit (3); + fail_exit (3, process_selinux); } if (gr_unlock (process_selinux) == 0) {