Linux – how to enable selinux in kernel

amazon-web-serviceslinuxselinuxsendmail

I am working with the Linux -64 AMI on AWS. I am trying to get my mail server running on the box.

In an attempt to turn on SELinux I did

Edited /boot/grub/grub.conf and added selinux=1 to the end of the kernel statement

Then touch /.autorelabel

And then rebooted.

Upon reboot I web browse to my website and I get a server access error saying I can not access /

Of course I do not want to be at the root. What has gone wrong here?

How can I get SELinux enabled so I can run a mail server?

Best Answer

SELinux is very restrictive by default, depending on distribution. You will have to explicitly enable access, depending on your configuration.

In the case of Red Hat, with SELinux enabled, /var/www is access, but if your sites are on /home, it won't be. You have to enable it with:

setsebool -P httpd_enable_homedirs on

You can pull the list of policies you can enable with:

getsebool -a

It is a lot, so you will have to grep for the service you want to enable access. Again, in the case of Red Hat, you only need to enable spooling for mail, so it will work by default. However, it may be different with your distribution. That and your web directory may be in a completely different location.

So you need go the selinux directory and look at the policies, roles and files contexts, which may be available at:

/etc/selinux

And apply the appropriate labels to the files.

I suggest you look at this as a base starting point:

http://selinuxproject.org/page/Main_Page

If you want to keep running SELinux. Otherwise, either use a different distribution that makes it easy for your to manage SELinux or put it in permissive mode for now and use some other mechanism to secure your server - at least until you get the hang of SELinux.