diff mbox

[3/3] python/semanage: Enable listing file_contexts.homedirs

Message ID 20171004153604.5817-3-vmojzis@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Vit Mojzis Oct. 4, 2017, 3:36 p.m. UTC
Include entries from file_contexts.homedirs when listing file contexts
via "semanage fcontext -l"

"semanage fcontext -l" so far ignored content of file_contexts.homedirs
file, which is confusing for users (more specific rules may be ignored in
favor of rules unseen to the user since file_contexts.homedirs has
higher priority than file_contexts).

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1409813

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
 python/semanage/seobject.py | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stephen Smalley Oct. 4, 2017, 8:24 p.m. UTC | #1
On Wed, 2017-10-04 at 17:36 +0200, Vit Mojzis wrote:
> Include entries from file_contexts.homedirs when listing file
> contexts
> via "semanage fcontext -l"
> 
> "semanage fcontext -l" so far ignored content of
> file_contexts.homedirs
> file, which is confusing for users (more specific rules may be
> ignored in
> favor of rules unseen to the user since file_contexts.homedirs has
> higher priority than file_contexts).
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1409813
> 
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>

For all three patches:
Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>

Queued for merging in a couple of days.

> ---
>  python/semanage/seobject.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/python/semanage/seobject.py
> b/python/semanage/seobject.py
> index 70fd192..1385315 100644
> --- a/python/semanage/seobject.py
> +++ b/python/semanage/seobject.py
> @@ -2566,10 +2566,15 @@ class fcontextRecords(semanageRecords):
>              if rc < 0:
>                  raise ValueError(_("Could not list file contexts"))
>  
> +            (rc, fchomedirs) =
> semanage_fcontext_list_homedirs(self.sh)
> +            if rc < 0:
> +                raise ValueError(_("Could not list file contexts for
> home directories"))
> +
>              (rc, fclocal) = semanage_fcontext_list_local(self.sh)
>              if rc < 0:
>                  raise ValueError(_("Could not list local file
> contexts"))
>  
> +            self.flist += fchomedirs
>              self.flist += fclocal
>  
>          ddict = {}
Stephen Smalley Oct. 6, 2017, 3:32 p.m. UTC | #2
On Wed, 2017-10-04 at 17:36 +0200, Vit Mojzis wrote:
> Include entries from file_contexts.homedirs when listing file
> contexts
> via "semanage fcontext -l"
> 
> "semanage fcontext -l" so far ignored content of
> file_contexts.homedirs
> file, which is confusing for users (more specific rules may be
> ignored in
> favor of rules unseen to the user since file_contexts.homedirs has
> higher priority than file_contexts).
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1409813
> 
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>

Thanks, merged all three patches.

> ---
>  python/semanage/seobject.py | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/python/semanage/seobject.py
> b/python/semanage/seobject.py
> index 70fd192..1385315 100644
> --- a/python/semanage/seobject.py
> +++ b/python/semanage/seobject.py
> @@ -2566,10 +2566,15 @@ class fcontextRecords(semanageRecords):
>              if rc < 0:
>                  raise ValueError(_("Could not list file contexts"))
>  
> +            (rc, fchomedirs) =
> semanage_fcontext_list_homedirs(self.sh)
> +            if rc < 0:
> +                raise ValueError(_("Could not list file contexts for
> home directories"))
> +
>              (rc, fclocal) = semanage_fcontext_list_local(self.sh)
>              if rc < 0:
>                  raise ValueError(_("Could not list local file
> contexts"))
>  
> +            self.flist += fchomedirs
>              self.flist += fclocal
>  
>          ddict = {}
diff mbox

Patch

diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 70fd192..1385315 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -2566,10 +2566,15 @@  class fcontextRecords(semanageRecords):
             if rc < 0:
                 raise ValueError(_("Could not list file contexts"))
 
+            (rc, fchomedirs) = semanage_fcontext_list_homedirs(self.sh)
+            if rc < 0:
+                raise ValueError(_("Could not list file contexts for home directories"))
+
             (rc, fclocal) = semanage_fcontext_list_local(self.sh)
             if rc < 0:
                 raise ValueError(_("Could not list local file contexts"))
 
+            self.flist += fchomedirs
             self.flist += fclocal
 
         ddict = {}