fedora-selinux / selinux

Fedora SELinux Userspace
Other
21 stars 17 forks source link

python: replace aliases with corresponding type names #56

Closed vmojzis closed 6 years ago

vmojzis commented 6 years ago

Aliases are not used in the selinux database. When user enters a type alias as a parameter it should be converted to the corresponding type in order to be processed correctly further in the userspace logic.

Fixes e.g.:

#sepolicy transition -s phpfpm_t / where phpfpm_t is a type alias of httpd_t /

Traceback (most recent call last): File "/usr/bin/sepolicy", line 691, in args.func(args) File "/usr/bin/sepolicy", line 458, in transition mytrans = setrans(args.source, args.target) File "/usr/lib/python3.6/site-packages/sepolicy/transition.py", line 48, in init self._process(self.source) File "/usr/lib/python3.6/site-packages/sepolicy/transition.py", line 54, in _process trans = _get_trans(source) File "/usr/lib/python3.6/site-packages/sepolicy/transition.py", line 36, in _get_trans src_list = [src] + list(filter(lambda x: x['name'] == src, sepolicy.get_all_types_info()))[0]['attributes'] IndexError: list index out of range

(cherry picked from SELinuxProject commit a3be73bea4fdffec515653229c20279b2827e424)