<?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>threeeighthsspacer.com &#187; wordpress</title>
	<atom:link href="http://threeeighthsspacer.com/blog/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://threeeighthsspacer.com/blog</link>
	<description>Cryptic Writings on the Tubes</description>
	<lastBuildDate>Sat, 12 Jun 2010 15:33:39 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting Permissions Properly in Wordpress</title>
		<link>http://threeeighthsspacer.com/blog/2009/08/31/setting-permissions-properly-in-wordpress/</link>
		<comments>http://threeeighthsspacer.com/blog/2009/08/31/setting-permissions-properly-in-wordpress/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 03:18:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://threeeighthsspacer.com/blog/?p=17</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>This is basically notes I am taking while learning in the school of hard knocks based on an article I posted 2008-July-31. To cut to the meat of the matter, here are the notes I took as I learned:</p>
<p>In the blog directory;<br />
Type the following to see <strong>folders</strong> in and under this directory that are writeable by group and/or others:<br />
<code>find . -type d -perm +022 -ls</code><br />
Do the following to take away write permissions from group and others on those same <strong>folders</strong>:<br />
<code>find . -type d -perm +022 -exec chmod go-w '{}' \;</code><br />
Type the following to see <strong>files</strong> in and under this directory that are writeable by group and/or others:<br />
<code>find . -type f -perm +033 -ls</code><br />
Do the following to take away write permissions from group and others on those same <strong>files</strong>:<br />
<code>find . -type f -perm +033 -exec chmod go-wx '{}' \;</code><br />
And then, test to see if your server can run wordpress with the wp-config.php file invisible. It is obviously more secure to do this, since this file contains your database passwords in plain text! To do this:<br />
<code>chmod 600 wp-config.php</code><br />
or, instead, just:<br />
<code>chmod go-rwx wp-config.php</code><br />
to make your config file unwriteable and unreadable by others and also by group. The former sets all perms explicitly; the latter merely takes away read, write, and execute from the group and other. These measures work great for me on my linux shared server but the resulting permissions on wp-config.php may be too tight for some servers which are set up another way.  My joyent server has something called php-suexec where Apache can run as my user or something like that.  If upon setting the permissions for wp-config.php to 600, you get an error about permissions in &#8216;wp-load.php on line 27&#8243;, or something like that, you may need to leave the wp-config.php readable by group and others, so just<br />
<code>chmod 644 wp-config.php</code></p>
<p>Edit: I have discovered that to coax the upload feature to function on a certain Linux configuration, where Apache apparently does not run as the user account (no suexec), the uploads folder inside wp-content must be writeable by the group and by everyone! That is unless it&#8217;s possible to make the apache user be in the same group as me or something. Anyway apparently according to the Wordpress codex, it was designed to work that way. On a different server where apache runs the suexec module so it can run as the user (me) I can still keep my uploads folder 755. Not in this configuration. So far it must be 777 for that folder only.  Unless there is a way for me and the web server to share group permissions somehow . . .<br />
And read on for my whole rant on the subject, including my first attempts down below&#8212;&#8211;</p>
<p>Security is a matter of trust, and access should be granted on a need-to-know basis, and (you) don&#8217;t need to know. ;)  loi<br />
Consider, for example, the case of running Wordpress on a shared server. It&#8217;s frequently recommended that after installing and setting up Wordpress we change the permissions on wp-config.php to 600.  Why? With permissions of 644 It would be readable by other user accounts on a shared server. Since wp-config contains sensitive database information that would be an insecure situation.  Of course, one could always change permissions and then change them back if and when one needs to edit the file.<br />
I&#8217;m going to digress a bit for some background on file permissions in Linux/BSD/Unix. Permissions can be symbolic , like drwxr-xr-x or octal, like 755. By the way, the &#8220;d&#8221; in the front of drwxr-xr-x tells us it&#8217;s a directory (folder). If it were a file, it would be a &#8220;-&#8221;.<br />
Here&#8217;s a table I made to help me remember :</p>
<table border="3">
<tbody>
<tr>
<td>read</td>
<td>write</td>
<td>execute</td>
</tr>
<tr>
<td>r</td>
<td>w</td>
<td>x</td>
</tr>
<tr>
<td>4</td>
<td>2</td>
<td>1</td>
</tr>
</tbody>
</table>
<p>To see information about the files in the current directory, including permissions, type</p>
<p><code>ls -la</code></p>
<p><a href="http://en.wikipedia.org/wiki/File_system_permissions">The Wikipedia entry has a more complete explanation.</a><br />
Setting permissions on all folders to 755 and on all files to 644 is emphatically recommended by many Wordpress blog owners. <a href="http://codex.wordpress.org/Changing_File_Permissions">Contrarily, the Wordpress Codex</a> says to make all the files in your wp-content directory writable by using the following two steps:</p>
<blockquote><p>1. Go to your WordPress main directory, with a command like cd wordpress/<br />
2. Enter chmod -R 777 wp-content</p></blockquote>
<p>The Codex also says if you use Permalinks you should change permissions of .htaccess to make sure that WordPress can update it when you change settings or add some new Page (which requires update of the file to work when Permalinks are enabled).</p>
<blockquote><p>1. Go to the main directory of WordPress<br />
2. Enter chmod 666 .htaccess</p></blockquote>
<p>I&#8217;m not doing that yet, though. I read that with a modern setup where the server (Apache, etc) runs as the user (setuid user) you can keep your wp-content directory 755. Also I read that you should simply set .htaccess temporarily to 666 while WP updates it when you change settings or create a Page.</p>
<p>STEPS I DID to my blog to tighten up the ol&#8217; security belt<br />
First, make sure I (the user) own everything in the blog directory.<br />
cd to your blog directory (or your web root if you like)</p>
<p><code>cd my/blog</code></p>
<p>and issue the following command to find files not owned by you (please replace the word &#8220;me&#8221; with your username):</p>
<p><code>find . ! -user me </code></p>
<p>Maybe do this if you can:</p>
<p><code>sudo chown -R me .</code></p>
<p>So now you could find all directories (folders) under the current folder and set their permissions to 755</p>
<p><code>find . -type d -exec chmod 755 '{}' ;</code></p>
<p>I&#8217;m following along with what&#8217;s recommended <a href="http://codex.wordpress.org/Hardening_WordPress">in the Wordpress Codex here</a>. Note that that document indicates cryptically that</p>
<blockquote><p>You have to omit to use this command for /wp-includes/.</p></blockquote>
<p>However, I think it&#8217;s a typo and they meant to refer to /wp-content/, which is the folder mentioned elsewhere as being the only folder needing different permissions, those being 777 ! World-writeable?!<br />
It seems that some or most of the files in /wp-includes have read-only permissions, 444 or -r&#8211;r&#8211;r&#8211; !<br />
I felt that it couldn&#8217;t hurt to leave the permissions as strict as possible, while I wanted to change the permissions recursively, and not have to issue a bunch of separate commands. I administer several blogs, and I&#8217;m going to have to duplicate this a few times. I did a little research:</p>
<p><code>man find</code></p>
<p>And I decided to find all files (not directories) under the current directory that are writeable by either the group or the world (other) or both and change their permission mode removing write permissions for group and for other. This will include the wp-includes directory but will leave more restricted permissions alone, instead of arbitrarily changing every file&#8217;s permissions (Please take note that this is the proper command for FreeBSD and probably will but might not be exactly right for Linux; please research for yourself) :</p>
<p><code>find . -type f -perm +066 -exec chmod 644 '{}' ;</code></p>
<p>After Wordpress is set up and running properly, and before it is attacked by someone who owns an account on your shared server,</p>
<p><code>chmod 600 wp-config.php</code></p>
<p>&#8212;EDIT 2009-01-06</p>
<p>I have now done this in a linux box and it seems like it&#8217;s different.</p>
<p>I think on Linux the find option, or test, &#8220;-perm +mode&#8221; might behave differently than on BSD. I&#8217;ll report back later but these are the ones that worked on Linux:</p>
<p><code>find . -type f -perm +033 -exec chmod 644 '{}' ;</code></p>
<p>The above means find in this directory files of type file (not a dir, etc) that are either group or others writeable, (I think) and change their permissions to 644. 644 is how you want most, if not all regular files&#8217; permissions set.<br />
Directories (folders) to be accessed publicly you want to be 755 generally. That means rwx for owner and rx for others and group.</p>
<p><code>find . -type d -perm +022 -exec chmod 755 '{}' ;</code></p>
<p>also use for instance to test the result:</p>
<p><code>find . -type d -perm +022 -exec ls -la '{}' ;</code></p>
<p>The above lists the contents of the dirs found as well as the dirs.<br />
You can use this to list files found &#8211; simpler:</p>
<p><code>find . -type d -perm +022 -ls</code></p>
<p>For more information, please type &#8220;man find&#8221; in the terminal.</p>
]]></content:encoded>
			<wfw:commentRss>http://threeeighthsspacer.com/blog/2009/08/31/setting-permissions-properly-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAD_SECURITY &#8211; &#8220;precondition failed&#8221; error on Wordpress post action</title>
		<link>http://threeeighthsspacer.com/blog/2008/05/26/mad_security/</link>
		<comments>http://threeeighthsspacer.com/blog/2008/05/26/mad_security/#comments</comments>
		<pubDate>Mon, 26 May 2008 21:56:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[mod security]]></category>
		<category><![CDATA[precondition failed]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://threeeighthsspacer.com/blog/?p=15</guid>
		<description><![CDATA[   May 26, 2008 &#8212; Until I &#8220;fixed&#8221; this problem, on this Wordpress 2.5.1 blog hosted on textdrive, If I typed &#8220;FTP&#8221; and &#8220;server&#8221; in the main text field of the &#8220;New Post&#8221; page, and then published or saved my post, I got &#8220;Precondition Failed&#8221; 
Try this on your wordpress blog.
Make a new [...]]]></description>
			<content:encoded><![CDATA[<p>   May 26, 2008 &#8212; Until I &#8220;fixed&#8221; this problem, on this Wordpress 2.5.1 blog hosted on textdrive, If I typed &#8220;FTP&#8221; and &#8220;server&#8221; in the main text field of the &#8220;New Post&#8221; page, and then published or saved my post, I got &#8220;Precondition Failed&#8221; </p>
<p>Try this on your wordpress blog.<br />
Make a new post.<br />
Type anything in the title field.<br />
Type the words<br />
&#8220;FTP&#8221; and &#8220;server&#8221; in the main text field you can type any other content too, but put those two words together and you will not be able to save your post. (edit: It appears that the only word  that I really had trouble was &#8220;FTP &#8221; &#8211; with the space after and without the quotes. I have heard of people having problems with words commonly found in porn spam and also some seemingly-innoccuous words such as &#8220;picture&#8221;)<br />
Try to publish your test post.<br />
Do you get the &#8220;Precondition Failed&#8221; error?</p>
<pre>
Precondition Failed

The precondition on the request for the URL /blog/wp-admin/post.php evaluated to false.
</pre>
<p>Update &#8211; I think it&#8217;s mod_security that causes that message.  See<br />
<a href="http://wordpress.org/support/topic/130554"> this Wordpress Support Page</a><br />
Also see <a href="http://help.joyent.com/index.php?pg=kb.page&#038;id=85">this Joyent help page</a><br />
I tried creating a .htaccess file in my public_html directory using the rules suggested there. According to that, you can disable MOD_SECURITY with the following in your .htaccess file:<br />
<code>SecFilterEngine Off</code><br />
This made it so that at one point I was able to post the word &#8220;FTP&#8221; alone in a post, which was impossible before. However, I didn&#8217;t want to completely disable MOD_SECURITY if I didn&#8217;t have to, so,<br />
I tried this in my .htaccess instead, as Joyent suggested at the url above:<br />
<code><br />
SecFilterEngine On<br />
SecFilterSelective "REQUEST_URI" "/blog/wp-admin/post.php" "allow,nolog"<br />
SecFilterSelective "POST_PAYLOAD" "FTP ,FTP,SSH ,SSH" "allow,nolog"<br />
</code><br />
(<em>Note that the above code consists of three lines, and the lines begin with SecFilt&#8230;. I will have to make a few adjustments to the theme CSS to make my blog wider </em>. . .)<br />
And that one worked! I don&#8217;t think I need the post.php entry so I may remove that line. Anyway it worked.<br />
 I am told that MOD_SECURITY is used for spam filtering, and there are many recommendations to disable mod_security as a workaround for this type of problem.  However I don&#8217;t know. I am rather experimenting here. I&#8217;m glad I didn&#8217;t have to completely disable it.<br />
   I&#8217;m tempted to think that overall rules (on my server) are too strict or need tweaking. Or that I need to make a custom filter of my own. However, one would think that one could blog the word &#8220;FTP&#8221; server without having to rewrite apache rules. When the 3rd and 5th blog posts I made failed, I started thinking &#8220;What&#8217;s the use? I got me a blog that I can&#8217;t post on!&#8221;<br />
   So here are some suggestions for some rules to put in your .htaccess file so that MOD_SECURITY will be generally functional, and allow apache to allow posts about FTP SSH, etc&#8230;<br />
   Status: MOD_SECURITY enabled. Blog works. All good.<br />
   To implement this solution on your own blog, edit (or create, if it doesn&#8217;t exist) a file called .htaccess in the web root of your blog and add the above code to it.  .htaccess files define per-directory rules for the apache web server. The .htaccess file which I added to fix my blog is in the folder which contains my Wordpress folder. I think that if you put the file in your actual blog folder it will work as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://threeeighthsspacer.com/blog/2008/05/26/mad_security/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
