]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: add SELinux control flag in sgr_unlock()
authorIker Pedrosa <ipedrosa@redhat.com>
Fri, 25 Apr 2025 14:03:58 +0000 (16:03 +0200)
committerIker Pedrosa <ipedrosa@redhat.com>
Tue, 7 Oct 2025 09:04:39 +0000 (11:04 +0200)
Expand sgr_unlock() interface to add a control flag for SELinux file
context processing.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
12 files changed:
lib/cleanup_group.c
lib/sgroupio.c
lib/sgroupio.h
src/chgpasswd.c
src/groupmems.c
src/grpck.c
src/grpconv.c
src/grpunconv.c
src/newusers.c
src/useradd.c
src/userdel.c
src/usermod.c

index 29013a0b221715c9b246850eea53ad8c2864a5a7..a65260cc3e285043f6da724ab716ccfb1c16621b 100644 (file)
@@ -201,7 +201,7 @@ void cleanup_unlock_group (MAYBE_UNUSED void *arg)
  */
 void cleanup_unlock_gshadow (MAYBE_UNUSED void *arg)
 {
-       if (sgr_unlock () == 0) {
+       if (sgr_unlock (true) == 0) {
                fprintf (log_get_logfd(),
                         _("%s: failed to unlock %s\n"),
                         log_get_progname(), sgr_dbname ());
index 349638522bcd0d03cc6af1e4a44f19df6250f2e7..ef6fb4d5941b68f229b27f104c6b0b63c5c0400b 100644 (file)
@@ -285,9 +285,9 @@ int sgr_close (bool process_selinux)
        return commonio_close (&gshadow_db, process_selinux);
 }
 
-int sgr_unlock (void)
+int sgr_unlock (bool process_selinux)
 {
-       return commonio_unlock (&gshadow_db, true);
+       return commonio_unlock (&gshadow_db, process_selinux);
 }
 
 void __sgr_set_changed (void)
index 2f41789fd63ff761be3e3cafca4d4dc65198a615..567e380a574023c9a3c9d6f01bf9c105d0ae6a3b 100644 (file)
@@ -28,7 +28,7 @@ extern /*@null@*/const struct sgrp *sgr_next (void);
 extern int sgr_open (int mode);
 extern int sgr_remove (const char *name);
 extern int sgr_rewind (void);
-extern int sgr_unlock (void);
+extern int sgr_unlock (bool process_selinux);
 extern int sgr_update (const struct sgrp *sg);
 extern int sgr_sort (void);
 
index 4b18b43e2d776ee5d95a6859ea79a8e6bd761cfb..e2a95fd21d729c0bc20c3d8a888b098a90a36c6b 100644 (file)
@@ -92,7 +92,7 @@ static void fail_exit (int code)
 
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -389,7 +389,7 @@ static void close_files (void)
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (1);
                }
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
index ca3d270652c6f63bcbe590f93a2b1d99f83c873e..ec3f04dd3b304868d7a6d5e6560102a9f906bff1 100644 (file)
@@ -469,7 +469,7 @@ static void fail_exit (int code)
 
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failed to unlock %s\n"),
                                 Prog, sgr_dbname ());
@@ -545,7 +545,7 @@ static void close_files (void)
                        fail_exit (EXIT_GROUP_FILE);
                }
                if (sgr_locked) {
-                       if (sgr_unlock () == 0) {
+                       if (sgr_unlock (true) == 0) {
                                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                                SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                                /* continue */
index 26293b9f0cbea1f57fba974d38a8baf020c11bf4..e4c8799e33a6768d884828b52978bc7969e2b295 100644 (file)
@@ -105,7 +105,7 @@ static void fail_exit (int status)
 
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -344,7 +344,7 @@ static void close_files (bool changed)
         */
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
index bc4c6f5188423269e89fc29af25f8df39d59e5ad..e36e0cef17422c4a6fad0b2aa6f35f118d6fc5c9 100644 (file)
@@ -65,7 +65,7 @@ static void fail_exit (int status)
        }
 
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -249,7 +249,7 @@ int main (int argc, char **argv)
                SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (3);
        }
-       if (sgr_unlock () == 0) {
+       if (sgr_unlock (true) == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                /* continue */
index 487f9479570d31d75cd3f8bf7c58e1022d9017c8..545474f6d2dad5f9bae5cc39b3ef181a6d125ba6 100644 (file)
@@ -64,7 +64,7 @@ static void fail_exit (int status)
        }
 
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -216,7 +216,7 @@ int main (int argc, char **argv)
                /* continue */
        }
 
-       if (sgr_unlock () == 0) {
+       if (sgr_unlock (true) == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                /* continue */
index 8fbd3dbe99963c5a9734659dd499c8cea1483f88..da88d40b156bf7827e7080cd0345e7bd204cebeb 100644 (file)
@@ -188,7 +188,7 @@ static void fail_exit (int code)
        }
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -1010,7 +1010,7 @@ static void close_files (void)
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (EXIT_FAILURE);
                }
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failed to unlock %s\n"),
                                 Prog, sgr_dbname ());
index 52091d816011b4261e2559669d3deb6eb2a8890a..c6dd5d54a77c35b2f82138db165fb26b9b6fb208 100644 (file)
@@ -279,7 +279,7 @@ static void fail_exit (int code)
                /* continue */
        }
 #ifdef SHADOWGRP
-       if (sgr_locked && sgr_unlock() == 0) {
+       if (sgr_locked && sgr_unlock(true) == 0) {
                fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname());
                SYSLOG((LOG_ERR, "failed to unlock %s", sgr_dbname()));
                /* continue */
@@ -1702,7 +1702,7 @@ static void unlock_group_files (void)
        gr_locked = false;
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
index b34177ef8cd2757c995a1fda853831541074bf3e..b045c7ebb1b400b27df47b791d9f7f6d57306bbd 100644 (file)
@@ -439,7 +439,7 @@ static void close_files (void)
                        fail_exit (E_GRP_UPDATE);
                }
 
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -507,7 +507,7 @@ static void fail_exit (int code)
        }
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
index dd2d965e55796ba3f3258bc5f110b7419a820483..eb3d6595fadf4c14a86b60e41114191791a42aa3 100644 (file)
@@ -643,7 +643,7 @@ fail_exit (int code)
        }
 #ifdef SHADOWGRP
        if (sgr_locked) {
-               if (sgr_unlock () == 0) {
+               if (sgr_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
                        /* continue */
@@ -1514,7 +1514,7 @@ static void close_files (void)
 #endif
 #ifdef SHADOWGRP
                if (is_shadow_grp) {
-                       if (sgr_unlock () == 0) {
+                       if (sgr_unlock (true) == 0) {
                                fprintf (stderr,
                                         _("%s: failed to unlock %s\n"),
                                         Prog, sgr_dbname ());