<?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>Jeff Combs - IT Professional / Web Developer</title>
	<atom:link href="http://jcombs.net/feed" rel="self" type="application/rss+xml" />
	<link>http://jcombs.net</link>
	<description>System Administration</description>
	<lastBuildDate>Sat, 24 Dec 2011 17:56:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Redirect root mail to external address in Debian</title>
		<link>http://jcombs.net/linux/redirect-root-mail-to-external-address-in-debian</link>
		<comments>http://jcombs.net/linux/redirect-root-mail-to-external-address-in-debian#comments</comments>
		<pubDate>Sat, 24 Dec 2011 17:53:14 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=217</guid>
		<description><![CDATA[To redirect root mail to an external email just use /etc/aliases # vi /etc/aliases root: youremail@email.com # newaliases]]></description>
			<content:encoded><![CDATA[<p>To redirect root mail to an external email just use /etc/aliases</p>
<pre class="brush: text">
# vi /etc/aliases
</pre>
<blockquote><p>
root:  youremail@email.com
</p></blockquote>
<pre class="brush: text">
# newaliases
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/linux/redirect-root-mail-to-external-address-in-debian/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drop Foreign Key Constraint using INNODB</title>
		<link>http://jcombs.net/database/drop-foreign-key-constraint-using-innodb</link>
		<comments>http://jcombs.net/database/drop-foreign-key-constraint-using-innodb#comments</comments>
		<pubDate>Tue, 23 Aug 2011 19:25:47 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=214</guid>
		<description><![CDATA[I recently needed to make some database modifications that required removing some existing foreign key constraints. The command looks like this. ALTER table tablename DROP FOREIGN KEY foreign_key_name MySQL was throwing errors. mysql> ALTER TABLE reviews DROP FOREIGN KEY priority_id; ERROR 1025 (HY000): Error on rename of &#8216;./dbname/reviews&#8217; to &#8216;./dbname/#sql2-62f5-145b&#8217; (errno: 152) If you run [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to make some database modifications that required removing some existing foreign key constraints.  The command looks like this.</p>
<pre class="brush: sql">
ALTER table tablename DROP FOREIGN KEY foreign_key_name
</pre>
<p>MySQL was throwing errors.</p>
<blockquote><p>
mysql> ALTER TABLE reviews DROP FOREIGN KEY priority_id;<br />
ERROR 1025 (HY000): Error on rename of &#8216;./dbname/reviews&#8217; to &#8216;./dbname/#sql2-62f5-145b&#8217; (errno: 152)
</p></blockquote>
<p>If you run</p>
<pre class="brush: sql">
SHOW CREATE TABLE tablename
</pre>
<p>You&#8217;ll see the constraint names.  You can then delete the foreign key based on the constraint.</p>
<pre class="brush: sql">
ALTER TABLE tablename DROP FOREIGN KEY `reviews_ibfk_24`;
</pre>
<p>You can then drop the column as needed. </p>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/database/drop-foreign-key-constraint-using-innodb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Alter Table with InnoDB Foreign Key Constraint</title>
		<link>http://jcombs.net/database/mysql-alter-table-with-innodb-foreign-key-constraint</link>
		<comments>http://jcombs.net/database/mysql-alter-table-with-innodb-foreign-key-constraint#comments</comments>
		<pubDate>Fri, 05 Aug 2011 13:06:53 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=207</guid>
		<description><![CDATA[In a recent project I needed to add a new table that would create a foreign key constraint on an existing table. I&#8217;m using the InnoDB storage engine. The existing table is employees and the new table is shifts. Shifts table is pretty simple. CREATE TABLE shifts ( id INT AUTO_INCREMENT NOT NULL, shift VARCHAR(15) [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I needed to add a new table that would create a foreign key constraint on an existing table.  I&#8217;m using the InnoDB storage engine.  The existing table is employees and the new table is shifts.  Shifts table is pretty simple.</p>
<pre class="brush: sql">
CREATE TABLE shifts (
        id INT AUTO_INCREMENT NOT NULL,
        shift VARCHAR(15) NOT NULL,
        PRIMARY KEY(id)
) ENGINE=InnoDB;
</pre>
<p>The existing employees table needed a new column called &#8220;shift_id&#8221; that would reference the shifts table. The following code can be used to add the column and then add the foreign key constraint.</p>
<pre class="brush: sql">
ALTER TABLE employees ADD shift_id INT AFTER group_id;
ALTER TABLE employees ADD CONSTRAINT FOREIGN KEY(shift_id) REFERENCES shifts(id) ON UPDATE CASCADE ON DELETE SET NULL;
</pre>
<p>The first alter statement worked fine, but the second kept throwing an error 150.  You can view more details about the last error with the following:</p>
<pre class="brush: sql">
SHOW INNODB STATUS;
</pre>
<p>I would see the following:</p>
<blockquote><p>
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
LATEST FOREIGN KEY ERROR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
110805  8:49:16 Error in foreign key constraint of table backlogreviews/#sql-62f5_23:<br />
FOREIGN KEY(shift_id) REFERENCES shifts(id) ON UPDATE CASCADE ON DELETE SET NULL:<br />
Cannot resolve table name close to:<br />
(id) ON UPDATE CASCADE ON DELETE SET NULL
</p></blockquote>
<p>This didn&#8217;t exactly help as I know the shifts table exists.  I did some searching on google and found some hints, but these mostly indicated the column doesn&#8217;t match up correctly.  Turns out I had a syntax error when creating the shifts table.  The engine was INNOBD (notice the BD should read DB).  Instead of throwing an error when creating the table it just used MyISAM.  Since the storage engines didn&#8217;t match I was getting the error.</p>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/database/mysql-alter-table-with-innodb-foreign-key-constraint/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allow remote access to MySQL</title>
		<link>http://jcombs.net/database/allow-remote-access-to-mysql</link>
		<comments>http://jcombs.net/database/allow-remote-access-to-mysql#comments</comments>
		<pubDate>Fri, 29 Jul 2011 20:51:13 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=203</guid>
		<description><![CDATA[I&#8217;m recently working on a project where I wanted to start playing with MySQL workbench to create an ER diagram for an existing database. I&#8217;m running Workbench on a Windows 7 machine with MySQL running on Ubuntu. Run the following to give the remote machine access. mysql&#62; grant all privileges on *.* to root@&#039;remote_machone&#039; identified [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m recently working on a project where I wanted to start playing with MySQL workbench to create an ER diagram for an existing database.  I&#8217;m running Workbench on a Windows 7 machine with MySQL running on Ubuntu.  Run the following to give the remote machine access.</p>
<pre class="brush: text">
mysql&gt; grant all privileges on *.* to root@&#039;remote_machone&#039; identified by &#039;root password&#039;;
Query OK, 0 rows affected (0.12 sec)
</pre>
<p>You may not want to use the root account, but this will give you remote access. </p>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/database/allow-remote-access-to-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password Hashing in CakePHP</title>
		<link>http://jcombs.net/cakephp/password-hashing-in-cakephp</link>
		<comments>http://jcombs.net/cakephp/password-hashing-in-cakephp#comments</comments>
		<pubDate>Wed, 27 Jul 2011 14:12:31 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=196</guid>
		<description><![CDATA[In a recent project I needed to add some validation to my User model. I&#8217;m using the Auth Component that is included with CakePHP. In this particular instance I wanted to allow a change password form. The form would have three fields (current_password, new_password, confirm_password). In the Model I wanted to first check if the [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I needed to add some validation to my User model.  I&#8217;m using the Auth Component that is included with CakePHP.  In this particular instance I wanted to allow a change password form.  The form would have three fields (current_password, new_password, confirm_password).  In the Model I wanted to first check if the current password was entered correctly.  </p>
<p>Validation should always happen in the model so I created a new function that would check for the current password for the logged in user.  The Auth component automatically hashes the password with SHA1 and uses the Security Salt as part of the password string to create the hash, so I needed to hash the &#8220;current_password&#8221; field from the form to check for a match.  This is where I ran into the problem.  I tried using the following:</p>
<pre class="brush: php">
function checkCurrentPassword($data) {
    $id = $this-&gt;data[$this-&gt;alias][&#039;id&#039;]; // passed the user ID from the form as a hidden field
    $pwd = $this-&gt;field(&#039;password&#039;, array(&#039;id&#039; =&gt; $id)); // get the current password from the database
    if(Security::hash($data[&#039;current_password&#039;]) != $pwd) {
        return false;
    }
    return true;
}
</pre>
<p>You can see that $id is passed from the form and $pwd is a variable for the current password in the database.  Auth will automatically hash an input with the name &#8220;password&#8221;, but my form is using &#8220;current_password&#8221;, so it is sent in cleartext.  This needs to be hashed first.  I attempted to use the Security::hash function but my validated kept failing.  </p>
<p>As it turns out the Security::hash function is only using SHA1 without the Security Salt added.  What I was able to do is use the AuthComponent::password function instead which does use the Security Salt configured in core.php.  New code looks like:</p>
<pre class="brush: php">
function checkCurrentPassword($data) {
    $id = $this-&gt;data[$this-&gt;alias][&#039;id&#039;];
    $pwd = $this-&gt;field(&#039;password&#039;, array(&#039;id&#039; =&gt; $id));
    if(AuthComponent::password($data[&#039;current_password&#039;]) != $pwd) {
        return false;
    }
    return true;
}
</pre>
<p>The validate array would look like this:</p>
<pre class="brush: php">
var $validate = array(
&#039;current_password&#039; =&gt; array(
    &#039;rule&#039; =&gt; &#039;checkCurrentPassword&#039;,
    &#039;message&#039; =&gt; &#039;Current password was not entered correctly&#039;
    )
);
</pre>
<p>Update:  Security::hash actually takes a third parameter documented in the API to use the Security.salt value</p>
<blockquote><p>
Create a hash from string using given method. Fallback on next available method.</p>
<p>Parameters:</p>
<p>        string $string required</p>
<p>        String to hash<br />
        string $type optional NULL</p>
<p>        Method to use (sha1/sha256/md5)<br />
        boolean $salt optional false</p>
<p>        If true, automatically appends the application&#8217;s salt value to $string (Security.salt)
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/cakephp/password-hashing-in-cakephp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cakephp form input using select with options</title>
		<link>http://jcombs.net/cakephp/cakephp-form-input-using-select-with-options</link>
		<comments>http://jcombs.net/cakephp/cakephp-form-input-using-select-with-options#comments</comments>
		<pubDate>Sun, 17 Jul 2011 16:58:05 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=189</guid>
		<description><![CDATA[There are times that you need to control the form->input helper with specific type setting and additional options. This is probably more comment when building custom form inputs that aren&#8217;t automagically being set from the model/controller. I recently had to build a list on distinct dates, but prefer to user $this->Form->input, rather than $this->Form->select. I [...]]]></description>
			<content:encoded><![CDATA[<p>There are times that you need to control the form->input helper with specific type setting and additional options.  This is probably more comment when building custom form inputs that aren&#8217;t automagically being set from the model/controller.  </p>
<p>I recently had to build a list on distinct dates, but prefer to user $this->Form->input, rather than $this->Form->select.  I first built an indexed array containing my date fields.</p>
<blockquote><p>
array(<br />
  [xxxx-xx-xx] => xxxx-xx-xx<br />
  [yyyy-yy-yy] => yyyy-yy-yy<br />
)
</p></blockquote>
<p>We&#8217;ll call this array $options.  You can then build the input using something like</p>
<pre class="brush: php">
$this-&gt;form-&gt;input(&#039;Input Name&#039;, array(
  &#039;type&#039; =&gt; &#039;select&#039;,
  &#039;options&#039; =&gt; &#039;options&#039;,
  &#039;label&#039; =&gt; &#039;label&#039;,
  &#039;empty&#039; =&gt; &#039;No data selected&#039;
);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/cakephp/cakephp-form-input-using-select-with-options/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.3 Virtual Fields</title>
		<link>http://jcombs.net/cakephp/cakephp-1-3-virtual-fields</link>
		<comments>http://jcombs.net/cakephp/cakephp-1-3-virtual-fields#comments</comments>
		<pubDate>Fri, 01 Jul 2011 00:12:12 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=184</guid>
		<description><![CDATA[A new feature of CakePHP 1.3 is to create VirtualFields. Why do you care? Typically Cake can use the $displayField variable of a model for drop down lists in your views. Suppose a User model contains two columns, firstname and lastname. There is no way to concatenate this with the $displayField variable. You can however, [...]]]></description>
			<content:encoded><![CDATA[<p>A new feature of CakePHP 1.3 is to create VirtualFields. Why do you care?  Typically Cake can use the $displayField variable of a model for drop down lists in your views.  Suppose a User model contains two columns, firstname and lastname.  There is no way to concatenate this with the $displayField variable.  You can however, use $virtualFields to create a new variable that can be assigned to $displayField.</p>
<p>My example uses an Employee model.</p>
<pre class="brush: php">
class Employee extends AppModel {
	var $name = &#039;Employee&#039;;
        var $virtualFields = array(&#039;full_name&#039; =&gt; &#039;CONCAT(Employee.firstname, &quot; &quot;, Employee.lastname)&#039;);
        var $displayField = &#039;full_name&#039;;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/cakephp/cakephp-1-3-virtual-fields/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recover Ubuntu Boot Problems</title>
		<link>http://jcombs.net/linux/recover-ubuntu-boot-problems</link>
		<comments>http://jcombs.net/linux/recover-ubuntu-boot-problems#comments</comments>
		<pubDate>Sun, 17 Apr 2011 19:37:11 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=176</guid>
		<description><![CDATA[I recently had a problem with my development machine. I haven&#8217;t used it in a while and realized I could not VNC or SSH to the box. This is a headless machine so I had to plugin a monitor and keyboard to see what was happening. I was greeted with the following: Target file system [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a problem with my development machine.  I haven&#8217;t used it in a while and realized I could not VNC or SSH to the box.  This is a headless machine so I had to plugin a monitor and keyboard to see what was happening. I was greeted with the following:</p>
<blockquote><p>
Target file system doesn&#8217;t have /sbin/init<br />
No init found. Try passing init= bootarg</p>
<p>Busybox v1.13.3 (Ubuntu 1:1.13.3-1ubuntu7) built-in shell (ash)<br />
Enter &#8216;help&#8217; for a list of built-in commands<br />
(initramfs) _
</p></blockquote>
<p>Not very happy about this.  Running &#8220;help&#8221; didn&#8217;t reveal any tools that would repair the boot volume. To recover I booted to an Ubuntu 10.10 CD and select the option to &#8220;Try Ubuntu&#8221;.  Once this started I used Ctrl + Alt + F1 to get to a shell and ran the following:</p>
<pre class="brush: text">
sudo fdisk -l
sudo fsck /dev/sda1
</pre>
<p>Running fdisk -l was just to be sure of the naming convention for my main drive, which in this case was /dev/sda1. I had to enter yes a couple times and then rebooted the machine which loaded successfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/linux/recover-ubuntu-boot-problems/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Database Connectivity</title>
		<link>http://jcombs.net/system-administration/testing-database-connectivity</link>
		<comments>http://jcombs.net/system-administration/testing-database-connectivity#comments</comments>
		<pubDate>Sun, 06 Mar 2011 01:52:25 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[System Administration]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=173</guid>
		<description><![CDATA[On windows you can simply create an empty file and give an .UDL extension. This will open a dialog to test DB connections.]]></description>
			<content:encoded><![CDATA[<p>On windows you can simply create an empty file and give an .UDL extension.  This will open a dialog to test DB connections.  </p>
<p><img class="alignnone size-full wp-image-181" title="Testing Database Connectivity with UDL File" src="http://jcombs.net/wp-content/uploads/2011/03/udl.png" alt="Testing Database Connectivity with UDL File" width="377" height="473" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/system-administration/testing-database-connectivity/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build pure-ftpd for Debian Lenny running on OpenVZ</title>
		<link>http://jcombs.net/linux/build-pure-ftpd-for-debian-lenny-running-on-openvz</link>
		<comments>http://jcombs.net/linux/build-pure-ftpd-for-debian-lenny-running-on-openvz#comments</comments>
		<pubDate>Sun, 14 Nov 2010 20:27:36 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://jcombs.net/?p=169</guid>
		<description><![CDATA[Capabilities on OpenVZ causes pure-ftpd not to start when installing with the package manager. Use the following method to download the source and build pure-ftpd without capabilities. mkdir /usr/src/pure-ftpd cd /usr/src/pure-ftpd apt-get source pure-ftpd apt-get build-dep pure-ftpd Edit the rules file and add the following to optflags [--without-capabilities] cd pure-ftpd-1.0.21/debian vi rules optflags=&#8211;with-everything &#8211;with-largefile &#8211;with-pam [...]]]></description>
			<content:encoded><![CDATA[<p>Capabilities on OpenVZ causes pure-ftpd not to start when installing with the package manager.  Use the following method to download the source and build pure-ftpd without capabilities.</p>
<pre class="brush: text">
mkdir /usr/src/pure-ftpd
cd /usr/src/pure-ftpd

apt-get source pure-ftpd
apt-get build-dep pure-ftpd
</pre>
<p>Edit the rules file and add the following to optflags [--without-capabilities]</p>
<pre class="brush: text">
cd pure-ftpd-1.0.21/debian
vi rules
</pre>
<blockquote><p>
optflags=&#8211;with-everything &#8211;with-largefile &#8211;with-pam &#8211;with-privsep &#8211;with-tls &#8211;without-capabilities
</p></blockquote>
<p>Build the package and install it.</p>
<pre class="brush: text">
cd ..
dpkg-buildpackage -uc -b

cd ..
dpkg -i pure-ftpd-common_1.0.21-11.4_all.deb pure-ftpd-mysql_1.0.21-11.4_i386.deb
/etc/init.d/pure-ftpd-mysql restart
</pre>
<p>Prevent the package manager from trying to update pure-ftpd</p>
<pre class="brush: text">
echo &#039;pure-ftpd-common hold&#039; | dpkg --set-selections
echo &#039;pure-ftpd-mysql hold&#039; | dpkg --set-selections
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jcombs.net/linux/build-pure-ftpd-for-debian-lenny-running-on-openvz/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

