A usual step in creating OS file system trees is to apply the correct SELinux labels for all files and directories. This is done by the org.osbuild.selinux stage, which internally uses the setfiles command in order to do so. The SELiunx policy to be used for this operation is the one of the newly created system, not the host one. It therefore can contain labels that are not known on the host. The kernel will prevent setting invalid, i.e. unknown, labels unless the caller has the CAP_MAC_ADMIN capability. By default, setfiles is executed in the setfiles_t domain, where it lacks that capability. Therefore a custom osbuild SELinux policy was created, with a special transition rule that will execute setfiles in the setfiles_mac_t domain. All stages, sources and assemblers as well as the main binary are label with the new osbuild_exec_t label. Additionally, allow a transition from osbuild_t to install_t by using `anaconda_domtrans_install`, so that ostree and rpm-ostree, which are labeled as install_exec_t, can transition to the install_t domain when called form osbuild. Update the spec file to build the policy and include it in a new osbuild-selinux sub-package.
95 lines
1.8 KiB
Text
95 lines
1.8 KiB
Text
|
|
## <summary>policy for osbuild</summary>
|
|
|
|
########################################
|
|
## <summary>
|
|
## Execute osbuild_exec_t in the osbuild domain.
|
|
## </summary>
|
|
## <param name="domain">
|
|
## <summary>
|
|
## Domain allowed to transition.
|
|
## </summary>
|
|
## </param>
|
|
#
|
|
interface(`osbuild_domtrans',`
|
|
gen_require(`
|
|
type osbuild_t, osbuild_exec_t;
|
|
')
|
|
|
|
corecmd_search_bin($1)
|
|
domtrans_pattern($1, osbuild_exec_t, osbuild_t)
|
|
')
|
|
|
|
######################################
|
|
## <summary>
|
|
## Execute osbuild in the caller domain.
|
|
## </summary>
|
|
## <param name="domain">
|
|
## <summary>
|
|
## Domain allowed access.
|
|
## </summary>
|
|
## </param>
|
|
#
|
|
interface(`osbuild_exec',`
|
|
gen_require(`
|
|
type osbuild_exec_t;
|
|
')
|
|
|
|
corecmd_search_bin($1)
|
|
can_exec($1, osbuild_exec_t)
|
|
')
|
|
|
|
########################################
|
|
## <summary>
|
|
## Execute osbuild in the osbuild domain, and
|
|
## allow the specified role the osbuild domain.
|
|
## </summary>
|
|
## <param name="domain">
|
|
## <summary>
|
|
## Domain allowed to transition
|
|
## </summary>
|
|
## </param>
|
|
## <param name="role">
|
|
## <summary>
|
|
## The role to be allowed the osbuild domain.
|
|
## </summary>
|
|
## </param>
|
|
#
|
|
interface(`osbuild_run',`
|
|
gen_require(`
|
|
type osbuild_t;
|
|
attribute_role osbuild_roles;
|
|
')
|
|
|
|
osbuild_domtrans($1)
|
|
roleattribute $2 osbuild_roles;
|
|
')
|
|
|
|
########################################
|
|
## <summary>
|
|
## Role access for osbuild
|
|
## </summary>
|
|
## <param name="role">
|
|
## <summary>
|
|
## Role allowed access
|
|
## </summary>
|
|
## </param>
|
|
## <param name="domain">
|
|
## <summary>
|
|
## User domain for the role
|
|
## </summary>
|
|
## </param>
|
|
#
|
|
interface(`osbuild_role',`
|
|
gen_require(`
|
|
type osbuild_t;
|
|
attribute_role osbuild_roles;
|
|
')
|
|
|
|
roleattribute $1 osbuild_roles;
|
|
|
|
osbuild_domtrans($2)
|
|
|
|
ps_process_pattern($2, osbuild_t)
|
|
allow $2 osbuild_t:process { signull signal sigkill };
|
|
')
|