Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2231112

Summary: semanage port configuration is not preserved during Leapp upgrade
Product: Red Hat Enterprise Linux 7 Reporter: Bram Mertens <bmertens>
Component: leappAssignee: Leapp Notifications Bot <leapp-notifications-bot>
Status: CLOSED MIGRATED QA Contact: upgrades-and-conversions
Severity: unspecified Docs Contact: Miriam Portman <mportman>
Priority: unspecified    
Version: 7.9CC: upgrades-and-conversions, vmojzis
Target Milestone: rcKeywords: MigratedToJIRA
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-12 12:24:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bram Mertens 2023-08-10 15:35:07 UTC
Description of problem:
After upgrading a RHEL 7 system to RHEL8 the semanage port configuration is not fully preserved.
Customer has configured type `http_cache_port_t` to port 8000.
Leap fails to set this configuration because it conflicts with the existing configuration for port 8000 as type `soundd_port_t`.

Version-Release number of selected component (if applicable):
policycoreutils-python-utils-2.9-24.el8.noarch
leapp-0.15.1-1.el7_9.noarch

How reproducible:
always

Steps to Reproduce:
1. spin up a rhel7 image (I used kcli from the rhel7 image from the portal downloads)

~~~
# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.9 (Maipo)
~~~

2. check default SELinux port for http_cache and port 8000:

~~~
# semanage port -l |grep http_cache
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
# semanage port -l |grep 8000
soundd_port_t                  tcp      8000, 9433, 16001
~~~

3. Add/modify port 8000

~~~
# semanage port -a -t http_cache_port_t -p tcp 8000
ValueError: Port tcp/8000 already defined
# semanage port -l |grep http_cache
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
# semanage port -l |grep 8000
soundd_port_t                  tcp      8000, 9433, 16001
# semanage port -m -t http_cache_port_t -p tcp 8000
# semanage port -l |grep http_cache
http_cache_port_t              tcp      8000, 8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
# semanage port -l |grep 8000
http_cache_port_t              tcp      8000, 8080, 8118, 8123, 10001-10010
soundd_port_t                  tcp      8000, 9433, 16001
~~~

4. reboot and verify

~~~
# semanage port -l |grep http_cache
http_cache_port_t              tcp      8000, 8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
# semanage port -l |grep 8000
http_cache_port_t              tcp      8000, 8080, 8118, 8123, 10001-10010
soundd_port_t                  tcp      8000, 9433, 16001
~~~

5. perform the leapp upgrade

~~~
# subscription-manager repos --enable rhel-7-server-rpms
# subscription-manager repos --enable rhel-7-server-extras-rpms
# subscription-manager release --unset
# yum versionlock clear
# yum update
# reboot
# yum install leapp-upgrade
# leapp answer --section remove_pam_pkcs11_module_check.confirm=True
# rmmod floppy
# rmmod pata_acpi
# leapp upgrade --debug
# reboot
~~~

Actual results:
The selinux port config is not retained:

~~~
# semanage port -l |grep 8000
soundd_port_t                  tcp      8000, 9433, 16001
# semanage port -l |grep http_cache
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
~~~


Expected results:
SELinux configuration to be retained after Leapp upgrade

Additional info:
The log `/var/log/leapp/leapp-upgrade.log` shows that Leapp attempts to set the type but fails because a definition already exists for port 8000:
~~~
2023-08-10 10:26:53.522 INFO     PID: 1268 leapp.workflow.Applications.selinuxapplycustom: Importing the following SELinux customizations collected by "semanage export":
2023-08-10 10:26:55.156 WARNING  PID: 1268 leapp.workflow.Applications.selinuxapplycustom: Error applying "semanage port -a -t http_cache_port_t -r 's0' -p tcp 8000": ValueError: Port tcp/8000 already defined
~~~

This is identical to the error seen in step 3. above.

The resulting configuration may not be valid for SELinux and may need to be adressed in policycore-utils but Leapp needs to handle or at least warn about this issue.

Comment 5 RHEL Program Management 2023-09-12 11:55:41 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 6 RHEL Program Management 2023-09-12 12:24:14 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.