<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>freebsd.munk.me.uk - PHP</title>
    <link>http://freebsd.munk.me.uk/</link>
    <description>FreeBSD System Administration</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://freebsd.munk.me.uk/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: freebsd.munk.me.uk - PHP - FreeBSD System Administration</title>
        <link>http://freebsd.munk.me.uk/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Solving permission problems with parsepath.pl</title>
    <link>http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html</link>
            <category>Apache</category>
            <category>FreeBSD</category>
            <category>General</category>
            <category>Perl</category>
            <category>PHP</category>
            <category>Security</category>
            <category>Shell</category>
            <category>SSH</category>
    
    <comments>http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=175</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=175</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;a href=&quot;http://sial.org/howto/debug/unix/parsepath&quot;  title=&quot;parsepath.pl - a script for solving file permission problems&quot;&gt;parsepath.pl&lt;/a&gt; is a brilliant perl script for fixing permissions problems on Unix based platforms by &lt;a href=&quot;http://sial.org/&quot;  title=&quot;Jeremy Mates&quot;&gt;Jeremy Mates&lt;/a&gt;.   Probably the most common type of permission problem from a sysadmin/webmaster&#039;s viewpoint is uploading a file to a directory in a website&#039;s document root folder and then trying to access the file or script in a web browser only to get the dreaded 403 error message:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Forbidden&lt;br /&gt;
