<?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>VerySimple &#187; *NIX</title>
	<atom:link href="http://verysimple.com/category/operating-systems/nix/feed/" rel="self" type="application/rss+xml" />
	<link>http://verysimple.com</link>
	<description>Custom Software</description>
	<lastBuildDate>Tue, 15 May 2012 07:40:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Your connection had to be retried using SSL 3.0 &#8211; Apache 2 SSL Certificate Configuration</title>
		<link>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/</link>
		<comments>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 04:45:33 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://verysimple.com/?p=1202</guid>
		<description><![CDATA[When viewing your SSL certification details in Chrome you may notice an annoying yellow warning icon with the error message &#8220;Your connection had to be retried using SSL 3.0 This typically means the server is using very old software and may have other security issues&#8221; This warning technically doesn&#8217;t affect or hurt anything but of [...]]]></description>
			<content:encoded><![CDATA[<p>When viewing your SSL certification details in Chrome you may notice an annoying yellow warning icon with the error message &#8220;Your connection had to be retried using SSL 3.0 This typically means the server is using very old software and may have other security issues&#8221;</p>
<p>This warning technically doesn&#8217;t affect or hurt anything but of course after paying for the SSL cert and going through the trouble of installing it, we all want our users to see the green lock icon and not a yellow warning icon!  If you&#8217;re running Apache2 the reason for this is that Chrome prefers to use TLS encryption but had to fall back to SSL encryption.  Apache2 supports TLS out of the box but may not be enabled by default.</p>
<p>To enable TLS, open your apache configuration file and add the two lines below:  (The config file is where you previously configured SSLCertificateFile and SSLCertificateKeyFile.  It&#8217;s possibly located in /etc/apache2/sites-enabled)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SSLProtocol <span style="color: #660033;">-all</span> +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:<span style="color: #000000; font-weight: bold;">!</span>aNULL:+SHA1:+MD5:+HIGH:+MEDIUM</pre></div></div>

<p>What these lines do is specify that both TLS version 1 and SSL version 3 are supported.  Once you&#8217;ve added these lines you need to restart Apache (/etc/init.d/apache2 restart).</p>
<p>If you refresh your browser at this point it&#8217;s likely that the warning icon is still there.   Shutting down and re-starting your browser should resolve it.  I suspect that the browser negotiates an SSL connection once and continues to use it until the session expires or the browser is restarted.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Connect to VNC over SSH</title>
		<link>http://verysimple.com/2011/03/27/connect-to-vnc-over-ssh/</link>
		<comments>http://verysimple.com/2011/03/27/connect-to-vnc-over-ssh/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 03:07:11 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Digital Life]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://verysimple.com/?p=861</guid>
		<description><![CDATA[Connecting to your VNC server over SSH is easily done and you most likely don&#8217;t need any special software to do so. Any system that has SSH installed can connect using an SSH Tunnel. I go into more detail about the concept on a separate post about mounting OSX AFS shares over SSH. First you [...]]]></description>
			<content:encoded><![CDATA[<p>Connecting to your VNC server over SSH is easily done and you most likely don&#8217;t need any special software to do so.  Any system that has SSH installed can connect using an SSH Tunnel.  I go into more detail about the concept on a separate post about <a href="http://verysimple.com/2008/03/09/mount-an-osx-afs-shared-drive-over-ssh/">mounting OSX AFS shares over SSH</a>.</p>
<p>First you need to have a server that is running VNC, but most likely only has it&#8217;s SSH port exposed.  I&#8217;ll assume that SSH is on port 22 and VNC is on port 5900 (these are the default ports for these services).  I&#8217;ll also assume that you have the ssh command and a VNC client installed on your client machine.</p>
<p><span id="more-861"></span>1. On your client machine, open a command line window and enter the following to create the SSH tunnel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-N</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">22</span> USERNAME<span style="color: #000000; font-weight: bold;">@</span>YOURSERVER <span style="color: #660033;">-L</span> <span style="color: #000000;">5901</span><span style="color: #000000; font-weight: bold;">/</span>localhost<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5900</span></pre></div></div>

<p><em>Replace USERNAME with your server username, and replace YOURSERVER with your server address (ie verysimple.com or 192.168.1.99)</em></p>
<p>2. Once you enter this command you&#8217;ll be prompted for the server password.  Enter the password.  You will see no feedback in the terminal window, but the SSH tunnel is now active.</p>
<p>3. Open your VNC client and connect to the address &#8220;localhost:5901&#8243;  If you have a password set for VNC access then you will need to enter that now.  If all goes well, you should see your server VNC desktop!</p>
<p>It might seem weird that you are connecting to localhost in your VNC client.  But the the SSH tunnel you created is actually routing port 5901 on your localhost to port 5900 on your server.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2011/03/27/connect-to-vnc-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP on OSX: Can&#039;t connect to local MySQL server through socket &#039;/var/mysql/mysql.sock&#039;</title>
		<link>http://verysimple.com/2009/01/07/php-on-os-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/</link>
		<comments>http://verysimple.com/2009/01/07/php-on-os-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 21:59:29 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/2009/01/07/osx-php-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/</guid>
		<description><![CDATA[When installing PHP and MySQL on OSX  you may get the error Can&#8217;t connect to local MySQL server through socket &#8216;/var/mysql/mysql.sock&#8217;.  Or you may also get &#8220;No such file or directory&#8221; when calling mysql_connect from a PHP page.  This occurs because PHP is looking for the file mysql.sock in it&#8217;s typical installation location of /var/mysql/mysql.sock. [...]]]></description>
			<content:encoded><![CDATA[<p>When installing PHP and MySQL on OSX  you may get the error <em>Can&#8217;t connect to local MySQL server through socket &#8216;/var/mysql/mysql.sock&#8217;</em>.   Or you may also get &#8220;<em>No such file or directory</em>&#8221; when calling mysql_connect from a PHP page.  This occurs because PHP is looking for the file mysql.sock in it&#8217;s typical installation location of /var/mysql/mysql.sock.  However the MySQL OSX installer actually puts the file in /tmp/mysql.sock.  There are two easy ways to solve the problem.</p>
<p><span id="more-266"></span></p>
<p><strong>Solution 1: Create a symbolic link</strong></p>
<p>Open terminal and do the following:</p>
<p>sudo su<br />
mkdir /var/mysql<br />
ln -s /tmp/mysql.sock /var/mysql/mysql.sock</p>
<p>You just created a symbolic link in the place where PHP expects the socket file to be located so it should be happy.</p>
<p><strong>Solution 2: Edit php.ini</strong></p>
<p>If you don&#8217;t like the idea of creating a symbolic link, you can also simply alter your php.ini file to point PHP to the real location of mysql.sock.</p>
<p>Locate /etc/php.ini.  (If php.ini doesn&#8217;t exist on your system, copy /etc/php.ini.default to /etc/php.ini).  You will likely have to do this from the terminal unless you have Finder configured to show hidden files.  Open the file and update the setting mysql.default_socket so it looks like this:</p>
<p>mysql.default_socket = /tmp/mysql.sock</p>
<p>To commit the change you need to restart Apache.  You can do that in System Settings -&gt; Sharing, then  uncheck, then recheck Web Sharing.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2009/01/07/php-on-os-cant-connect-to-local-mysql-server-through-socket-varmysqlmysqlsock/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Binding Flex TextInput UI Controls to a DataProvider</title>
		<link>http://verysimple.com/2008/09/16/binding-flex-textinput-ui-controls-to-a-dataprovider/</link>
		<comments>http://verysimple.com/2008/09/16/binding-flex-textinput-ui-controls-to-a-dataprovider/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 22:33:25 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=219</guid>
		<description><![CDATA[In Flex when you bind data to a UI control like a DataGrid, the grid cells refresh every time the dataSource changes. The reverse is also true if the DataGrid is enabled for editing. That is, the dataSource is also updated when you edit a cell. The TextInput can be bound as well so that [...]]]></description>
			<content:encoded><![CDATA[<p>In Flex when you bind data to a UI control like a DataGrid, the grid cells refresh every time the dataSource changes.  The reverse is also true if the DataGrid is enabled for editing.  That is, the dataSource is also updated when you edit a cell.</p>
<p>The TextInput can be bound as well so that when the dataSource changes, the value of the TextInput will automatically update.  However, unlike the DataGrid, changing the text of the TextInput will not automatically update the dataSource.  Take the following code for example (assuming &#8220;source&#8221; is a String variable):</p>

<div class="wp_syntax"><div class="code"><pre class="as3" style="font-family:monospace;">&lt;mx:TextInput id=&quot;text1&quot; text=&quot;{source}&quot; change=&quot;{source= text1.text}&quot; /&gt;</pre></div></div>

<p>When the TextInput is changed, the value of <em>source</em> remains the same.  It&#8217;s only bound one-way.  If you want the value of <em>source</em> to be updated when TextInput changes, it&#8217;s actually easy, but there are at least five (5) different ways to do it of which I know.  For the most straight-forward two-way binding, you could update the TextInput code like so:</p>
<p>Technically <em>source</em> is not bound to the TextInput, but it does produce the desired result.  <em>source</em> is updated manually whenever the valueCommit event fires.  The <strong>valueCommit</strong> event fires when the TextInput text has been changed <em>onBlur</em> (ie when when TextInput loses focus).  If you prefer source to be updated on every key stroke, you can change <strong>valueCommit</strong> to <strong>change</strong> instead and the update will occur on every <em>keyUp</em>.  If I&#8217;m updating a database or making a service call, I prefer valueCommit so the back-end code only fires once after the user is finished updating the field.  If the TextInput is an ajax-style auto complete or lookup, the change event might be more desirable so the application can react after each key stroke.</p>
<p>As I mentioned there are five methods to do this.  You can bind controls using Flex&#8217;s binding features in either MX code or ActionScript.  Depending on your application one may be better than the rest as far as keeping your code clean and consistent.  For the most part they all achieve the same result.  Below is source code that demonstrates all five techniques:</p>

<div class="wp_syntax"><div class="code"><pre class="as3" style="font-family:monospace;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:WindowedApplication xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot; creationComplete=&quot;{init()}&quot;&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.binding.utils.BindingUtils;
			import mx.binding.utils.ChangeWatcher;
&nbsp;
			/**
			 * Called at creation complete and initializes all of the examples
			 */
			private function init():void
			{
				this.initExample2();
				this.initExample3();
				this.initExample4();
				this.initExample5();
			}
&nbsp;
			/**
			 * Example 1: simple inline binding (see the MXML)
			 * -----------------------------------------------------------------------
			 */
&nbsp;
			[Bindable]
			private var value1:String = &quot;example 1&quot;;
&nbsp;
			/**
			 * Example 2: use ChangeWatcher to assign a change watcher to text2.text
			 * -----------------------------------------------------------------------
			 */
&nbsp;
			[Bindable]
			public var value2:String = &quot;example 2&quot;;
&nbsp;
			private var watcher2:ChangeWatcher;
&nbsp;
			public function initExample2():void
			{
				watcher2 = ChangeWatcher.watch(text2,&quot;text&quot;,text2changed);
			}
&nbsp;
			/**
			 * notice that the argument is an event
			 */
			public function text2changed(event:Event):void
			{
				this.value2 = (event.currentTarget as TextInput).text;
			}
&nbsp;
			/**
			 * Example 3: use BindingUtils to bind a change watcher to the text3.text setter
			 * -----------------------------------------------------------------------
			 */
&nbsp;
			[Bindable]
			private var value3:String = &quot;example 3&quot;;
&nbsp;
			private var watcher3:ChangeWatcher;
&nbsp;
			public function initExample3():void
			{
				watcher3 = BindingUtils.bindSetter(text3changed,text3,&quot;text&quot;);
			}
&nbsp;
			/**
			 * notice that the function argument is a string (the value of text3.text)
			 */
			public function text3changed(val:String):void
			{
				this.value3 = val;
			}
&nbsp;
			/**
			 * Example 4: Use BindingUtils to bind text4.text to this.value4 (notice value4 has to be public)
			 * -----------------------------------------------------------------------
			 */
&nbsp;
			[Bindable]
			public var value4:String = &quot;example 4&quot;;
&nbsp;
			private var watcher4:ChangeWatcher;
&nbsp;
			public function initExample4():void
			{
				watcher4 = BindingUtils.bindProperty(this, &quot;value4&quot;, text4, &quot;text&quot;);
			}
&nbsp;
			/**
			 * Example 5: using MX:Binding in the MXML (see below)
			 * -----------------------------------------------------------------------
			 */
&nbsp;
			[Bindable]
			private var value5:String = &quot;example 5&quot;;
&nbsp;
			public function initExample5():void
			{
				text5.text = this.value5;
			}
&nbsp;
		]]&gt;
	&lt;/mx:Script&gt;
&nbsp;
	&lt;mx:HBox&gt;
		&lt;mx:TextInput id=&quot;text1&quot; text=&quot;{this.value1}&quot; change=&quot;{this.value1 = text1.text}&quot; /&gt;
		&lt;mx:Label id=&quot;label1&quot; text=&quot;{this.value1}&quot; /&gt;
	&lt;/mx:HBox&gt;
&nbsp;
	&lt;mx:HBox&gt;
		&lt;mx:TextInput id=&quot;text2&quot; text=&quot;{this.value2}&quot; /&gt;
		&lt;mx:Label id=&quot;label2&quot; text=&quot;{this.value2}&quot; /&gt;
	&lt;/mx:HBox&gt;
&nbsp;
	&lt;mx:HBox&gt;
		&lt;mx:TextInput id=&quot;text3&quot; text=&quot;{this.value3}&quot; /&gt;
		&lt;mx:Label id=&quot;label3&quot; text=&quot;{this.value3}&quot; /&gt;
	&lt;/mx:HBox&gt;
&nbsp;
	&lt;mx:HBox&gt;
		&lt;mx:TextInput id=&quot;text4&quot; text=&quot;{this.value4}&quot; /&gt;
		&lt;mx:Label id=&quot;label4&quot; text=&quot;{this.value4}&quot; /&gt;
	&lt;/mx:HBox&gt;
&nbsp;
	&lt;mx:HBox&gt;
		&lt;mx:TextInput id=&quot;text5&quot; /&gt;
		&lt;mx:Label id=&quot;label5&quot; text=&quot;{this.value5}&quot; /&gt;
	&lt;/mx:HBox&gt;
&nbsp;
	&lt;!-- Configure the binding here in MXML --&gt;
	&lt;mx:Binding source=&quot;text5.text&quot; destination=&quot;this.value5&quot; /&gt;
&nbsp;
&lt;/mx:WindowedApplication&gt;</pre></div></div>

<p>If you know of any other ways to bind data to UI Controls, please post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2008/09/16/binding-flex-textinput-ui-controls-to-a-dataprovider/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Using WGET to automate web-based applications</title>
		<link>http://verysimple.com/2007/08/22/using-wget-to-automate-web-based-applications/</link>
		<comments>http://verysimple.com/2007/08/22/using-wget-to-automate-web-based-applications/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 21:19:54 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/2007/08/22/using-wget-to-automate-web-based-applications/</guid>
		<description><![CDATA[wget in combination with cron is a useful utility for automating processes in a web application. It&#8217;s possible to run most scripting languages from the command line, but sometimes it&#8217;s tricky to get those to run correctly when they don&#8217;t have the server context. One simple way to achieve this is to write your automation [...]]]></description>
			<content:encoded><![CDATA[<p>wget in combination with cron is a useful utility for automating processes in a web application. It&#8217;s possible to run most scripting languages from the command line, but sometimes it&#8217;s tricky to get those to run correctly when they don&#8217;t have the server context.</p>
<p>One simple way to achieve this is to write your automation functions as a regular web-based page within the app and then use wget to post a web request to that URL.  You can use cron to schedule the frequency.</p>
<p>wget is fairly simple to use, however one thing that is difficult to find in the documentation is how to get the contents of the document and append them to a file.  The normal behavior is to just download the file and save it with it&#8217;s original name.   You can remedy this by specifying a dash &#8220;-&#8221; as the output filename, which tells wget to output the document to the console.  the &#8211;quiet parameter tells wget not to output a bunch of connection info.  Finally, we redirect the console output to append to a file using &gt;&gt; at the end.  The resulting statement looks something like this:</p>
<pre>wget --quiet --output-document=- http://localhost/auto.php?arg=123 &gt;&gt; /path/to/file.log</pre>
<p>Depending on your server configuration you may need to put quotes around your URL as well, like so:</p>
<pre>wget --quiet --output-document=- "http://localhost/auto.php?arg=123" &gt;&gt; /path/to/file.log</pre>
<p>If you are attempting to connect to a secure URL (beginning with &#8220;https&#8221;), you may also need to add the &#8220;&#8211;no-check-certificate&#8221; option to the command in which case your command would like like so:</p>
<pre>wget --quiet --no-check-certificate --output-document=- "https://localhost/auto.php?arg=123" &gt;&gt; /path/to/file.log</pre>
<p>If you have your automation script output debug information, then your log file will contain useful information.  As an example, I like to output the date and time that the script runs and then any info about failures that may have occurred.</p>
<p>One note about security &#8211; if you don&#8217;t want people poking around and firing off your automation and/or viewing your debug information, you should implement some type of security, such as a simple username/password arguments or something more robust if required.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2007/08/22/using-wget-to-automate-web-based-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Common UNIX Commands for Web Developers</title>
		<link>http://verysimple.com/2006/03/30/common-unix-commands-for-webmasters/</link>
		<comments>http://verysimple.com/2006/03/30/common-unix-commands-for-webmasters/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=5</guid>
		<description><![CDATA[Below are various examples of UNIX commands that I&#8217;ve found helpful when modifying web sites, configuration files and viewing log files on a server. Most UNIX commands have many options and parameters which I have not listed here. Instead I have given examples of practical uses. For more complete information on most command, you can [...]]]></description>
			<content:encoded><![CDATA[<p>Below are various examples of UNIX commands that I&#8217;ve found helpful when modifying web sites, configuration files and viewing log files on a server. Most UNIX commands have many options and parameters which I have not listed here. Instead I have given examples of practical uses. For more complete information on most command, you can refer to the online manual by typing man [command] at the UNIX prompt. Some commands you can type [command] &#8211;help or [command] -?</p>
<p><em>Note, when I specify something in brackets like so: [filename] that is to indicate that you type in a filename or whatever. Do not include the brackets in your command.</em></p>
<h2><strong>Navigating UNIX:</strong></h2>
<ul>
<li>/    (refers to the root directory on the server)</li>
<li>./   (the current directory that you are in)</li>
<li>../  (parent directory of your current directory)</li>
<li>pwd (shows what you current directory is &#8211; giving the full path)</li>
<li>ls                    (lists all the files in your current directory)</li>
<li>ls -al                (lists filenames + information)</li>
<li>ls -alR               (lists filenames + information in all subdirectories)</li>
<li>ls -alR | more        (lists filenames + information in all subdirectories,</li>
<li>pausing when the screen become full)</li>
<li>ls -alR &gt; result.txt  (lists filenames + information in all subdirectories,</li>
<li>and ouputs the results to a file instead of the screen)</li>
<li>ls *.html             (lists all files ending with .html)</li>
<li>ls -al /home/usr/bob/ (lists files + info for /home/usr/bob)</li>
<li>cd                    (changes you to a new directory)</li>
<li>cd images</li>
<li>cd /                  (changes you to the root directory)</li>
<li>cd /home/usr/images</li>
<li>cd ..                 (this goes back one directory)</li>
</ul>
<p><strong>Moving, Copying and Deleting Files:</strong></p>
<ul>
<li>mv [old name] [new name]      (move/rename a file)</li>
<li>cp [filename] [new filename]  (copy a file)</li>
<li>rm [filename]                 (delete a file)</li>
<li>rm *                          (delete all files in your current directory)</li>
<li>rm *.html                     (delete all files ending in .html in your current directory)</li>
</ul>
<h2>Creating, Moving, Copying and Deleting Directories:</h2>
<ul>
<li>mkdir [directoryname]           (creates a new directory)</li>
<li>ls -d */                        (lists all directories within current directory)</li>
<li>cp -r [directoryname] [new directoryname] (copy a directory and all</li>
<li>files/directories in it)</li>
<li>rmdir [directoryname]           (remove a directory if it is empty)</li>
<li>rm -r [directoryname]           (remove a directory and all files in it)</li>
</ul>
<h2>Searching Files and Directories</h2>
<ul>
<li>find / -name [filename] -print (search the whole server for a file)</li>
<li>find . -name [filename] -print (search for a file starting with the current directory)</li>
<li>find / -name [directoryname] &#8211; type d -print (search the whole server for a direcory)</li>
<li>grep [text] [filename]         (search for text within a file)</li>
<li>sed s/[oldtext]/[newtext]/g [filename]  (searches file and replaces all occurances of [oldtext] with [newtext]</li>
</ul>
<h2>Viewing and Editing Files:</h2>
<ul>
<li>tail [filename]  &#8211; view the tail end of a file, useful for checking the error log when debugging a script</li>
<li>vi [filename]  &#8211; opens a file using the vi text editor.  you are a true geek if you use vi, however it&#8217;s fairly easy to use.  (refer to the vi primer in this support forum)</li>
</ul>
<h2>Installing Software &amp; Scripts</h2>
<h2><span style="font-weight: normal; font-size: 13px;"><em>For downloaded &#8216;tar&#8217; scripts, to un-tar and un-gz</em></span></h2>
<ul>
<li>tar -xvf [archive.tar] &#8211; extracts files from the tar archive &#8216;archive.tar&#8217;</li>
<li>tar -zxvf [archive.tar.gz] extracts files from the tar archive &#8216;archive.tar.gz&#8217;</li>
</ul>
<h2>Getting Server Information</h2>
<ul>
<li>which (displays path to an executable, ex which perl, which php)</li>
<li>whoami &#8211; displays your current username</li>
<li>uptime &#8211; displays how long the server has been up and some performance statistics</li>
</ul>
<h3>Viewing disk space</h3>
<ul>
<li>du (to view disk usage on server)</li>
<li>quota (to view your disk usage on server)</li>
</ul>
<h3>Viewing and Stopping Processes</h3>
<ul>
<li>ps  &#8211; displays running processes</li>
<li>top   &#8211; (may be only available to admins) similar to windows task manager</li>
<li>kill -9 [process Id]  &#8211; terminiates a running process (out of control CGI, etc).  The process Id can be obtained using &#8220;ps&#8221;</li>
</ul>
<h2>File and Directory Permissions</h2>
<p><em>There are three levels of file permission: read, write and execute.  In addition, there are three groups to which you can assign permission, The file owner, the user group, and everyone.  The command chmod followed by three numbers is used to change permissons.  The first number is the permission for the owner, the second for the group and the third for everyone.  Here are how the levels of permission translate:</em></p>
<ul>
<li>0 = &#8212;  (no permission)</li>
<li>1 = &#8211;x  (execute only)</li>
<li>2 = -w-  (write only)</li>
<li>3 = -wx  (write and execute)</li>
<li>4 = r&#8211;  (read only)</li>
<li>5 = r-x  (read and execute)</li>
<li>6 = rw-  (read and write)</li>
<li>7 = rwx  (read, write and execute)</li>
</ul>
<p><em>I prefer that the group always have permission of 0.  This prevents other users on the server from browsing files via Telnet and FTP.  Here are the most common file permissions used:</em></p>
<ul>
<li>chmod 604 [filename]      (minimum permission for www HTML file)</li>
<li>chmod 705 [directoryname] (minimum permission for www directories)</li>
<li>chmod 705 [filename]      (minimum permission for www scripts &amp; programs)</li>
<li>chmod 606 [filename]      (permission for datafiles used by www scripts)</li>
<li>chmod 703 [directoryname] (write-only permission for public FTP uploading)</li>
</ul>
<p><em>Note that some systems use AFS filesystem and chmod does not behave as expected.You can sometimes identify AFS if the path that you are using begins like so /afs/path/to/files/    If your system uses AFS, then the following commands are used instead of chmod.</em></p>
<ul>
<li>fs setacl [directory] [group] [access] (set file permissions)</li>
<li>fs listacl [directory] (list file permissions)</li>
</ul>
<h3>example:</h3>
<p>fs setacl . httpd rliw       (set read, lookup, insert, write to http for current dir)</p>
<h2>Scheduling Tasks</h2>
<p><em>You can schedule tasks to run automatically by using the UNIX cron command. To use this, you create a text file with cron instructions, then process this file.  cron instructions are basically UNIX commands with extra info about the time that they will run.</em></p>
<p><em>One important thing to note is that it is best to use full paths when creating your cron file.  As an example, create a file called mycronfile and in it place one line:</em></p>
<p>0 1 * * * cp /usr/www/file.txt /usr/www/backup.txt</p>
<p>now at the command line, type the following:</p>
<p>crontab mycronfile</p>
<p>You have just scheduled an automated task!  This task will run at the time specified until you decide you want to cancel it.<br />
There are six fields in this file.  The first five represent the time that the job will run.  The sixth field is a UNIX command that will run at the specified time.  The above example will run every night at 1AM, at which time it will copy a file.</p>
<h3>Here is how the fields break down:</h3>
<p>Field 1  |  Field 2  |  Field 3       |  Field 4  |  Field 5<br />
Minutes  |  Hours    |  Day of Month  |  Month    |  Day of Week<br />
(0-59)   |  (0-23)   |  (1-31)        |  (1-12)   |  (0-6)</p>
<p>You can enter a number in the field, a range of numbers, or an * to indicate all. Here are a few more examples.  These examples use the ls command, which would be pretty useless.  Note the time that it runs, though.</p>
<ul>
<li>0  1 * * 1-5   ls  (this would run every Monday-Friday at 1am)</li>
<li>0  1 * * 1,3,5 ls  (this would run every Monday, Wednesday and Friday at 1am)</li>
<li>10 2 1 * *     ls  (this would run at 2:10am on the first of every month)</li>
<li>0  1 1 1 *     ls  (this would run at 1am on January 1 every year)</li>
</ul>
<p>If you have a more complicated command that you want to run, it is sometimes helpful to create a shell script and have that script run.  You specify the shell script as you would any UNIX command.  For example:</p>
<ul>
<li>0 1 * * * /usr/www/myscript</li>
</ul>
<h3>There are some other crontab switches that are useful:</h3>
<ul>
<li>crontab -l  (lists your currently scheduled tasks)</li>
<li>crontab -r  (delete all currently scheduled tasks)</li>
<li>crontab -e  (directly edit your scheduled tasks)</li>
</ul>
<h2>Credits</h2>
<ul>
<li>Originally created by Jason Hinkle</li>
<li>Additional content provided by Dave Wojo</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/common-unix-commands-for-webmasters/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>File Permissions</title>
		<link>http://verysimple.com/2006/03/30/file-permissions/</link>
		<comments>http://verysimple.com/2006/03/30/file-permissions/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=6</guid>
		<description><![CDATA[This page explains how to set file permissions for the three most common type of web files: pages, scripts and data/config files. To keep things simple, let&#8217;s make the following assumptions: a. pages should be readable/writable by the owner and readable by the web visitor. b. scripts should be readable/writable/executable by the owner and readable/executable [...]]]></description>
			<content:encoded><![CDATA[<p>This page explains how to set file permissions for the three most common type of web files: pages, scripts and data/config files.</p>
<p>To keep things simple, let&#8217;s make the following assumptions:</p>
<p>a. pages should be readable/writable by the owner and readable by the web visitor.<br />
b. scripts should be readable/writable/executable by the owner and readable/executable by the web visitor.<br />
c. data-config files should be readable/writable by the owner and readable/writable by the web visitor.<br />
And also, lets use the following abbreviations:</p>
<p>- &#8211; - (or 0) = no permission<br />
r &#8211; - (or 4) = read-only permission<br />
rw &#8211; (or 6) = read/write permission<br />
rwx (or 7) = read/write/execute permission</p>
<p>To change UNIX file permissions using your shell account (Telnet):</p>
<p>When changing file permissions on a UNIX server, there are three groups to which you assign permissions: owner, group, other. Owner is typically you. Group is typically all users with accounts on your server. Other is typically the web visitors. Using the chmod command on a UNIX server, you can set the permissions for each of those groups.</p>
<p>1. Log into your account and go to the directory where the files are located<br />
2. Use the chmod command to change permissions like so:<br />
2a. chmod 604 page.html<br />
2b. chmod 705 script.cgi<br />
2c. chmod 606 config-data.txt</p>
<p>To change UNIX file permissions using your FTP software:</p>
<p>1. Log into your account and go to the directory where the files are located.<br />
2. Highlight the file that you want to change permission.<br />
3. Locate the &#8220;file permission&#8221; or &#8220;chmod&#8221; command on your FTP software software (you may need to refer to the manual or help file)<br />
4. There should be three groups. Each group should have either checkboxes or a selection for the permission type.<br />
4a. set pages to rw- for the owner, no permission for the group, and r&#8211;for other<br />
4b. set scripts to rwx for the owner, no permission for the group, and r-x for other<br />
4c. set data/config files to rw- for the owner, no permission for the group, and rw- for other</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/file-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Perl modules on UNIX w/o root permissions</title>
		<link>http://verysimple.com/2006/03/30/installing-perl-modules-on-unix-wo-root-permissions/</link>
		<comments>http://verysimple.com/2006/03/30/installing-perl-modules-on-unix-wo-root-permissions/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=7</guid>
		<description><![CDATA[Installing Perl modules on a UNIX virtual server when you don&#8217;t have root or administrator privledges. Before you begin: In order to install modules, you have to have SSH or Telnet access to the server. If you don&#8217;t have this access (or you don&#8217;t know what SSH/Telnet means) then you&#8217;ll probably have to get your [...]]]></description>
			<content:encoded><![CDATA[<p>Installing Perl modules on a UNIX virtual server when you don&#8217;t have root or administrator privledges.</p>
<p>Before you begin: In order to install modules, you have to have SSH or Telnet access to the server. If you don&#8217;t have this access (or you don&#8217;t know what SSH/Telnet means) then you&#8217;ll probably have to get your system administrator to install modules for you.</p>
<p>I recently wanted to install the DBD::CSV module on my virtual host server (UNIX FreeBSD) and found that it was more challenging than I would have liked.  I&#8217;m not positive I have the best approach, but it did work for me in the end.  Following are the steps that I had to take to get the module and all those on which it depends installed.  The primary problem is that on the virtual server, I don&#8217;t have root/administrator privledges.  So, I have to install Perl modules in an alternate directory.  The scripts have to be altered to point to that directory as well.</p>
<p>To install my beloved DBD::CSV, I notice that I also have to have all of the following modules installed and working:</p>
<p><code>DBI<br />
File::Spec<br />
Text::CSV_XS<br />
SQL::Statement</code></p>
<p>So, we will install those first, then finally install DBD::CSV.</p>
<p>First, I set up MCPAN.  This is a Perl utility that automatically downloads, unpacks, compiles and installs Perl modules.  Since I don&#8217;t have root, I was only able to utilize MCPAN for the downloading and upacking part.  I still had to compile and install the modules manually.  If you don&#8217;t have access to, or don&#8217;t want to bother with MCPAN, then you can just download the modules directly from http://www.cpan.org and unpack them yourself.</p>
<p>To run MCPAN, you enter something like this (this will start the process of installing DBI, the first required module):</p>
<p><code>perl -MCPAN -e 'install DBI'</code></p>
<p>The first time I ran this utility, I was automatically taken through an installation process.  A directory ~/.cpan was created in my home directory and I was prompted with several questions.  I simply used all the defaults.  There was only one question that I had trouble with, which was something like &#8220;What is your favorite CPAN mirror.&#8221;  This seemed to be asking where to look for downloadable modules.  I wish I remembered what I put, but it took me several tries to find one that worked.  I finally wound up entering a server in Japan, which I&#8217;m sure is not good.  But it worked.  You might check for possible server locations here: http://www.perl.com/CPAN</p>
<p>Anyway, after running that the first time, the DBI module installation files were saved in ~/.cpan/build/DBI-1.14.  (in case you don&#8217;t know ~/ usually means your home directory), however the installation failed because it tried to write some stuff to the main Perl installation location and, again, I don&#8217;t have permission to write there.  however, when you are manually installing modules, I do know that you can specify an alternate directory.  So, I went into the ~/.cpan/build/DBI-1.14 directory and manually installed it like so:</p>
<p><code>cd ~/.cpan/build/DBI-1.14<br />
perl Makefile.PL INSTALLDIRS=site INSTALLSITELIB=/usr/www/users/myaccount/cgi-bin/lib<br />
make<br />
make test<br />
make install</code></p>
<p>When I installed it, I see that I got a few errors and such.  Upon closer inspection, it seems that the POD documentation and other stuff is still trying to go in the main Perl library location.  I ignore these errors, since it doesn&#8217;t seem to effect anything but the documentation.  Obviously, you want to replace /usr/www/users/myaccount/cgi-bin/lib with the location on your server where you want to save the modules.</p>
<p>Anyway, now I try the File::Spec module:</p>
<p><code>perl -MCPAN -e 'install File::Spec'<br />
cd ~/.cpan/build/File-Spec-0.82<br />
perl Makefile.PL INSTALLDIRS=site INSTALLSITELIB=/usr/www/users/myaccount/cgi-bin/lib<br />
make<br />
make test<br />
make install</code></p>
<p>That one was easy.  I still got errors, but I just ignore them.  Now I try Text::CSV_XS:</p>
<p><code>perl -MCPAN -e 'install Text::CSV_XS'<br />
cd ~/.cpan/build/Text-CSV_XS-0.21<br />
perl Makefile.PL INSTALLDIRS=site INSTALLSITELIB=/usr/www/users/myaccount/cgi-bin/lib<br />
make<br />
make test<br />
make install</code></p>
<p>Same old thing.  More errors.  Moving along to SQL::Statement&#8230;</p>
<p><code>perl -MCPAN -e 'install SQL::Statement'<br />
cd ~/.cpan/build/SQL-Statement-0.1016<br />
perl Makefile.PL INSTALLDIRS=site INSTALLSITELIB=/usr/www/users/myaccount/cgi-bin/lib<br />
make<br />
make test<br />
make install</code></p>
<p>Another one bites the dust.  The final one, DBD::CSV is more tricky because when I tried the same thing, it doesn&#8217;t work.  I can&#8217;t do the Makefile.PL part of it because it says I am missing some required modules.  What is happening is that the installer is looking in the standard Perl path &#8211; however we have been installing all of our goodies to an alternate location and Perl doesn&#8217;t know about it.  My solution is that I simply comment out the lines in Makefile.PL where it checks for all the required modules!  That&#8217;s a crappy way to do it, but it works.<br />
<code><br />
perl -MCPAN -e 'install DBD::CSV'<br />
cd ~/.cpan/build/DBD-CSV-0.1024</code></p>
<p>Now I edit Makefile.PL and comment out these lines (about 20 lines down from the top or so)<br />
<code><br />
# $ok &amp;&amp;= CheckModule('DBI', '1.00');<br />
# $ok &amp;&amp;= CheckModule('Text::CSV_XS', '0.16');<br />
# $ok &amp;&amp;= CheckModule('SQL::Statement', '0.1011');</code></p>
<p>That&#8217;s it.  the rest is the same.</p>
<p><code>perl Makefile.PL INSTALLDIRS=site INSTALLSITELIB=/usr/www/users/myaccount/cgi-bin/lib<br />
make<br />
make test<br />
make install</code></p>
<p>All done at last!  I tried my script and it worked just fine.  One adjustment that you might have to make to your script is to add the location of your libraries to your script.  You do this by putting the location in a BEGIN clause in your script like so:</p>
<p><code>BEGIN {<br />
unshift(@INC,"/usr/www/users/myaccount/cgi-bin/lib");<br />
}</code></p>
<p>Put this at the top of your script before any other subroutines or anything. That tells your script to look there when loading modules.  Since you use the &#8220;unshift&#8221; function, your path is added to the front of the list.  If you would rather your script look in the regular places first, and look in your custom path last, then you can use &#8220;push&#8221; instead of &#8220;unshift.&#8221;</p>
<p>One final thing.  I went into ~/.cpan/build/ and deleted all the files and folders.  I get charged for disk space overusage, so no use keeping all those installation files, right?</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/installing-perl-modules-on-unix-wo-root-permissions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vi primer for UNIX dummies</title>
		<link>http://verysimple.com/2006/03/30/vi-primer-for-unix-dummies/</link>
		<comments>http://verysimple.com/2006/03/30/vi-primer-for-unix-dummies/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=10</guid>
		<description><![CDATA[vi is a text editor that is installed pretty much on all UNIX systems. favored by old-school geeks, vi can be somewhat complex to use. However the basics are pretty easy. Most of us only need the basics to go into a config file and change a setting. Starting vi: vi [filename] &#8211; opens a [...]]]></description>
			<content:encoded><![CDATA[<p>vi is a text editor that is installed pretty much on all UNIX systems.  favored by old-school geeks, vi can be somewhat complex to use.  However the basics are pretty easy.  Most of us only need the basics to go into a config file and change a setting.</p>
<p>Starting vi:</p>
<p>vi [filename]  &#8211; opens a file using the vi text editor.  if this is an existing file, it will edit.  otherwise, it will create a new, blank file.</p>
<p>Panic Button!</p>
<p>:q!  then hit the enter key= exit without saving.  useful when things go out of control!</p>
<p>Switching &#8220;modes&#8221;</p>
<p>the first confusing part is that vi has different &#8220;modes&#8221; while you are editing a file.  They are known as &#8220;command&#8221; mode and &#8220;input&#8221; mode.</p>
<p>Esc &#8211;  takes you back to command mode.</p>
<p>i, a, A, r or R &#8211; (while in command mode) goes into insert mode.</p>
<p>Moving Around:</p>
<p>Moving around the file is done in command mode.  if your terminal is set up correctly, the up,down,left,right arrows will nmove the cursor around.</p>
<p>if your terminal is not set up correctly, then you have to use j=down, k=up, h=left, l=right.</p>
<p>/[search term] then hit enter = the slash followed by a search term will move the cursor to the next occurance of that term.  handy for locating configuration settings.</p>
<p>?[search term] then hit enter = same as search, but searches backwards.</p>
<p>ctrl+shift+R = screen refresh.  especially when scrolling, vi has a tendency not to redraw the whole screen correctly.  use this to refresh the screen.</p>
<p>Deleting</p>
<p>Deleting is again done from command mode.  This is probably the most confusing part of vi for me personally.  because input mode allows you to enter new characters.  but to delete existing ones, you must exit back to command mode and delete them.</p>
<p>x = delete current character<br />
dd = delete entire current line<br />
u = undo last edit</p>
<p>Inserting / Editing</p>
<p>i = enter insert mode starting before current char<br />
a = goto insert mode starting after current character<br />
A = goto insert mode at end of current line.<br />
r = overwrites next character typed then exits back to command mode<br />
R = goto insert mode, but overwriting instead of inserting</p>
<p>when you enter insert mode, you just start typing as you would with any editor.  it&#8217;s pretty simple.  When you&#8217;re done typing, or you want to move the cursor to make a correction, hit Esc to return to command mode.</p>
<p>Exiting vi with and without saving</p>
<p>(This is all done in command mode)</p>
<p>:q!  then hit enter = exit without saving</p>
<p>shift+ZZ  then hit enter = save and exit.</p>
<p>Getting Help</p>
<p>:viusage = shows vi commands<br />
:h = general help screen</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/vi-primer-for-unix-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing your cgi-bin</title>
		<link>http://verysimple.com/2006/03/30/securing-your-cgi-bin/</link>
		<comments>http://verysimple.com/2006/03/30/securing-your-cgi-bin/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=11</guid>
		<description><![CDATA[The Problem: I find a lot of surprising security problems as I work on client&#8217;s sites. Even large, reputable companies often have gross security issues. I know more than anyone how difficult it can be to get a cgi script installed and working. It&#8217;s tempting to walk away without double-checking the security. One of the [...]]]></description>
			<content:encoded><![CDATA[<p>The Problem:</p>
<p>I find a lot of surprising security problems as I work on client&#8217;s sites.  Even large, reputable companies often have gross security issues.  I know more than anyone how difficult it can be to get a cgi script installed and working.  It&#8217;s tempting to walk away without double-checking the security.  One of the most common things that I see is poor security of the cgi-bin.  Depending on the setup of your server, someone can take total control of your account easily through a poorly secured cgi-bin.</p>
<p>The particular problem i&#8217;m writing about involves writable files/directories within your cgi-bin, or scripts that make calls to external programs (like sendmail).  These are both very common types of scripts that you would find in just about any cgi-bin.</p>
<p>The writable file issue is that most cgi scripts rely on a datafile to store their information.  In some cases, they need an entire writable directory to store data (file uploads, etc).  The tricky part is that you have to allow the script write access to the file/directory.  If your server is running as &#8220;nobody&#8221; then you need to allow world write access to the file.  This is dangerous because other users on the server also have the ability to run under the &#8220;nobody&#8221; user &#8211; which means they can also write to those files.  Some servers are configured so that scripts execute under your own userid.  Otherwise sensible people are fooled into thinking that they are protected by this.  Although it does protect you from the &#8220;nobody&#8221; exploits, it actually make the potential damage much worse if you have poor security settings.</p>
<p>The issue with scripts that make calls to external programs (like Formail for sending email via sendmail, etc) is that if they are not coded properly, someone can input malicious text that causes an arbitrary shell command to run in addition to the sendmail command.  This command will run under whatever userid that the original script has.</p>
<p>One dangerous situation is a script that allows file uploads and it&#8217;s writable directory is in the cgi-bin.  Any script like this should have serious security checks in place to prevent malicious files from being uploaded.  If the script doesn&#8217;t check file types as they upload, any anonymous user can upload a script or executable file right to your cgi-bin.</p>
<p>Another situation is on a virtual host where you share your account with lots of other users.  This exploit is only available to people who have an account on your machine, however it is no less a problem.  All users on your server can install cgi scripts in their account which run under the &#8220;nobody&#8221; permissions.  If they install a simple command processing script, they can manipulate any file in your account that allows world write access.</p>
<p>So, take a look at your cgi-bin and look for any writable files or directories.  Imagine what would happen if someone could edit or add any file there in your cgi-bin.  A writable directory is particularly bad because the other person on your server can actually write a new script file there and then browse to the url to execute it.</p>
<p>Normally if someone can totally compromise your site in this way, they are limited to running as the user &#8220;nobody.&#8221;  However, there is still quite a bit of damage that can be done.  Formmail scripts can be installed to send spam.  Scripts to snoop into your datafiles can be installed.  Large files can be uploaded and shared (using your bandwith).  I once had a client who incurred a $10,000 bandwidth bill after their server was compromised by hackers sharing video game software.  Nothing more than &#8220;nobody&#8221; access is needed to do this.</p>
<p>If cgi-wrap is enabled, the situation is compounded because the scripts in your cgi-bin can be executed through cgi-wrap to run under your own userid.  At that point, they own your account.</p>
<p>How To Secure cgi-bin:</p>
<p>There&#8217;s a few simple things that can help lock down your cgi-bin.</p>
<p>1. Never, ever have a file with both world-execute and world-write permissions.  This can be overwritten with any arbritrary code by any user on your server.  Once they overwrite, they can execute it through the browser.  Scripts themselves should never require write permission.  Read/Execute is fine (chmod 505 is nice and secure).</p>
<p>2. If possible, never have any writable directories or files in the cgi-bin.  Not even writable by your own user id.  there is no reason that a file needs to be writable within the cgi-bin.  Depending on what scripts you have installed, this can be challenging.  The solution is to move all datafiles to an area that is not accessible through the web browser.  If this is not possible, see # 3</p>
<p>3. If you must have writable files or folders in the cgi-bin because of the functionality of a script, keep them in a subdirectory and put an .htaccess file in there that has the contents &#8220;deny from all&#8221; in it.  Your scripts can still read/write files there, but nothing can be executed through the browser.  if you are not able to put them in a separate directory, you can deny access to specific files using .htaccess.</p>
<p>4. Never give any permissions to the &#8220;group.&#8221;  In UNIX you have three permissions to grant &#8211; owner, group, world.  for example, chmod 644 grants 6 (rw) to owner, 4 (r) to group and 4 (r) to the world.  The group is almost always other accounts on your server.  You generally do not know these other users and there is no reason to give them any permissions for any file in your account.  The middle value should always be zero.  for example: chmod 604 gives the group 0 (no access) which is fine.</p>
<p>5. be very careful when cgi-wrap is enabled or your cgi-bin executes using your own account&#8217;s userid.  in this case you have to make sure that nothing can be written arbitrarily into your cgi-bin even using your own account permissions.  Keep in mind that you do not need permission to write to a script.  You can remove the write permission even for yourself.  If you need to change it later, you first change the permission to allow write, then change it back.  It doesn&#8217;t need to sit there with write permissions.  You have to be very cautious about what scripts are installed, because any script with an exploit can be dangerous.  if someone can write or upload to your cgi-bin, they can create their own script and run it under you userid.  If you use cgi-wrap, there is no reason for the group or the world to have any permissions on your files.  so, you should change permissions something like this: chmod 400 (only you have read permission).  scripts can be chmod 500.  writable datafiles can be chmod 600, but should not be stored in a public area.  remember that if someone can run arbitrary code as your userid, they own your account!</p>
<p>6. Try to break into your own account.  Go through your scripts and try to upload a file that shouldn&#8217;t be allowed.  Look at scripst that send email and see if you can enter data in such a way that code gets executed.</p>
<p>Summary:</p>
<p>The moral of the story is to be cautious with your cgi-bin.  Especially look for writable files and directories.  Never trust other users on your server.  It may not seem important to take security seriously for your homepage with a bulletin board and formmail script.  But there are malicious people out there always scanning for easy targets.  Your data can be compromised or your bandwidth stolen &#8211; leaving you with the bill.  A little bit of extra time can save you a lot of grief later.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/securing-your-cgi-bin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

