RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 974158 - semanage wrongly modifies port types
Summary: semanage wrongly modifies port types
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: policycoreutils
Version: 6.4
Hardware: All
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 974163
TreeView+ depends on / blocked
 
Reported: 2013-06-13 14:29 UTC by Dalibor Pospíšil
Modified: 2015-03-03 14:14 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 974163 (view as bug list)
Environment:
Last Closed: 2015-03-03 14:14:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Dalibor Pospíšil 2013-06-13 14:29:31 UTC
Description of problem:
semanage allow to modify default port type while keeps the assignment to the old type. This leads to situation where one port has two types. Also semanage -o - generates wrong outut which cannot be applied. Moreover after modifying the the port and modyfying it back to the original type I can delete the type for the first time. The second time I get '... is defined in policy, cannot be deleted' message.

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

How reproducible:
100%

Steps to Reproduce:
[root@rhel6 ~]# semanage port -m -t http_port_t -p tcp 8080
[root@rhel6 ~]# semanage port -l | grep 8080
http_cache_port_t              tcp      3128, 8080, 8118, 8123, 10001-10010
http_port_t                    tcp      8080, 80, 443, 488, 8008, 8009, 8443
[root@rhel6 ~]# semanage -o - | grep 8080
port -a -t http_port_t -p tcp 8080
[root@rhel6 ~]# semanage port -m -t http_cache_port_t -p tcp 8080
[root@rhel6 ~]# semanage port -l | grep 8080
http_cache_port_t              tcp      8080, 3128, 8080, 8118, 8123, 10001-10010
[root@rhel6 ~]# semanage -o - | grep 8080
port -a -t http_cache_port_t -p tcp 8080
[root@rhel6 ~]# semanage port -d -t http_cache_port_t -p tcp 8080
[root@rhel6 ~]# semanage port -d -t http_cache_port_t -p tcp 8080
/usr/sbin/semanage: Port tcp/8080 is defined in policy, cannot be deleted

I would expect that semanage is able to remove default rule as local customization and then add new rule. So the 'semanage port -m' would be internally translated into 'semanage port -d' and 'semanage port -a' sequence.

Comment 2 RHEL Program Management 2013-10-13 23:28:45 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 3 Daniel Walsh 2013-10-15 17:03:30 UTC
Well in actuality the label is the second label, the tooling is showing it incorrectly, I believe as far as the kernel is concerned the second label wins.

Comment 4 Stephen Smalley 2013-10-15 17:14:34 UTC
First matching entry in the port contexts list wins as far as the kernel is concerned.  But I think semanage and friends are not representing it that way and thus the presented order (a hash walk?) may be arbitrary and unrelated to what is used.  It should just prevent redundant definitions from being added (removing/replacing the old if necessary)

Comment 5 Miroslav Grepl 2014-02-04 13:21:08 UTC
(In reply to Dalibor Pospíšil from comment #0)
> Description of problem:
> semanage allow to modify default port type while keeps the assignment to the
> old type. This leads to situation where one port has two types. Also
> semanage -o - generates wrong outut which cannot be applied. Moreover after
> modifying the the port and modyfying it back to the original type I can
> delete the type for the first time. The second time I get '... is defined in
> policy, cannot be deleted' message.
> 
> Version-Release number of selected component (if applicable):
> policycoreutils-python-2.0.83-19.30.el6
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> [root@rhel6 ~]# semanage port -m -t http_port_t -p tcp 8080
> [root@rhel6 ~]# semanage port -l | grep 8080
> http_cache_port_t              tcp      3128, 8080, 8118, 8123, 10001-10010
> http_port_t                    tcp      8080, 80, 443, 488, 8008, 8009, 8443
> [root@rhel6 ~]# semanage -o - | grep 8080
> port -a -t http_port_t -p tcp 8080
> [root@rhel6 ~]# semanage port -m -t http_cache_port_t -p tcp 8080
> [root@rhel6 ~]# semanage port -l | grep 8080
> http_cache_port_t              tcp      8080, 3128, 8080, 8118, 8123,
> 10001-10010
> [root@rhel6 ~]# semanage -o - | grep 8080
> port -a -t http_cache_port_t -p tcp 8080
> [root@rhel6 ~]# semanage port -d -t http_cache_port_t -p tcp 8080
> [root@rhel6 ~]# semanage port -d -t http_cache_port_t -p tcp 8080
> /usr/sbin/semanage: Port tcp/8080 is defined in policy, cannot be deleted
> 
> I would expect that semanage is able to remove default rule as local
> customization and then add new rule. So the 'semanage port -m' would be
> internally translated into 'semanage port -d' and 'semanage port -a'
> sequence.

We don't want to remove the default port declaration. The local modification is used if you define it.

So it looks it is a bug in "semanage-port -l".

Comment 8 Miroslav Grepl 2015-03-03 14:14:08 UTC
I believe we can close it as WONTFIX in RHEL6 per Comment #5.


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