You don&#039;t have permission to access /foo/bar/test.php on this server.&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Most time the solution is very simple, just change the permissions on &#039;test.php&#039; to make sure the user the webserver runs as can read the file correctly - the simplest and most common method being to change the mode of the file to &#039;755&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;chmod&amp;#160;755&amp;#160;test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately sometimes it&#039;s not that easy and many times you see users asking &#039;I&#039;m getting &#039;access denied&#039; errors even though I&#039;ve changed the perms to 755&#039;.  The problem is that one of the subdirectories that the &#039;test.php&#039; file lives in has permissions set so that the webserver can&#039;t read the file properly.  Now that&#039;s where the headache comes in :)&lt;br /&gt;
&lt;br /&gt;
However, &lt;a href=&quot;http://sial.org/howto/debug/unix/parsepath&quot;  title=&quot;parsepath.pl - a script for solving file permission problems&quot;&gt;parsepath.pl&lt;/a&gt; can take the headache out of fixing permissions problems.&lt;br /&gt;
&lt;br /&gt;
Say you have a website document root directory tree /usr/local/www/web/www.munk.me.uk/foo/bar and you upload a web script &#039;test.php&#039; into that directory.  You try and access the file in a webbrowser but get the 403 permission denied error above.  First off you check the permissions on the file itself:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;23&amp;#58;58&amp;#58;17&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;;&amp;#160;ls&amp;#160;-l&lt;br /&gt;
total&amp;#160;0&lt;br /&gt;
-rwxr-xr-x&amp;#160;&amp;#160;1&amp;#160;www&amp;#160;www&amp;#160;&amp;#160;0&amp;#160;Sep&amp;#160;&amp;#160;4&amp;#160;23&amp;#58;39&amp;#160;test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
That looks ok, with permissions 755 and the owner/group set to &#039;www&#039; the webserver user &#039;www&#039; should be able to read the file ok.  So in this case the problem must be with the permissions on one of the parent subdirectories.  The old method of working out the perms would be either to trawl one by one through each directory checking the perms on each subdirectory or to change the permissions recursively on the document root folder so all subfolders have the read bit set for the webserver user/group.&lt;br /&gt;
&lt;br /&gt;
With parsepath.pl things are a lot simpler though - just run the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;0&amp;#58;03&amp;#58;21&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;parsepath.pl&amp;#160;user=www&amp;#160;+r&amp;#160;test.php&lt;br /&gt;
!&amp;#160;group=www&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
!&amp;#160;unix-other&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
With this command parsepath.pl  recurses through each subdirectory below the file/path you feed it on the commandline and tells you the permissions problems - if any - for the user &#039;www&#039; (the user=www argument) to read (the +r argument) the file &#039;test.php&#039;.&lt;br /&gt;
&lt;br /&gt;
In the output, we&#039;re told that permissions to read the test.php by the user www fails on two counts:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#&amp;#160;the&amp;#160;group&amp;#160;bit&amp;#160;on&amp;#160;the&amp;#160;folder&amp;#160;&#039;foo&#039;&amp;#160;doesn&#039;t&amp;#160;have&amp;#160;the&amp;#160;+rx&amp;#160;flag&amp;#160;set&amp;#58;&lt;br /&gt;
!&amp;#160;group=www&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;the&amp;#160;other&amp;#160;bit&amp;#160;on&amp;#160;the&amp;#160;folder&amp;#160;&#039;bar&#039;&amp;#160;doesn&#039;t&amp;#160;have&amp;#160;the&amp;#160;+rx&amp;#160;flag&amp;#160;set&amp;#58;&lt;br /&gt;
!&amp;#160;unix-other&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
With this information it&#039;s easy enough to go in and make the changes necessary to fix the problem using &#039;chmod g+rx foo foo/bar&#039;.&lt;br /&gt;
&lt;br /&gt;
There are other ways of invoking parsepath.pl though.  Running it just with a file/path as an argument it&#039;ll tell you the permissions on each subdirectory under it:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;0&amp;#58;10&amp;#58;33&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;&lt;br /&gt;
&amp;#62;&amp;#160;parsepath.pl&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;br /&gt;
%&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www&lt;br /&gt;
d&amp;#160;0770&amp;#160;www&amp;#58;wheel&amp;#160;/usr/local/www/web&lt;br /&gt;
d&amp;#160;0750&amp;#160;www&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk&lt;br /&gt;
d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;br /&gt;
f&amp;#160;0755&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which can is better to see a whole tree in one go.  &lt;br /&gt;
&lt;br /&gt;
No permissions were harmed in the making of this article!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&#039;ll include the parsepath.pl script in the extended article just in case the original ever gets lost - big credit of course goes to the author of the script, &lt;a href=&quot;http://sial.org/&quot;  title=&quot;Jeremy Mates&quot;&gt;Jeremy Mates&lt;/a&gt;.  His site is actually very interesting from a sysadmin&#039;s point of view containing lots of interesting admin scripts and thoughts on system administration in general - spent quite a while grazing through his stuff there - cheers Jeremy.&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html#extended&quot;&gt;Continue reading &quot;Solving permission problems with parsepath.pl&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 04 Sep 2006 22:41:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/175-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Apachectl Leaks Sensitive in phpinfo() PHP Calls</title>
    <link>http://freebsd.munk.me.uk/archives/165-Apachectl-Leaks-Sensitive-in-phpinfo-PHP-Calls.html</link>
            <category>Apache</category>
            <category>PHP</category>
            <category>Security</category>
    
    <comments>http://freebsd.munk.me.uk/archives/165-Apachectl-Leaks-Sensitive-in-phpinfo-PHP-Calls.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=165</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=165</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Quite a while ago I posted a question to the freebsd-isp mailing list about a minor modification that could be added to the apachectl apache startup shell script to stop it from displaying a lot of sensitive information when PHP and other CGI applications display apache&#039;s environment information to users.  A bit mouthful - the gist of it is that when you use apachectl to start/stop apache from a shell, the environment variables of the shell user that invokes the apachectl script become available to CGI applications by default.&lt;br /&gt;
