Skip to contentSkip to conversation

Revert "libsemanage/genhomedircon: check usepasswd"

PATCH Applied Petr Lautrbach 2 participants 2 messages Dec 18, 2020 – Dec 30, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "libsemanage/genhomedircon: check usepasswd"

This reverts commit ce46daab7cc90a6b9cd3bff9f99cf40ff19c3d9a.

The behavior described in the reverted commit is correct. useradd -Z creates new mapping between new created user and *unconfined_u*, genhomedircon then uses this new mapping, not /etc/passwd entries, for generating new homedir contexts.

---
 libsemanage/src/genhomedircon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/genhomedircon.c +1 -1
index 18d3d99a1254..d08c88de99a7 100644
@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out)
 			s->fallback->home = NULL;
 		}
 	}
-	if ((s->usepasswd) && (user_context_tpl || username_context_tpl)) {
+	if (user_context_tpl || username_context_tpl) {
 		if (write_username_context(s, out, username_context_tpl,
 					   s->fallback) != STATUS_SUCCESS) {
 			retval = STATUS_ERR;
Signature · 1 line
2.29.2
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 7 lines · Petr Lautrbach

This reverts commit ce46daab7cc90a6b9cd3bff9f99cf40ff19c3d9a.

The behavior described in the reverted commit is correct. useradd -Z creates new mapping between new created user and *unconfined_u*, genhomedircon then uses this new mapping, not /etc/passwd entries, for generating new homedir contexts.

I confirm this behavior. On Fedora 33 (with git master of the userspace libraries and "usepasswd=False" in /etc/selinux/semanage.conf):

# useradd -Z unconfined_u -d /tmp test
# matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
# semanage login -l
Login Name           SELinux User         MLS/MCS Range        Service
__default__          unconfined_u         s0-s0:c0.c1023       *
root                 unconfined_u         s0-s0:c0.c1023       *
test                 unconfined_u         s0-s0:c0.c1023       *
# semanage login -d test
# matchpathcon /tmp
/tmp system_u:object_r:tmp_t:s0

I applied the commit (as it was sent quite some time ago). Thanks! Nicolas

Quoted 22 lines
---
 libsemanage/src/genhomedircon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/genhomedircon.c +1 -2
index 18d3d99a1254..d08c88de99a7 100644
@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out)
                        s->fallback->home = NULL;
                }
        }
-       if ((s->usepasswd) && (user_context_tpl || username_context_tpl)) {
+       if (user_context_tpl || username_context_tpl) {
                if (write_username_context(s, out, username_context_tpl,
                                           s->fallback) != STATUS_SUCCESS) {
                        retval = STATUS_ERR;
--

2.29.2