Redhat – SELinux: How to add a new security context

redhatselinux

I'm new to SELinux and am trying to add a new security context (label) to test denial. To do this, I try changing a filew to a new context:

chcon -t new_t test

But it fails with "Invalid argument". How do I add the new type "new_t"?

Best Answer

An example for how to create a new type is at http://fedoraproject.org/wiki/PackagingDrafts/SELinux#Creating_new_types

Once you have build the module (make -f /usr/share/selinux/devel/Makefile) and inserted it into SELinux (semodule -i foobar.pp) then you can chcon -t foobar_t test.