Bug 1122850 - semanage -o doesn't work in combination with -S mls
Summary: semanage -o doesn't work in combination with -S mls
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: policycoreutils
Version: 6.6
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Petr Lautrbach
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-07-24 08:30 UTC by Michal Trunecka
Modified: 2015-07-22 07:03 UTC (History)
3 users (show)

Fixed In Version: policycoreutils-2.0.83-21.el6
Doc Type: Bug Fix
Doc Text:
The semanage utility previously listed only changes made to the currently used SELinux policy. For example, when the targeted policy was loaded and changes were made to the Multi-Level Security (MLS) policy, the "semanage -S mls -o" command did not list all the changes, even when the changes were applied correctly. This bug has been fixed, and semanage now lists all changes as expected.
Clone Of:
: 1208797 (view as bug list)
Environment:
Last Closed: 2015-07-22 07:03:55 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1360 normal SHIPPED_LIVE policycoreutils bug fix update 2015-07-20 17:59:22 UTC

Description Michal Trunecka 2014-07-24 08:30:29 UTC
Description of problem:
semanage -S mls -o -    seems to show always the changes for the currently loaded policy. Changes made to e.g. mls policy seems to be applied correctly, but are not shown in this listing.

For example, when targeted policy is used:

##### Both listings for targeted and mls are empty (showing just fcontext part):
# semanage -o -
....
fcontext -D
# semanage -S mls -o -
....
fcontext -D

##### I add fcontext rule to mls storage
# semanage fcontext -S mls -a -N -t httpd_sys_content_t /test1

##### ..and it is not shown in niether:
# semanage -o -
....
fcontext -D
# semanage -S mls -o -
....
fcontext -D

##### But it is in the correct config file:
# cat /etc/selinux/mls/modules/active/file_contexts.local 
  # This file is auto-generated by libsemanage
  # Do not edit directly.

  /test1    system_u:object_r:httpd_sys_content_t:s0
##### And not in the targeted:
# cat /etc/selinux/targeted/modules/active/file_contexts.local 

  # This file is auto-generated by libsemanage
  # Do not edit directly.


Version-Release number of selected component (if applicable):
policycoreutils-2.0.83-19.45.el6.x86_64

Comment 1 Daniel Walsh 2014-08-06 22:09:43 UTC
Are you getting AVCs?  Does it work in permissive mode?

Comment 4 Petr Lautrbach 2015-03-09 14:11:45 UTC
I has not been fixed yet.

Comment 5 Miroslav Grepl 2015-03-09 16:28:49 UTC
Should work with

--- /usr/sbin/semanage.old	2015-03-09 14:53:54.707000662 +0100
+++ /usr/sbin/semanage	2015-03-09 16:12:56.290999834 +0100
@@ -560,7 +560,7 @@
                              sys.stdout = open(output, 'w')
                       for i in manageditems:
                              print "%s -D" % i
-                             process_args([i, "-E"])
+                             process_args([i, "-E",("-S%s") % store ])
                       sys.exit(0)
 
                if input != None:

Comment 6 Petr Lautrbach 2015-03-10 15:16:36 UTC
The proposed patch wouldn't work when semanage is called without -S. This one should fix it:

--- /usr/sbin/semanage.orig     2015-03-10 14:24:54.577229283 +0100
+++ /usr/sbin/semanage  2015-03-10 16:14:20.247141124 +0100
@@ -560,7 +560,10 @@ Object-specific Options (see above):
                              sys.stdout = open(output, 'w')
                       for i in manageditems:
                              print "%s -D" % i
-                             process_args([i, "-E"])
+                             if store == "":
+                                    process_args([i, "-E"])
+                             else:
+                                    process_args([i, "-E", "-S", store])
                       sys.exit(0)
 
                if input != None:

Comment 7 Miroslav Grepl 2015-03-10 16:25:04 UTC
Yeap, thanks.

Comment 10 errata-xmlrpc 2015-07-22 07:03:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1360.html


Note You need to log in before you can comment on or make changes to this bug.