libselinux python bindings

libselinux provides an API for SELinux applications to get and set process and file security contexts and to obtain security policy decisions Examples Two simple one line examples which get basic information about SELinux status. $ python3 -c 'import selinux; print(selinux.is_selinux_enabled())' 1 $ python3 -c 'import selinux; print(["permissive", "enforcing …

libselinux provides an API for SELinux applications to get and set process and file security contexts and to obtain security policy decisions

Examples

Two simple one line examples which get basic information about SELinux status.

$ python3 -c 'import selinux; print(selinux.is_selinux_enabled())'
1

$ python3 -c 'import selinux; print(["permissive", "enforcing", "disabled"][selinux.security_getenforce()])'
enforcing

Another example with a check if SELinux was updated.

>>> import selinux
>>> selinux.selinux_status_open(0)
0
>>> selinux.selinux_status_updated()
0
>>> selinux.selinux_status_policyload()
9
>>> selinux.selinux_status_updated()
0
>>> import os
>>> os.system("sudo semodule -B")
0
>>> selinux.selinux_status_updated()
1
>>> selinux.selinux_status_policyload()
10

Receive Updates

ATOM