<?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>crimulus-dot-com &#187; Computers</title>
	<atom:link href="http://www.crimulus.com/category/computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crimulus.com</link>
	<description>A blog; ineptly autobiographical</description>
	<lastBuildDate>Sun, 29 Jan 2012 10:20:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Solution: Use PHP&#8217;s pcntl_fork to limit execution time of MySQL queries</title>
		<link>http://www.crimulus.com/2011/12/16/the-solution-use-phps-pcntl_fork-to-limit-execution-time-of-mysql-queries/</link>
		<comments>http://www.crimulus.com/2011/12/16/the-solution-use-phps-pcntl_fork-to-limit-execution-time-of-mysql-queries/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 23:13:54 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[limit mysql query execution time with php]]></category>
		<category><![CDATA[pcntl_fork]]></category>
		<category><![CDATA[pcntl_fork share data from child process to parent]]></category>
		<category><![CDATA[php fork child to parent communication]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1438</guid>
		<description><![CDATA[One of the worst parts of a web application can be the variability of mysql queries that get sent into your database.  You can add indices, tweak hardware configurations, etc., but wouldn&#8217;t it be nice to simply kill any database query that takes longer than whatever you deem is &#8220;too long&#8221;? Well, no, not any [...]]]></description>
			<content:encoded><![CDATA[<p>One of the worst parts of a web application can be the variability of mysql queries that get sent into your database.  You can add indices, tweak hardware configurations, etc., but wouldn&#8217;t it be nice to simply kill any database query that takes longer than whatever you deem is &#8220;too long&#8221;?</p>
<p>Well, no, not any query.  I would never want to kill a write &#8212; just a read-only query; in particular: search queries.</p>
<p>So, as it turns out, the hurdles for this are immense, and, because my solution uses PHP&#8217;s pcntl_fork() function, even my solution, while it works, it has to make assumptions and is not perfect.</p>
<p>That being said, it would seem easy enough for this to be built into PHP or for some similar mechanism to be built into MySQL: Execute this query but only if it takes less than n seconds.  If not, kill it.  This is not the case, however, so we&#8217;re left to our own cleverness.</p>
<p>There are hundreds of reasons why you would never want to do this, but I only need one reason to want to do it to try to implement it.</p>
<p>So here is my solution steps in techno-layman&#8217;s terms, followed by the necessary code:</p>
<ul>
<li>Call a function to execute a MySQL query (again, preferably read-only)</li>
<li>Open a shared memory space so that we can pass the query results back to the parent from the child</li>
<li>Store process state information in a database</li>
<li>Fork, and execute the query in the child process</li>
<li>Keep time in the parent process</li>
<li>Kill the child process if it takes longer than n seconds</li>
<li>Return the results</li>
</ul>
<p>&nbsp;</p>
<p>Just to forwarn, I have tested this as proof of concept, but I am uncertain about the particulars of PHP&#8217;s shared memory and am not confident how reliable the shared memory implementation will in a production environment.  I plan to try it out, but right now I&#8217;m just getting the info out there.</p>
<p>So the state database will be defined as follows:</p>
<p><code>CREATE TABLE IF NOT EXISTS `pcntlFork` (<br />
`idx` bigint(20) unsigned NOT NULL AUTO_INCREMENT,<br />
`status` enum('0','1') NOT NULL DEFAULT '0',<br />
`output` longblob NOT NULL,<br />
PRIMARY KEY (`idx`)<br />
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=58 ;</code></p>
<p>The PHP class is available to download here:  <a href="http://mysql-restrictor.googlecode.com/files/mysqlRestrictor.class.php">http://mysql-restrictor.googlecode.com/files/mysqlRestrictor.class.php</a> (I had it inline, but WordPress did not want to format it properly)</p>
<p>And you would use it something like this</p>
<p><code>$m = new mysqlRestrictor();<br />
$results = $m-&gt;dbQuery("SELECT * FROM `table`");<br />
var_dump($results);</code></p>
<p>Since this took me an extremely long time to build and just verify that it even works, I welcome comments for improvement, and by all means use it for yourself. Let me know how it does in production!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2011/12/16/the-solution-use-phps-pcntl_fork-to-limit-execution-time-of-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Random String and POST Form Generator</title>
		<link>http://www.crimulus.com/2011/07/08/php-random-string-and-post-form-generator/</link>
		<comments>http://www.crimulus.com/2011/07/08/php-random-string-and-post-form-generator/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 15:17:37 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[php random form generator]]></category>
		<category><![CDATA[php random string generator]]></category>
		<category><![CDATA[random POST form]]></category>
		<category><![CDATA[random string]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1387</guid>
		<description><![CDATA[Just a little snippet of sample code.  Sometimes you just need a random string generator, and on top of that, a random form to test a page. Maybe I&#8217;m just keeping this for my own future reference, but maybe someone else out there could use it too.  The function generates a string containing numbers and [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little snippet of sample code.  Sometimes you just need a random string generator, and on top of that, a random form to test a page.</p>
<p>Maybe I&#8217;m just keeping this for my own future reference, but maybe someone else out there could use it too.  <img src='http://www.crimulus.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The function generates a string containing numbers and letters only (it&#8217;s easily customizable to contain other chars).  The form just creates inputs with random names from the string generator and random values from the string generator.</p>
<p><code><br />
function randomString() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';<br />
&nbsp; &nbsp; &nbsp; &nbsp; for ($i=0; $i&lt;rand(10,20); $i++) { $string .= $chars[rand(0,strlen($chars))]; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return $string;<br />
}</p>
<p>?&gt;&lt;form action=&quot;&quot; method=&quot;POST&quot;&gt;&lt;?php<br />
&nbsp; &nbsp; &nbsp; &nbsp; for ($i=1; $i&lt;=rand(5,10); $i++) { ?&gt;&lt;p /&gt;&lt;input name=&quot;&lt;?php echo randomString(); ?&gt;&quot; value=&quot;&lt;?php echo randomString(); ?&gt;&quot; /&gt;&lt;?php }<br />
&nbsp; &nbsp; &nbsp; &nbsp; ?&gt;&lt;p /&gt;&lt;input type=&quot;submit&quot; /&gt;&lt;?php<br />
?&gt;&lt;/form&gt;&lt;?php<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2011/07/08/php-random-string-and-post-form-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to process PayPal Express Checkout for third party merchants</title>
		<link>http://www.crimulus.com/2011/05/18/how-to-process-paypal-express-checkout-for-third-party-merchants/</link>
		<comments>http://www.crimulus.com/2011/05/18/how-to-process-paypal-express-checkout-for-third-party-merchants/#comments</comments>
		<pubDate>Wed, 18 May 2011 19:11:53 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Electronic commerce]]></category>
		<category><![CDATA[google-search-query-nuance tweaking]]></category>
		<category><![CDATA[Payment systems]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[paypal express checkout for third party merchants]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1379</guid>
		<description><![CDATA[This is a very simple one, but one that can take a lot of google-search-query-nuance tweaking to find. It&#8217;s easy to find the documentation to do PayPal Express Checkout, but to find that one little field where you send an alternate user as the recipient of the payments, well that&#8217;s downright impossible.  It is not [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very simple one, but one that can take a lot of google-search-query-nuance tweaking to find.</p>
<p>It&#8217;s easy to find the documentation to do PayPal Express Checkout, but to find that one little field where you send an alternate user as the recipient of the payments, well that&#8217;s downright impossible.  It is not in the docs (at least not as of this writing 5-18-2011).</p>
<p>How simple is it? Very &#8212; the variable is &#8220;SUBJECT&#8221;</p>
<p>Yes, you specify an alternate &#8220;SUBJECT&#8221; of the transaction.</p>
<p>Normally your SetExpressCheckout request looks something like:</p>
<pre>METHOD=&lt;method_name&gt;&amp;VERSION=&lt;version&gt;&amp;PWD=&lt;API_Password&gt;&amp;USER=&lt;API_UserName&gt;&amp;SIGNATURE=&lt;API_Signature&gt;&amp;...</pre>
<p>Now it will look like this:</p>
<pre>METHOD=&lt;method_name&gt;&amp;VERSION=&lt;version&gt;&amp;PWD=&lt;API_Password&gt;&amp;USER=&lt;API_UserName&gt;&amp;SIGNATURE=&lt;API_Signature&gt;&amp;SUBJECT=&lt;Payee_PayPal_Account&gt;...</pre>
<p>Payee_PayPal_Account is the email address/username the user uses to log in.</p>
<p>Hope this helps!  Took us valuable time to find &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2011/05/18/how-to-process-paypal-express-checkout-for-third-party-merchants/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nano global search and replace tabs to spaces or spaces to tabs</title>
		<link>http://www.crimulus.com/2011/05/17/nano-global-search-and-replace-tabs-to-spaces-or-spaces-to-tabs/</link>
		<comments>http://www.crimulus.com/2011/05/17/nano-global-search-and-replace-tabs-to-spaces-or-spaces-to-tabs/#comments</comments>
		<pubDate>Tue, 17 May 2011 12:39:06 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[linux text editors]]></category>
		<category><![CDATA[nano convert spaces to tabs]]></category>
		<category><![CDATA[nano convert tabs to spaces]]></category>
		<category><![CDATA[nano text editor]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1374</guid>
		<description><![CDATA[I have been an avid user of nano/pico since about 1999, and yes, many naysayers think it is crap for programming, but it works for me, and I like it. That being said, one of the major issues I&#8217;ve had is that the Xorg select/paste always copies tab characters as the corresponding number of spaces.  [...]]]></description>
			<content:encoded><![CDATA[<p>I have been an avid user of <a href="http://www.nano-editor.org/">nano</a>/pico since about 1999, and yes, many naysayers think it is crap for programming, but it works for me, and I like it.</p>
<p>That being said, one of the major issues I&#8217;ve had is that the Xorg select/paste always copies tab characters as the corresponding number of spaces.  So, when I select text in one file, paste into another, I have to replace all the spaces with tabs.</p>
<p>Typically I paste into <a href="http://projects.gnome.org/gedit/">gedit</a> first, do the replace there, then c/p into the file.  This preserves the tabs.</p>
<p>(If you&#8217;re still wondering why I use nano, I just like having my editor accessible as long as I have server access.  I never got used to vi, and nano is more than effective for me.)</p>
<p>I have always thought nano should be able to search and replace tabs and spaces, but I could never get it to work.  Even without the gedit technique, I would typically just replace all double spaces to nothing, then manually insert the tabs.  My workarounds, again, are generally sufficient.  I have not NEEDED search and replace of tabs within nano, but today I decided I wanted to really find out if I could.</p>
<p>And it required some digging &#8230;</p>
<p>But, I finally found it: verbatim input!</p>
<p>Nano has a feature to disable character interpretation, and for one character, accept input literally.</p>
<p>To turn it on (again it&#8217;s for just the first character typed), hit alt-SHIFT-V (alt-V without shift may trigger x-windows menus), then just hit the tab key (it may or may not show a note that you&#8217;re in verbatim input mode).</p>
<p>You only need to do this in the search / replace prompts.  Obviously, you can type tabs directly into the file.</p>
<p>So an example &#8212; let&#8217;s say you want to convert any instance of 8 spaces to a tab character.</p>
<p>Here is the command stack:</p>
<p>control-W (search)<br />
control-R (replace)<br />
hit space 8 times, then hit enter<br />
alt-shift-V (verbatim input)<br />
hit the tab key, hit enter</p>
<p>Proceed as normal.</p>
<p>Hopefully this post is easier to find than the seemingly impossible digging I just undertook &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2011/05/17/nano-global-search-and-replace-tabs-to-spaces-or-spaces-to-tabs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Linux BASH Script: Search current directory for files containing text</title>
		<link>http://www.crimulus.com/2010/12/29/linux-bash-script-search-current-directory-for-files-containing-text/</link>
		<comments>http://www.crimulus.com/2010/12/29/linux-bash-script-search-current-directory-for-files-containing-text/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 22:20:45 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[linux directory text search]]></category>
		<category><![CDATA[linux multi-file grep]]></category>
		<category><![CDATA[linux search all files for text]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1306</guid>
		<description><![CDATA[I have written a simple BASH script to scan the current directory for all files containing certain text. I use this all the time as I don&#8217;t know of a better Linux alternative, but it&#8217;s simple enough.  Just put save it as &#8220;/sbin/find-file-with&#8221; with executable permissions, and use it like so: find-file-with sometext If a [...]]]></description>
			<content:encoded><![CDATA[<p>I have written a simple BASH script to scan the current directory for all files containing certain text.</p>
<p>I use this all the time as I don&#8217;t know of a better Linux alternative, but it&#8217;s simple enough.  Just put save it as &#8220;/sbin/find-file-with&#8221; with executable permissions, and use it like so:</p>
<p><code>find-file-with sometext</code></p>
<p>If a matching file is found, it will print the full path of the file as well as the lines matching using grep (so the &#8220;some text&#8221; is passed directly into grep if you need help on how to vary your search)</p>
<p>Obviously some advancements can be performed, but without this script, I always just type (each time):</p>
<p><code>for I in `find ./*` ; do echo $I; cat $I | grep sometext; done</code></p>
<p>This script just keeps me from filling the screen with directory errors and unmatching files.</p>
<p>As a side note, if you want to include quotes (as in grep &#8220;some text&#8221;), you need to escape them:</p>
<p><code>find-file-with \"some text\"</code></p>
<p>Hope others find it useful &#8230; but the main reason it is here is so I have an online backup.  <img src='http://www.crimulus.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<pre><code>#!/bin/sh
echo "";
for I in `find ./*` ; do
        if [ ! -d "$I" ] ; then
                if [ -e "$I" ] ; then
                        CMD="cat $I | grep $* | wc -c";
                        C=`eval $CMD`
                        if [ $C -gt 0 ] ; then
                                </code>echo "\033[1m[ "$I" ]\033[0m"
<code>                                cat $I | grep $* -n --color=auto;</code><code>
                                echo ""</code>
<code>                        fi;
                fi;
        fi;
done;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/12/29/linux-bash-script-search-current-directory-for-files-containing-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3 Multisite and Base URL Forwarding (www subdomain requirements)</title>
		<link>http://www.crimulus.com/2010/12/29/wordpress-3-multisite-and-base-url-forwarding-www-subdomain-requirements/</link>
		<comments>http://www.crimulus.com/2010/12/29/wordpress-3-multisite-and-base-url-forwarding-www-subdomain-requirements/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 22:11:47 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[avoid redirection to wp-signup.php]]></category>
		<category><![CDATA[subdomain redirection in wordpress]]></category>
		<category><![CDATA[wordpress 3 multisite]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1301</guid>
		<description><![CDATA[One of the annoying quirks about WordPress 3 multisite is that it does not properly redirect or display when users connect to your domain without using the &#8220;www.&#8221; subdomain.  At least, this is the case for me as I&#8217;m using a &#8220;hack&#8221; to use multiple domains in the multisite install. This post is more for [...]]]></description>
			<content:encoded><![CDATA[<p>One of the annoying quirks about WordPress 3 multisite is that it does not properly redirect or display when users connect to your domain without using the &#8220;www.&#8221; subdomain.  At least, this is the case for me as I&#8217;m using a &#8220;hack&#8221; to use multiple domains in the multisite install.</p>
<p>This post is more for my own future reference, because seriously, what keywords would anyone use to find this?  Anyway, the solution is just to edit this file:</p>
<p><code>/wp-includes/ms-settings.php</code></p>
<p>Find the if clause containing &#8220;wp-signup.php&#8221; &#8212; the phrase only exists in the file in one place, so just do a text search.</p>
<p>It is actually nested in two if clauses.</p>
<p>Simply change:</p>
<p><code>if (defined('NOBLOGREDIRECT')) {</code></p>
<p>to</p>
<p><code>if ($_SERVER['SERVER_NAME'] == "mydomain.com") {<br />
$destination = 'http://www.mydomain.com'.$_SERVER['REQUEST_URI'];<br />
} else if (defined('NOBLOGREDIRECT')) {</code></p>
<p>You can obviously do other variations if you need more advanced redirection, but this is where the magic happens.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/12/29/wordpress-3-multisite-and-base-url-forwarding-www-subdomain-requirements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Linux SSH to Remote Server, execute a command and stay logged in</title>
		<link>http://www.crimulus.com/2010/12/14/howto-linux-ssh-to-remote-server-execute-a-command-and-stay-logged-in/</link>
		<comments>http://www.crimulus.com/2010/12/14/howto-linux-ssh-to-remote-server-execute-a-command-and-stay-logged-in/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 17:10:52 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[remote ssh commands]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh execute command and stay logged in]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1289</guid>
		<description><![CDATA[One of the shortcuts I always keep in my gnome taskbar is a link to a gnome-terminal with 3 tabs, each in the websites base directory of my web development server. It took my quite a long time to figure out how to get it to change to that directory then stay logged in, even [...]]]></description>
			<content:encoded><![CDATA[<p>One of the shortcuts I always keep in my gnome taskbar is a link to a  gnome-terminal with 3 tabs, each in the websites base directory of my  web development server.</p>
<p>It took my quite a long time to figure out  how to get it to change to that directory then stay logged in, even  though it is rather simple.  It also took my a long time again recently  because I reinstalled without backing that up.  So, this post is mainly  so I don&#8217;t have to do that again, but maybe it will help others too.</p>
<p>The  trick is to make SSH behave like a terminal (with the oft-overlooked -t  flag), then to execute a login bash shell using normal SSH command  execution.</p>
<p>So:</p>
<p>ssh -t &#8216;cd /path/to/go/to; bash -l&#8217;</p>
<p>So for me, my shortcut in the gnome taskbar is</p>
<p>gnome-terminal &#8211;tab -e &#8220;ssh -t &#8216;cd /path; bash -l&#8217;&#8221; &#8211;tab -e &#8220;ssh -t &#8216;cd /path; bash -l&#8217;&#8221; &#8211;tab -e &#8220;ssh -t &#8216;cd /path; bash -l&#8217;&#8221;</p>
<p>There &#8212; saved myself (and you) some time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/12/14/howto-linux-ssh-to-remote-server-execute-a-command-and-stay-logged-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3 Auto-Update &amp; Unable To Create Directory wp-content/upgrade/wordpress-3.tmp</title>
		<link>http://www.crimulus.com/2010/12/06/wordpress-3-auto-update-unable-to-create-directory-wp-contentupgradewordpress-3-tmp/</link>
		<comments>http://www.crimulus.com/2010/12/06/wordpress-3-auto-update-unable-to-create-directory-wp-contentupgradewordpress-3-tmp/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 16:09:53 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[wordpress ftp upgrade fails]]></category>
		<category><![CDATA[Wordpress VSFTP unable to create directory wp-content upgrade wordpress-3.tmp]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1283</guid>
		<description><![CDATA[Many, many, many users have apparently been experiencing an issue with this in WordPress &#8212; for some reason their auto update doesn&#8217;t work anymore.  I use the word &#8220;anymore,&#8221; because, for some users, it never worked.  For you, the solution is this: change permissions on the &#60;install-dir&#62;/wp-content/upgrade/ directory to 777 (only that directory for very [...]]]></description>
			<content:encoded><![CDATA[<p>Many, many, many users have apparently been experiencing an issue with this in WordPress &#8212; for some reason their auto update doesn&#8217;t work anymore.  I use the word &#8220;anymore,&#8221; because, for some users, it never worked.  For you, the solution is this: change permissions on the &lt;install-dir&gt;/wp-content/upgrade/ directory to 777 (only that directory for very obvious security reasons).</p>
<p>For users like me, however, there is an equally stupid result, and that is that VSFTP apparently disabled all FTP write commands in new versions.  Are you running VSFTP and using FTP to do your WordPress upgrades?</p>
<p>Well just edit your /etc/vsftpd.conf (exact location may vary by distro) and uncomment the line:</p>
<p>#write_enable=YES</p>
<p>(Just remove the #, save, and restart VSFTP.)</p>
<p>This worked for me, and I just figured it out on my own.  Stupid, yes, but for those of use who have become search-engine-instant-success-addicts, impossible to find.  Hopefully not so for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/12/06/wordpress-3-auto-update-unable-to-create-directory-wp-contentupgradewordpress-3-tmp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The mathematical effectiveness of salt and hash (using sha1)</title>
		<link>http://www.crimulus.com/2010/09/30/the-effectiveness-of-salting-a-sha1-hash-then-storing-it-as-a-sha1-hash/</link>
		<comments>http://www.crimulus.com/2010/09/30/the-effectiveness-of-salting-a-sha1-hash-then-storing-it-as-a-sha1-hash/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 14:35:52 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Computer security]]></category>
		<category><![CDATA[Cryptographic hash functions]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Hash function]]></category>
		<category><![CDATA[internet security]]></category>
		<category><![CDATA[novemdecillion]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[Password cracking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[quindecillion]]></category>
		<category><![CDATA[Rainbow table]]></category>
		<category><![CDATA[Salt]]></category>
		<category><![CDATA[SHA hash functions]]></category>
		<category><![CDATA[sha1 encryption]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1235</guid>
		<description><![CDATA[I have been heavily researching password storage lately, because I believe there are still lapses in internet security that keep it far behind what hackers are able to achieve, and, as a programmer, I want to keep such things as lock-tight as possible. It, shamefully, just clicked with me the power of rainbow tables (for [...]]]></description>
			<content:encoded><![CDATA[<p>I have been heavily researching password storage lately, because I believe there are still lapses in internet security that keep it far behind what hackers are able to achieve, and, as a programmer, I want to keep such things as lock-tight as possible.</p>
<p>It, shamefully, just clicked with me the power of rainbow tables (for which I only learned the term in the last few days).  For some background, any legitimate website or authentication system does not store your password in plain text.  It uses a one-way encryption and stores that encryption.  Then to check if you used the right password, it encrypts the one you send it and compares it against the stored encryption.  This minimizes opportunities for a copy of your password to be easily accessible, decryptable, or readable, in any sense to someone who want to use it for malfeasance.</p>
<p>The trick with all one-way encryptions used for such &#8220;hashing&#8221; purposes is their resulting strings are fixed length.  For example, sha1, which is probably the most widely used method on the web, creates <span style="text-decoration: line-through;">alphanumeric (0-9, a-z not case sensitive)</span> hexadecimal strings of length 40 (at least using the php sha1() method with which I am familiar &#8212; I&#8217;m not a sha1 expert).  Because of this, there are possible collisions.  In other words, although your password might encrypt to one string, there are effectively infinite other strings that would encrypt to that same string.</p>
<p>Before getting too uptight about this, just do the basic numbers.  The sha1 encryption creates 40 character strings with <span style="text-decoration: line-through;">36</span> 16 possible characters in each place, meaning there are <span style="text-decoration: line-through;">36^40</span> 16^40 possible resulting encryptions.  That number?</p>
<p><span style="text-decoration: line-through;">178,689,910,246,017,054,531,432,477,289,437,798,228,285,773,001,601,743,140,683,776<br />
</span>1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,976</p>
<p>Is there even a word for that?  Yes &#8230; <span style="text-decoration: line-through;">178.69 novemdecillion</span> 1.46 quindecillion.  (that is a big number)</p>
<p>So a hacker would build the corresponding rainbow table by finding exactly 1 string that converts to each of those <span style="text-decoration: line-through;">178,689</span> 1,461,501 &#8230; hashes.  Then, somehow, they get your encrypted password, and all they have to do is look it up in this table, and they have your password (or at least one that collides with yours&#8217; hash).</p>
<p>It is very simple, but, fortunately, at this point, that rainbow table would not fit on all the hard drives in the world.  In fact, <span style="text-decoration: line-through;">it would take about 50 billion earths to find an equivalent number of <em>atoms</em></span> the earth is only composed of about 133 quindecillion <em>atoms</em>. (That&#8217;s one hash per 89 atoms &#8212; a human hair is about 10000 atoms thick).</p>
<p>But let&#8217;s abandon the seeming impossibility of the existence of this table temporarily.  A common practice in secure storage of passwords these days is to &#8220;salt&#8221; the password before hashing and storing it.  That is, you take the password, prepend (or append) a random string, then encrypt the resulting string.  (More complex salts can exist, but the idea is that you modify the password in a predictable, repeatable way).  What this does is force a hacker to build a corresponding rainbow table for EVERY password he/she wants to hack, because the unsalted rainbow table won&#8217;t work (I&#8217;ll leave this to you to figure out why if you don&#8217;t know at this point.)</p>
<p>The problem is, if you&#8217;re still using sha1 to encrypt the salted password, it&#8217;s no different than if you didn&#8217;t salt the password.  If this complete sha1 rainbow table DID exist, the salt would serve absolutely no purpose, it would just shift the collision.  Some infinite subset of strings would still map to this encrypted string.</p>
<p>As a side note, the rainbow tables that exist are simply compilations of common types of passwords, and, in many instances, they work, because people just don&#8217;t use strong enough passwords.  This reduces the size of the tables to a usable form, so, in this case, the salting is imperative.  I am discussing today the case where a complete sha1 rainbow table exists.  I have said that it is pretty much impossible, but, from a purely theoretical standpoint, eventually, even the number <span style="text-decoration: line-through;">178.69 novemdecillion</span> 1.46 quindecillion will become small as technology improves with time.</p>
<p>By the way, &#8220;strong,&#8221; for all intents and purposes of one-way hashing, just means  long.  Knowing a password is short drastically decreases the number of  hashes that need to be generated for the table.  Good advice? Use  passwords 20 characters or longer &#8212; i.e. a sentence &#8220;This is my  password, baby. Nothing personal, but don&#8217;t steal it.&#8221;</p>
<p>My question is, is it really effective to use the same encryption mechanism after you salt the password?  Salting is little more than an obfuscation in the presence of a complete rainbow table.  In the face of the assumed existence of this rainbow table, and ignoring that most passwords aren&#8217;t truly &#8220;random,&#8221; there is exactly no difference between &#8220;salt and hash&#8221; and simply &#8220;hash.&#8221; This just leads me to the conclusion that the inherent flaw in one way hashes is that they create strings of finite length, but that is exactly why they are useful.</p>
<p>Perhaps the only purpose of this post was to legitimately use the word <span style="text-decoration: line-through;">novemdecillion</span> quindecillion more than once.  I dunno, but I would certainly appreciate expert commentary on the topic.</p>
<p><em>Edit: After initially writing this, I realized that sha1 created hex strings, not alphanumeric.  This changed the numbers, but fortunately not the article.  I decided to leave the old numbers in strikethrough because, well, novemdecillion is a cool freaking word.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/09/30/the-effectiveness-of-salting-a-sha1-hash-then-storing-it-as-a-sha1-hash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Howto: Enable PCNTL in Ubuntu PHP installations</title>
		<link>http://www.crimulus.com/2010/07/30/howto-enable-pcntl-in-ubuntu-php-installations/</link>
		<comments>http://www.crimulus.com/2010/07/30/howto-enable-pcntl-in-ubuntu-php-installations/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 17:51:40 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pcntl]]></category>
		<category><![CDATA[pcntl on ubuntu]]></category>
		<category><![CDATA[pcntl_fork php5 ubuntu]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ubuntu lamp pcntl_fork]]></category>

		<guid isPermaLink="false">http://www.crimulus.com/?p=1203</guid>
		<description><![CDATA[PCNTL in PHP allows for some handy advanced &#8220;trickery&#8221; using the OS process functions inherent in Linux (*nix?).  I believe some features are available in Windows, but I know for certain that pcntl_fork() is not. Anyway, it is not enabled by default, so if you want to take advantage of the functions on your Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>PCNTL in PHP allows for some handy advanced &#8220;trickery&#8221; using the OS process functions inherent in Linux (*nix?).  I believe some features are available in Windows, but I know for certain that <a href="http://php.net/manual/en/function.pcntl-fork.php">pcntl_fork()</a> is not.</p>
<p>Anyway, it is not enabled by default, so if you want to take advantage of the functions on your Ubuntu LAMP server, you might spend hours searching the web for that magic aptitude command.  But, as far as I can tell, it doesn&#8217;t exist.</p>
<p>Luckily, I stumbled across <a href="http://ubuntuforums.org/showthread.php?t=549953">this article</a> on the Ubuntu forums, so I&#8217;m dedicating a post here with the hopes that other will find it more easily.</p>
<p>Please note that you&#8217;ll probably need build-essentials and a few other source compilation basics, but as long as you have that, the following code will get you what you want.</p>
<p>First, in your home directory:</p>
<pre dir="ltr">mkdir php
cd php
apt-get source php5
cd php5-(WHATEVER_RELEASE)/ext/pcntl
phpize
./configure
make
</pre>
<p>Then:</p>
<pre>cp modules/pcntl.so /usr/lib/php5/WHEVER_YOUR_SO_FILES_ARE/
echo "extension=pcntl.so" &gt; /etc/php5/conf.d/pcntl.ini
</pre>
<p>FYI: &#8220;make install&#8221; does not appear to put the files in the correct place.</p>
<p>Btw, please direct any thanks/praise to <a href="http://ubuntuforums.org/member.php?s=d1752fb7a07c097ec02e7c427ffb22ad&amp;u=117773">skout23</a> on the <a href="http://ubuntuforums.org/showpost.php?s=d1752fb7a07c097ec02e7c427ffb22ad&amp;p=5365169&amp;postcount=2">Ubuntu forums</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crimulus.com/2010/07/30/howto-enable-pcntl-in-ubuntu-php-installations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

