<?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>Into.the.Void.</title>
	<atom:link href="http://www.void.gr/kargig/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.void.gr/kargig/blog</link>
	<description>Into The Void</description>
	<lastBuildDate>Sun, 13 May 2012 10:55:22 +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>AthCon 2012 Review</title>
		<link>http://www.void.gr/kargig/blog/2012/05/06/athcon-2012-review/</link>
		<comments>http://www.void.gr/kargig/blog/2012/05/06/athcon-2012-review/#comments</comments>
		<pubDate>Sun, 06 May 2012 12:07:59 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Privacy]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[athcon]]></category>
		<category><![CDATA[athens]]></category>
		<category><![CDATA[beef]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[ctf]]></category>
		<category><![CDATA[exploitation]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[packing]]></category>
		<category><![CDATA[postscript]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1354</guid>
		<description><![CDATA[Alternate title: &#8220;Being a lamb around a pack of wolves&#8221; &#8230; A venue full of hackers that are eager to attack your systems&#8230; On 3-4/05/2012 the third AthCon conference was held in Athens. AthCon is an international security conference whose motto is &#8220;The First HIGHLY TECHNICAL Security Conference in Greece&#8221;. Even though I am not [...]]]></description>
			<content:encoded><![CDATA[<p>Alternate title: &#8220;Being a lamb around a pack of wolves&#8221; &#8230; A venue full of hackers that are eager to attack your systems&#8230;</p>
<p>On 3-4/05/2012 the third <a href="http://athcon.org/">AthCon</a> conference was held in Athens. AthCon is an international security conference whose motto is &#8220;The First HIGHLY TECHNICAL Security Conference in Greece&#8221;. </p>
<p>Even though I am not a security professional, my daily job title is &#8220;<a href="//www.linkedin.com/in/kargig">Systems and Services Engineer</a>&#8221; which of course includes various aspects of security but I am certainly not a security researcher, I had decided months ago that I would be attending this year&#8217;s AthCon. Since I like messing a lot with IPv6 for the past 2-3 years, I decided that I could try and submit an introductory talk about IPv6 security issues. My talk was accepted, so I was not only attending AthCon this year but I was going to give a presentation as well.</p>
<p><strong><a href="//www.void.gr/kargig/blog/2012/05/03/athcon-2012-are-you-ready-for-ipv6-insecurities/">My presentation &#8211; Are you ready for IPv6 insecurities ?</a></strong> was during the first day of the conference. I am always worried when I give presentations on IPv6 that the people attending have probably no clue about this &#8216;not-so-new&#8217; protocol. Most people think that IPv6 is like IPv4 with bigger addresses and &#8216;:&#8217; instead of &#8216;.&#8217; to separate the address groups, which is of course a HUGE mistake/misunderstanding. I was hopeful that this wouldn&#8217;t be the case in AthCon, so when I started my presentation and I asked the crowd &#8216;how many of you know what SLAAC is ?&#8217; and I only saw 3-4 hands raised I kinda froze, I was expecting at least a double digit&#8230;I was going to give a presentation on IPv6 security concepts to people that have absolutely no idea what I&#8217;m talking about. Being prepared for the fact that some people would need some &#8216;refreshing&#8217; on their IPv6 knowledge, I had prepared around 20 introductory slides explaining some IPv6 concepts before I entered the security details, but I doubt these were enough for most people there. I am hopeful though that some of the attendees might be motivated to read more about the protocol since I think my security slides contained enough details, references and links to get people started. If someone needs more details feel free to contact me.</p>
<p>Enough with my presentation, <strong>what about other presentations ?</strong><br />
My personal view is that this year&#8217;s AthCon had some great talks, some that were ok and some that I didn&#8217;t like. I won&#8217;t mention which ones I didn&#8217;t like, but I noticed that a LOT of people were gossiping about these in the hallways. I will only mention here the ones that I really liked.</p>
<p>Day 1:<br />
<strong>&#8220;Packing Heat!&#8221; by Dimitrios Glynos</strong><br />
A presentation that every pentester should download/watch somehow. Techniques about packing your executables to avoid detection by anti-virus programs, need I say more ? Great content and very well presented. Congrats <a href="https://twitter.com/#!/dfunc">Dimitris</a>!</p>
<p><strong>&#8220;PostScript: Danger Ahead&#8221; by Andrei Costin</strong><br />
How to use PostScript programming language to take advantage of Printers, OS, etc. Very interesting concepts were presented and also the examples/demos shown were pretty cool and easy to understand.</p>
<p>Day 2:<br />
<strong>&#8220;Apple vs. Google Client Platforms&#8221; by Felix &#8216;FX&#8217; Lindner</strong><br />
I guess mostly everyone reading this blog knows FX and what a great speaker he is. If you don&#8217;t then start watching his previous presentations and start reading about his work. His presentation at AthCon, apart from being the best one in terms of &#8220;presenting it&#8221;, was also extremely interesting. He connected the security concepts behind Apple&#8217;s iOS and Google&#8217;s Chromebook with their business tactics and policies. Just wait for AthCon to publish the videos and watch it. Probably the best talk at AthCon 2012.</p>
<p><strong>&#8220;Advances in BeEF: RESTful API, WebSockets, XssRays enhancements&#8221; by Michele Orru</strong><br />
Jaw-dropping. That&#8217;s all I have to say about <a href="//beefproject.com/">BeEF</a>. Scary. Watch it to see what browsers and IDS have to face and defend against&#8230;not in the future but right now.</p>
<p><strong>&#8220;Exploitation and state machines&#8221; by Halvar Flake</strong><br />
This presentation was about exploitation techniques and why automated exploitation engines don&#8217;t work that well. Even though reversing and exploitation is far from my interest topics I enjoyed the talk a lot. Very well structured and very clear points. Too bad this talk did not appear on the schedule and was there as &#8220;tbc&#8221;, I am sure many more people would come just to listen to this talk and speak to Halvar.</p>
<p>If I were to suggest a couple of things for next year&#8230;<br />
a) Please put the CTF in separate slots within the day, not at the same time with the presentations. In a conference of 150-200 people (just guessing here) having 30+ people leaving the presentation room and just attending the CTF all day long leaves the main room a bit empty. I am pretty sure there were people that wanted to attend both the presentations and the CTF, unfortunately they had to make a choice.<br />
b) Send some details/info to the speakers about the conference a few days earlier. Maybe non-greek presenters were given but we weren&#8217;t, at least I wasn&#8217;t.<br />
c) The venue is really nice, but maybe it would help if the next AthCon was organized somewhere downtown. Yeah I can understand that the cost would be higher but number of people attending would also raise (I think).<br />
d) Give us even more highly technical presentations/speakers! People starve for these kind of talks!</p>
<p>My congratulations fly to AthCon people for organizing the conference. See you next year!</p>
<p>You can find some of the pics I took from the speakers at: <a href="https://picasaweb.google.com/107692279482600798910/AthCon2012">AthCon 2012 speaker pics</a> (if any of the speakers wants his pic removed please <a href="//www.void.gr/kargig/blog/contact/">contact</a> me ASAP)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/05/06/athcon-2012-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AthCon 2012 &#8211; Are you ready for IPv6 insecurities ?</title>
		<link>http://www.void.gr/kargig/blog/2012/05/03/athcon-2012-are-you-ready-for-ipv6-insecurities/</link>
		<comments>http://www.void.gr/kargig/blog/2012/05/03/athcon-2012-are-you-ready-for-ipv6-insecurities/#comments</comments>
		<pubDate>Thu, 03 May 2012 20:41:17 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[athcon]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[DHCPv6]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ids]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[scanning]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[slaac]]></category>
		<category><![CDATA[thc-ipv6]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1350</guid>
		<description><![CDATA[My presentation for AthCon 2012 is now available online: Are you ready for IPv6 insecurities ?]]></description>
			<content:encoded><![CDATA[<p>My presentation for AthCon 2012 is now available online: <a href="//void.gr/kargig/presentations/athcon_2012_kargig.pdf" title="Are you ready for IPv6 insecurities ?">Are you ready for IPv6 insecurities ?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/05/03/athcon-2012-are-you-ready-for-ipv6-insecurities/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Greek AdblockPlus Filter on github</title>
		<link>http://www.void.gr/kargig/blog/2012/04/26/greek-adblockplus-filter-on-github/</link>
		<comments>http://www.void.gr/kargig/blog/2012/04/26/greek-adblockplus-filter-on-github/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 17:32:34 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Greek]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[adblock plus]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1342</guid>
		<description><![CDATA[For the past months Greek AdblockPlus Filter has steadily been growing in subscribers. I recently did a change in the metadata so that clients fetch/check the list every 2 days instead of the default 7, and the daily subscriber count has surpassed 10.000 unique IPs. The following graph shows this increase over time: In order [...]]]></description>
			<content:encoded><![CDATA[<p>For the past months <a href="/kargig/blog/greek-adblock-plus-filter/">Greek AdblockPlus Filter</a> has steadily been growing in subscribers. I recently did a change in the metadata so that clients fetch/check the list every 2 days instead of the default 7, and the daily subscriber count has surpassed 10.000 unique IPs.</p>
<p>The following graph shows this increase over time:<br />
<a href="http://www.void.gr/kargig/blog/wp-content/greek_adblockplus_filter_subscribers_201204.png"><img src="http://www.void.gr/kargig/blog/wp-content/greek_adblockplus_filter_subscribers_201204.png" alt="" title="greek_adblockplus_filter_subscribers_201204" width="500" height="190" class="aligncenter size-medium wp-image-1343" /></a></p>
<p>In order to help people contribute to the project I&#8217;ve created a repo on github: <a href="https://github.com/kargig/greek-adblockplus-filter">greek-adblockplus-filter</a>. So now, if you want to help filter out ads from the greek web just get fork the project via git, make your changes and send me a pull request on github <img src='http://www.void.gr/kargig/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/04/26/greek-adblockplus-filter-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>open magnet URLs with xdg-open</title>
		<link>http://www.void.gr/kargig/blog/2012/01/24/open-magnet-urls-with-xdg-open/</link>
		<comments>http://www.void.gr/kargig/blog/2012/01/24/open-magnet-urls-with-xdg-open/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 21:39:24 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[deluge]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[magnet]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[torrent]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1333</guid>
		<description><![CDATA[Browsers on Linux should use xdg-open to open URLs. From xdg-open&#8217;s description: xdg-open opens a file or URL in the user&#8217;s preferred application. If a URL is provided the URL will be opened in the user&#8217;s preferred web browser. If a file is provided the file will be opened in the preferred application for files [...]]]></description>
			<content:encoded><![CDATA[<p>Browsers on Linux should use xdg-open to open URLs. From xdg-open&#8217;s description:</p>
<blockquote><p>xdg-open opens a file or URL in the user&#8217;s preferred application. If a URL is<br />
provided the URL will be opened in the user&#8217;s preferred web browser. If a file<br />
is provided the file will be opened in the preferred application for files of<br />
that type. xdg-open supports file, ftp, http and https URLs.</p></blockquote>
<p><a href="http://en.wikipedia.org/wiki/Magnet">Magnet</a> is a new type of URLs that&#8217;s currently not supported by xdg-open. It&#8217;s very easy to add a quick hack to support it though. Just copy xdg-open to a local binary path (e.g /usr/local/bin or preferably $HOME/bin) and apply the following patch. Change <em>deluge</em> with your preferred torrent application.</p>
<p><pre><code2>--- /usr/bin/xdg-open&nbsp;&nbsp;2010-09-15 14:08:29.000000000 +0300
+++ bin/xdg-open&nbsp;&nbsp;2012-01-24 22:05:03.935338593 +0200
@@ -437,6 +437,11 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit_success
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
+&nbsp;&nbsp;&nbsp;&nbsp;elif (echo &quot;$1&quot; | grep -q &#039;^magnet:&#039;); then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deluge &quot;$1&quot; 
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if [ $? -eq 0 ]; then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit_success
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fi
&nbsp;&nbsp;&nbsp;&nbsp; fi
 
&nbsp;&nbsp;&nbsp;&nbsp; sensible-browser &quot;$1&quot;
</code2></pre></p>
<p>For those who don&#8217;t know how to patch a file, here it is in full: <a href="/kargig/blog/wp-content/xdg-open">patched xdg-open to open magnet URLs</a></p>
<p>Works fine on my Debian using <a href="https://www.google.com/chrome">Chrome</a> which properly uses xdg-open to handle URLs. <a href="http://www.mozilla.org/en-US/firefox/">Firefox</a> after version 3.5 became a piece of bloatware and it&#8217;s not possible to open magnet links using <em>about:config settings</em> or xdg-open. For <a href="http://www.opera.com/">Opera</a> just go to Settings->Preferences->Programs and add new protocol with name <em>magnet</em>. At <em>Open with other application</em>, use the path that you saved the patched xdg-open.</p>
<p>Now go download some creative commons licensed files.</p>
<p>*UPDATE*<br />
Patch for latest xdg-utils (since some people complained that previous patch does not apply):<br />
<pre><code2>

--- xdg-open&nbsp;&nbsp;2012-02-18 14:22:48.058497027 +0200
+++ xdg-open&nbsp;&nbsp;2012-02-18 14:24:04.326875223 +0200
@@ -440,6 +440,11 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit_success
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
+&nbsp;&nbsp;&nbsp;&nbsp;elif (echo &quot;$1&quot; | grep -q &#039;^magnet:&#039;); then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deluge &quot;$1&quot; 
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if [ $? -eq 0 ]; then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit_success
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fi
&nbsp;&nbsp;&nbsp;&nbsp; fi
 
&nbsp;&nbsp;&nbsp;&nbsp; IFS=&quot;:&quot;
</code2></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/01/24/open-magnet-urls-with-xdg-open/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Music Player Daemon on OS X</title>
		<link>http://www.void.gr/kargig/blog/2012/01/16/music-player-daemon-on-os-x/</link>
		<comments>http://www.void.gr/kargig/blog/2012/01/16/music-player-daemon-on-os-x/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 20:52:24 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[gmpc]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[mac mini]]></category>
		<category><![CDATA[mpd]]></category>
		<category><![CDATA[MPDroid]]></category>
		<category><![CDATA[mpdscribble]]></category>
		<category><![CDATA[Music Player Daemon]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[scrobble]]></category>
		<category><![CDATA[Theremin]]></category>
		<category><![CDATA[ULA]]></category>
		<category><![CDATA[Unique Local Address]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1327</guid>
		<description><![CDATA[I use a Mac Mini with OS X 10.5.8 as a media center connected to my TV and I wanted to install Music Player Daemon on it so I could control the music remotely from my laptop or phone. I mostly followed the OS X guide from MPD&#8217;s wiki to do it but I ran [...]]]></description>
			<content:encoded><![CDATA[<p>I use a Mac Mini with OS X 10.5.8 as a media center connected to my TV and I wanted to install <a href="http://mpd.wikia.com/">Music Player Daemon</a> on it so I could control the music remotely from my laptop or phone. I mostly followed the <a href="http://mpd.wikia.com/wiki/MPD_on_OSX">OS X guide from MPD&#8217;s wiki</a> to do it but I ran into some problems while trying to daemonize mpd.</p>
<p>I got the following error while running mpd <em>without &#8211;no-daemon</em>:</p>
<blockquote><p>The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().<br />
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.</p></blockquote>
<p>When I ran <strong>mpd &#8211;no-daemon</strong> everything was fine though. So in order to &#8220;solve&#8221; this problem I&#8217;ve changed the plist file to include a <a href="http://www.gnu.org/software/screen/">screen</a> invocation.</p>
<p>My mpd.plist looks like that now:<br />
<pre><code2>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;dict&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;key&gt;Label&lt;/key&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;mpd&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;key&gt;ProgramArguments&lt;/key&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;array&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;/opt/local/bin/daemondo&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;--label=mpd&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;--start-cmd&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;screen&lt;/string&gt; &lt;!-- path to screen --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;-dmS&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;mpd&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;/opt/local/bin/mpd&lt;/string&gt; &lt;!-- path to MPD --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;-v&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;--no-daemon&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;/Users/kargig/.mpd/mpd.conf&lt;/string&gt; &lt;!-- path to MPD config --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;;&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;--stop-cmd&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;/opt/local/bin/mpd&lt;/string&gt; &lt;!-- path to MPD, again --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;--kill&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;/Users/kargig/.mpd/mpd.conf&lt;/string&gt; &lt;!-- path to MPD config, again --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;string&gt;;&lt;/string&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/array&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;key&gt;RunAtLoad&lt;/key&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;true/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;key&gt;Disabled&lt;/key&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;false/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/dict&gt;
&lt;/plist&gt;
</code2></pre></p>
<p>So <em>launchctl</em> calls <em>daemondo</em> which calls <em>screen</em> which runs <em>mpd &#8211;no-daemon</em>, so mpd doesn&#8217;t crash.</p>
<p>I use <a href="http://mpd.wikia.com/wiki/Client%3AMpdscribble">mpdscribble</a> for scrobbling my music to <a href="http://last.fm">last.fm</a>. Clients-wise, I use <a href="http://theremin.sigterm.eu/">Theremin</a> on OS X, <a href="http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client">Gnome Music Player Client/gmpc</a> on Debian Linux and <a href="https://market.android.com/details?id=com.namelessdev.mpdroid&#038;hl=en">MPDroid</a> on Android. And all those connections over IPv6 of course, over my LAN&#8217;s <a href="http://en.wikipedia.org/wiki/Unique_local_address">Unique Local Addresses</a> to be exact, mpd and all clients listed above work fine with IPv6.</p>
<p><pre><code2> # lsof -n -i | grep ESTABLISHED | grep 6600
mpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kargig&nbsp;&nbsp; 12u&nbsp;&nbsp;IPv6 0x49c719c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0t0&nbsp;&nbsp;&nbsp;&nbsp;TCP [fdbf:aaaa:aab0:447d:216:XXff:feaa:11XX]:6600-&gt;[fdbf:aaaa:aab0:447d:222:XXff:fe1e:d8XX]:48703 (ESTABLISHED)
mpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 43025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kargig&nbsp;&nbsp; 15u&nbsp;&nbsp;IPv6 0x3127cd4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0t0&nbsp;&nbsp;&nbsp;&nbsp;TCP [fdbf:aaaa:aab0:447d:216:XXff:feaa:11XX]:6600-&gt;[fdbf:aaaa:aab0:447d:fadb:XXff:fe4f:aXX]:51113 (ESTABLISHED)
</code2></pre></p>
<p>Apart from MPD&#8217;s wiki there&#8217;s another nice blog post you can read to help you install mpd on OS X, <a href="http://www.foldplop.com/blog/2011/05/10/integrating-mpd-with-os-x/">Integrating MPD with OS X</a>.<br />
For general reference on setting up mpd, <a href="https://wiki.archlinux.org/index.php/Music_Player_Daemon">Archilinux has a fine wiki entry</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/01/16/music-player-daemon-on-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux SSD partition alignment tips</title>
		<link>http://www.void.gr/kargig/blog/2012/01/11/linux-ssd-partition-alignment-tips/</link>
		<comments>http://www.void.gr/kargig/blog/2012/01/11/linux-ssd-partition-alignment-tips/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 19:49:03 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[alignment]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[erase block size]]></category>
		<category><![CDATA[ext4]]></category>
		<category><![CDATA[fdisk]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[partitions]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[SSD]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1307</guid>
		<description><![CDATA[Yes, this is another post on the internet about properly aligning your SSD partitions on Linux. It&#8217;s mostly my notes that I have gathered from other posts around the net. Please read the whole post before starting to create partitions on your SSD. Intro I bought myself a brand new SSD for Xmas, OCZ Agilty [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, this is another post on the internet about properly aligning your SSD partitions on Linux. It&#8217;s mostly my notes that I have gathered from other posts around the net. Please read the whole post before starting to create partitions on your SSD.</p>
<p><strong><em>Intro</em></strong><br />
I bought myself a brand new SSD for Xmas, <a href="http://www.ocztechnology.com/ocz-agility-3-sata-iii-2-5-ssd.html">OCZ Agilty 3 120Gb</a>. But I also bought a <a href="http://www.ebay.com/sch/i.html?_from=R40&#038;_trksid=m570.l2736&#038;_nkw=caddy+macbook">CDROM caddy</a> so that I could replace my useless macbook CDROM drive, last time I used it was probably 2009 or 2010. So my plan was to put the old, original macbook SATA hard disk inside the caddy and use the SSD as the primary one. Sounds easy right ? Well you just need patience, lots of patience in order to remove all necessary screws in order to get the CDROM drive out and replace it with the caddy. Instructions for this procedure can be found at <a href="http://www.ifixit.com/Guide/MacBook-Core-2-Duo-Optical-Drive-Replacement/518/1">iFixIt.com</a>. </p>
<p><strong><em>Create Partitions on the SSD disk</em></strong><br />
Before one begins some definitions!</p>
<blockquote><p>Heads = Tracks per cylinder<br />
Sectors = Sectors per track</p></blockquote>
<p>The goal here is to have the partitions aligned to the SSD&#8217;s <a href="http://en.wikipedia.org/wiki/Flash_memory#Block_erasure">Erase Block Size</a>.<br />
Googling around the net I found out that OCZ always uses 512Kb as Erase Block Size. If one uses fdisk with 32 Heads and 32 Sectors that makes a cylinder size of 1024b = 1Kb. Multiplying with 512 (sector size), which is fdisk&#8217;s default unit size, that makes it 512kb (=32*32*512)! Exactly the Erase Block Size that&#8217;s needed. So one needs to start fdisk issuing the following command:<br />
<code># fdisk -H32 -S32 /dev/sdb</code><br />
where /dev/sdb is the SSD.</p>
<p><em>It is very important to remember to start the first partition from the 2nd unit (or 512th cylinder if you prefer). Due to MS-DOS compatibility if the first partition were to start at the first cylinder, it would skip one track. So it would actually start at 32(sectors)*512(sector size)=16Kb, messing up the alignment.</em></p>
<p>Then create necessary partitions as needed.</p>
<p><strong><em>LVM alignment</em></strong><br />
So, the partitions on the SSD are aligned, but what if one wants to use LVM ? Then LVM&#8217;s overhead has to be taken into account as well.<br />
To create an aligned PV based on the partitions that have already been created one needs to use the &#8220;&#8211;dataalignment&#8221; option found in newer versions of LVM utilities.<br />
<code># pvcreate --dataalignment 512k /dev/sdb3</code><br />
To check the alignment use the following command:<br />
<pre><code2># pvs /dev/sdb3 -o+pe_start
&nbsp;&nbsp;PV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VG&nbsp;&nbsp; Fmt&nbsp;&nbsp;Attr PSize&nbsp;&nbsp; PFree&nbsp;&nbsp;1st PE 
&nbsp;&nbsp;/dev/sdb3&nbsp;&nbsp;ssd&nbsp;&nbsp;lvm2 a-&nbsp;&nbsp; 111.46g 81.46g 512.00k
</code2></pre><br />
Check that &#8220;1st PE&#8221; is what is actually needed for the alignment.</p>
<p>Proceed creating VGs and LVs as needed.</p>
<p><strong><em>Formatting Partitions with ext4</em></strong><br />
There&#8217;s no reason to use ext3 on SSD, one needs to take advantage of ext4 SSD features. I prefer 4K as block size.<br />
For a further explanation of the following formulas read <a href="https://raid.wiki.kernel.org/articles/r/a/i/RAID_setup_cbb2.html">Linux RAID Wiki &#8211; RAID setup</a><br />
<code>stride = chunk (Sector size) / block size = 512Kb / 4K = 128</code><br />
stripe-width is usually calculated by a formula that uses multiple disks. Since there&#8217;s only one disk in this scenario, stripe-width is equal to stride.<br />
<code>stripe-width = 128</code></p>
<p><code># mkfs.ext4 -O extent -b 4096 -E stride=128,stripe-width=128 /dev/mapper/ssd-debian</code></p>
<p><strong><em>Mounting the partition</em></strong><br />
To enable SSD <a href="http://en.wikipedia.org/wiki/TRIM">TRIM support</a>, which protects the disk from wearing off, one needs to enable the discard option while mounting the partition. Edit /etc/fstab and add the discard mount option (and noatime if you want to).<br />
<code>/dev/mapper/ssd-deb     /               ext4    discard,noatime,errors=remount-ro 0       1</code></p>
<p><em>Note 1: As of 2.6.37 Linux Kernel supports TRIM on device mapper. Previous kernel versions will report errors upon trying to mount an LVM partition with discard mount option. If you have an older kernel either don&#8217;t use LVM on your SSD yet or upgrade your kernel!</em><br />
<em>Note 2: Read the links posted below for a complete blog post over TRIM command. Apparently it&#8217;s not always the best choice</em></p>
<p>That&#8217;s basically it&#8230;</p>
<p><strong><em>Extra &#8211; copying the old root partition to the new disk</em></strong><br />
<pre><code2># mkdir /mnt/ssd/
# mount /dev/mapper/ssd-debian /mnt/ssd/
# rsync -aPEHv --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/mnt --exclude=/var/cache/apt/archives/ / /mnt/ssd/
# mkdir /mnt/ssd/dev
# mkdir /mnt/ssd/proc
# mkdir /mnt/ssd/sys
# mkdir /mnt/ssd/mnt
# cp -avp /dev/console /mnt/ssd/dev/
# cp -avp /dev/urandom /mnt/ssd/dev/
# cp -avp /dev/zero /mnt/ssd/dev/
# cp -avp /dev/random /mnt/ssd/dev/
# Edit /mnt/ssd/etc/fstab to change the device names
# Update grub
</code2></pre></p>
<p>Using the above commands one avoids copying unneeded directories like /dev, /sys, etc that will be recreated later. Don&#8217;t forget to at least copy the above 4 devices in the new /mnt/ssd/dev dir, else the partition won&#8217;t be bootable.</p>
<p><strong><em>References</em></strong><br />
1. <a href="http://web.archive.org/web/20090309070227/http://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size">Aligning Filesystems to an SSD’s Erase Block Size</a> (link goes to archive.org since original article has unfortunately disappeared from the web)<br />
2. <a href="http://www.redhat.com/archives/linux-lvm/2009-July/msg00004.html">[linux-lvm] Re: Aligning PVs on SSDs?</a><br />
3. <a href="http://www.nuclex.org/blog/personal/80-aligning-an-ssd-on-linux">Aligning an SSD on Linux</a> (excellent article!)<br />
4. <a href="https://wiki.archlinux.org/index.php/Solid_State_Drives">ArchWiki &#8211; Solid State Drives</a><br />
5. <a href="http://www.bit-integrity.com/2011/11/ssd-performance-tips-for-rhel6-and.html">SSD performance tips for RHEL6 and Fedora</a><br />
6. <a href="https://www.redhat.com/archives/dm-devel/2011-January/msg00035.html">Re: [dm-devel] trim support (discard)</a><br />
7. <a href="http://andyduffell.com/techblog/?p=852">How to check TRIM is working on your SSD running Linux</a><br />
8. <a href="https://patrick-nagel.net/blog/archives/337">Impact of ext4′s discard option on my SSD</a> (very useful insight on TRIM command, read the comments as well)</p>
<p><strong><em>Thanks</em></strong><br />
Thanks fly to <a href="https://twitter.com/apoikos">@apoikos</a> for helping me with the CDROM replacement and <a href="https://twitter.com/faidonl">@faidonl</a> for his original SSD alignment tips <img src='http://www.void.gr/kargig/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2012/01/11/linux-ssd-partition-alignment-tips/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Rate limit outgoing emails from PHP web applications using postfix and policyd</title>
		<link>http://www.void.gr/kargig/blog/2011/12/19/rate-limit-outgoing-emails-from-php-web-applications-using-postfix-and-policyd/</link>
		<comments>http://www.void.gr/kargig/blog/2011/12/19/rate-limit-outgoing-emails-from-php-web-applications-using-postfix-and-policyd/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 21:53:01 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[antispam]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[policyd]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[postfix-policyd]]></category>
		<category><![CDATA[relay]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1291</guid>
		<description><![CDATA[One of the worst things a webmaster or a anyone else that runs some web application can do, is to constantly send &#8220;informative newsletters&#8221; to people. Most CMS applications make it really easy to send such emails. These are 99% spam, and as such there are many good reasons that you should limit the amount [...]]]></description>
			<content:encoded><![CDATA[<p>One of the worst things a webmaster or a anyone else that runs some web application can do, is to constantly send &#8220;informative newsletters&#8221; to people. Most CMS applications make it really easy to send such emails. These are 99% spam, and as such there are many good reasons that you should limit the amount of such outgoing &#8220;newsletters&#8221; coming out of your email server. Else there&#8217;s a good chance you might get added to a blacklist, and you don&#8217;t want your legitimate clients to have their emails blocked because of some irresponsible people. I recently had to deploy such a solution to a hosting server that serves multiple (>300) domains. The server already ran <a href="http://www.postfix.org/">postfix</a>, so I had to implement something useful around it.</p>
<p>The problem with postfix is that you can&#8217;t really rate-limit the outgoing queue per sender domain/address. There are only generic settings that control the general mail server&#8217;s capabilities of sending emails. What I wanted though is to have the ability to restrict specific domains to some specific email message count per day. This is something that a postfix addon named <a href="http://www.policyd.org/">postfix-policyd</a> can do by deferring/greylisting, but still just on the incoming queue. One would think that the problems would be solved by just applying this, but truth is that they don&#8217;t. Applying a defer/greylisting policy on the incoming queue is fine while the client on the remote side is another SMTP server that can happily store the deferred email on its queue and retry some minutes/hours later. What happens though if the SMTP client is a PHP application that connects through the <a href="http://php.net/manual/en/function.mail.php">mail() function</a> ? There you have no queue and if you defer a message at the SMTP server it will get forever lost, PHP can&#8217;t resend it. So the solution would be to apply an intermediate SMTP queue between PHP and the primary SMTP server, that is another local postfix installation that would only serve as a queue that relays emails to the primary.</p>
<p>Using a &#8220;simple&#8221; diagram sending an email from PHP should follow this path upon a successful installation:</p>
<blockquote><p>PHP mail() &#8211;(sendmail binary)&#8211;> intermediate_POSTFIX &#8211;(SMTP relay)&#8211;> POSTFIX &#8211;(smtpd_sender_restrictions)&#8211;> POLICYD &#8211;(pickup)&#8211;> POSTFIX &#8211;(SMTP)&#8211;> REMOTE SERVER</p></blockquote>
<p>Here are the steps I took on a <a href="http://www.debian.org/">Debian</a> Squeeze server to install this little monster.</p>
<p><em><strong>1. Create a new postfix configuration directory for the new intermediate postfix instance</strong></em><br />
I named my intermediate postfix config dir as postfix2525, name comes from the port that it will listen on but you can definitely be more creative.<br />
<pre><code2># mkdir /etc/postfix2525
# cp -av /etc/postfix /etc/postfix2525</code2></pre></p>
<p>Remove everything from /etc/postfix2525/main.cf and just add the following lines:<br />
<pre><code2>data_directory = /var/lib/postfix2525
queue_directory = /var/spool/postfix2525
relayhost = 127.0.0.1:12525</code2></pre></p>
<p>This defines a new data and queue directory and instructs this postfix to relay all emails through another one that listens on the localhost, the primary one, on port 12525. More about this port later when you will create some special config on the primary postfix.</p>
<p>Remove previous contents of /etc/postfix2525/master.cf and just add these lines:<br />
<pre><code2>127.0.0.1:2525&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inet&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtpd
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o syslog_name=postfix2525
pickup&nbsp;&nbsp;&nbsp;&nbsp;fifo&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pickup
cleanup&nbsp;&nbsp; unix&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&n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bsp;&nbsp;&nbsp; flush
proxymap&nbsp;&nbsp;unix&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxymap
proxywrite unix -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxymap
smtp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unix&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay&nbsp;&nbsp;&nbsp;&nbsp; unix&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; smtp
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-o smtp_fallback_relay=
#&nbsp;&nbsp;&nbsp;&nbsp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1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scache</code2></pre></p>
<p>Obviously the most important part here is the first line. It defines that this postfix instance will listen for SMTP connections on localhost, port 2525 and it&#8217;s syslog output name will be postfix2525 so that it&#8217;s easier to tell apart which SMTP instance spits which errors.</p>
<p>After this is done you need to run the following command that will create all necessary directories with their proper permissions.<br />
<pre><code2># postfix -c /etc/postfix2525/ check
</code2></pre></p>
<p>You will also need a new init script. Since the script by itself is quite big and there are only a few lines that actually differ, I will post my diff here:<br />
<pre><code2>--- /etc/init.d/postfix&nbsp;&nbsp;2011-05-04 21:17:47.000000000 +0200
+++ /etc/init.d/postfix2525&nbsp;&nbsp;2011-12-19 19:22:09.000000000 +0100
@@ -17,8 +17,10 @@
 # Description:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; postfix is a Mail Transport agent
 ### END INIT INFO
 
+CONFDIR=/etc/postfix2525
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 DAEMON=/usr/sbin/postfix
+DAEMON_OPTIONS=&quot;-c /etc/postfix2525&quot;
 NAME=Postfix
 TZ=
 unset TZ
@@ -28,13 +30,13 @@
 
 test -f /etc/default/postfix &amp;&amp; . /etc/default/postfix
 
-test -x $DAEMON &amp;&amp; test -f /etc/postfix/main.cf || exit 0
+test -x $DAEMON &amp;&amp; test -f /etc/postfix2525/main.cf || exit 0
 
 . /lib/lsb/init-functions
 #DISTRO=$(lsb_release -is 2&gt;/dev/null || echo Debian)
 
 running() {
-&nbsp;&nbsp;&nbsp;&nbsp;queue=$(postconf -h queue_directory 2&gt;/dev/null || echo /var/spool/postfix)
+&nbsp;&nbsp;&nbsp;&nbsp;queue=$(postconf -c $CONFDIR -h queue_directory 2&gt;/dev/null || echo /var/spool/postfix2525)
&nbsp;&nbsp;&nbsp;&nbsp; if [ -f ${queue}/pid/master.pid ]; then
&nbsp;&nbsp; pid=$(sed &#039;s/ //g&#039; ${queue}/pid/master.pid)
&nbsp;&nbsp; # what directory does the executable live in.&nbsp;&nbsp;stupid prelink systems.
@@ -66,7 +68,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # see if anything is running chrooted.
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NEED_CHROOT=$(awk &#039;/^[0-9a-z]/ &amp;&amp; ($5 ~ &quot;[-yY]&quot;) { print &quot;y&quot;; exit}&#039; /etc/postfix/master.cf)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NEED_CHROOT=$(awk &#039;/^[0-9a-z]/ &amp;&amp; ($5 ~ &quot;[-yY]&quot;) { print &quot;y&quot;; exit}&#039; /etc/postfix2525/master.cf)
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if [ -n &quot;$NEED_CHROOT&quot; ] &amp;&amp; [ -n &quot;$SYNC_CHROOT&quot; ]; then
&nbsp;&nbsp;&nbsp;&nbsp; # Make sure that the chroot environment is set up correctly.
@@ -111,7 +113,7 @@
&nbsp;&nbsp;&nbsp;&nbsp; umask $oldumask
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fi
 
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if start-stop-daemon --start --exec ${DAEMON} -- quiet-quick-start; then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if start-stop-daemon --start --exec ${DAEMON} -- ${DAEMON_OPTIONS} quiet-quick-start; then
&nbsp;&nbsp;&nbsp;&nbsp; log_end_msg 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp; log_end_msg 1
@@ -123,7 +125,7 @@
&nbsp;&nbsp; RUNNING=$(running)
&nbsp;&nbsp; log_daemon_msg &quot;Stopping Postfix Mail Transport Agent&quot; postfix
&nbsp;&nbsp; if [ -n &quot;$RUNNING&quot; ]; then
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ${DAEMON} quiet-stop; then
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ${DAEMON} ${DAEMON_OPTIONS} quiet-stop; then
&nbsp;&nbsp;&nbsp;&nbsp; log_end_msg 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp; log_end_msg 1
</code2></pre></p>
<p>If everything went well up to now you should be able to start your new postfix instance and check that it is actually running.<br />
<pre><code2># /etc/init.d/postfix2525 start
# netstat -antp | grep 2525
tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:2525&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6138/master</code2></pre></p>
<p><em><strong>2. Configure main postfix to accept emails from the intermediate</strong></em><br />
Edit /etc/postfix/master.cf and add this line at the bottom:<br />
<pre><code2>127.0.0.1:12525 inet n - - - - smtpd&nbsp;&nbsp;-o smtp_fallback_relay= -o smtpd_client_restrictions=&nbsp;&nbsp;-o smtpd_helo_restrictions=&nbsp;&nbsp;-o smtpd_recipient_restrictions=permit_mynetworks,reject&nbsp;&nbsp;-o smtpd_data_restrictions=&nbsp;&nbsp;-o receive_override_options=no_unknown_recipient_checks
</code2></pre></p>
<p>This defines a special port for the main postfix instance that has (or maybe it hasn&#8217;t actually) some special restrictions.<br />
Actually you will have to change this line later on upon installing postfix-policyd, but this should be good enough for now, in order for you to do some testing.<br />
Restart postfix<br />
<pre><code2># /etc/init.d/postfix restart
# netstat -antp | grep 2525
tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:12525&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;26799/master&nbsp;&nbsp;&nbsp;&nbsp;
tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 127.0.0.1:2525&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0.0.0.0:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6138/master&nbsp;&nbsp; 
</code2></pre></p>
<p>The intermediate postfix listens on 127.0.0.1:2525 and the main one has another special listening port on 127.0.0.1:12525.</p>
<p><em><strong>3. Test your intermediate postfix instance</strong></em><br />
You can do this in a gazillion different ways. One of my favorite ways to test SMTP connectivity is through telnet (&#8212;> shows data entry):<br />
<pre><code2># telnet localhost 2525
Trying 127.0.0.1...
Connected to localhost.
Escape character is &#039;^]&#039;.
220 server.mydomain.gr ESMTP Postfix
---&gt; EHLO koko.gr
250-server.mydomain.gr
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
---&gt; MAIL FROM: lala@koko.gr
250 2.1.0 Ok
---&gt; RCPT TO: koko@destination.gr
250 2.1.5 Ok
---&gt; DATA
354 End data with &lt;CR&gt;&lt;LF&gt;.&lt;CR&gt;&lt;LF&gt;
---&gt; THIS IS A TEST
---&gt; .
250 2.0.0 Ok: queued as C41E21C84FF
---&gt; quit
</code2></pre></p>
<p>If you were keeping an eye on syslog messages you should have seen some connection messages both from postfix2525 and from postfix. If everything went well your email _should_ have arrived at it&#8217;s destination. If this is true then your primary postfix instance now works as a relay for your intermediate queue.</p>
<p><strong>Don&#8217;t read the next parts of this post if you haven&#8217;t previously managed this step!</strong></p>
<p><em><strong>4. Install and configure postfix-policyd</strong></em><br />
<pre><code2># aptitude install postfix-policyd
</code2></pre><br />
To run policyd you need to create a database and import policyd SQL schema to it. Your distro has probably already taken care of the previous step, if it hasn&#8217;t&#8230;do it manually and think about changing distro!<br />
Then edit the config file usually located at /etc/postfix-policyd.conf. The options I chose to play with were the following:<br />
<pre><code2>SENDERTHROTTLE=1
SENDER_THROTTLE_SASL=1
SENDER_THROTTLE_HOST=0</code2></pre></p>
<p>Since all emails will be relayed through localhost there&#8217;s no point in throttling per host, what is needed is throttling per envelope sender.<br />
You should manually review your desired limits though. I won&#8217;t post mine here because everyone has different needs and there&#8217;s no sane config for everyone.</p>
<p>Start postfix-policyd<br />
<code># /etc/init.d/postfix-policyd start</code></p>
<p>If you get weird startup errors like:<br />
<code>postfix-policyd: fatal: didn't find priority 'LOG_IFOO', exiting</code><br />
Edit /etc/postfix-policyd.conf, find the following line:<br />
<code>SYSLOG_FACILITY="LOG_MAIL | LOG_INFO"</code><br />
and change it to (mind the removed spaces):<br />
<code>SYSLOG_FACILITY="LOG_MAIL|LOG_INFO"</code></p>
<p><em><strong>5. Configure main postfix instance to use postifix-policyd</strong></em><br />
Edit /etc/postfix/main.cf and add this:<br />
<code>webclient_restrictions = check_policy_service inet:127.0.0.1:10031</code></p>
<p>Then edit /etc/postfix/master.cf again and change the line you had previously added to the bottom of the file with this:<br />
<pre><code2>127.0.0.1:12525 inet n - - - - smtpd&nbsp;&nbsp;-o smtp_fallback_relay= -o smtpd_client_restrictions=&nbsp;&nbsp;-o smtpd_helo_restrictions=&nbsp;&nbsp;-o smtpd_recipient_restrictions=permit_mynetworks,reject&nbsp;&nbsp;-o smtpd_data_restrictions=&nbsp;&nbsp;-o receive_override_options=no_unknown_recipient_checks -o smtpd_sender_restrictions=${webclient_restrictions}
</code2></pre></p>
<p>The difference is<br />
<code>-o smtpd_sender_restrictions=${webclient_restrictions}</code><br />
which practically instructs postfix to use postfix-policyd for emails that arrive on port 12525, which is the port that the intermediate postfix instance uses to relay all emails.</p>
<p><em><strong>6. Test your intermediate postfix instance again</strong></em><br />
If everything went well, the main postfix instance should now be able to enforce sender policies. Try sending a new email through the intermediate postfix again, yes using telnet, and you should pickup some new log lines at your syslog:</p>
<blockquote><p>Dec 19 21:56:40 myserver postfix-policyd: connection from: 127.0.0.1 port: 45635 slots: 0 of 4096 used<br />
Dec 19 21:56:40 myserver postfix-policyd: rcpt=5, greylist=new, host=127.0.0.1 (unknown), from=lala@koko.gr, to=koko@lalala.gr, size=348<br />
Dec 19 21:56:40 myserver postfix/smtpd[9168]: NOQUEUE: reject: RCPT from unknown[127.0.0.1]: 450 4.7.1 <lala @koko.gr>: Sender address rejected: Policy Rejection- Please try later.; from=</lala><lala @koko.gr> to=<koko @lalala.gr> proto=ESMTP helo=<myserver .mydomain.gr><br />
Dec 19 21:56:40 myserver postfix/smtp[8970]: C41E21C84FF: to=<koko @lalala.gr>, relay=127.0.0.1[127.0.0.1]:12525, delay=20, delays=20/0/0.01/0, dsn=4.7.1, status=deferred (host 127.0.0.1[127.0.0.1] said: 450 4.7.1 <lala @koko.gr>: Sender address rejected: Policy Rejection- Please try later. (in reply to RCPT TO command))</lala></koko></myserver></koko></lala></p></blockquote>
<p>The above means that greylisting through policyd works.</p>
<p><em><strong>7. make PHP use your new intermediate postfix instance</strong></em><br />
PHP on linux by default uses the sendmail binary to send emails via the mail() function. That would use the main postfix instance though, so one needs to edit /etc/php/apache2/php.ini and change the following line:<br />
<code>sendmail_path = sendmail -C /etc/postfix2525 -t -i</code></p>
<p>The -C directive instructs sendmail to use the alternate config dir, so that emails will be sent to the new intermediate postfix instance and then to the main one, passing through policyd of course.</p>
<p>To check the queue size of the intermediate postfix:<br />
<code># postqueue -p -c /etc/postfix2525/</code></p>
<p>If any PHP applications that are hosted have explicit SMTP server/port directives, then be sure to notify your clients/developers that they _MUST_ use localhost:2525 to send their emails to and not the default localhost:25. This is one of the shortcomings of the above method, if someone manually sets up his application to use the default localhost:25 his emails will get right through. But being a good sysadmin, you should monitor such behavior and punish those users accordingly!</p>
<p>That&#8217;s about it&#8230;with the above configuration and some tweaking to the thresholds you have very good chances of avoiding getting blacklisted because someone decided to send a few thousand spams emails. And most importantly, your normal mail service will continue to work flawlessly, no matter how big the queue of the intermediate mail server is.</p>
<p>Enjoy!</p>
<p>Reference for policyd: <a href="http://policyd.sourceforge.net/readme.html">http://policyd.sourceforge.net/readme.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/12/19/rate-limit-outgoing-emails-from-php-web-applications-using-postfix-and-policyd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Handling right clicks on a macbook running Linux &#8211; The 2011 Awesome Edition</title>
		<link>http://www.void.gr/kargig/blog/2011/12/18/handling-right-clicks-on-a-macbook-running-linux-the-2011-awesome-edition/</link>
		<comments>http://www.void.gr/kargig/blog/2011/12/18/handling-right-clicks-on-a-macbook-running-linux-the-2011-awesome-edition/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 20:38:10 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[fluxbox]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[right-click]]></category>
		<category><![CDATA[tiling]]></category>
		<category><![CDATA[xautomation]]></category>
		<category><![CDATA[xbindkeys]]></category>
		<category><![CDATA[xte]]></category>
		<category><![CDATA[xvkbd]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1283</guid>
		<description><![CDATA[2 years ago I had written a post about handling right clicks on a macbook running linux. Along with changing my window manager of choice, I think I&#8217;ve found a better/more elegant solution to that problem. On my computer&#8217;s workspaces one will normally find one or two browser windows open, some instant messaging applications (skype,pidgin), [...]]]></description>
			<content:encoded><![CDATA[<p>2 years ago I had written a post about <a href="/kargig/blog/2009/06/11/handling-right-clicks-on-a-macbook-running-linux/">handling right clicks on a macbook running linux</a>. Along with changing my window manager of choice, I think I&#8217;ve found a better/more elegant solution to that problem.</p>
<p>On my computer&#8217;s workspaces one will normally find one or two browser windows open, some instant messaging applications (skype,pidgin), an mp3 player (audacious2) and terminals. Lots of them. I need them to ssh to the servers I monitor/administer and for coding (with vim of course!). I even use one for my email client (mutt). So I need my terminals to be as efficient as possible. After many trials over the years I&#8217;ve decided on using <a href="http://software.schmorp.de/pkg/rxvt-unicode.html">urxvt</a> as my terminal of choice.</p>
<p>About a month ago I gave <a href="http://awesome.naquadah.org/">awesome</a> a try and since then it&#8217;s been my window manager of choice instead of <a href="http://fluxbox.org/">fluxbox</a>. The reason behind this is mostly fluxbox&#8217;s inability to tile terminal (call me urxvt) windows efficiently while changing resolutions. I mostly use my laptop with an external 23&#8221; monitor but I wanted to be able to tile my terminals independently of using only my laptop&#8217;s screen or both laptop&#8217;s and the external one. In fluxbox you can make a window appear on specific area of the screen, so I could open 3-4 terminals on a specific workspace/monitor. Resizing though one of them to fit some monitoring program more efficiently didn&#8217;t resize the others &#8216;automagically&#8217; as well. So, I had to manually resize all open windows of that workspace. Yes, this is horrible from a usability point of view, luckily I didn&#8217;t have to do it that frequently. So, I gave awesome a try for its tiling features. I really miss though <a href="http://fluxbox-wiki.org/index.php?title=Editing_the_apps_file#Grouping_apps_via_the_apps_file">fluxbox&#8217;s tabbing features</a> that I constantly used along with it&#8217;s amazing keybindings flexibility (Rant: isn&#8217;t it stupid that you have to write your keybindings in lua for awesome and in haskell for xmonad ?) but the tiling capabilities of awesome are currently more important to me.</p>
<p>So while my previous solution for right clicking without a mouse worked pretty well for fluxbox, in my new awesome world I&#8217;ve replaced it with <a href="http://hoopajoo.net/projects/xautomation.html">xautomation</a> tools. First of all, one needs to install xautomation tools </p>
<p><code>aptitude install xautomation</code></p>
<p>Then find <em>clientbuttons</em> configuration part in the default <em>~/.config/awesome/rc.lua</em> and add this line to it:</p>
<p><code>awful.button({ modkey }, 2, function () awful.util.spawn("xte 'mouseclick 3'") end)</code></p>
<p>restart awesome and try <em>modkey + 3 finger tap on your touchpad</em>. You should be seeing a right click &#8220;menu&#8221;.<br />
If you don&#8217;t know what 3 finger tap is or how to configure it, read the 2009 article.</p>
<p>That&#8217;s it, no more xbindkeys + xvkbd for awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/12/18/handling-right-clicks-on-a-macbook-running-linux-the-2011-awesome-edition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>my past 2 articles for LinuxInside</title>
		<link>http://www.void.gr/kargig/blog/2011/11/30/my-past-2-articles-for-linuxinside/</link>
		<comments>http://www.void.gr/kargig/blog/2011/11/30/my-past-2-articles-for-linuxinside/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 18:21:58 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Greek]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[linuxinside]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1270</guid>
		<description><![CDATA[Following my first article on the Greek Linux Magazine called LinuxInside about IPv6, I uploaded my past 2 articles for it. Both articles are in Greek of course. The first one is about debugging network connectivity issues using the command line on Linux. It was published on the 2nd issue of LinuxInside. Εντοπίζοντας ένα πρόβλημα [...]]]></description>
			<content:encoded><![CDATA[<p>Following my first article on the Greek Linux Magazine called <a href="http://www.linuxinside.gr/">LinuxInside</a> about <a href="http://www.void.gr/kargig/presentations/LinuxInside_1_IPv6.pdf">IPv6</a>, I uploaded my past 2 articles for it. Both articles are in Greek of course.</p>
<p>The first one is about debugging network connectivity issues using the command line on Linux. It was published on the 2nd issue of LinuxInside.<br />
<a href="http://www.void.gr/kargig/presentations/LinuxInside_2_Network-Debugging.pdf">Εντοπίζοντας ένα πρόβλημα δικτύωσης</a></p>
<p>The other one is an introduction to <a href="http://www.zsh.org/">Zsh</a>. It was published on the 3rd issue of LinuxInside.<br />
<a href="http://www.void.gr/kargig/presentations/LinuxInside_3_Zsh.pdf">Κατακτήστε το Z shell</a></p>
<p>If you haven&#8217;t read the magazine already, feel free to download those pdfs and read them.<br />
All my presentations/articles can be found at: <a href="/kargig/blog/presentations/">Articles/Presentations</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/11/30/my-past-2-articles-for-linuxinside/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>0&#215;375 &#8211; 0&#215;07 &#8211; Security Considerations for a brave new (IPv6) World</title>
		<link>http://www.void.gr/kargig/blog/2011/11/28/0x375-0x07-security-considerations-for-a-brave-new-ipv6-world/</link>
		<comments>http://www.void.gr/kargig/blog/2011/11/28/0x375-0x07-security-considerations-for-a-brave-new-ipv6-world/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 19:06:30 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Greek]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[0x375]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Thessaloniki]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1253</guid>
		<description><![CDATA[I finally had the chance to present something at the Thessaloniki Tech Talk Sessions also known as 0&#215;375. The people over there have done a great job, and I truly mean that, bringing tech people together. Almost once a month 2 speakers can present a tech topic they like at an open auditorium inside the [...]]]></description>
			<content:encoded><![CDATA[<p>I finally had the chance to present something at the <a href="http://0x375.org">Thessaloniki Tech Talk Sessions</a> also known as <a href="http://0x375.org">0&#215;375</a>. The people over there have done a great job, and I truly mean that, bringing tech people together. Almost once a month 2 speakers can present a tech topic they like at an open auditorium inside the <a href="http://www.auth.gr/">Aristotle University of Thessaloniki</a>. On those events people from Thessaloniki, but also from nearby cities, gather and have a great time, not only during the presentations but afterwards as well. I won&#8217;t spoil the events that take place during the tech talks, because you should definitely go if you are curious, but I can tell you that it&#8217;s not uncommon for as many as 15 to 20 people to go for beers after the talks!</p>
<p>So, the past Friday (25/11/2011), me and <a href="https://twitter.com/#!/apoikos">@apoikos</a> traveled from Athens to Thessaloniki to present at 0&#215;375. My presentation was about some security concepts on IPv6 networks, how old attacks of the IPv4 world transform to new ones on the IPv6 world and about some new ones that will appear on local networks sooner or later. I also had prepared some small live demos, but as always it&#8217;s very hard to succeed in a live demo if you don&#8217;t quite control the environment. At least some of the stuff I wanted to show were successful, and I&#8217;m happy with those. (Thanks to <a href="http://codelab.wordpress.com/">Nuclear</a> for booting his OS X guinea pig)</p>
<p>Some apologies&#8230;When giving a presentation on IPv6, in an event that has no other introductory IPv6 presentations, I always face the same problem, most people are not very well aware of how different this protocol is from IPv4. When I ask the audience how well do they know IPv6, most people are embarrassed to say they have never actually used it, so the audience stays very, VERY silent. This means that I have to put around 15-20 slides to make a &#8220;quick introduction to IPv6&#8243;, and this unfortunately takes usually over 30&#8242; of presentation time. Some techy/advanced people might be bored with this, but there&#8217;s no other way to overcome this &#8220;issue&#8221;. If you go straight to the point and start discussing about ND ICMPv6 messages most people won&#8217;t be able to keep up&#8230;so I&#8217;m sorry if I made some of the audience get bored by my first slides. I promise that my next talk on 0&#215;375, cause there will surely be a next one, will be less boring for you <img src='http://www.void.gr/kargig/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thank you all for coming there, I hope you enjoyed it as much as I did!</p>
<p>You can find the slides and my live demo notes here:<br />
<a href="/kargig/presentations/0x375-kargig_-_Security_considerations_for_IPv6.pdf">0&#215;375 &#8211; 0&#215;07 &#8211; kargig &#8211; Security Considerations for a brave new (IPv6) World</a> (pdf)<br />
<a href="/kargig/presentations/0x375-kargig_-_Security_considerations_for_IPv6_demo_notes.txt">0&#215;375 &#8211; 0&#215;07 &#8211; kargig &#8211; Security Considerations for a brave new (IPv6) World &#8211; live demo notes</a> (txt)</p>
<p>P.S. I&#8217;ve started collecting some interesting (for me) presentations regarding IPv6 topics at <a href="/kargig/ipv6/">void.gr/kargig/ipv6/</a>. Check them out if you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/11/28/0x375-0x07-security-considerations-for-a-brave-new-ipv6-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GrRBL goes django</title>
		<link>http://www.void.gr/kargig/blog/2011/11/07/grrbl-goes-django/</link>
		<comments>http://www.void.gr/kargig/blog/2011/11/07/grrbl-goes-django/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 19:27:28 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Greek]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Privacy]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[adblock plus]]></category>
		<category><![CDATA[antispam]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[grrbl]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rbl]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1239</guid>
		<description><![CDATA[I&#8217;ve had this thought for some time now, I needed a nice interface for GrRBL so that it would make it easier for others, read more, people to contribute. Many people have been, politely, complaining about lack of features, policy and so on. Right now most people use either the submission form or they bounce [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had this thought for some time now, I needed a nice interface for <a href="http://grrbl.void.gr">GrRBL</a> so that it would make it easier for others, read more, people to contribute. Many people have been, politely, complaining about lack of features, policy and so on.</p>
<p>Right now most people use either the <a href="http://grrbl.void.gr/grrbl_submission.php">submission form</a> or they bounce their emails to grrbl [at] void [dot] gr. Then their emails get manually processed, filtered and if everything goes well the &#8220;useful&#8221; parts of their email end up in the <a href="http://grrbl.void.gr/">DNS RBL </a>or the <a href="http://grrbl.void.gr/#email_blacklist">email address blacklist</a>. This process is not automated at all, entries are manually added to a database, and is therefore quite time consuming. What&#8217;s worse is that people who are listed don&#8217;t have an &#8216;easy&#8217; way to opt-out, apart from emailing us. The algorithm of adding someone to these lists is also not well-defined. The main rule that is followed is that an IP or email address is added to these lists when at least 3 people have submitted them on different days.</p>
<p>Hopefully this is about to change soon (I don&#8217;t know how soon, but soon!). During the past month I&#8217;ve been trying to code an interface in django, even though I had no prior experience in it. It&#8217;s mostly a self educating process and I like it very much. This django application will be generic enough to cover submissions and listings for IPs, emails and possibly URLs.</p>
<li>Short term goals:</li>
<p>Anonymous users will only get to see details about an IP they search for. People though will be able to register and add their own entries to a database. These registered users will be able to see the complete listings. Each user will belong to a group and every group will have a different weight which will depend on his &#8216;expertise&#8217; (I know this is broad, but read on). For example, the group of the individual users will certainly have less weight than the group of the postmasters of Greek ISPs (yeap there are some who regularly contribute). Using their weights users will be able to vote on each entry that&#8217;s inside the database. Upon a certain score these entries will be flagged as eligible to be on the blacklist. Listed people will be able to opt-out but this process will be moderated by the superusers, that means that spammers like the infamous sofokleous10 will never get a chance to opt-out even for a single second.<br />
Most of this functionality is already coded and is working quite well.</p>
<li>Mid term goals:</li>
<p>Various export formats will be supported (BIND/RBLDNSD, Spamassassin/Postifix/Exim/sendmail/etc). Selective/custom export of entries will be provided. Users will be able to select if they want to export/use a strict blacklist, that is hosts that are scored very high, a moderate one and a very broad/risky one. Levels have yet to be defined. An API will be published so that entries can be re-used in other applications (json format ?)</p>
<li>Long term goals:</li>
<p>A method/interface that someone would copy/paste their email and it would automagically parse it, provide the user with the discovered malicious entries (IP, emails, URLs) and propose him to add them to the database. Maybe automate this even further so that they are added on a separate moderated queue without user interaction, that would be suitable for submitting entries via email plugins for clients such as mutt/thunderbird/etc.</p>
<li>The code:</li>
<p>The django application code resides in github for now: <a href="https://github.com/kargig/grrbl_django">https://github.com/kargig/grrbl_django</a>. Everyone is welcome to submit ideas (as issues) and code! Feel free to download, test and provide feedback.</p>
<li>Greek Adblock Plus Filter</li>
<p>Since the code is very flexible I am thinking whether <a href="http://www.void.gr/kargig/blog/greek-adblock-plus-filter/">Greek Adblock Plus Filter</a> can also be benefited by this voting system. It probably can, so expect some changes to that list as well. One interface to rule them all.</p>
<p>Many thanks go to <a href="https://twitter.com/#/apoikos">@apoikos</a> who has been helping me a lot with the tons of questions I still have on django stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/11/07/grrbl-goes-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes on HP raid controllers</title>
		<link>http://www.void.gr/kargig/blog/2011/10/02/notes-on-hp-raid-controllers/</link>
		<comments>http://www.void.gr/kargig/blog/2011/10/02/notes-on-hp-raid-controllers/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 09:15:35 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Accelerator ratio]]></category>
		<category><![CDATA[cache ratio]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[hpacucli]]></category>
		<category><![CDATA[P410]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[raid controller]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Write Cache]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1228</guid>
		<description><![CDATA[Lately I had to deal with some HP raid controllers and I&#8217;ve gathered some notes on them. I&#8217;ll post them here so I won&#8217;t forget about them. First of all, don&#8217;t even think on using them without a battery pack. Seriously DON&#8217;T. The performance degradation is humongous. Without a battery pack the controllers were giving [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I had to deal with some HP raid controllers and I&#8217;ve gathered some notes on them. I&#8217;ll post them here so I won&#8217;t forget about them.</p>
<p>First of all, don&#8217;t even think on using them without a battery pack. Seriously DON&#8217;T. The performance degradation is humongous. Without a battery pack the controllers were giving me 1/20th of the results with a battery pack. If you want to quickly test them, try <a href="http://www.iozone.org">iozone</a> using the following options: <code>iozone -t4 -I</code></p>
<p>Installing hpacucli is a also a must if you want to monitor or configure the controllers from within your OS. Be sure to add the repositories from <a href="http://hwraid.le-vert.net/">HWraid</a> to your system and then issue: <code>aptitude install hpacucli</code> (you are using Debian, arent&#8217; you?). That reminds me that I am using those repositories on so many systems I manage that I must send a donation to the people at hwraid to thank them.</p>
<p>Below are some commands using hpacucli that I used.<br />
# Show everything about your raid controllers<br />
<code># hpacucli controller all show config detail</code></p>
<blockquote><p>   Cache Board Present: True<br />
   Cache Status: OK<br />
   Accelerator Ratio: 25% Read / 75% Write<br />
   Drive Write Cache: Enabled<br />
   Total Cache Size: 512 MB<br />
   Battery Pack Count: 1<br />
   Battery Status: OK<br />
   SATA NCQ Supported: True</p></blockquote>
<p>What you must take notice here is the Accelerator Ratio, Drive Write Cache and Battery Pack Count.<br />
if you have a battery pack installed but your Drive Write Cache is still shown as &#8220;Disabled&#8221;, you can enable it using the command:<br />
<code># hpacucli controller slot=X modify dwc=enable</code><br />
You&#8217;ll know what to put instead of &#8220;slot=X&#8221; from the output of the previous command (show config detail).</p>
<p>To modify Accelerator Ratio (read/write):<br />
<code># hpacucli controller slot=X modify cacheratio=25/75</code></p>
<p>To enable Array Acceleration for one of your logical drives use:<br />
<code> # hpacucli controller slot=X logicaldrive Y modify aa=enable</code></p>
<p>If you happen to face the following error while opening hpacucli, don&#8217;t worry. You don&#8217;t need to reboot your machine as I&#8217;ve seen in various blogs.</p>
<blockquote><p>Error: Another instance of ACU is already running (possibly a service). Please<br />
       terminate the ACU application before running the ACU CLI. Press ENTER to<br />
       exit.</p></blockquote>
<p>What you need to do is delete the shared IPC that hpacucli left when it got killed for some reason.<br />
To see all your ipcs:<br />
<pre><code2># ipcs
------ Shared Memory Segments --------
key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shmid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bytes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nattch&nbsp;&nbsp;&nbsp;&nbsp; status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

------ Semaphore Arrays --------
key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;semid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nsems&nbsp;&nbsp;&nbsp;&nbsp; 
0xffffffff 32768&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

------ Message Queues --------
key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msqid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used-bytes&nbsp;&nbsp; messages&nbsp;&nbsp;&nbsp;&nbsp;
</code2></pre></p>
<p>Then use ipcrm to remove the array with the semid you want:<br />
<code># ipcrm -s 32768</code></p>
<p>and try to start hpacucli again.</p>
<p>References:<br />
1. <a href="http://www.datadisk.co.uk/html_docs/redhat/hpacucli.htm">http://www.datadisk.co.uk/html_docs/redhat/hpacucli.htm</a><br />
2. <a href="http://people.freebsd.org/~jcagle/hpacucli-readme">http://people.freebsd.org/~jcagle/hpacucli-readme</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/10/02/notes-on-hp-raid-controllers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Block Greek ads with Internet Explorer 9+</title>
		<link>http://www.void.gr/kargig/blog/2011/08/24/block-greek-ads-with-internet-explorer-9/</link>
		<comments>http://www.void.gr/kargig/blog/2011/08/24/block-greek-ads-with-internet-explorer-9/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 21:22:20 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Greek]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[adblock plus]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[iceweasel]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[tpl]]></category>
		<category><![CDATA[tracking protection list]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1223</guid>
		<description><![CDATA[Greek Adblock Plus filter list has more than 3500 regular unique (as per IP) subscribers daily. The majority of them uses some Mozilla-based browser (Firefox/Iceweasel). An increasing number of users has started using Chrome along with the Chrome Adblock Extension and Opera. Thanks to Panagiotis Dimopoulos, Greek Adblock Plus filter has now been converted to [...]]]></description>
			<content:encoded><![CDATA[<p>Greek Adblock Plus filter list has more than 3500 regular unique (as per IP) subscribers daily. The majority of them uses some Mozilla-based browser (Firefox/Iceweasel). An increasing number of users has started using Chrome along with the <a href="https://chrome.google.com/webstore/detail/gighmmpiobklfepjocnamgkkbiglidom">Chrome Adblock Extension</a> and Opera. Thanks to Panagiotis Dimopoulos, Greek Adblock Plus filter has now been converted to a <a href="http://ie.microsoft.com/testdrive/Browser/TrackingProtectionLists/faq.html">Tracking Protection List</a> for Internet Explorer 9+. </p>
<p>To load the protection list visit the url: <a href="http://void.gr/kargig/ie_tpl.html">Greek Adblock Tracking Protection List for Internet Explorer 9+</a></p>
<p>For more details about using Greek Adblock Plus filter on various browsers please visit: <a href="http://www.void.gr/kargig/blog/greek-adblock-plus-filter/">Greek Adblock Plus Filter</a>.</p>
<p>Don&#8217;t forget to send in comments and URLs to block. If you are using Firefox&#8217;s addon, please use the &#8220;Report Issue on this page&#8230;&#8221; feature of it by right clicking on the status icon of adblock.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/08/24/block-greek-ads-with-internet-explorer-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why vacation auto-reply messages can sometimes be bad</title>
		<link>http://www.void.gr/kargig/blog/2011/08/20/why-vacation-auto-reply-messages-can-sometimes-be-bad/</link>
		<comments>http://www.void.gr/kargig/blog/2011/08/20/why-vacation-auto-reply-messages-can-sometimes-be-bad/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 09:20:23 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Privacy]]></category>
		<category><![CDATA[auto-reply]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[vacation]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1218</guid>
		<description><![CDATA[Say that a user has an email account at the company he works for. Before going on vacation he activates his cool &#8220;vacation auto-reply&#8221; feature that adds Out of Office &#8211; I will be back from holidays at the end of July. on the top and then quotes the email he was sent. During his [...]]]></description>
			<content:encoded><![CDATA[<p>Say that a user has an email account at the company he works for. Before going on vacation he activates his cool &#8220;vacation auto-reply&#8221; feature that adds</p>
<blockquote><p>Out of Office &#8211; I will be back from holidays at the end of July.</p></blockquote>
<p>on the top and then quotes the email he was sent.</p>
<p>During his vacation, he receives a call and he is told he has to urgently sent an email about some financial updates. He rushes to an internet cafe and sends the email. He makes a mistake though and mistypes one of the email addresses of the recipients. Instead of sending the email to &#8220;user@domain.com&#8221; he sends it at &#8220;usar@domain.com&#8221;.</p>
<p>His company&#8217;s SMTP server though receives the following error message from the remote SMTP server while trying to deliver the email:<br />
<pre><code2>&lt;usar@domain.com&gt;: host mx.domain.com[1.2.3.4] said: 550 5.1.1
&nbsp;&nbsp; &lt;usar@domain.com&gt;... User unknown (in reply to RCPT TO command)</code2></pre></p>
<p>This means that his SMTP server will then send an email to him informing him about the error and quoting parts if not all of the email he had previously sent. The email will likely appear to be from &#8220;postmaster@company.com&#8221; or &#8220;do-not-reply@company.com&#8221; or something similar.<br />
It will look like this:<br />
<pre><code2>This is the mail system at host mail.company.com.

I&#039;m sorry to have to inform you that your message could not
be delivered to one or more recipients. It&#039;s attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The mail system

&lt;usar@domain.com&gt;: host mx.domain.com[1.2.3.4] said: 550 5.1.1
&nbsp;&nbsp; &lt;usar@domain.com&gt;... User unknown (in reply to RCPT TO command)
Reporting-MTA: dns; mail.company.com
X-Postfix-Queue-ID: AE4812AE328
X-Postfix-Sender: rfc822; employee1@company.com
Arrival-Date: Thu,&nbsp;&nbsp;5 May 2011 20:05:27 +0200 (CEST)

Final-Recipient: rfc822; usar@domain.com
Original-Recipient: rfc822;usar@domain.com
Action: failed
Status: 5.1.1
Remote-MTA: dns; mx.domain.com
Diagnostic-Code: smtp; 550 5.1.1 &lt;usar@domain.com&gt;... User unknown

From: Loyal Employee &lt;employee1@company.com&gt;
Date: July 5, 2011 9:05:29 PM GMT+03:00
To: User User &lt;usar@domain.com&gt;
Subject: Re: Financial updates

Financial data goes here
</code2></pre></p>
<p>But the user has still his vacation auto-reply turned on, so when the automatic postmaster&#8217;s email reaches his mailbox, the system will automatically reply back to the &#8220;postmaster@company.com&#8221; quoting the previous email and adding his auto-reply message:</p>
<blockquote><p>Out of Office &#8211; I will be back from holidays at the end of July.</p></blockquote>
<p>So the postmaster@company.com currently has all the financial details that he shouldn&#8217;t!</p>
<p>Apart from the fact that the user was sending financial data to somebody else in a clear text email instead of an encrypted one, the second biggest mistake that the user has made was that he has enabled vacation auto-replies that <b>quote</b> the email he was previously sent. That&#8217;s very very wrong. If you don&#8217;t want sensitive stuff ending at the postmaster&#8217;s inbox avoid quoting previous emails in your auto-replies by all means.</p>
<p>Based on a true story <img src='http://www.void.gr/kargig/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/08/20/why-vacation-auto-reply-messages-can-sometimes-be-bad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>please use indexes in your database tables</title>
		<link>http://www.void.gr/kargig/blog/2011/08/03/please-use-indexes-in-your-database-tables/</link>
		<comments>http://www.void.gr/kargig/blog/2011/08/03/please-use-indexes-in-your-database-tables/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 19:06:43 +0000</pubDate>
		<dc:creator>kargig</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[explain]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.void.gr/kargig/blog/?p=1196</guid>
		<description><![CDATA[I don&#8217;t know how many times I&#8217;ve heard a sysadmin swearing at a web/application developer that has &#8220;forgotten&#8221; to add proper index to their database tables. Please dear developers, add those indexes, it&#8217;s not that hard! Today I had to do it on a table for a xoops module. A single query could keep mysql [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know how many times I&#8217;ve heard a sysadmin swearing at a web/application developer that has &#8220;forgotten&#8221; to add proper index to their database tables. Please dear developers, add those indexes, it&#8217;s not that hard!</p>
<p>Today I had to do it on a table for a xoops module. A single query could keep mysql very very busy&#8230;how busy ? the query could take more than 2 minutes, unless it was already cached! I&#8217;ll post the way I solved it as an example. It is actually usually quite easy to solve these kind of issues.</p>
<p>1) How to spot the problem<br />
Your application is slow and your server&#8217;s &#8220;top&#8221; shows mysql running constantly at full load.</p>
<p>2) Find the problematic query. Login to mysql and run a &#8216;show processlist;&#8217;</p>
<p><pre><code2>
mysql&gt; show processlist;
+------+--------------+-----------+--------------------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| Id&nbsp;&nbsp; | User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Host&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| db&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Command | Time | State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Info&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
+------+--------------+-----------+--------------------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
| 1792 | admin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| localhost | aaa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Sleep&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;0 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
| 4790 | user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | localhost | bbb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Query&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;0 | Sorting result | SELECT * FROM foobar WHERE (com_rootid = &#039;22797&#039; AND com_id &gt;= &#039;22797&#039;) ORDER BY com_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| 4791 | user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | localhost | bbb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Query&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;0 | Sorting result | SELECT * FROM foobar WHERE (com_rootid = &#039;22797&#039; AND com_id &gt;= &#039;22797&#039;) ORDER BY com_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| 4817 | admin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| localhost | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Query&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;0 | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | show processlist&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
+------+--------------+-----------+--------------------+---------+------+----------------+------------------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)
</code2></pre></p>
<p>3) Take a closer look at the structure of the table<br />
<pre><code2>
mysql&gt; describe foobar;
+--------------+-----------------------+------+-----+---------+----------------+
| Field&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Null | Key | Default | Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
+--------------+-----------------------+------+-----+---------+----------------+
| com_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | mediumint(8) unsigned | NO&nbsp;&nbsp; | PRI | NULL&nbsp;&nbsp;&nbsp;&nbsp;| auto_increment | 
| com_pid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| mediumint(8) unsigned | NO&nbsp;&nbsp; | MUL | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| com_rootid&nbsp;&nbsp; | mediumint(8) unsigned | NO&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| com_modid&nbsp;&nbsp;&nbsp;&nbsp;| smallint(5) unsigned&nbsp;&nbsp;| NO&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| com_itemid&nbsp;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0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| doxcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| tinyint(1) unsigned&nbsp;&nbsp; | NO&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| doimage&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| tinyint(1) unsigned&nbsp;&nbsp; | NO&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
| dobr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | tinyint(1) unsigned&nbsp;&nbsp; | NO&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| 
+--------------+-----------------------+------+-----+---------+----------------+
20 rows in set (0.01 sec)
</code2></pre></p>
<p>4) run EXPLAIN on the problematic query<br />
<pre><code2>
mysql&gt; explain SELECT * FROM foobar WHERE (com_rootid = &#039;17536&#039; AND com_id &gt;= &#039;17536&#039;) ORDER BY com_id;
+----+-------------+--------------------+------+-----------------------+------+---------+------+-------+-----------------------------+
| id | select_type | table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| type | possible_keys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | key&nbsp;&nbsp;| key_len | ref&nbsp;&nbsp;| rows&nbsp;&nbsp;| Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
+----+-------------+--------------------+------+-----------------------+------+---------+------+-------+-----------------------------+
|&nbsp;&nbsp;1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ALL&nbsp;&nbsp;| PRIMARY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | NULL | NULL&nbsp;&nbsp;&nbsp;&nbsp;| NULL | 18271 | Using where; Using filesort | 
+----+-------------+--------------------+------+-----------------------+------+---------+------+-------+-----------------------------+
1 row in set (0.02 sec)
</code2></pre></p>
<p>If &#8220;type&#8221; is &#8220;ALL&#8221;, like the case above, then you have a problem. This is the worst &#8220;type&#8221; you could have. The query above scans the whole table and has to go through 18271 rows and then has to do a filesort on these rows.</p>
<p>5) Look at indexes, if there are any&#8230;.<br />
<pre><code2>
mysql&gt; show index from foobar;
+--------------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| Non_unique | Key_name&nbsp;&nbsp; | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+--------------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 | PRIMARY&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 | com_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18272 |&nbsp;&nbsp;&nbsp;&nbsp; NULL | NULL&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| BTREE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 | com_pid&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 | com_pid&nbsp;&nbsp;&nbsp;&nbsp; | A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&n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p; | A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6 |&nbsp;&nbsp;&nbsp;&nbsp; NULL | NULL&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| BTREE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 | com_title&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 | com_title&nbsp;&nbsp; | A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18272 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 40 | NULL&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| BTREE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
+--------------------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
5 rows in set (0.00 sec)
</code2></pre></p>
<p>6)Create necessary new index<br />
<pre><code2>
ALTER TABLE&nbsp;&nbsp;`DB`.`foobar` ADD INDEX `com_id_rootid` (&nbsp;&nbsp;`com_id` ,&nbsp;&nbsp;`com_rootid` )
</code2></pre></p>
<p>7) Explain the query again<br />
<pre><code2>
mysql&gt; explain SELECT * FROM foobar WHERE (com_rootid = &#039;17536&#039; AND com_id &gt;= &#039;17536&#039;) ORDER BY com_id;
+----+-------------+--------------------+------+------------------------+---------------+---------+-------+------+-----------------------------+
| id | select_type | table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| type | possible_keys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | key_len | ref&nbsp;&nbsp; | rows | Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
+----+-------------+--------------------+------+------------------------+---------------+---------+-------+------+-----------------------------+
|&nbsp;&nbsp;1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ref&nbsp;&nbsp;| PRIMARY,com_id_rootid&nbsp;&nbsp;| com_id_rootid | 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | const |&nbsp;&nbsp;&nbsp;&nbsp;1 | Using where; Using filesort | 
+----+-------------+--------------------+------+------------------------+---------------+---------+-------+------+-----------------------------+
1 row in set (0.00 sec)
</code2></pre></p>
<p>now the query is of type &#8220;ref&#8221; and it only fetches 1 row!<br />
If the query could be optimized even more by the developer and he/she could replace &#8216;>=&#8217; with &#8216;=&#8217; then it would make us even happier<br />
<pre><code2>
mysql&gt; explain SELECT * FROM foobar WHERE (com_rootid = &#039;17536&#039; AND com_id = &#039;17536&#039;) ORDER BY com_id;
+----+-------------+--------------------+-------+-----------------------+---------+---------+-------+------+-------+
| id | select_type | table&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| type&nbsp;&nbsp;| possible_keys&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | key&nbsp;&nbsp;&nbsp;&nbsp; | key_len | ref&nbsp;&nbsp; | rows | Extra |
+----+-------------+--------------------+-------+-----------------------+---------+---------+-------+------+-------+
|&nbsp;&nbsp;1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| foobar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | const | PRIMARY,com_id_rootid | PRIMARY | 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | const |&nbsp;&nbsp;&nbsp;&nbsp;1 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 
+----+-------------+--------------------+-------+-----------------------+---------+---------+-------+------+-------+
1 row in set (0.00 sec)
</code2></pre></p>
<p>the type would now be &#8216;const&#8217;, which is the best type we could have.</p>
<p>The problem got fixed with just one command! Now the queries take milliseconds to finish and the web application is as fast as ever. The server load dropped from 2.5 to 0.4 with just this tiny addition to the indexes.<br />
<div id="attachment_1214" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.void.gr/kargig/blog/wp-content/load.png"><img src="http://www.void.gr/kargig/blog/wp-content/load-300x166.png" alt="CPU load drops dramatically after adding the proper index to the table" title="load" width="300" height="166" class="size-medium wp-image-1214" /></a><p class="wp-caption-text">CPU Load</p></div></p>
<p>So dear developers, please run EXPLAIN to your queries before you submit your applications and if you find queries with type=ALL try to add indexes! It saves all of us a loooooot of trouble!</p>
<p>For anyone who wants to read a nice blog post about EXPLAIN and what each part of the output means, I recommend that he/she reads this: <a href="http://weevilgenius.net/2010/09/mysql-explain-reference/">MySQL Explain – Reference</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.void.gr/kargig/blog/2011/08/03/please-use-indexes-in-your-database-tables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

