* Configuring libsemanage to invoke a policy checker
@ 2009-09-29 19:52 Stephen Smalley
2009-09-29 20:31 ` Daniel J Walsh
2009-11-20 17:01 ` Joshua Brindle
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Smalley @ 2009-09-29 19:52 UTC (permalink / raw)
To: selinux
This came up as a question at the SELinux summit, so I thought I'd also
post the answer on the list since it is a largely undocumented feature.
If you want libsemanage to invoke a program to check a policy for some
property before allowing it to be installed and loaded, then you can
configure libsemanage as follows.
Add the following lines to your /etc/selinux/semanage.conf file:
[verify kernel]
path = /usr/bin/mypolicychecker
args = $@
[end]
Then create /usr/bin/mypolicychecker, e.g.:
#!/bin/sh
ls -l $1
exit 0
chmod +x /usr/bin/mypolicychecker
Subsequent semodule or semanage commands will trigger its execution,
passing it the path to the kernel policy file in the sandbox before
installing it. If it returns non-zero, the transaction will abort and
roll back.
Obviously you would replace mypolicychecker with an actual program that
applies some set of checks to the policy and exits with an appropriate
error status based on whether the checks passed.
There is also a variant for running a policy checking program on each
individual module ([verify module]) but I'm not sure how useful that
would be.
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Configuring libsemanage to invoke a policy checker
2009-09-29 19:52 Configuring libsemanage to invoke a policy checker Stephen Smalley
@ 2009-09-29 20:31 ` Daniel J Walsh
2009-11-20 17:01 ` Joshua Brindle
1 sibling, 0 replies; 3+ messages in thread
From: Daniel J Walsh @ 2009-09-29 20:31 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux
On 09/29/2009 03:52 PM, Stephen Smalley wrote:
> This came up as a question at the SELinux summit, so I thought I'd also
> post the answer on the list since it is a largely undocumented feature.
> If you want libsemanage to invoke a program to check a policy for some
> property before allowing it to be installed and loaded, then you can
> configure libsemanage as follows.
>
> Add the following lines to your /etc/selinux/semanage.conf file:
> [verify kernel]
> path = /usr/bin/mypolicychecker
> args = $@
> [end]
>
> Then create /usr/bin/mypolicychecker, e.g.:
> #!/bin/sh
> ls -l $1
> exit 0
>
> chmod +x /usr/bin/mypolicychecker
>
> Subsequent semodule or semanage commands will trigger its execution,
> passing it the path to the kernel policy file in the sandbox before
> installing it. If it returns non-zero, the transaction will abort and
> roll back.
>
> Obviously you would replace mypolicychecker with an actual program that
> applies some set of checks to the policy and exits with an appropriate
> error status based on whether the checks passed.
>
> There is also a variant for running a policy checking program on each
> individual module ([verify module]) but I'm not sure how useful that
> would be.
>
So a better example might be you want to guarantee that no one can write to a shadow_t
#!/bin/sh
domain_ctr = `sesearch --allow -t shadow_t -c file -p write $1 | wc -l`
if [ $domain_ctr != 10 ]; then
exit 1
fi
exit 0
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Configuring libsemanage to invoke a policy checker
2009-09-29 19:52 Configuring libsemanage to invoke a policy checker Stephen Smalley
2009-09-29 20:31 ` Daniel J Walsh
@ 2009-11-20 17:01 ` Joshua Brindle
1 sibling, 0 replies; 3+ messages in thread
From: Joshua Brindle @ 2009-11-20 17:01 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux
Stephen Smalley wrote:
> This came up as a question at the SELinux summit, so I thought I'd also
> post the answer on the list since it is a largely undocumented feature.
> If you want libsemanage to invoke a program to check a policy for some
> property before allowing it to be installed and loaded, then you can
> configure libsemanage as follows.
>
> Add the following lines to your /etc/selinux/semanage.conf file:
> [verify kernel]
> path = /usr/bin/mypolicychecker
> args = $@
> [end]
>
> Then create /usr/bin/mypolicychecker, e.g.:
> #!/bin/sh
> ls -l $1
> exit 0
>
> chmod +x /usr/bin/mypolicychecker
>
> Subsequent semodule or semanage commands will trigger its execution,
> passing it the path to the kernel policy file in the sandbox before
> installing it. If it returns non-zero, the transaction will abort and
> roll back.
>
> Obviously you would replace mypolicychecker with an actual program that
> applies some set of checks to the policy and exits with an appropriate
> error status based on whether the checks passed.
>
> There is also a variant for running a policy checking program on each
> individual module ([verify module]) but I'm not sure how useful that
> would be.
>
In case anyone here is interested I've added a document page to the
selinuxproject wiki with information about the validation hook and with
an example validator that uses sesearch to ensure no rules allowing
user_t to access shadow_t are added to the policy. The URL is
<http://selinuxproject.org/page/PolicyValidate>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-20 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-29 19:52 Configuring libsemanage to invoke a policy checker Stephen Smalley
2009-09-29 20:31 ` Daniel J Walsh
2009-11-20 17:01 ` Joshua Brindle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.