Fedora Core 5 Tomcat 4 problems
Hello All:
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s /bin/bash -c /usr/local/tomcat/bin/startup.sh
In addition, the tomcat user has /sbin/nologin in the password file.
Steps to make it work:
1) Set SELinux to permissive and reboot
2) Take resultant AVC messages and create local policy
3) Load policy, set SELinux to enforcing and reboot
If I leave SELinux in permissive the tomcat script works just fine and, if I allow root to run tomcat that works as well. I would like to have the security of SELinux and an unprivileged user running Tomcat, so any help would be greatly appreciated.
Below is a copy of the local.te file that was generated from the AVC messages in /var/log/messages after setting to permissive. The Tomcat directory is /usr/local/tomcat and shows as:
drwxr-xr-x tomcat tomcat user_u:object_r:usr_t
jakarta-tomcat-4.1.31
lrwxrwxrwx root root user_u:object_r:usr_t tomcat ->/usr/local/jakarta-tomcat-4.1.31
Thanks in advance,
Mike
module local 1.0;
require {
class lnk_file read;
class dir { getattr search };
class security compute_av;
class file { execmod getattr read };
type initrc_su_t;
type usr_t;
type file_t;
type hald_t;
type initrc_su_t;
type initrc_t;
type locale_t;
type mysqld_db_t;
type pam_console_t;
type security_t;
type semanage_t;
type user_home_t;
type initrc_t;
type locale_t;};
allow initrc_su_t usr_t:lnk_file read;
allow hald_t mysqld_db_t:dir getattr;
allow initrc_su_t security_t:security compute_av;
allow pam_console_t file_t:dir search;
allow initrc_t user_home_t:file execmod;
allow semanage_t locale_t:file { getattr read };
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Michael K. Smith
Hello All:
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s
/bin/bash-c/usr/local/tomcat/bin/startup.sh
Quoted 7 lines
In addition, the tomcat user has
/sbin/nologinin the password file.Steps to make it work:
1) Set SELinux to permissive and reboot
2) Take resultant AVC messages and create local policy
3) Load policy, set SELinux to enforcing and reboot
Rebooting shouldn't be strictly necessary in the above sequence.
Quoted 9 lines
If I leave SELinux in permissive the tomcat script works just fine and, if I allow root to run tomcat that works as well. I would like to have the security of SELinux and an unprivileged user running Tomcat, so any help would be greatly appreciated.
Below is a copy of the local.te file that was generated from the AVC messages in
/var/log/messagesafter setting to permissive. The Tomcat directory is/usr/local/tomcatand shows as:
Quoted 5 lines
drwxr-xr-x tomcat tomcat user_u:object_r:usr_t
jakarta-tomcat-4.1.31lrwxrwxrwx root root user_u:object_r:usr_t tomcat ->
/usr/local/jakarta-tomcat-4.1.31
This should really be in a different type than just usr_t.
Quoted 27 lines
Thanks in advance,
Mike
module local 1.0;
require { class lnk_file read; class dir { getattr search }; class security compute_av; class file { execmod getattr read }; type initrc_su_t; type usr_t; type file_t; type hald_t; type initrc_su_t; type initrc_t; type locale_t; type mysqld_db_t; type pam_console_t; type security_t; type semanage_t; type user_home_t; type initrc_t; type locale_t;
Quoted 3 lines
};
allow
initrc_su_tusr_t:lnk_file read;
su checking for the home directory.
Quoted 2 lines
allow
hald_tmysqld_db_t:dir getattr;
allowinitrc_su_tsecurity_t:securitycompute_av;
pam_rootok permission check from su.
Quoted 2 lines
allow
pam_console_tfile_t:dir search;
allowinitrc_tuser_home_t:file execmod;
Can we see the full avc message for the execmod denial?
Signature · 8 lines
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 [email protected] with the words "unsubscribe selinux" without quotes as the message.
Hello Stephen:
Quoted 10 lines · Stephen Smalley
Quoted 9 lines · Michael K. Smith
Hello All:
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s
/bin/bash-c/usr/local/tomcat/bin/startup.shIn addition, the tomcat user has
/sbin/nologinin the password file.
Quoted 8 lines
Quoted 5 lines
Steps to make it work:
1) Set SELinux to permissive and reboot
2) Take resultant AVC messages and create local policy
3) Load policy, set SELinux to enforcing and rebootRebooting shouldn't be strictly necessary in the above sequence.
Sadly, it's necessary to confirm whether or not the rc script will fire at boot. If I run the script after the system has booted everything works just fine.
<snip>
Quoted 5 lines
Quoted 5 lines
Below is a copy of the local.te file that was generated from the AVC messages in
/var/log/messagesafter setting to permissive. The Tomcat directory is/usr/local/tomcatand shows as:
Quoted 8 lines
Quoted 5 lines
drwxr-xr-x tomcat tomcat user_u:object_r:usr_t
jakarta-tomcat-4.1.31lrwxrwxrwx root root user_u:object_r:usr_t tomcat ->
/usr/local/jakarta-tomcat-4.1.31This should really be in a different type than just
usr_t.
I set it to system_u:object_r:user_home_t to match the HTTP directory but that didn't change the initial behavior.
<snip>
Quoted 2 lines
Can we see the full avc message for the execmod denial?
Absolutely.
May 27 08:03:57 bmedia kernel: audit(1117206233.280:4): avc: denied { read} for pid=1813 comm="su" name="tomcat" dev=sda6 ino=98262 scontext=system_u:system_r:initrc_su_t:s0 tcontext=user_u:object_r:usr_t:s0 tclass=lnk_file
Thanks again,
Mike
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · Michael K. Smith
Sadly, it's necessary to confirm whether or not the rc script will fire at boot. If I run the script after the system has booted everything works just fine.
Hmmm...it should run in the same context in both cases (i.e. initrc_t) so that manual execution of the rc script yields the expected behavior. If I create a script in /etc/init.d and restorecon it, executing it manually does run it in initrc_t as expected here.
Quoted 8 lines
Quoted 1 line
Can we see the full avc message for the execmod denial?
Absolutely.
May 27 08:03:57 bmedia kernel: audit(1117206233.280:4): avc: denied { read} for pid=1813 comm="su" name="tomcat" dev=sda6 ino=98262 scontext=system_u:system_r:initrc_su_t:s0 tcontext=user_u:object_r:usr_t:s0 tclass=lnk_file
Not that one - the execmod denial, please. Might help to boot with audit=1 as well to get the full syscall audit record for it.
Signature · 8 lines
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 [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Stephen Smalley
Quoted 4 lines · Michael K. Smith
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application.
allow
initrc_su_tsecurity_t:securitycompute_av;
pam_rootokpermission check from su.
I have added this to su domains in reference policy.
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 10 lines · Christopher J. PeBenito
Quoted 7 lines · Stephen Smalley
Quoted 4 lines · Michael K. Smith
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application.
allow
initrc_su_tsecurity_t:securitycompute_av;
pam_rootokpermission check from su.I have added this to su domains in reference policy.
Thank you to everyone for the help. I did the runuser modification and that did indeed fix the issue. Once I download the new reference policy I'll also remove the local policy per Stephen's advice.
Regards,
Mike
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 10 lines · Christopher J. PeBenito
Quoted 7 lines · Stephen Smalley
Quoted 4 lines · Michael K. Smith
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application.
allow
initrc_su_tsecurity_t:securitycompute_av;
pam_rootokpermission check from su.I have added this to su domains in reference policy.
It's really not needed. With runuser there should not be any need for initrc_su_t in Fedora. When I write the necessary code for Debian there will be no need for such things in Debian either. So this may end up being a Gentoo-only thing if you do such things in Gentoo.
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · Michael K. Smith
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s
/bin/bash-c/usr/local/tomcat/bin/startup.sh
The tomcat start script is broken, it should be using runuser instead. Change it to use runuser instead of su (runuser takes the same parameters so it's an easy change) and many of the problems you list will go away.
Also please file a bug report requesting that runuser be used.
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 11 lines · Russell Coker
Quoted 4 lines · Michael K. Smith
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s
/bin/bash-c/usr/local/tomcat/bin/startup.shThe tomcat start script is broken, it should be using runuser instead. Change it to use runuser instead of su (runuser takes the same parameters so it's an easy change) and many of the problems you list will go away.
Also please file a bug report requesting that runuser be used.
Has runuser been upstreamed, or generally ported to other distros yet? Or is it still Fedora-specific?
Signature · 8 lines
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 [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 2 lines · Stephen Smalley
Quoted 1 line · Russell Coker
On Thursday 25 May 2006 02:20, "Michael K. Smith" <[email protected]>
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 5 lines
I am attempting to start Tomcat 4 using an rc script that uses the unprivileged user "tomcat" to run the application. The relevant line is:
su -l tomcat -p -s
/bin/bash-c/usr/local/tomcat/bin/startup.sh
Quoted 8 lines
Quoted 5 lines
The tomcat start script is broken, it should be using runuser instead. Change it to use runuser instead of su (runuser takes the same parameters so it's an easy change) and many of the problems you list will go away.
Also please file a bug report requesting that runuser be used.
Has runuser been upstreamed, or generally ported to other distros yet? Or is it still Fedora-specific?
It is specific to Fedora.
For Debian the best solution is to modify start-stop-daemon, this is on my todo list. For Gentoo the best solution is to modify the program that they use to start daemons (not sure of the name but know that they have one).
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.