Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
selinux [2012/10/12 00:03] 188.143.232.12 fGCLktjBf |
selinux [2012/10/15 11:58] (current) zagi old revision restored |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Yeah that's what I'm tlaknig about baby--nice work! | + | ====== SELinux ====== |
+ | |||
+ | more @ http:// | ||
+ | |||
+ | ===== History ===== | ||
+ | |||
+ | |||
+ | When SELinux was first developed, the goal was to confine as many system processes | ||
+ | |||
+ | Logged-in user’s processes were unconfined in targeted policy. A logged-in user’s process is started by login programs (like login, sshd, or gdm) when the user provides authentication. | ||
+ | |||
+ | In Red Hat Enterprise Linux 5, we still did not confine the user. Strict policy was still provided, but few people used the confined user components. Multi Level Security (MLS) policy–which was developed for Red Hat Enteprise Linux 5–attains the highest level of security possible for a main line operating system used in military environments. | ||
+ | |||
+ | The MLS development forced us to concentrate more on confining users, and we realized that we could take advantage of this confinement within targeted policy. | ||
+ | |||
+ | Customers/ | ||
+ | |||
+ | The two types of logged-in users we had developed for strict and MLS policy were user_t and staff_t. | ||
+ | |||
+ | staff_t was able to transition to sysadm_t, which was sort of a poor mans unconfined process. But trying to build a confined user policy out of either of these user types was impossible, since you needed to take lots of privileges away. | ||
+ | |||
+ | I reexamined the policy and decided it was necessary to create a least privileged user, a user that could login to the system with no access other than to read/write his home directory and use /tmp. This user would not be allowed to access the network, or run any setuid applications. | ||
+ | |||
+ | Customers also requested that the user not be able to execute files in his home directory. | ||
+ | |||
+ | ===== The guest_t and xguest_t user types ===== | ||
+ | |||
+ | |||
+ | In Fedora 8, we introduced the guest_t and xguest_t user types. The guest_t user has only the privileges necessary to login to a system via a terminal (Login, sshd, rshd, rlogind, and telnet). | ||
+ | |||
+ | Once we had created these users, we began to find more possible uses for them. For example, at Red Hat, I have ssh access to people.redhat.com and people.fedoraproject.org. | ||
+ | |||
+ | http:// | ||
+ | |||
+ | Files at this site are actually just files in my home/ | ||
+ | |||
+ | xguest_t also comes in handy for use on desktop machines. | ||
+ | |||
+ | Other users have suggested using xguest_t for running games and other untrusted software | ||
+ | |||
+ | This “xguest” user can log in to your system from the console without a password when SELinux is in enforcing mode. The xguest rpm also sets up pam_namespace to create temporary home directories and /tmp directories, | ||
+ | |||
+ | You can try out xguest by executing: | ||
+ | |||
+ | |||
+ | # yum install xguest | ||
+ | |||
+ | |||
+ | ===== The user_t SELinux user type ===== | ||
+ | |||
+ | |||
+ | For Fedora 9, we combined the strict policy with the targeted policy. | ||
+ | |||
+ | The user_t SELinux user is the standard SELinux user. At Red Hat, we have a distribution of Red Hat Enterprise Linux that is given to all non-engineers by the IT department. Sales people, support, administration, | ||
+ | |||
+ | Accounts like these should be set up to use the user_u SELinux user. user_u is a complete login user account, unlike xguest, and it has full networking so that the user can connect to any network port. It does not have the ability to run setuid applications without a transition. | ||
+ | |||
+ | setuid applications are executables that have a special flag set on them. This flag tells the kernel to run the application with the identity of the owner of the application rather then the identity of the person executing the program. | ||
+ | |||
+ | Since the users of this machine have no reason to ever become root, they do not have the ability to run su, sudo, userhelper, or any other application that requires setuid. | ||
+ | |||
+ | If you have a setuid application that you want the user to be able to run, you can write policy to allow the user_u account to transition to a different domain to execute the code. For example, xlock uses pam to verify the users password. pam executes / | ||
+ | |||
+ | Like xguest , the user_u account can be set to disallow execution of programs in the home directory or /tmp. | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | If you want to set up your system to try out the user account, you can execute the following command as root: | ||
+ | |||
+ | |||
+ | # semanage login -m -s user_u USERNAME | ||
+ | |||
+ | |||
+ | or | ||
+ | |||
+ | |||
+ | # usermod -Z user_u USERNAME | ||
+ | |||
+ | |||
+ | If you want to add a user with user_u, you can execute: | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | If you want all users on your system to default to user_u you would execute: | ||
+ | |||
+ | |||
+ | # semanage login -m -s user_u __default__ | ||
+ | |||
+ | |||
+ | ===== The staff_t SELinux user type ===== | ||
+ | |||
+ | |||
+ | The staff_t user is for users who need to do some system administration, | ||
+ | |||
+ | I actually have a transition defined between the staff_t to unconfined_t. | ||
+ | |||
+ | My sudoers file has the following line in it: | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | To only allow this user to administer apache server I could use: | ||
+ | |||
+ | |||
+ | dwalsh ALL=(ALL) TYPE=webadm_t ROLE=webadm_r ALL | ||
+ | |||
+ | |||
+ | To try out the staff account, execute the following command as root: | ||
+ | |||
+ | |||
+ | # semanage login -a -s staff_u -r s0-s0: | ||
+ | |||
+ | |||
+ | or | ||
+ | |||
+ | |||
+ | # usermod -Z staff_u USERNAME | ||
+ | |||
+ | |||
+ | Configure the staff_u user to allow it webadm_r and/or unconfined_r by executing: | ||
+ | |||
+ | |||
+ | # semanage user -m -R" | ||
+ | |||
+ | ===== 4 Effective Methods to Disable SELinux Temporarily or Permanently ===== | ||
+ | |||
+ | ==== Method 1: Disable SELinux Temporarily ==== | ||
+ | |||
+ | To disable SELinux temporarily you have to modify the / | ||
+ | |||
+ | # cat / | ||
+ | 1 | ||
+ | # echo 0 > / | ||
+ | # cat / | ||
+ | 0 | ||
+ | |||
+ | |||
+ | You can also use setenforce command as shown below to disable SELinux. Possible parameters to setenforce commands are: Enforcing , Permissive, 1 (enable) or 0 (disable). | ||
+ | |||
+ | # setenforce 0 | ||
+ | |||
+ | ==== Method 2: Disable SELinux Permanently ==== | ||
+ | |||
+ | |||
+ | To disable the SELinux permanently, | ||
+ | |||
+ | # cat / | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | Following are the possible values for the SELINUX variable in the / | ||
+ | |||
+ | * **enforcing** | ||
+ | * **permissive** - This just simulates the enforcing policy by only printing warning messages and not really enforcing the SELinux. This is good to first see how SELinux works and later figure out what policies should be enforced. | ||
+ | * **disabled** - Completely disable SELinux | ||
+ | |||
+ | |||
+ | Following are the possible values for SELINUXTYPE variable in the / | ||
+ | |||
+ | * **targeted** - This policy will protected only specific targeted network daemons. | ||
+ | * **strict** - This is for maximum SELinux protection. | ||
+ | |||
+ | ==== Method 3: Disable SELinux from the Grub Boot Loader ==== | ||
+ | |||
+ | If you can’t locate / | ||
+ | |||
+ | < | ||
+ | # cat / | ||
+ | default=0 | ||
+ | timeout=5 | ||
+ | splashimage=(hd0, | ||
+ | hiddenmenu | ||
+ | title Enterprise Linux Enterprise Linux Server (2.6.18-92.el5PAE) | ||
+ | root (hd0,0) | ||
+ | kernel / | ||
+ | initrd / | ||
+ | title Enterprise Linux Enterprise Linux Server (2.6.18-92.el5) | ||
+ | root (hd0,0) | ||
+ | kernel / | ||
+ | initrd / | ||
+ | </ | ||
+ | |||
+ | ==== Method 4: Disable Only a Specific Service in SELinux - HTTP/Apache ==== | ||
+ | |||
+ | |||
+ | If you are not interested in disability the whole SELinux, you can also disable SELinux only for a specific service. For example, do disable SELinux for HTTP/Apache service, modify the httpd_disable_trans variable in the / | ||
+ | |||
+ | Set the httpd_disable_trans variable to 1 as shown below. | ||
+ | |||
+ | < | ||
+ | # grep httpd / | ||
+ | httpd_builtin_scripting=1 | ||
+ | httpd_disable_trans=1 | ||
+ | httpd_enable_cgi=1 | ||
+ | httpd_enable_homedirs=1 | ||
+ | httpd_ssi_exec=1 | ||
+ | httpd_tty_comm=0 | ||
+ | httpd_unified=1 | ||
+ | </ | ||
+ | |||
+ | Set SELinux boolean value using setsebool command as shown below. Make sure to restart the HTTP service after this change. | ||
+ | |||
+ | # setsebool httpd_disable_trans 1 | ||
+ | # service httpd restart |