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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
15 files changed:
lib/groupio.c
lib/groupio.h
src/chgpasswd.c
src/gpasswd.c
src/groupadd.c
src/groupdel.c
src/groupmems.c
src/groupmod.c
src/grpck.c
src/grpconv.c
src/grpunconv.c
src/newusers.c
src/useradd.c
src/userdel.c
src/usermod.c

index 0bce549fdabc5749f0a257755d0072188ec5b8fa..b5a587aa271caa727552f4716f9abdb127767c01 100644 (file)
@@ -185,9 +185,9 @@ int gr_rewind (void)
        return commonio_next (&group_db);
 }
 
-int gr_close (void)
+int gr_close (bool process_selinux)
 {
-       return commonio_close (&group_db, true);
+       return commonio_close (&group_db, process_selinux);
 }
 
 int gr_unlock (void)
index 2014de0cab3ba3e0428714d6a625ac1ec246cbfc..ef9242d04840e5a8f2315c76c027f435786f7e69 100644 (file)
@@ -14,8 +14,9 @@
 
 #include <sys/types.h>
 #include <grp.h>
+#include <stdbool.h>
 
-extern int gr_close (void);
+extern int gr_close (bool process_selinux);
 extern /*@observer@*/ /*@null@*/const struct group *gr_locate (const char *name);
 extern /*@observer@*/ /*@null@*/const struct group *gr_locate_gid (gid_t gid);
 extern int gr_lock (void);
index c0017e3380b5641fecbaf73c761d9cbdb905f07d..8f8f1a68e3e3f22ad5fcad2f259f014eeaba4466 100644 (file)
@@ -398,7 +398,7 @@ static void close_files (void)
        }
 #endif
 
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index a64c270178abf6f6e5e8c09a2ea6f2546ad7a5f5..a9115824a1a3cf4e6b14dbb3d6b16f0259e83ee1 100644 (file)
@@ -594,7 +594,7 @@ static void log_gpasswd_success_group (MAYBE_UNUSED void *arg)
  */
 static void close_files (void)
 {
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
@@ -725,7 +725,7 @@ static void get_group (struct group *gr)
        gr->gr_passwd = xstrdup (tmpgr->gr_passwd);
        gr->gr_mem = dup_list (tmpgr->gr_mem);
 
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while closing read-only %s\n"),
                         Prog, gr_dbname ());
index 8210388bd3dd288301d5d300028f51a71dc334a8..10d9d781c949ac574da9469200554a19878c4c8f 100644 (file)
@@ -275,7 +275,7 @@ check_new_name(void)
 static void close_files (void)
 {
        /* First, write the changes in the regular group database */
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index 2e754e31a757419dd3a2f11c04429bd5e7209e55..c43ff227358419b053c7530aacc047fb685089b4 100644 (file)
@@ -149,7 +149,7 @@ static void grp_update (void)
 static void close_files (void)
 {
        /* First, write the changes in the regular group database */
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index 68a186730ebea98b39979e24d6af1ec14423a88c..48a76aed6d13c4c73a11eb07d35599f422076047 100644 (file)
@@ -523,7 +523,7 @@ static void open_files (void)
 
 static void close_files (void)
 {
-       if ((gr_close () == 0) && !list) {
+       if ((gr_close (true) == 0) && !list) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
                SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (EXIT_GROUP_FILE);
index 66559432200dae249265f8eb43d642cbe238a87a..7cd7fb03e303bddcaf18851e3c62fb6038cd8d51 100644 (file)
@@ -483,7 +483,7 @@ static void process_flags (int argc, char **argv)
  */
 static void close_files (void)
 {
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index 2a6a11ee9b297a48073f2605c854711e8e066341..a3bf80ce353015f021af3f5a31bd0bb1fc7bbee9 100644 (file)
@@ -325,7 +325,7 @@ static void close_files (bool changed)
         * changes to the files.
         */
        if (changed) {
-               if (gr_close () == 0) {
+               if (gr_close (true) == 0) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"),
                                 Prog, grp_file);
                        fail_exit (E_CANT_UPDATE);
index 64b2157d2296e2951b12acb813be53953adef11f..99620edee9f31af8ec9a60744895a5628a229875 100644 (file)
@@ -242,7 +242,7 @@ int main (int argc, char **argv)
                SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                fail_exit (3);
        }
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index 4a822f7ed5b78679b1d1b411a2cd0b172f6ba5d4..9b05d162ef1dfd3a19fe0211babde9fabdcb87e0 100644 (file)
@@ -194,7 +194,7 @@ int main (int argc, char **argv)
 
        (void) sgr_close (); /* was only open O_RDONLY */
 
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index ebe467441bed9431581a144a36f256fefa4c1f0c..327bc6db56152b15e7ce4a11bf222ceeee3acbbb 100644 (file)
@@ -970,7 +970,7 @@ static void close_files (void)
                spw_locked = false;
        }
 
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
index 55444c811fee1eb67bd87aea8d5b2b086d09dae0..1971f69ad94b0e4d2eb122da56d44a3d90ff8b8b 100644 (file)
@@ -1662,7 +1662,7 @@ static void close_group_files (void)
        if (!do_grp_update)
                return;
 
-       if (gr_close() == 0) {
+       if (gr_close(true) == 0) {
                fprintf(stderr,
                        _("%s: failure while writing changes to %s\n"),
                        Prog, gr_dbname());
index d60c974b3abdb0fd1aab9e7ed4a105f1194f5ca5..7f118343a591f3b068d30202a85b5be68166a9a5 100644 (file)
@@ -418,7 +418,7 @@ static void close_files (void)
                spw_locked = false;
        }
 
-       if (gr_close () == 0) {
+       if (gr_close (true) == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
                SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (E_GRP_UPDATE);
index f392ed58bd101ae0a31213c63137d5057e7b6bad..7ac9e6c467b3009d3519174dd633d36ebd0a6764 100644 (file)
@@ -1490,7 +1490,7 @@ static void close_files (void)
        }
 
        if (Gflg || lflg) {
-               if (gr_close () == 0) {
+               if (gr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, gr_dbname ());