<?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>edeca.net &#187; linux</title>
	<atom:link href="http://edeca.net/wp/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://edeca.net/wp</link>
	<description>Musings of a geek</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:28:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding fake ethernet headers to pcap files</title>
		<link>http://edeca.net/wp/2011/06/adding-fake-ethernet-headers-to-pcap-files/</link>
		<comments>http://edeca.net/wp/2011/06/adding-fake-ethernet-headers-to-pcap-files/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 10:32:48 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pcap]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://edeca.net/wp/?p=652</guid>
		<description><![CDATA[Occasionally I see packet captures which have been saved as Raw IP, which can really mess up many of the tools developed to deal with pcap. Anything based on libnids, including the Perl module I maintain, cannot deal with it and will produce no (or bizarre) results. Wireshark displays these captures just fine, with &#8220;Raw [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally I see packet captures which have been saved as Raw IP, which can really mess up many of the tools developed to deal with pcap.  Anything based on libnids, including the Perl module I maintain, cannot deal with it and will produce no (or bizarre) results.  Wireshark displays these captures just fine, with &#8220;Raw packet data &#8211; no link information available&#8221; just above the IP layer.</p>
<p>There are many situations where packet capture will lack the ethernet header for a good reason, but if you simply want to run it through other tools that deal only with IP and above then adding a fake header is a viable choice.  </p>
<p>Fortunately, adding a &#8220;fake&#8221; ethernet header to these pcap files using <a href="http://tcpreplay.synfin.net/wiki/tcprewrite">tcprewrite</a> (part of the tcpreplay suite) is simple:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ tcprewrite --dlt=enet --enet-dmac=00:11:22:33:44:55 --enet-smac=66:77:88:99:AA:BB --infile=input.pcap --outfile=output.pcap</div></div>
<p>Overriding the output data layer type is essential, as is providing the ethernet MAC addresses of the two endpoints.  That&#8217;s all there is to it.</p>
<p>tcprewrite is available as part of the Debian package <a href="http://packages.debian.org/squeeze/tcpreplay">tcpreplay</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://edeca.net/wp/2011/06/adding-fake-ethernet-headers-to-pcap-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limiting command runtime in Linux</title>
		<link>http://edeca.net/wp/2010/05/limiting-command-runtime-in-linux/</link>
		<comments>http://edeca.net/wp/2010/05/limiting-command-runtime-in-linux/#comments</comments>
		<pubDate>Sun, 02 May 2010 10:55:10 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://edeca.net/wp/?p=474</guid>
		<description><![CDATA[It is sometimes useful to limit the running time of a process, either to stop it from using up all resources or to make sure nightly cron jobs don&#8217;t continue into working hours. I needed this for rsync, to let a remote backup server slowly catch up if large amounts of data were added to [...]]]></description>
			<content:encoded><![CDATA[<p>It is sometimes useful to limit the running time of a process, either to stop it from using up all resources or to make sure nightly cron jobs don&#8217;t continue into working hours.</p>
<p>I needed this for rsync, to let a remote backup server slowly catch up if large amounts of data were added to the live server during the day.  A <a href="http://old.nabble.com/Limit-rsync-running-time-td25490601.html">useful post</a> on the rsync mailing list discusses an rsync patch but also the <tt>timeout</tt> command.</p>
<p>After installing (the Debian package is simply <tt>timeout</tt>) it is as easy as running with the number of seconds to run for:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ timeout 21600 rsync -a ...</div></div>
<p>It is also possible to specify the signal which will be sent to a program, which is useful if you do not want to simply send SIGKILL.  I used SIGHUP in the hope that rsync would have a chance to exit gracefully:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ timeout -1 21600 rsync -a ...</div></div>
<p>A full list of signals and their numeric values can be found in <tt>man 1 kill</tt>.</p>
<p>A <a href="http://johannes.jakeapp.com/blog/category/fun-with-linux/200901/bash-timeouts">wrapper script</a> is also available from Johannes Buchner.  </p>
]]></content:encoded>
			<wfw:commentRss>http://edeca.net/wp/2010/05/limiting-command-runtime-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Training dspam from Thunderbird junk messages</title>
		<link>http://edeca.net/wp/2010/02/training-dspam-from-thunderbird-junk-messages/</link>
		<comments>http://edeca.net/wp/2010/02/training-dspam-from-thunderbird-junk-messages/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 14:53:20 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[dspam]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://edeca.net/wp/?p=347</guid>
		<description><![CDATA[Recently I have installed and configured dspam on my mailserver. It seems to work nicely but needs occasional training. I wanted to integrate this with Thunderbird so that users could automatically train dspam from their mail client. Based on this code I knocked together a few lines of bash script which will scan junk mail [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have installed and configured <a href="http://www.nuclearelephant.com">dspam</a> on my mailserver.  It seems to work nicely but needs occasional training.  I wanted to integrate this with Thunderbird so that users could automatically train dspam from their mail client.<br />
<span id="more-347"></span><br />
Based on <a href="http://www.ghidinelli.com/2006/10/01/combining-thunderbird-junk-mail-filtering-and-dspam">this code</a> I knocked together a few lines of bash script which will scan junk mail directories on the server and automatically train dspam.  This means that an end-user can click the &#8220;Junk&#8221; button in Thunderbird (or Mail.app, etc) and dspam will be trained for them automagically.  The user could even just move the messages there manually, or use some sort of filtering or an extension.</p>
<p>The best bit is that it is completely transparent to the end user and doesn&#8217;t require them to forward messages with headers intact to a weird <tt>user-spam@example.net</tt> address in order to conduct training.</p>
<p>If you find it useful or make changes, please let me know in the comments below.</p>
<h3>The code</h3>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<br />
<span style="color: #666666; font-style: italic;">########</span><br />
<span style="color: #666666; font-style: italic;"># TrainDspam.sh</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">#   Author: David Cannings &lt;david @edeca.net&gt;</span><br />
<span style="color: #666666; font-style: italic;">#     Date: 21/02/2010</span><br />
<span style="color: #666666; font-style: italic;"># Based on: http://tinyurl.com/yhky5w9</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># This script scans mail directories for the Thunderbird &quot;Junk&quot; folder</span><br />
<span style="color: #666666; font-style: italic;"># (or any other folder with the same name) and trains dspam with the</span><br />
<span style="color: #666666; font-style: italic;"># messages contained within it.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># It can be used for periodic (e.g. daily) training of spam messages which</span><br />
<span style="color: #666666; font-style: italic;"># a user has flagged as junk in their mail client.</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># It will only train for accounts which appear to be using dspam.</span><br />
<span style="color: #666666; font-style: italic;">########</span><br />
<br />
<span style="color: #666666; font-style: italic;">########</span><br />
<span style="color: #666666; font-style: italic;"># Configuration</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Path to mail directory, which should contain folders per domain and</span><br />
<span style="color: #666666; font-style: italic;"># user e.g. /home/mail/&lt;domain&gt;/&lt;user1&gt;/</span><br />
<span style="color: #007800;">MAIL_PATH</span>=<span style="color: #ff0000;">&quot;/home/mail&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Path to the directory containing 'dspam'</span><br />
<span style="color: #007800;">DSPAM_BIN_DIR</span>=<span style="color: #ff0000;">&quot;/usr/bin&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Path to the directory containing the dspam user data files</span><br />
<span style="color: #007800;">DSPAM_DATA_DIR</span>=<span style="color: #ff0000;">&quot;/var/spool/dspam&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># If you want this script to delete messages from the Junk folder</span><br />
<span style="color: #666666; font-style: italic;"># after training, set this to 1.</span><br />
<span style="color: #007800;">DELETE_MAIL</span>=<span style="color: #000000;">0</span><br />
<br />
<span style="color: #666666; font-style: italic;"># DON'T EDIT BELOW THIS LINE</span><br />
<span style="color: #666666; font-style: italic;">########</span><br />
<br />
<span style="color: #000000; font-weight: bold;">for</span> FOLDER <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$MAIL_PATH</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'.Junk'</span> <span style="color: #660033;">-type</span> d -print<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp;<span style="color: #007800;">DOMAIN</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$FOLDER</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #ff0000;">'{print $(NF-3)}'</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp;<span style="color: #007800;">USER</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$FOLDER</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #ff0000;">'{print $(NF-2)}'</span><span style="color: #000000; font-weight: bold;">`</span><br />
<br />
&nbsp;<span style="color: #666666; font-style: italic;"># We only want to train for accounts that are dspam users,</span><br />
&nbsp;<span style="color: #666666; font-style: italic;"># so check the data directory</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${DSPAM_DATA_DIR}</span>/data/<span style="color: #007800;">${DOMAIN}</span>/<span style="color: #007800;">${USER}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp;<span style="color: #007800;">TRAINED_MESSAGES</span>=<span style="color: #000000;">0</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$FOLDER</span><span style="color: #000000; font-weight: bold;">/</span>cur<span style="color: #000000; font-weight: bold;">/</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">for</span> MESSAGE <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> -<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp;<span style="color: #007800;">TRAINED_MESSAGES</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$TRAINED_MESSAGES</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$MESSAGE</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$DSPAM_BIN_DIR</span><span style="color: #000000; font-weight: bold;">/</span>dspam <span style="color: #660033;">--user</span> <span style="color: #800000;">${USER}</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #800000;">${DOMAIN}</span> <span style="color: #660033;">--class</span>=spam <span style="color: #660033;">--source</span>=error<br />
&nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$DELETE_MAIL</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$NAME</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">done</span><br />
&nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;- Trained <span style="color: #007800;">$TRAINED_MESSAGES</span> messages for <span style="color: #007800;">${USER}</span>@<span style="color: #007800;">${DOMAIN}</span>&quot;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div>
<p></user1></domain></david></p>
]]></content:encoded>
			<wfw:commentRss>http://edeca.net/wp/2010/02/training-dspam-from-thunderbird-junk-messages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blocking SSH brute forcing using denyhosts</title>
		<link>http://edeca.net/wp/2010/01/blocking-ssh-brute-forcing-using-denyhosts/</link>
		<comments>http://edeca.net/wp/2010/01/blocking-ssh-brute-forcing-using-denyhosts/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 23:04:44 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://edeca.net/wp/?p=254</guid>
		<description><![CDATA[Tired of seeing repeated attempts to login to a Linux server you run?  There are a number of options, all with their own benefits and disadvantages.  The easiest way is to move the port that the SSH server runs on, perhaps to 2222 instead of 22.  However. this can be annoying behind some firewalls and [...]]]></description>
			<content:encoded><![CDATA[<p>Tired of seeing repeated attempts to login to a Linux server you run?  There are a number of options, all with their own benefits and disadvantages.  The easiest way is to move the port that the SSH server runs on, perhaps to <tt>2222</tt> instead of <tt>22</tt>.  However. this can be annoying behind some firewalls and means that you need to specify the port each time you SSH to a host.  This post looks at denyhosts, a viable alternative.<br />
<span id="more-254"></span><br />
denyhosts will monitor your authorisation log (typically <tt>/var/log/auth.log</tt>) and ban IPs that repeatedly fail to authorise as a genuine user.  It will deny future logins by adding the IP address to <tt>/etc/hosts.deny</tt>.</p>
<p>On a sensible Debian or Ubuntu install, getting denyhosts is as simple as running:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ aptitude install denyhosts</div></td></tr></tbody></table></div>
<p>denyhosts should work as soon as it is installed.  However, a few options can be tweaked to make it work nicely.  The configuration file is at <tt>/etc/denyhosts.conf</tt>.</p>
<p>Firstly, set a proper administration email by changing <tt>ADMIN_EMAIL</tt>.  The option <tt>RESET_ON_SUCCESS</tt> might also be important to you, by setting it to <tt>yes</tt> the failure count for an IP address will be reset if there is a successful login.  If you want the blocks to expire (which is more important if you use synchronisation) then you should tweak <tt>PURGE_DENY</tt> to a sensible value, for example 1 week.</p>
<p>Synchronisation is one nice feature of denyhosts that means that information on IPs that attempt SSH bruteforcing can be shared between servers.  Information about synchronisation can be read <a title="denyhosts FAQ" href="http://denyhosts.sourceforge.net/faq.html#sync">in the FAQ</a> but enabling it is as simple as uncommenting the <tt>SYNC_SERVER</tt> line.  By default, your server will share information on bruteforcers and receive it from other administrators who run denyhosts.</p>
<p>You can check how denyhosts is working by watching the logfile at <tt>/var/log/denyhosts</tt>.  You can see newly added blocks logged as a line like the below:</p>
<p><tt>new denied hosts: ['202.107.228.xxx']</tt></p>
<p>Of course, you don&#8217;t need this as you&#8217;ve already disabled SSH password logins and your firewall disables access to port 22 from anywhere except a specially crafted list of IPs.  But for 5 minutes work, it provides some peace of mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://edeca.net/wp/2010/01/blocking-ssh-brute-forcing-using-denyhosts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vim vs. Linux extended ACLs</title>
		<link>http://edeca.net/wp/2009/08/vim-vs-linux-extended-acls/</link>
		<comments>http://edeca.net/wp/2009/08/vim-vs-linux-extended-acls/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 12:55:53 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://staging.edeca.net/wp/?p=177</guid>
		<description><![CDATA[Extended ACLs on Linux can be incredibly useful.  Permissions can actually be more secure whilst allowing a number of users or daemons access to a file, no longer are unwieldy groups necessary to allow reading or writing.  But for some reason, I noticed that these extended ACLs disappeared when a file was edited in vim. [...]]]></description>
			<content:encoded><![CDATA[<p>Extended ACLs on Linux can be incredibly useful.  Permissions can actually be more secure whilst allowing a number of users or daemons access to a file, no longer are unwieldy groups necessary to allow reading or writing.  But for some reason, I noticed that these extended ACLs disappeared when a file was edited in vim.<span id="more-177"></span></p>
<p>The solution is very simple, you just need to <tt>set backupcopy=yes</tt> in your <tt>.vimrc</tt>.  Note that <tt>backupcopy=auto</tt> currently does <strong>not</strong> work.</p>
<p>The way that vim normally works is to rename the file you are working on and write a new file.  This is fast and means that no files have to be deleted.  Unfortunately, it also means that any special attributes that vim does not understand are lost.</p>
<p>Setting <tt>backupcopy=yes</tt> ensures that the original file is copied and then overwritten upon save.  This takes a little longer, but will preserve the attributes correctly.  More information can be found in the topic <tt>:help backupcopy</tt> inside vim.</p>
<p>You can check <a href="http://articles.techrepublic.com.com/5100-10878_11-6091748.html">this page</a> for a quick rundown or <a href="http://www.suse.de/~agruen/acl/linux-acls/online/">this one</a> for a longer explanation on how ACLs work in Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://edeca.net/wp/2009/08/vim-vs-linux-extended-acls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

