Hello<br><br>I tried to integrate an SELinux patch with upstart but it didn't work for various reasons, so here's the next best thing, initializing it with a pre-init program. This is also a tutorial for how to compile the program and make it run with upstart, after that, you're on your own =).
<br><br>sudo su<br><br>#0.) Get the required tools.<br>$ apt-get -y install libselinux1 libselinux1-dev setools selinux-basics selinux-utils selinux-policy-refpolicy-targeted build-essential linux-headers-$(uname -r) m4<br>
<br>#1.) <br>$ cd /usr/src ; apt-get -y install selinux-policy-refpolicy-src; tar -zxvf selinux-policy-refpolicy-src.tar.gz ; cd selinux-policy-refpolicy-src<br><br>#2.)<br>Edit these values in the build.conf file:<br>OUTPUT_POLICY = 21
<br>MONOLITHIC = y<br><br>#3.)<br>$ make clean<br>$ make<br>$ cp policy.21 /etc/selinux/refpolicy-targeted/policy/<br><br>#4.)<br>paste this into a file named pre-init.cpp:<br>#include <iostream><br>#include <unistd.h
><br>#include <selinux/selinux.h><br>using namespace std;<br><br>int main(int argc, char *argv[]) {<br> int enforce = 0;<br><br> if(getenv("SELINUX_INIT") == NULL) {<br> putenv("SELINUX_INIT=YES");
<br> if(selinux_init_load_policy(&enforce) == 0) {<br> cout << "Policy loaded..." << endl;<br> execv("/sbin/init", argv);<br>
} else {<br> if(enforce > 0) {<br> cout << "SELinux in enforcing mode but load_policy failed" << endl;<br> exit(1);
<br> }<br> }<br> }<br><br> return 0;<br>}<br><br>#5.)<br>$ g++ pre-init.cpp -l selinux -l sepol -o pre-init<br>$ cp pre-init /sbin/ ; chown root:root /sbin/pre-init<br><br>
#6.)<br>Reboot and at grub, uset his kernel parameter:<br>init=/sbin/pre-init<br><br>------------------------------------------------<br><br># the selinux-basics service, which relabels the filesystem at boot when you do 'touch /.autorelabel' is also buggy (/sbin/fixfiles at line 58+).
<br><br># Also I'd recommend getting (and using) the latest refpolicy from tresys at:<br><a href="http://oss.tresys.com/projects/refpolicy">http://oss.tresys.com/projects/refpolicy</a><br>and the latest selinux tools.
<br><br>GL<br><br>