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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
15 files changed:
lib/sgroupio.c
lib/sgroupio.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 2cf509bc1156b2cf6ec730ef3d6da77455467e5a..f2a5bdaaffc50e2e405bcc1eb2a9fdfbc1c425da 100644 (file)
@@ -280,9 +280,9 @@ int sgr_rewind (void)
        return commonio_next (&gshadow_db);
 }
 
-int sgr_close (void)
+int sgr_close (bool process_selinux)
 {
-       return commonio_close (&gshadow_db, true);
+       return commonio_close (&gshadow_db, process_selinux);
 }
 
 int sgr_unlock (void)
index d37526f5ea151db05dfcf19f23dd21acea2c0069..2f41789fd63ff761be3e3cafca4d4dc65198a615 100644 (file)
@@ -18,7 +18,7 @@
 #include "shadow/gshadow/sgrp.h"
 
 
-extern int sgr_close (void);
+extern int sgr_close (bool process_selinux);
 extern bool sgr_file_present (void);
 extern /*@observer@*/ /*@null@*/const struct sgrp *sgr_locate (const char *name);
 extern int sgr_lock (void);
index 8f8f1a68e3e3f22ad5fcad2f259f014eeaba4466..e510ecd7a8150dd74a71a1cee5add13edd69a02f 100644 (file)
@@ -382,7 +382,7 @@ static void close_files (void)
 {
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
index a9115824a1a3cf4e6b14dbb3d6b16f0259e83ee1..77257845dba4dffd3e2a6ef341cbe52e0f435306 100644 (file)
@@ -608,7 +608,7 @@ static void close_files (void)
 
 #ifdef SHADOWGRP
        if (is_shadowgrp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
@@ -763,7 +763,7 @@ static void get_group (struct group *gr)
                        sg->sg_adm[0] = NULL;
 
                }
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while closing read-only %s\n"),
                                 Prog, sgr_dbname ());
index 10d9d781c949ac574da9469200554a19878c4c8f..d1610b3935286f08ef38d013129d01d4f01dc292 100644 (file)
@@ -296,7 +296,7 @@ static void close_files (void)
        /* Now, write the changes in the shadow database */
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
index c43ff227358419b053c7530aacc047fb685089b4..35123265fc45c03838a89e61ea8bd6a70d37889d 100644 (file)
@@ -173,7 +173,7 @@ static void close_files (void)
        /* Then, write the changes in the shadow database */
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
index 48a76aed6d13c4c73a11eb07d35599f422076047..7e302018f7be1b7e4777486fa4e048bc56dd1108 100644 (file)
@@ -539,7 +539,7 @@ static void close_files (void)
 
 #ifdef SHADOWGRP
        if (is_shadowgrp) {
-               if ((sgr_close () == 0) && !list) {
+               if ((sgr_close (true) == 0) && !list) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (EXIT_GROUP_FILE);
index 7cd7fb03e303bddcaf18851e3c62fb6038cd8d51..66886324b3faf95b75cf293bf8ca4bde12921c24 100644 (file)
@@ -506,7 +506,7 @@ static void close_files (void)
 #ifdef SHADOWGRP
        if (   is_shadow_grp
            && (pflg || nflg || user_list)) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
index a3bf80ce353015f021af3f5a31bd0bb1fc7bbee9..e086c3067fb338236d1190eb7e1b81be08571b83 100644 (file)
@@ -331,7 +331,7 @@ static void close_files (bool changed)
                        fail_exit (E_CANT_UPDATE);
                }
 #ifdef SHADOWGRP
-               if (is_shadow && (sgr_close () == 0)) {
+               if (is_shadow && (sgr_close (true) == 0)) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_file);
                        fail_exit (E_CANT_UPDATE);
index 99620edee9f31af8ec9a60744895a5628a229875..82dbe73d3e540584e01925d373ca8df960097b0d 100644 (file)
@@ -235,7 +235,7 @@ int main (int argc, char **argv)
                }
        }
 
-       if (sgr_close () == 0) {
+       if (sgr_close (true) == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, sgr_dbname ());
index 9b05d162ef1dfd3a19fe0211babde9fabdcb87e0..abea1d4e64431c3499da3a5f31169793b8699c74 100644 (file)
@@ -192,7 +192,7 @@ int main (int argc, char **argv)
                }
        }
 
-       (void) sgr_close (); /* was only open O_RDONLY */
+       (void) sgr_close (true); /* was only open O_RDONLY */
 
        if (gr_close (true) == 0) {
                fprintf (stderr,
index 327bc6db56152b15e7ce4a11bf222ceeee3acbbb..2cbe74f6ad33e383045ef55f817a6721eb51815b 100644 (file)
@@ -1003,7 +1003,7 @@ static void close_files (void)
 
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
index 1971f69ad94b0e4d2eb122da56d44a3d90ff8b8b..3cd7bd10f864dd0199d38077cf2ea262517758ae 100644 (file)
@@ -1670,7 +1670,7 @@ static void close_group_files (void)
                fail_exit(E_GRP_UPDATE);
        }
 #ifdef SHADOWGRP
-       if (is_shadow_grp && sgr_close() == 0) {
+       if (is_shadow_grp && sgr_close(true) == 0) {
                fprintf(stderr,
                        _("%s: failure while writing changes to %s\n"),
                        Prog, sgr_dbname());
index 7f118343a591f3b068d30202a85b5be68166a9a5..a9e2e3ac98612ed6144d84474439d246ccc27df2 100644 (file)
@@ -432,7 +432,7 @@ static void close_files (void)
 
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
-               if (sgr_close () == 0) {
+               if (sgr_close (true) == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
index 7ac9e6c467b3009d3519174dd633d36ebd0a6764..4e2d225555efe24191290315c6efe10c40fc0a2c 100644 (file)
@@ -1501,7 +1501,7 @@ static void close_files (void)
                }
 #ifdef SHADOWGRP
                if (is_shadow_grp) {
-                       if (sgr_close () == 0) {
+                       if (sgr_close (true) == 0) {
                                fprintf (stderr,
                                         _("%s: failure while writing changes to %s\n"),
                                         Prog, sgr_dbname ());