&lt;br /&gt;
For example in my case the following types of sensitive environmental information is available by default when someone runs phpinfo.php on my server:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;_ENV&amp;#91;&quot;USER&quot;&amp;#93;	root&lt;br /&gt;
_ENV&amp;#91;&quot;MAIL&quot;&amp;#93;	/var/mail/root&lt;br /&gt;
_ENV&amp;#91;&quot;qbertconf&quot;&amp;#93;	/home/munk/eggdrop/bots/qbert/qbert.conf&lt;br /&gt;
_ENV&amp;#91;&quot;webcpdevcvs&quot;&amp;#93;	/home/munk/cvs/ver2&lt;br /&gt;
_ENV&amp;#91;&quot;alllog&quot;&amp;#93;	/var/log/all.log&lt;br /&gt;
_ENV&amp;#91;&quot;apacheerrlog&quot;&amp;#93;	/var/log/httpd-error.log&lt;br /&gt;
_ENV&amp;#91;&quot;SHLVL&quot;&amp;#93;	2&lt;br /&gt;
_ENV&amp;#91;&quot;VENDOR&quot;&amp;#93;	intel&lt;br /&gt;
_ENV&amp;#91;&quot;snortruledir&quot;&amp;#93;	/usr/local/share/snort&lt;br /&gt;
_ENV&amp;#91;&quot;PHP4_OPTFILE&quot;&amp;#93;	/root/php4_options&lt;br /&gt;
_ENV&amp;#91;&quot;IRCNICK&quot;&amp;#93;	munk&lt;br /&gt;
_ENV&amp;#91;&quot;HOME&quot;&amp;#93;	/root&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
and so on along with all the other environment variables I have set in my default root shell - not really what I want displayed to all and sundry :P  To see this yourself on your own server, try running phpinfo() from a php script:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#60;?php&amp;#160;phpinfo&amp;#40;&amp;#41;;&amp;#160;?&amp;#62;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Anyway the solution I found is to &#039;sanitize&#039; the environment when the apachectl script starts up the apache httpd process by using the following simple line in apachectl:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;HTTPD=`echo&amp;#160;/usr/bin/env&amp;#160;-i&amp;#160;$HTTPD`&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lists.freebsd.org/pipermail/freebsd-isp/2003-November/001246.html&quot;&gt;A problem report I was considering sending to the FreeBSD ports team&lt;/a&gt; is included in the extended article below - I didn&#039;t bother sending it in the end because it&#039;s not really a FreeBSD issue.  Not sure why I didn&#039;t send it to the Apache mailing list though, I thought I did but I can&#039;t find it now. Ho hum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/165-Apachectl-Leaks-Sensitive-in-phpinfo-PHP-Calls.html#extended&quot;&gt;Continue reading &quot;Apachectl Leaks Sensitive in phpinfo() PHP Calls&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sat, 15 Jan 2005 10:27:36 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/165-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Attempts To Exploit My_ eGallery Vulnerability Target Random Sites</title>
    <link>http://freebsd.munk.me.uk/archives/153-Attempts-To-Exploit-My_-eGallery-Vulnerability-Target-Random-Sites.html</link>
            <category>Apache</category>
            <category>PHP</category>
            <category>Security</category>
            <category>WWW</category>
    
    <comments>http://freebsd.munk.me.uk/archives/153-Attempts-To-Exploit-My_-eGallery-Vulnerability-Target-Random-Sites.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=153</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=153</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    This is &lt;a href=&quot;http://www.securityfocus.com/bid/9113/info/&quot;&gt;by no means a new attempt &lt;/a&gt;to exploit a vulnerability in a PHP web application, but since I started using snort as a full time intrusion detection system I&#039;ve picked up countless attempts to exploit a vulnerability in an online PHP photo gallery called &lt;a href=&quot;http://lottasophie.sourceforge.net/&quot;&gt;My_ eGallery&lt;/a&gt;.  The annoying thing about this is that I&#039;ve never had this gallery system installed on any of the sites I maintain - particularly the one that keeps getting hit - but they continue to try their exploits.  Read on for more... &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/153-Attempts-To-Exploit-My_-eGallery-Vulnerability-Target-Random-Sites.html#extended&quot;&gt;Continue reading &quot;Attempts To Exploit My_ eGallery Vulnerability Target Random Sites&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 26 Aug 2004 06:21:27 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/153-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Added Remember Me Functionality To SimpleAuth</title>
    <link>http://freebsd.munk.me.uk/archives/107-Added-Remember-Me-Functionality-To-SimpleAuth.html</link>
            <category>PHP</category>
    
    <comments>http://freebsd.munk.me.uk/archives/107-Added-Remember-Me-Functionality-To-SimpleAuth.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=107</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=107</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Been very quiet this week - over 10 days since last posting... hrm where&#039;s the time gone?&lt;br /&gt;
&lt;br /&gt;
Anyway just yesterday I added some &#039;remember me&#039; functionality to the SimpleAuth code base, detailing the changes needed in the SimpleAuth FAQ.  The FAQ seems to have gone down a treat - since writing it a few months ago the number of questions has gone from 2-3/week to about 1/fortnight - score.&lt;br /&gt;
&lt;br /&gt;
Anyway the details about the code are in the FAQ here:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://forums.munk.me.uk/index.php?showtopic=110&amp;view=findpost&amp;p=556&quot;&gt;SimpleAuth Remember Me&lt;/a&gt; 
    </content:encoded>

    <pubDate>Fri, 27 Feb 2004 21:05:35 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/107-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>

</channel>
</rss>