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

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
lib/subordinateio.c
lib/subordinateio.h
src/newusers.c
src/useradd.c
src/userdel.c
src/usermod.c

index 44393d0331579c03709fa1a8899e0e7b63fc08cc..8384683a9920f1d221b3d2af2e679ac0541d8267 100644 (file)
@@ -674,9 +674,9 @@ int sub_uid_close (bool process_selinux)
        return commonio_close (&subordinate_uid_db, process_selinux);
 }
 
-int sub_uid_unlock (void)
+int sub_uid_unlock (bool process_selinux)
 {
-       return commonio_unlock (&subordinate_uid_db, true);
+       return commonio_unlock (&subordinate_uid_db, process_selinux);
 }
 
 uid_t sub_uid_find_free_range(uid_t min, uid_t max, unsigned long count)
@@ -1046,7 +1046,7 @@ bool new_subid_range(struct subordinate_range *range, enum subid_type id_type, b
                }
                if (!sub_uid_open(O_CREAT | O_RDWR)) {
                        printf("Failed opening subuids (errno %d)\n", errno);
-                       sub_uid_unlock();
+                       sub_uid_unlock(true);
                        return false;
                }
                db = &subordinate_uid_db;
@@ -1093,7 +1093,7 @@ bool new_subid_range(struct subordinate_range *range, enum subid_type id_type, b
 out:
        if (id_type == ID_TYPE_UID) {
                sub_uid_close(true);
-               sub_uid_unlock();
+               sub_uid_unlock(true);
        } else {
                sub_gid_close(true);
                sub_gid_unlock();
@@ -1118,7 +1118,7 @@ bool release_subid_range(struct subordinate_range *range, enum subid_type id_typ
                }
                if (!sub_uid_open(O_CREAT | O_RDWR)) {
                        printf("Failed opening subuids (errno %d)\n", errno);
-                       sub_uid_unlock();
+                       sub_uid_unlock(true);
                        return false;
                }
                db = &subordinate_uid_db;
@@ -1143,7 +1143,7 @@ bool release_subid_range(struct subordinate_range *range, enum subid_type id_typ
 
        if (id_type == ID_TYPE_UID) {
                sub_uid_close(true);
-               sub_uid_unlock();
+               sub_uid_unlock(true);
        } else {
                sub_gid_close(true);
                sub_gid_unlock();
index ff231f30e8db085f22f0e95ec9dfdee08dab89a2..88f1ec97fcc7bb5c634d3656e30acc6a6d6ee4fa 100644 (file)
@@ -21,7 +21,7 @@ extern int sub_uid_lock (void);
 extern int sub_uid_setdbname (const char *filename);
 extern /*@observer@*/const char *sub_uid_dbname (void);
 extern int sub_uid_open (int mode);
-extern int sub_uid_unlock (void);
+extern int sub_uid_unlock (bool process_selinux);
 extern int sub_uid_add (const char *owner, uid_t start, unsigned long count);
 extern int sub_uid_remove (const char *owner, uid_t start, unsigned long count);
 extern uid_t sub_uid_find_free_range(uid_t min, uid_t max, unsigned long count);
index da88d40b156bf7827e7080cd0345e7bd204cebeb..dd79a5ae2eb8c1f53f9432b1ee839f599c3a91c8 100644 (file)
@@ -197,7 +197,7 @@ static void fail_exit (int code)
 #endif
 #ifdef ENABLE_SUBIDS
        if (sub_uid_locked) {
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */
@@ -1022,7 +1022,7 @@ static void close_files (void)
 #endif
 #ifdef ENABLE_SUBIDS
        if (is_sub_uid) {
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */
index c6dd5d54a77c35b2f82138db165fb26b9b6fb208..93293050c926ed0a4cdbb55b66e3f8d1ef41f976 100644 (file)
@@ -286,7 +286,7 @@ static void fail_exit (int code)
        }
 #endif
 #ifdef ENABLE_SUBIDS
-       if (sub_uid_locked && sub_uid_unlock() == 0) {
+       if (sub_uid_locked && sub_uid_unlock(true) == 0) {
                fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname());
                SYSLOG((LOG_ERR, "failed to unlock %s", sub_uid_dbname()));
                /* continue */
@@ -1621,7 +1621,7 @@ static void close_files (void)
 
 #ifdef ENABLE_SUBIDS
        if (is_sub_uid) {
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
 #ifdef WITH_AUDIT
index b045c7ebb1b400b27df47b791d9f7f6d57306bbd..e57b845fde83f440a982dc97ccece31e03fcfe86 100644 (file)
@@ -455,7 +455,7 @@ static void close_files (void)
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sub_uid_dbname ()));
                        fail_exit (E_SUB_UID_UPDATE);
                }
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */
@@ -516,7 +516,7 @@ static void fail_exit (int code)
 #endif                         /* SHADOWGRP */
 #ifdef ENABLE_SUBIDS
        if (sub_uid_locked) {
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */
index eb3d6595fadf4c14a86b60e41114191791a42aa3..7817b23b690b4e9592b31582d68f7aa1c445598c 100644 (file)
@@ -666,7 +666,7 @@ fail_exit (int code)
        }
 #ifdef ENABLE_SUBIDS
        if (sub_uid_locked) {
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */
@@ -1569,7 +1569,7 @@ static void close_files (void)
                        SYSLOG ((LOG_ERR, "failure while writing changes to %s", sub_uid_dbname ()));
                        fail_exit (E_SUB_UID_UPDATE);
                }
-               if (sub_uid_unlock () == 0) {
+               if (sub_uid_unlock (true) == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ());
                        SYSLOG ((LOG_ERR, "failed to unlock %s", sub_uid_dbname ()));
                        /* continue */