libsemanage/genhomedircon: check usepasswd in add_user
PATCH 1/1 libsemanage/genhomedircon: check usepasswd in add_user
Only add user homedir context entry when usepasswd = True
Resolves:
\#cat /etc/selinux/semanage.conf | grep usepasswd
usepasswd=False
\#useradd -Z unconfined_u -d /tmp test
\#matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
--- libsemanage/src/genhomedircon.c | 3 +++ 1 file changed, 3 insertions(+)
libsemanage/src/genhomedircon.c +3 -0
@@ -966,6 +966,9 @@ static int add_user(genhomedircon_settings_t * s, } } +if (!(s->usepasswd)) +return STATUS_SUCCESS ; +int retval =STATUS_ERR ;char *rbuf =NULL ;
Signature · 1 line
2.25.4
Quoted 8 lines · Vit Mojzis
Only add user homedir context entry when usepasswd = True
Resolves:
\#cat/etc/selinux/semanage.conf| grep usepasswd
usepasswd=False
\#useradd -Zunconfined_u-d /tmp test
\#matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
It should be enough to indent lines with few spaces, e.g.
Resolves:
# grep usepasswd /etc/selinux/semanage.conf
usepasswd=False
# useradd -Z unconfined_u -d /tmp test
# matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0Also please provide Signed-off-by: see
https://github.com/SELinuxProject/selinux/blob/master/CONTRIBUTING.md
Quoted 21 lines
--- libsemanage/src/genhomedircon.c | 3 +++ 1 file changed, 3 insertions(+)libsemanage/src/genhomedircon.c +3
-0@@ -966,6 +966,9 @@ static int add_user(genhomedircon_settings_t * s, } } +if (!(s->usepasswd)) +return STATUS_SUCCESS ; +int retval =STATUS_ERR ;char *rbuf =NULL ;Signature · 1 line
2.25.4
PATCH 1/1 libsemanage/genhomedircon: check usepasswd in add_user
Only add user homedir context entry when usepasswd = True
Resolves:
#cat /etc/selinux/semanage.conf | grep usepasswd usepasswd=False
#useradd -Z unconfined_u -d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
--- libsemanage/src/genhomedircon.c | 3 +++ 1 file changed, 3 insertions(+)
libsemanage/src/genhomedircon.c +3 -0
@@ -966,6 +966,9 @@ static int add_user(genhomedircon_settings_t * s, } } +if (!(s->usepasswd)) +return STATUS_SUCCESS ; +int retval =STATUS_ERR ;char *rbuf =NULL ;
Signature · 1 line
2.25.4
Quoted 31 lines · Vit Mojzis
Only add user homedir context entry when usepasswd = True
Resolves:
#cat/etc/selinux/semanage.conf| grep usepasswd usepasswd=False
#useradd -Zunconfined_u-d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0Signed-off-by Vit Mojzis <[email protected]>--- libsemanage/src/genhomedircon.c | 3 +++ 1 file changed, 3 insertions(+)libsemanage/src/genhomedircon.c +3
-0@@ -966,6 +966,9 @@ static int add_user(genhomedircon_settings_t * s, } } +if (!(s->usepasswd)) +return STATUS_SUCCESS ; +int retval =STATUS_ERR ;char *rbuf =NULL ;Signature · 1 line
2.25.4
add_user() seems to be too deep. Would it make sense to (s->usepasswd) in write_context_file() as part of a condition on line 1338:
if (user_context_tpl || username_context_tpl) {?
PATCH 1/1 libsemanage/genhomedircon: check usepasswd
Only add user homedir contexts when usepasswd = True
Resolves:
\#cat /etc/selinux/semanage.conf | grep usepasswd
usepasswd=False
\#useradd -Z unconfined_u -d /tmp test
\#matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
--- libsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/genhomedircon.c +1 -1
@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home =NULL ; } } -if (user_context_tpl || username_context_tpl) { +if (!(s->usepasswd) && (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.26.2
PATCH 1/1 libsemanage/genhomedircon: check usepasswd
In reply to Petr LautrbachOnly add user homedir contexts when usepasswd = True
Resolves:
#cat /etc/selinux/semanage.conf | grep usepasswd usepasswd=False
#useradd -Z unconfined_u -d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
--- libsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/genhomedircon.c +1 -1
@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home =NULL ; } } -if (user_context_tpl || username_context_tpl) { +if (!(s->usepasswd) && (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.26.2
Re: [PATCH] libsemanage/genhomedircon: check usepasswd
Quoted 19 lines · Vit Mojzis
Only add user homedir contexts when usepasswd = True
Resolves:
#cat/etc/selinux/semanage.conf| grep usepasswd usepasswd=False
#useradd -Zunconfined_u-d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0Signed-off-by Vit Mojzis <[email protected]>--- libsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsemanage/src/genhomedircon.c +0
-0
libsemanage/src/genhomedircon.c static int write_context_file(genhomedircon_settings_t * s, FILE * out) · line 1335
Quoted 5 lines
libsemanage/src/genhomedircon.c +1
-1@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home =NULL ; } } -if (user_context_tpl || username_context_tpl) { +if (!(s->usepasswd) && (user_context_tpl || username_context_tpl)) {
I guess this condition is reversed - we want to write user contexts when usepasswd is True
Quoted 6 lines
libsemanage/src/genhomedircon.c +0
-0if (write_username_context (s, out, username_context_tpl, s->fallback) !=STATUS_SUCCESS ) { retval =STATUS_ERR ;Signature · 1 line
2.26.2
PATCH v2 1/1 libsemanage/genhomedircon: check usepasswd
Only add user homedir contexts when usepasswd = True
Resolves:
#cat /etc/selinux/semanage.conf | grep usepasswd usepasswd=False
#useradd -Z unconfined_u -d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0
---
v2 - invert condition as suggested by plautrba
libsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsemanage/src/genhomedircon.c +1 -1
@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home =NULL ; } } -if (user_context_tpl || username_context_tpl) { +if ((s->usepasswd) && (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.26.2
Re: [PATCH v2] libsemanage/genhomedircon: check usepasswd
Quoted 10 lines · Vit Mojzis
Only add user homedir contexts when usepasswd = True
Resolves:
#cat/etc/selinux/semanage.conf| grep usepasswd usepasswd=False
#useradd -Zunconfined_u-d /tmp test #matchpathcon /tmp
/tmp unconfined_u:object_r:user_home_dir_t:s0Signed-off-by Vit Mojzis <[email protected]>
Merged with slightly changed commit message, thanks!
Quoted 22 lines
---
v2 - invert condition as suggested by plautrbalibsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsemanage/src/genhomedircon.c +1
-1@@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home =NULL ; } } -if (user_context_tpl || username_context_tpl) { +if ((s->usepasswd) && (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.26.2