Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semanage: list all ports even if not attributed with port_type #394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/semanage/semanage-bash-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ __get_all_types () {
seinfo -t 2> /dev/null | tail -n +3
}
__get_all_port_types () {
seinfo -aport_type -x 2>/dev/null | tail -n +2
sepolicy network -l
}
__get_all_domains () {
seinfo -adomain -x 2>/dev/null | tail -n +2
Expand Down
2 changes: 1 addition & 1 deletion python/semanage/seobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ class portRecords(semanageRecords):
def __init__(self, args = None):
semanageRecords.__init__(self, args)
try:
self.valid_types = list(list(sepolicy.info(sepolicy.ATTRIBUTE, "port_type"))[0]["types"])
self.valid_types = [x["type"] for x in [*sepolicy.info(sepolicy.ATTRIBUTE, "port_type"), *sepolicy.info(sepolicy.PORT)]]
except RuntimeError:
pass

Expand Down
2 changes: 1 addition & 1 deletion python/sepolicy/sepolicy-bash-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ __get_all_classes () {
seinfo -c 2> /dev/null | tail -n +2
}
__get_all_port_types () {
seinfo -aport_type -x 2> /dev/null | tail -n +2
sepolicy network -l
}
__get_all_domain_types () {
seinfo -adomain -x 2> /dev/null | tail -n +2
Expand Down
4 changes: 2 additions & 2 deletions python/sepolicy/sepolicy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,8 @@ def get_all_port_types():
global port_types
if port_types:
return port_types
port_types = list(sorted(info(ATTRIBUTE, "port_type"))[0]["types"])
return port_types
port_types = set(next(info(ATTRIBUTE, "port_type"))["types"] + [x["type"] for x in info(PORT)])
return sorted(port_types)


def get_all_bools():
Expand Down