<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ejohansson.se &#187; selinux</title>
	<atom:link href="http://ejohansson.se/tags/selinux/feed/" rel="self" type="application/rss+xml" />
	<link>http://ejohansson.se</link>
	<description>Random bits about Linux, programming, computers and occasionally other stuff.</description>
	<lastBuildDate>Sun, 18 Apr 2010 20:23:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SELinux and mail() in&#160;PHP</title>
		<link>http://ejohansson.se/archives/2008/02/22/selinux-and-mail-in-php/</link>
		<comments>http://ejohansson.se/archives/2008/02/22/selinux-and-mail-in-php/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 21:37:13 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2008/02/22/selinux-and-mail-in-php/</guid>
		<description><![CDATA[Since I upgraded my server and activated SELinux I haven&#8217;t gotten any emails from wordpress when people post comments on this blog (that&#8217;s why it has taken my so long time to approve comments). Today I decided it was time to look into the problem. It turned out that the problem was related to the [...]]]></description>
			<content:encoded><![CDATA[<p>Since I upgraded my server and activated SELinux I haven&#8217;t gotten any emails from wordpress when people post comments on this blog (that&#8217;s why it has taken my so long time to approve comments). Today I decided it was time to look into the problem.</p>
<p>It turned out that the problem was related to the following message that I&#8217;ve been seeing in my log:</p>
<pre>
avc:  denied  { execute_no_trans } for  pid=972 comm="apache2"
name="bash" dev=hda1 ino=26110
scontext=user_u:system_r:httpd_t:s0
tcontext=system_u:object_r:shell_exec_t:s0 tclass=file
</pre>
<p>The mail() function in PHP (which is what wordpress uses to send the notification mail) is implemented using popen(3). When you call mail(), PHP executes popen(&#8220;sendmail &#8230;&#8221;, &#8220;w&#8221;). This ends up with a call to &#8220;sh -c sendmail &#8230;&#8221;, which explains the log message.</p>
<p>The solution was allow execute_no_trans for httpd:</p>
<pre>
allow httpd_t shell_exec_t:file execute_no_trans;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2008/02/22/selinux-and-mail-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SELinux, Subversion and&#160;mod_svn</title>
		<link>http://ejohansson.se/archives/2007/11/04/selinux-subversion-and-mod_svn/</link>
		<comments>http://ejohansson.se/archives/2007/11/04/selinux-subversion-and-mod_svn/#comments</comments>
		<pubDate>Sun, 04 Nov 2007 01:22:48 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2007/11/04/selinux-subversion-and-mod_svn/</guid>
		<description><![CDATA[After upgrading my server (from Debian Sarge to Debian Etch) I decided to enabled SELinux. After reading some documentation (besides Debian&#8217;s basic setup documentation I can recommend Fedora&#8217;s SELinux wiki and especially this presentation) I got the basic setup working. Getting Subversion to fully work required a few extra steps. For your convenience and my [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading my server (from Debian Sarge to Debian Etch) I decided to enabled SELinux. After reading some documentation (besides <a href="http://wiki.debian.org/SELinux">Debian&#8217;s basic setup documentation</a> I can recommend <a href="http://fedoraproject.org/wiki/SELinux">Fedora&#8217;s SELinux wiki</a> and especially <a href="http://people.redhat.com/dwalsh/SELinux/Presentations/ManageRHEL5.pdf">this presentation</a>) I got the basic setup working. Getting Subversion to fully work required a few extra steps. For your convenience and my memory I&#8217;ve listed them below.</p>
<p>1. Turn on httpd_builtin_scripting and httpd_enable_cgi. Turning on httpd_builtin_scripting gives httpd_t (i.e. apache) permission to read and write files marked httpd_sys_script_rw_t. This is needed for commits to work. Turning on httpd_enable_cgi gives httpd_t permission to execute scripts (marked httpd_sys_script_exec_t), something which is needed for hooks to work.</p>
<pre>
# setsebool -P httpd_builtin_scripting=1
# setsebool -P httpd_enable_cgi=1
</pre>
<p>2. Set the proper security context on the files in the repository. Assuming that all repositories are located under /home/svn, the following commands will do the job. Also make sure that the user apache is running as (e.g. www-data) has read access to the repository and write access to the directories dav and db (<a href="http://svn.ejohansson.se/repos/src/misc/bash/svn_perms">this is the script I use for that</a>).</p>
<pre>
# semanage fcontext -a -t httpd_sys_content_t '/home/svn(/.*)?'
# semanage fcontext -a -t httpd_sys_script_rw_t '/home/svn/[^/]+/(dav|db)(/.*)?'
# semanage fcontext -a -t httpd_sys_script_exec_t '/home/svn/[^/]+/hooks(/.*)?'
# restorecon -Rv /home/svn
</pre>
<p>3. Make sure selinux-policy-refpolicy-dev is installed.</p>
<p>4. Create the directory mysvn. In that directory, create the file mysvn.te with the following contents:</p>
<pre>
policy_module(mysvn,0.0.1)

require {
        type httpd_t;
        type shell_exec_t;
        type httpd_sys_script_t;
        type var_run_t;
};

# If hooks are shell scripts, apache must be able to run a shell. The
# hooks will run in httpd_sys_script_t.
allow httpd_t shell_exec_t:file rx_file_perms;

# For some reason the scripts searches /var/run
allow httpd_sys_script_t var_run_t:dir search;
</pre>
<p>5. Then run:</p>
<pre>
# make -f /usr/share/selinux/refpolicy-targeted/include/Makefile
# semodule -i mysvn.pp
</pre>
<p>The mysvn policy module is needed because hooks are normally shell scripts. For apache to be able to run them it must be able to run a shell. Once the scripts have started, they run in the httpd_sys_script_t domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2007/11/04/selinux-subversion-and-mod_svn/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SELinux on NSLU2 now&#160;working</title>
		<link>http://ejohansson.se/archives/2007/09/02/selinux-on-nslu2-now-working/</link>
		<comments>http://ejohansson.se/archives/2007/09/02/selinux-on-nslu2-now-working/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 18:10:11 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[nslu2]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2007/09/02/selinux-on-nslu2-now-working/</guid>
		<description><![CDATA[Not willing to wait any longer for a resolution to the bug I wrote about in my last post I decided to take action. I have now compiled libsepol with my fix applied and uploaded the debian package to my repository. Since libsepol1-dev ships with a static version of libsepol, I&#8217;ve also recompiled some of [...]]]></description>
			<content:encoded><![CDATA[<p>Not willing to wait any longer for a resolution to the <a href="http://bugs.debian.org/439539">bug</a> I wrote about in my last post I decided to take action. I have now compiled libsepol with my fix applied and uploaded the debian package to my <a href="/archives/2006/03/11/presenting-my-debian-repository/">repository</a>.</p>
<p>Since libsepol1-dev ships with a static version of libsepol, I&#8217;ve also recompiled some of the packages that build-depends on libsepol1-dev and added them to the repository as well.</p>
<p>If you wish to use SELinux on you slug and feel that you trust me enough to use my version of this rather central piece of security software, add this to your sources.list:</p>
<pre>
deb http://eddie.ejohansson.se/debian/ etch main
</pre>
<p>The version number is the same as the version in etch with &#8216;a&#8217; added at the end. Hopefully this means that when updated official packages are released they will automatically be upgraded.</p>
<p>If you want information on how to configure SELinux, this <a href="http://wiki.debian.org/SELinux">guide</a> worked for me. But before you follow that guide (and after installing my updated packages), run &#8216;dpkg-reconfigure selinux-policy-refpolicy-targeted&#8217; so that the base module and modules for the daemons you&#8217;re using are properly loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2007/09/02/selinux-on-nslu2-now-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSLU2 +&#160;SELinux</title>
		<link>http://ejohansson.se/archives/2007/08/25/nslu2-selinux/</link>
		<comments>http://ejohansson.se/archives/2007/08/25/nslu2-selinux/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 14:24:30 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[nslu2]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2007/08/25/nslu2-selinux/</guid>
		<description><![CDATA[It took some time, but I finally figured out why SELinux wouldn&#8217;t work on my Debian/NSLU2 installation. The bug report has all the details.]]></description>
			<content:encoded><![CDATA[<p>It took some time, but I finally figured out why SELinux wouldn&#8217;t work on my <a href="http://www.nslu2-linux.org/wiki/Debian/HomePage">Debian/NSLU2</a> installation.  The <a href="http://bugs.debian.org/439539">bug report</a> has all the details.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2007/08/25/nslu2-selinux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
