<?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>The DF Lab &#187; linux</title>
	<atom:link href="http://blog.danfego.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danfego.net</link>
	<description>A guy like me?</description>
	<lastBuildDate>Tue, 03 Nov 2009 15:31:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New Computer (and its woes)</title>
		<link>http://blog.danfego.net/2009/05/new-computer-and-its-woes/</link>
		<comments>http://blog.danfego.net/2009/05/new-computer-and-its-woes/#comments</comments>
		<pubDate>Tue, 26 May 2009 06:03:02 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=234</guid>
		<description><![CDATA[After a long time coming, I finally took the plunge and bought a new computer, mostly for the occasion of graduating from college. So after a bunch of looking around, I went and bought this computer. In any case, I received it after a couple of days of intense waiting, and now I&#8217;ve got it [...]]]></description>
			<content:encoded><![CDATA[<p>After a long time coming, I finally took the plunge and bought a new computer, mostly for the occasion of graduating from college. So after a bunch of looking around, I went and bought <a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16883103154">this computer</a>. In any case, I received it after a couple of days of intense waiting, and now I&#8217;ve got it and am very pleased with it (and the 23&#8243; monitor I got with it).</p>
<p>However, after spending a day on it, I felt the need to get started with Linux. However, Vista isn&#8217;t <em>that</em> bad when you have a quad-core processor and 8 gigs of RAM. My problem is as follows:</p>
<ul>
<li>I need to be able to play games</li>
<li>I want my games to run <em>well</em></li>
<li>I need a Linux environment</li>
<li>Ideally, I&#8217;d run Linux natively</li>
</ul>
<p>This leaves me with the obvious option of dual-booting, but I&#8217;d really rather not. I find it so&#8230; traumatic, if you will, to have to reboot my computer every time I want to change what I&#8217;m doing. And since I tend to fire up <a href="http://teamfortress.com/">Team Fortress 2</a> rather frequently, I&#8217;m afraid I&#8217;d sit in Vista most of the time because of it, and only go to Linux when I <em>need</em> to. And that&#8217;s exactly the opposite of what I&#8217;d want. So what to do?</p>
<p>I don&#8217;t know what I&#8217;m going to do. In addition, while I&#8217;ve always had fun with Gentoo, the new installation I started has been proving challenging. The basic system was easy, but the framebuffered console and a desktop (with Compiz-Fusion) has proven difficult. This is in large part, I believe, because of the now-scattered documentation due to the data loss of our beloved <a href="http://en.gentoo-wiki.com/wiki/Main_Page">Gentoo Wiki</a>. And then I pop in an&#8230; an&#8230; Ubuntu (sorry, it just feels dirty to me) CD, and everything works. But it&#8217;s not quite <em>right</em>. It&#8217;s not perfect, and I don&#8217;t have portage, and I can&#8217;t use my shiny new computer to compile things all the time! (that was part of the reason I wanted such power <img src='http://blog.danfego.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>So I&#8217;m left with a dilemma. And because of my tendency to get paralyzed by indecision, I&#8217;ll probably stick with Vista for a while, until I figure out my solution, which will still probably involve dual-booting, since <a href="http://www.winehq.org/">Wine</a> doesn&#8217;t seem to be <a href="http://appdb.winehq.org/objectManager.php?sClass=version&#038;iId=9901">up to the task</a>. If anyone&#8217;s got a similar situation/setup/solution, I&#8217;d love to hear about it. I love my Linux, but I also love my games.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/05/new-computer-and-its-woes/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Follow-up on mplayer&#8217;s tab-completion</title>
		<link>http://blog.danfego.net/2009/03/follow-up-on-mplayers-tab-completion/</link>
		<comments>http://blog.danfego.net/2009/03/follow-up-on-mplayers-tab-completion/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 13:08:32 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=200</guid>
		<description><![CDATA[So after a big of Googling and finding this bug (after several others), I was made aware of three things (in response to my previous post):

mplayer&#8217;s tab-completion support does in fact come from bashcomp
this support is covered in the &#8220;base&#8221; module
the appropriate file uses strange regular expressions

At the time this bug was filed, the appropriate [...]]]></description>
			<content:encoded><![CDATA[<p>So after a big of Googling and finding <a href="http://bugs.gentoo.org/show_bug.cgi?id=145727">this bug</a> (after several others), I was made aware of three things (in response to my <a href="http://blog.danfego.net/2009/03/flv-files-finally-tab-complete-with-mplayer/">previous post</a>):</p>
<ol>
<li>mplayer&#8217;s tab-completion support does in fact come from bashcomp</li>
<li>this support is covered in the &#8220;base&#8221; module</li>
<li>the appropriate file uses strange regular expressions</li>
</ol>
<p>At the time this bug was filed, the appropriate file to edit was (or was in) /etc/bash_completion. Since bash-completion-20081218, the bug was fixed, but the package also underwent some changes that seemingly caused locations of config files to change. (Apologies if this is incorrect, but I never went diving into the configs of bashcomp before now!)</p>
<p>In any case, the bashcomp configuration files are now in /usr/share/bash-completion. Since mplayer&#8217;s support is in base, the file that handles mplayer is &#8220;base&#8221; in that directory.</p>
<p>Now as for the &#8220;strange&#8221; regular expressions, that deserves some qualification. I&#8217;ve already seen lots of regular expressions on my (albeit rather short) day, but the reason I consider these ones strange is because they seem both unnecessary and redundant. The line in question is currently 5983 on my version 20081219-r1:</p>
<p><code>_filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|...|fl[iv]|FL[IV]...'</code></p>
<p>The two ellipses are my own adding, since the actual expression is one humongous line that ends up looking rather horrible here. My problems with this are both the explicit writing out of upper and lower case alternatives and the the bothering to do things like fl[iv]. Actually, I don&#8217;t have a problem with the latter except in the presence of the former. And to be fair, I probably wouldn&#8217;t have ever cared or noticed if I hadn&#8217;t been able to find &#8220;flv&#8221; when grepping numerous files. Not that &#8220;greppability&#8221; is necessarily a goal for configuration files, but it&#8217;s certainly annoying when it&#8217;s specifically hindered by regular expressions that save negligible space like the ones in this file.</p>
<p>As a final note, I&#8217;m going to disclaim that I&#8217;m no expert on bash scripting and the various intricacies of handling regular expressions therein, so I&#8217;d be happy to hear from anyone who knows better about why I should lay off the poor bash-completion folks. <img src='http://blog.danfego.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p><strong>External Links</strong></p>
<ul>
<li><a href="http://bugs.gentoo.org/show_bug.cgi?id=145727">Gentoo Bugzilla bug on mplayer tab-completion</a></li>
<li><a href="http://blog.danfego.net/2009/03/flv-files-finally-tab-complete-with-mplayer/">Previous post on mplayer&#8217;s tab-completion</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/03/follow-up-on-mplayers-tab-completion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>.flv files finally tab-complete with mplayer</title>
		<link>http://blog.danfego.net/2009/03/flv-files-finally-tab-complete-with-mplayer/</link>
		<comments>http://blog.danfego.net/2009/03/flv-files-finally-tab-complete-with-mplayer/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 05:46:00 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=193</guid>
		<description><![CDATA[After a long time of playing .flv files in mplayer on the command line in Gentoo, I noticed recently that they now tab-complete. I&#8217;m not quite sure how recently this change occurred or what caused it, but I&#8217;m very pleased with the update.
I&#8217;m not quite sure how the tab-completion infrastructure works, but I know it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>After a long time of playing .flv files in mplayer on the command line in Gentoo, I noticed recently that they now tab-complete. I&#8217;m not quite sure how recently this change occurred or what caused it, but I&#8217;m very pleased with the update.</p>
<p>I&#8217;m not quite sure how the tab-completion infrastructure works, but I know it&#8217;s got a lot of &#8220;packages&#8221; for different programs. A surprising amount, actually. For the uninitiated, on my system, I&#8217;m looking at:</p>
<p><code>dfego@antica ~ $ eselect bashcomp list<br />
Available completions:<br />
  [1]   _subversion<br />
  [2]   apache2ctl<br />
  [3]   base *<br />
  [4]   bitkeeper<br />
  [5]   bittorrent<br />
  [6]   cksfv<br />
  [7]   clisp<br />
  [8]   dsniff<br />
  [9]   eselect *<br />
  [10]  freeciv<br />
  [11]  gcl<br />
  [12]  gentoo *<br />
  [13]  git *<br />
  [14]  gkrellm<br />
  [15]  gnatmake<br />
  [16]  gpg2<br />
  [17]  gvim<br />
  [18]  harbour<br />
  [19]  isql<br />
  [20]  larch<br />
  [21]  lilypond<br />
  [22]  lisp<br />
  [23]  mailman<br />
  [24]  mcrypt<br />
  [25]  mercurial *<br />
  [26]  modules<br />
  [27]  monodevelop<br />
  [28]  mpc *<br />
  [29]  mtx<br />
  [30]  p4<br />
  [31]  povray<br />
  [32]  qdbus<br />
  [33]  ri<br />
  [34]  sbcl<br />
  [35]  sitecopy<br />
  [36]  snownews<br />
  [37]  ssh *<br />
  [38]  subversion *<br />
  [39]  tig *<br />
  [40]  tree *<br />
  [41]  unace<br />
  [42]  unrar *<br />
  [43]  vim *<br />
  [44]  xxd</code></p>
<p>The ones with the asterisks are ones I currently have enabled for my main user. As you can see, there are a lot of options to choose from, and for some weird reason, my git functionality died after a recent update. But wait&#8230; mplayer isn&#8217;t there&#8230; Interesting&#8230;</p>
<p>Interesting&#8230;</p>
<p>So where <em>does</em> mplayer&#8217;s tab-completion come from? It&#8217;s not just the normal one provided by the shell, because it before excluded certain file types.</p>
<p>Interesting. This must be investigated.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/03/flv-files-finally-tab-complete-with-mplayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>/etc/mtab Boot Nightmare</title>
		<link>http://blog.danfego.net/2009/02/etcmtab-boot-nightmare/</link>
		<comments>http://blog.danfego.net/2009/02/etcmtab-boot-nightmare/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 21:31:45 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=160</guid>
		<description><![CDATA[The other day, I was working on my senior design project (a kernel project), and I did the good ol&#8217; make/make install/reboot to see my changes. Coming back, expecting my computer to have booted, I found it hung at:

Cannot create link /etc/mtab
perhaps there is a stale lockfile?

Naturally thinking it was my project&#8217;s fault (it was), [...]]]></description>
			<content:encoded><![CDATA[<p>The other day, I was working on my senior design project (a kernel project), and I did the good ol&#8217; make/make install/reboot to see my changes. Coming back, expecting my computer to have booted, I found it hung at:</p>
<blockquote><p>
Cannot create link /etc/mtab<br />
perhaps there is a stale lockfile?
</p></blockquote>
<p>Naturally thinking it was my project&#8217;s fault (it was), I rebooted into my normal kernel. To my horror, the same error came up. After a period of mini-panic, I ran to Google and at the same time reached for my Gentoo CD (the newest I could find was 2007.0 minimal, but it still works!). I ran e2fsck on both my home and root partitions for good measure, and then mounted my root partition and looked at /etc/mtab*. <strong>Apparently, the fact that there was mtab, mtab~, mtab~2205 and mtab~2213 isn&#8217;t normal.</strong> On recommendation from <a href="http://www.oesf.org/forum/index.php?showtopic=18484&#038;st=0&#038;p=120298&#entry120298">this obscure post from three years ago</a>, I deleted the extra files (after examining them and noting they were not only extraneous but empty), rebooted, and viola! Problem solved!</p>
<p>Turns out a number of different things I did caused this error several different times. Not exactly sure why, but it always seems to coincide with the boot of or boot after a kernel oops or panic.</p>
<p><strong>External Links</strong></p>
<ul>
<li><a href="http://www.oesf.org/forum/index.php?showtopic=18484&#038;st=0&#038;p=120298&#entry120298">Obscure post from 2006</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/02/etcmtab-boot-nightmare/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CCDC Qualifying Round Review and Excitement</title>
		<link>http://blog.danfego.net/2009/01/ccdc-qualifying-round-review-and-excitement/</link>
		<comments>http://blog.danfego.net/2009/01/ccdc-qualifying-round-review-and-excitement/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 06:24:17 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=142</guid>
		<description><![CDATA[The Competition
On Saturday, myself and 7 of my classmates from GWU had a chance to head up to Lancaster, PA to the home of White Wolf Security for the 4th Annual Mid-Atlantic Collegiate Cyber Defense Competition Qualifying Round.  At this round of the competition along with GWU were George Mason, Jameson Madison, and Millersville [...]]]></description>
			<content:encoded><![CDATA[<h3>The Competition</h3>
<p>On Saturday, myself and 7 of my classmates from GWU had a chance to head up to Lancaster, PA to the home of <a href="http://www.whitewolfsecurity.com/">White Wolf Security</a> for the 4th Annual Mid-Atlantic Collegiate Cyber Defense Competition Qualifying Round.  At this round of the competition along with GWU were George Mason, Jameson Madison, and Millersville Universities.  For those who aren&#8217;t familiar, the competition puts the students in the roles of system administrators who were recently hired to secure and maintain a company&#8217;s network.  The whole affair is pretty exciting, and the pressure can get very intense.  While attempting to prevent and root out attacks from an all-volunteer (but skilled) red team sitting in another room, a white team also throws business injects at us that have us do things like install wikis, set up PKI, and create office templates for our company.  We get scored separately on attack prevention, injects, and service uptime, and at the end of the day the top two teams move on to the next round.  The whole competition ran for about 7 hours, and we were getting pounded from minute 1.</p>
<h3>The Plan</h3>
<p>After experiencing the chaos last year, we put together a list of basic things to do as soon as everything started that would keep out the easiest attacks.  After blocking all external traffic with our firewall (for a few minutes so we could have some &#8220;safe time&#8221;), we set out to do these things in the first 15 minutes or so.  This was just changing all the passwords on the boxes, killing extraneous services, setting client firewalls, and backing up important data and configuration files.  I only managed to get to changing passwords on the boxes I was handling.  They gave us 4 Linux boxes, and those were the ones I was in charge of.  They weren&#8217;t the newest versions of the OS&#8217;s, and for the life of me I can&#8217;t understand how our <a href="http://www.nagios.org/">Nagios</a> box (Fedora, I believe) didn&#8217;t come with lsof, but I did my best to get everything locked down.</p>
<h3>The First Problem</h3>
<p>Well, the best plans of mice and men blah blah blah, and in the few minutes it took our firewall guy to figure out where the admin console was, the red had team managed to get onto two of the Linux boxes and leave their mark before I had a chance to change the root passwords.  After about an hour, I noticed the intrusion on one of the boxes as I attempted to set up iptables and noticed that there were a bunch of identical ACCEPT rules in there that I didn&#8217;t put there.  It was go time.</p>
<h3>The Source</h3>
<p>I called over our team captain to let him know there was a problem, and I set out to figure out just what was going on.  I flushed the tables, set the firewall policies to DROP, and hopped over to /sbin to take a look if anything seemed weird.  After checking iptables again, I noticed some more ACCEPT rules were in there.  I cleared them out and opened the crontab to see if anything was running; it wasn&#8217;t.  Not sure what was going on, I took a moment to restart SSH to boot off any active connections, just in case.  Upon examining the files in /sbin, there were some that were world-writable.  I knew that wasn&#8217;t quite right.  One of those files, however, was iptables.  At cappy&#8217;s suggestion, I viewed the contents of the file, and sure enough it was a perl script instead of the iptables binary.  Since I was under the gun I didn&#8217;t quite deduce <em>what</em> the script did, but it called the real iptables (which they renamed) with ACCEPT commands, instead of the ones I kept giving it.  While the real iptables was mentioned in that perl script, I didn&#8217;t quite catch on right away, so I looked at the size of iptables on another computer and looked for a binary in /sbin with a similar size, and found it.  After that, I chmod-ed all the files in /sbin to remove world-writability, to prevent any further problems in case of non-root intrusion.</p>
<h3>The Solution</h3>
<p>At this point, I had found intruder access, a malicious script, and a moved iptables.  However, more and more ACCEPTs kept being added to my chains.  Once again at cappy&#8217;s suggestion, I moved the real iptables to another name, and left their script in place as &#8220;evidence,&#8221; and in case they had any mechanism for replacing it.  This seemed to finally stop the problem.  At this point, I just needed to figure out where our attackers came from.  The rules of the competition say we can&#8217;t completely block any IP addresses without approval from the white team, which will come if we have details proving that the IP is malicious.  I believe the reasoning for this is so that we can&#8217;t just block any IP range, as well as the fact that the scoring bot shifts IPs, so we could also screw ourselves if we just blocked lots of them.</p>
<h3>The Culprit</h3>
<p>I needed to find out the intruder, but I didn&#8217;t know how.  I took a look in /var/log and saw a bunch of files, more than I usually see, so apparently I don&#8217;t log enough on my own computer. <img src='http://blog.danfego.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />   My first look was at /var/log/messages, but that didn&#8217;t yield anything of value.  Next, I stumbled across /var/log/secure, which seemed to be a log of SSH activity.  I hit the jackpot, because I found logins about an hour and a half prior by two specific IP addresses.  I was ecstatic.  This was our culprit.  I was surprised that they didn&#8217;t delete such logs, but perhaps they didn&#8217;t think of it, or were instructed not to by the white team, as not to make our jobs of tracking them impossible.  In any case, I saved the log to a file, filled out an incident report, and sent it over to the white team.  They looked over the report and checked on <em>something</em> (I honestly don&#8217;t know what) and then let us block the IPs.  Mission accomplished.</p>
<h3>The Wikis</h3>
<p>Well, at least <em>that</em> mission was accomplished.  I felt pretty good a little after 11am when this all was wrapped up, but that quickly faded as business injects got annoying.  We had to install wiki software, which gave us infinite problems.  We first tried <a href="http://www.mediawiki.org/">MediaWiki</a>, which was a bust because our database server was using MySQL 3.x.  3.x?  What the hell?  I&#8217;ve never seen that anywhere before.  My <a href="http://en.wikipedia.org/wiki/MySQL#History">impeccable sources</a> tell me that it&#8217;s about 9 years old! Yeah, pretty egregious, but there wasn&#8217;t too much we could do about it under the circumstances.  So we looked for other softwares, of which there were many.  However, after failing to find Tigerwiki (apparently it&#8217;s discontinued) and having ridiculous troubles with <a href="http://moinmo.in/">MoinMoin</a> and <a href="http://tikiwiki.org/">TikiWiki</a>, we ended up running out of time and failing the inject.  That wouldn&#8217;t have been so bad if it weren&#8217;t for having another inject which built off of that one later in the day.  So that sucked.  In the end, we found an older version of MediaWiki (why didn&#8217;t we think of it earlier?) and installed that for the second inject, but we ran out of time and failed.  And in that last bit when I say &#8220;we,&#8221; I mean two of my teammates, because I was sick of wikis and had to step away before bashing the computer with a chair.</p>
<h3>The Cable</h3>
<p>The rest of the day was <em>relatively</em> less pressure for me, just keeping a check on my systems, handling another inject, and trying to get our damn Nagios box to actually work.  For some reason, it wasn&#8217;t connected to anything.  We couldn&#8217;t explain it, though we thought our routes were a bit screwy.  After a lot of investigation, one of my teammates brilliantly found that there was no network cable in the computer.  I know, I know, that&#8217;s normally the first thing to check, but we were given computers and were allowed to assume that there&#8217;d at least be cables in everything!  And it&#8217;s not like it had come loose or fallen out or anything; there was just no cable for that box.  So we went to the white team and they remedied the problem, but we all had a good laugh over that.  In the afternoon there was also another intrusion that I helped get logs for, but it wasn&#8217;t nearly as exciting as the morning breach.</p>
<h3>The Nagios Box</h3>
<p>Amidst everything else I was doing, I took a good shot in the afternoon to configure our Nagios box.  I remembered from the last competition that the IPs were wrong, so that seemed to be what I&#8217;d probably have to do again, just fix up the network portion to that which we were assigned for all the entries.  Simple enough with sed.  However, I found enormous difficulties getting into the web console, considering they didn&#8217;t give us the username and password, and they weren&#8217;t any kind of defaults.  Well, in the end, it turns out they were.  &#8220;nagiosadmin&#8221; is apparently a standard username, and the password was the standard one for the competition.  It just took <strong>way</strong> too long to figure that out.  Once I fixed the IPs and logged in, I realized that all most of the checks were failing.  Not good.  That generally meant that the scorebot also would be counting those tests as failures.  I talked to our firewall guy, who had egress filtering on (blocking outgoing traffic), which he suggested would give such results.  We argued, he got busy, and I never got to see the beautiful green colors of Nagios that come with a fully working network.  Oh well.  At around 4, the competition ended, we packed up our computers, and we headed over to another room for a debrief.</p>
<h3>The End</h3>
<p>All tired, hungry, and anxious to hear the results, we waited and were fed pizza while the event organizers talked to us for a while.  Then they let the red team have a go and both tell us what they did to us over the day, as well as query us about our strategies and give us some tips for defending.  I actually got to talk to the guy who put that perl script on the Linux boxes, and he asked &#8220;did you find the others?&#8221;  We laughed, and then realized that we hadn&#8217;t even <em>looked</em> for others.  It didn&#8217;t even occur to us for some reason.  So he pointed out that if you find something malicious, there&#8217;s almost certainly something else there, and you should make some effort to find it.  He suggested grepping all the files in /sbin for &#8220;perl&#8221;, while I probably would have used &#8220;find&#8221; to find any files modified in the last few hours.  Either way, it&#8217;s something solid that I learned and will most certainly apply at the next competition.  Which leads to the most awesome part: GWU got 2nd place, and we&#8217;ll be competing at the regionals in Baltimore in March!  We&#8217;ve got a lot of work to do, myself included.</p>
<p>All in all, I found the whole thing very worthwhile for the third time, and recommend any college students in the US with an interest in computer security to look at creating a team and competing in a regional competition.  The whole affair, while stressful, is not only fun but a great experience for anyone interested in information assurance.  As a matter of fact, I&#8217;m not particularly enthralled with security and I found it a great experience too.  In past events (but not this one, because of the inauguration), we had Secret Service agents there as well to talk to us a bit and have to consult regarding some of the legal issues with intrusions, to discuss our incident reports with, and have drinks with afterward. <img src='http://blog.danfego.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' />   I can&#8217;t wait until March.  Maybe we&#8217;ll make nationals!</p>
<p><strong>External Links</strong></p>
<ul>
<li><a href="http://www.whitewolfsecurity.com/">White Wolf Security</a></li>
<li><a href="http://cyberwatchcenter.org/ccdc/">Mid-Atlantic CCDC Information</a></li>
<li><a href="http://nationalccdc.org/">National CCDC Website</a></li>
<li><a href="http://www.nagios.org/">Nagios Website</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/01/ccdc-qualifying-round-review-and-excitement/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ubuntu, PAM, and MD5 logins</title>
		<link>http://blog.danfego.net/2009/01/ubuntu-pam-and-md5-logins/</link>
		<comments>http://blog.danfego.net/2009/01/ubuntu-pam-and-md5-logins/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 16:23:22 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=130</guid>
		<description><![CDATA[At work today, I came upon a startling revelation when I typed in a 20+ character password on our Ubuntu server.  I typed in the password, not sure I got it quite right, and got in.  I thought I typed it in right, and obviously I did.  But I wasn&#8217;t sure, since [...]]]></description>
			<content:encoded><![CDATA[<p>At work today, I came upon a startling revelation when I typed in a 20+ character password on our Ubuntu server.  I typed in the password, not sure I got it quite right, and got in.  I thought I typed it in right, and obviously I did.  But I wasn&#8217;t sure, since our passwords are complicated.  So I exited, typed it in again, but typed it intentionally differently.  And It logged in.</p>
<p>As it turns out, after the first 8 characters, I could have put in anything at all, and the login would work.  I was shocked that such a strange security issue would come up on a mostly stock-configured Ubuntu 8.04 server.  In fact, it was <em>better</em> than stock configured, as I already had to do a bunch of configurations to secure it.</p>
<p>As it turns out, the problem lied with the way PAM was authenticating (or something).  I went and checked that my configurations were right (you should have &#8220;md5&#8243; in a &#8220;password&#8221; line where commented to do so in /etc/pam.d/common-password).  Then, after doing some more poking around online, I found an Ubuntu forum <a href="http://ubuntuforums.org/archive/index.php/t-581515.html">post</a> that mentioned that in /etc/shadow, if any given password has <strong>$1$</strong> at the beginning, it&#8217;s using MD5.  Upon looking at my shadow file, it turned out that one of my users (the one with the issue) was somehow not using MD5.  I don&#8217;t quite know how that happened, but I&#8217;m going to guess that I configured PAM for MD5 after last setting his password.  At least that&#8217;s my best guess.</p>
<p>To fix the issue, I just used passwd to change the password for the given user, and it properly took on its MD5 encryption.  I hope this proves useful to someone in the future!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2009/01/ubuntu-pam-and-md5-logins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux Kernel Queues</title>
		<link>http://blog.danfego.net/2008/12/linux-kernel-queues/</link>
		<comments>http://blog.danfego.net/2008/12/linux-kernel-queues/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 17:46:02 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[kernel]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=114</guid>
		<description><![CDATA[My senior design project for university has involved a lot of working in the Linux kernel.  I&#8217;ve found that my primary difficulty with kernel work has been figuring out how the mass of code that already exists works and interacts with each other.  It&#8217;s mostly very well thought out, but some things take [...]]]></description>
			<content:encoded><![CDATA[<p>My senior design project for university has involved a lot of working in the Linux kernel.  I&#8217;ve found that my primary difficulty with kernel work has been figuring out how the mass of code that already exists works and interacts with each other.  It&#8217;s mostly very well thought out, but some things take a little time to wrap your head around.  One such thing is the kernel&#8217;s unified implementation of linked lists.</p>
<p>It&#8217;s actually rather ingenious if you think about it, and there are <a href="http://isis.poly.edu/kulesh/stuff/src/klist/">plenty</a> of <a href="http://kernelnewbies.org/FAQ/LinkedLists">references</a> that give great explanations of how it all works, so I won&#8217;t do that here.  The short version is that the list actually acts like an element within another data structure, which allows it to work for all types, rather than having to create new structures and functions for every structure to act like a list.  What I recently found myself trying to do was create a queue (first-in-first-out) data structure using the linked lists provided.  I decided to go about this after getting a little <a href="http://stackoverflow.com/questions/389582/queues-in-the-linux-kernel">advice</a> from a couple of fellas over at Stack Overflow.  I haven&#8217;t fleshed it all out yet, but came to an important realization on how things work.  It&#8217;s not really all that hard, but it was important enough for me to want to document: <strong>because it is a <em>circular</em>, <em>doubly-linked</em> structure, adding an item to the front and back of the list look <em>very</em> similar.</strong>  In fact, they&#8217;re pretty much the same operation, except for where the external head and tail pointers point to.  They&#8217;re so similar that I spent a bunch of time confused on how it all worked.  I suppose that&#8217;s my fault for delving in and examining the <del datetime="2008-12-27T17:23:19+00:00">overly-short</del> elegant code.</p>
<p>The result of this is that their list_add_tail() function (which is commented to be useful for queues) is, in fact, useful for queues.  It adds an element linked after the &#8220;last&#8221; element and before the &#8220;first,&#8221; given the head of the list.  &#8220;Last&#8221; and &#8220;first&#8221; are in quotes here because it&#8217;s a circular list, so there <em>technically</em> aren&#8217;t a first and last, but there are.  Anyway, what I still don&#8217;t quite understand is how the list_add() function is useful for stacks (also in the comments).  Though I&#8217;m getting myself slightly confused just thinking about it further, so I&#8217;ll end the tirade here.</p>
<p>I guess if there&#8217;s one thing I can pass on here, it&#8217;s that if there&#8217;s comments documenting a series of functions (which the kernel&#8217;s <a href="http://lxr.linux.no/linux+v2.6.28/include/linux/list.h">include/linux/list.h</a> file does), <em>listen</em> to the comments.  I suppose this was a learning experience for me in the end, but I could have saved a bunch of time by just trusting what they said the functions do.  On the flip side, if you&#8217;re curious, don&#8217;t trust them, and want to be <em>sure</em> about what the code is doing, you <em>are</em> always free to dive right in!  I&#8217;m just convinced that the kernel developers are a lot smarter than I am, at least at this point in my career.</p>
<p><strong>Related Links</strong></p>
<ul>
<li><a href="http://isis.poly.edu/kulesh/stuff/src/klist/">Linux Kernel Linked List Explained</a></li>
<li><a href="http://kernelnewbies.org/FAQ/LinkedLists">Another Kernel Linked List Explanation</a></li>
<li><a href="http://stackoverflow.com/questions/389582/queues-in-the-linux-kernel">Stack Overflow question about kernel queues</a></li>
<li><a href="http://lxr.linux.no/linux+v2.6.28/include/linux/list.h">list.h on Linux Cross Reference</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2008/12/linux-kernel-queues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music Solutions</title>
		<link>http://blog.danfego.net/2008/12/music-solutions/</link>
		<comments>http://blog.danfego.net/2008/12/music-solutions/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 14:13:11 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://blog.danfego.net/?p=108</guid>
		<description><![CDATA[A couple of months ago, I spent a lot of time working on a solution for handling all my music and its various uses.  Namely, I wanted to keep separate track of:

All my music (even the music I don&#8217;t listen to, so I don&#8217;t have to get rid of it)
The music I listen to [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago, I spent a lot of time working on a <a href="http://blog.danfego.net/2008/10/concatenatecombine-mp3-files/">solution</a> for handling all my music and its various uses.  Namely, I wanted to keep separate track of:</p>
<ul>
<li>All my music (even the music I don&#8217;t listen to, so I don&#8217;t have to get rid of it)</li>
<li>The music I listen to on my computer</li>
<li>The music I have on my limited-space iPod</li>
</ul>
<p>In addition, I wanted to make sure there was as little wasted disk space as possible, so I used hard links and had all the files in separate directories.</p>
<p>You&#8217;d think there would be a relatively simple solution, and I&#8217;d hope so too, but I came up with this really convoluted system that involved synchronizing three directories with two scripts whenever music had to be added or removed.  What it results in is that I never add music anymore.  And somewhere along the line, my &#8220;music on my computer&#8221; folder got messed up, so I&#8217;m back to square-one with that one.  Hundreds of songs I filtered out back in the mix.</p>
<p>I wonder if some of my problems would be solved if I used a GUI music player, but I&#8217;m not so sure.  My current setup uses MPD, which runs nice and light.  Anyway, I&#8217;m out of mental energy, and am hoping someone else might have a better idea.  <strong>Does anyone have any good ideas how to maintain my music?</strong>  Or perhaps a better ideal to work under?  Until then, I&#8217;ll just suffer under a horrible manual version where I just delete and add things at will to everything and hope I don&#8217;t miss things.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2008/12/music-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>equery and q</title>
		<link>http://blog.danfego.net/2008/11/equery-and-q/</link>
		<comments>http://blog.danfego.net/2008/11/equery-and-q/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 05:37:27 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[portage]]></category>

		<guid isPermaLink="false">http://dlflab.wordpress.com/?p=25</guid>
		<description><![CDATA[As both an experienced user of Gentoo and a lover of the command line, I often find myself querying portage for various things.  Sometimes, if it&#8217;s in a particular package, I go looking at the ebuild itself.  Others, I run a find command in /usr/portage.  However, there are tools to take care [...]]]></description>
			<content:encoded><![CDATA[<p>As both an experienced user of Gentoo and a lover of the command line, I often find myself querying portage for various things.  Sometimes, if it&#8217;s in a particular package, I go looking at the ebuild itself.  Others, I run a find command in /usr/portage.  However, there <em>are</em> tools to take care of all these silly things in a much more elegant fashion.  Namely, there&#8217;s <a href="http://www.gentoo.org/doc/en/gentoolkit.xml">equery</a> and <a href="http://www.gentoo.org/doc/en/portage-utils.xml">q</a>.  Since I&#8217;ve only now realized that they both not only exist and are useful, I figure there must be someone else who could benefit from this knowledge as well.  In this post, I&#8217;ll briefly describe the uses and benefits of each, as well as why they should co-exist on your system, at least for the time being.</p>
<h3>Commonalities and Usage</h3>
<p>First things first, equery and q are both very similar both in offered functionality and usage from the command line.  Basic usage goes like so:</p>
<p><code>$ equery [command] [package]</code><br />
or<br />
<code>$ q [command] [package]</code></p>
<p>Simple, right?  There are also options to modify usage, but this is the most basic and common usage pattern.</p>
<p>In terms of functionality, equery and q have the following in common:</p>
<table border="1">
<tbody>
<tr>
<th><strong>Function</strong></th>
<th><strong>equery command</strong></th>
<th><strong>q command</strong></th>
</tr>
<tr>
<td>List packages owning file</td>
<td>equery b</td>
<td>q file</td>
</tr>
<tr>
<td>Verify integrity of package</td>
<td>equery k</td>
<td>q check</td>
</tr>
<tr>
<td>List dependencies of package</td>
<td>equery d</td>
<td>q depends</td>
</tr>
<tr>
<td>List files owned by package</td>
<td>equery f</td>
<td>q list</td>
</tr>
<tr>
<td>List all packages with USE flag</td>
<td>equery h</td>
<td>q use</td>
</tr>
<tr>
<td>List all packages matching search</td>
<td>equery l</td>
<td>q search</td>
</tr>
<tr>
<td>Show size of files in package</td>
<td>equery s</td>
<td>q size</td>
</tr>
</tbody>
</table>
<p>The usage of each of the above commands is pretty straightforward, so I won&#8217;t bore you with details.  Running just &#8220;equery&#8221; or &#8220;q&#8221; from the command line will show all basic usage, and running one of the above commands without arguments (or with a -h local argument, for equery) will show similar usage info for the specific command.</p>
<h3>equery</h3>
<p>equery is a part of the gentoolkit package, is written in Python, and is rather well-endowed (in terms of features, of course).  In terms of features unique from q, equery boasts:</p>
<ul>
<li><strong>depgraph</strong>: display a dependency tree for a given package</li>
<li><strong>uses</strong>: display USE flags for a given package</li>
<li><strong>which</strong>: print full path to ebuild for a given package</li>
</ul>
<p>Personally, of these three, I&#8217;ve only ever used <em>uses</em>, since I the few times I&#8217;ve ever attempted to use <em>depgraph</em>, the results have been too big to really get a handle on.  Either way, the uses command makes it a lot easier to find out what USE flags are available for a particular package as well as their current states.  Of course, you could just do a (not so quick):</p>
<p><code>$ emerge -pv [package]</code></p>
<p>However, that won&#8217;t give the information on what the USE flags actually are, just what their status is on the package.</p>
<p>equery in general gives more detail and nicer output than its shorter-named counterpart.  Since I always like to see screen shots (yes, even from command-line programs), I&#8217;ll take the liberty of doing just that to illustrate my point:</p>
<div id="attachment_40" class="wp-caption alignnone" style="width: 487px"><a href="http://blog.danfego.net/wp-content/uploads/2008/11/equery-list-zsnes.png"><img class="size-full wp-image-40" title="equery-list-zsnes" src="http://blog.danfego.net/wp-content/uploads/2008/11/equery-list-zsnes.png" alt="Output of equery list command." width="477" height="107" /></a><p class="wp-caption-text">Output of equery list zsnes command.</p></div>
<div id="attachment_42" class="wp-caption alignnone" style="width: 487px"><a href="http://blog.danfego.net/wp-content/uploads/2008/11/qsearch-zsnes-cutoff.png"><img class="size-full wp-image-42" title="qsearch-zsnes-cutoff" src="http://blog.danfego.net/wp-content/uploads/2008/11/qsearch-zsnes-cutoff.png" alt="Output of qsearch zsnes command." width="477" height="38" /></a><p class="wp-caption-text">Output of qsearch zsnes command.</p></div>
<p>One thing to note about this particular command is that while qsearch automatically searches both installed packages and those in the portage tree, equery requires the -p option, as shown above, to do the same thing.  On the flip side, qsearch has no capability (at this time) of searching overlays, but equery can be made to do so with the -o option.  Tradeoffs, tradeoffs!</p>
<p>As a final note on equery, there are in fact two ways to call each of the sub-programs (like list, depgraph, etc.).  There&#8217;s a short and long option for each of them, which is rather convenient.  &#8220;equery l&#8221; is much nicer than &#8220;equery list&#8221; and &#8220;equery g&#8221; is way better than &#8220;equery depgraph.&#8221;</p>
<h3>q</h3>
<p>On to q!  After reading the above section, you might wonder why anyone would want to use q when they&#8217;ve got equery in their toolbox.  Is it for those few features that q has that are so dazzling?  Is it because the name is shorter?  No, no, let me just show you, you&#8217;ll understand:</p>
<div id="attachment_45" class="wp-caption alignnone" style="width: 479px"><a href="http://blog.danfego.net/wp-content/uploads/2008/11/time-equery-list-zsnes.png"><img class="size-full wp-image-45" title="time-equery-list-zsnes" src="http://blog.danfego.net/wp-content/uploads/2008/11/time-equery-list-zsnes.png" alt="Timed output of equery list zsnes." width="469" height="173" /></a><p class="wp-caption-text">Timed output of equery list zsnes.</p></div>
<div id="attachment_46" class="wp-caption alignnone" style="width: 352px"><a href="http://blog.danfego.net/wp-content/uploads/2008/11/time-qsearch-zsnes.png"><img class="size-full wp-image-46" title="time-qsearch-zsnes" src="http://blog.danfego.net/wp-content/uploads/2008/11/time-qsearch-zsnes.png" alt="Timed output of qsearch zsnes." width="342" height="102" /></a><p class="wp-caption-text">Timed output of qsearch zsnes.</p></div>
<p>For those of you who can&#8217;t see the images or are just in plain shock, let me spell it out: q is <em>fast</em>.  In that particular query, about 34 times faster.  <strong>34 times faster!</strong> That makes a big difference, whether you&#8217;re sitting in front of the keyboard twiddling your thumbs or putting it in a shell script.  As a matter of fact, on running just the q or equery commands alone (to show the helpful usage messages), the speed difference is over 500 times!  That being said, if you don&#8217;t need the fancy formatting and extra frills of equery for a given task, just use q.  It&#8217;s faster.  According to its <a href="http://www.gentoo.org/doc/en/portage-utils.xml">Gentoo page</a>, that&#8217;s its purpose anyway:</p>
<blockquote><p>portage-utils is a collection of very fast utilities written in C, which are meant to offer a faster but more limited alternative to their gentoolkit counterparts. Please note that portage-utils is not meant to replace gentoolkit. Its utilities are much more efficient than the equivalent ones from gentoolkit and might be better suited to be used in scripts that need to call Portage repeatedly, but portage-utils does not offer the same functionalities.</p></blockquote>
<p>Well hot-damn, I could have told you that from the beginning, no?  It&#8217;s times like this that I sing the praises of C and mock all those Python people.  Then I try to write a difficult program and cry myself to sleep.</p>
<p>Anyway, language wars and tearful nights aside, there are also a couple of other distinguishing things about q.  First, its simple format can make parsing a bit simpler.  Then again, it could make it harder, so let&#8217;s not go there.  As a matter of fact, equery makes a point of modifying its output if you redirect its output.  If you don&#8217;t like the modified style of output, you can pass the -N (&#8211;no-pipe) flag to turn that behavior off.</p>
<p>Second, q does bring a few unique functions to the table.  Namely:</p>
<ul>
<li><strong>atom</strong>: split up an atom string (like games-emulation/zsnes-1.51-r2 -&gt; games-emulation zsnes 1.51 r2)</li>
<li><strong>cache</strong>: search the metadata cache</li>
<li><strong>grep</strong>: grep in ebuilds</li>
<li><strong>lop</strong>: emerge log analyzer</li>
<li><strong>merge</strong>, <strong>pkg</strong>, <strong>tbz2</strong>, <strong>xpak</strong>: all pertain to actually handling various types of packages, which I have no experience with, so I don&#8217;t know their usage.</li>
</ul>
<p>The one that I find particularly is &#8220;lop.&#8221;  In an example from that Gentoo page on portage-utils, try something like:</p>
<p><code>$ qlop -tH openoffice</code></p>
<p>It&#8217;ll tell you &#8220;the merge time&#8221; for that package.  Now, I&#8217;m not sure if that means the last merge or some sort of aggregate.  My output tells me:</p>
<p><code>openoffice: 9 hours, 19 minutes, 11 seconds for 12 merges</code></p>
<p>I&#8217;m guessing that means that it took 9:19:11 to merge 12 <em>packages</em>, in terms of the package in question and its dependencies, but I&#8217;m not totally sure on that one.  Either way, this is a damn nifty feature.  I make jokes all the time about how long some packages take to emerge, and how I can have actual times to back me up!  Oh the joys of Gentoo&#8230;</p>
<p>As another very useful note, the qsearch command is also substantially faster than &#8220;emerge &#8211;search.&#8221;  It&#8217;s not nearly as impressive as it is against equery, but it holds its own.  An advantage that qsearch has over its equery counterpart, however, is that it has the ability (and has it default) of displaying descriptions of packages.  I actually for a long time forgot how to do that on my system, and always ran to <a href="http://www.gentoo-portage.com/">gentoo-portage.com</a>.</p>
<p>Last but not least, just like equery, q commands can be shortened as well.  Unfortunately, that just means changing something like &#8220;q search&#8221; to &#8220;qsearch.&#8221;  Not a big improvement, but with a one-letter command, how much can you really ask for?</p>
<h3>Why both?</h3>
<p>In brief, the snippet above from the Gentoo article on portage-utils gives the answer quite nicely.  q may be lacking, but it can be an order of magnitude faster than equery.  For those times when you don&#8217;t need all that fancy-shmancy formatting and just want to get quick and dirty results, q is your tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2008/11/equery-and-q/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Music Syncing Issues</title>
		<link>http://blog.danfego.net/2008/10/music-syncing-issues/</link>
		<comments>http://blog.danfego.net/2008/10/music-syncing-issues/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 03:37:28 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://dlflab.wordpress.com/?p=14</guid>
		<description><![CDATA[I can sum up most of my computer-related decisions over the last 3 years or so as all being related to dealing with my hardware as best as possible.  This first led me to ditch Windows XP and try out Linux (Ubuntu first).  Then I tried fluxbox because GNOME was too heavy.  [...]]]></description>
			<content:encoded><![CDATA[<p>I can sum up most of my computer-related decisions over the last 3 years or so as all being related to dealing with my hardware as best as possible.  This first led me to ditch Windows XP and try out Linux (Ubuntu first).  Then I tried fluxbox because GNOME was too heavy.  Then I decided that Ubuntu didn&#8217;t deal all too well with switching out your desktop environment for a window manager, so I naively tried out this distribution I&#8217;ve come to know and love called Gentoo.  Now that I&#8217;m with Gentoo/fluxbox combo, I&#8217;ve managed, over time, to slim down my machine to just what I want, and have a pretty lean box, IMHO.  Not the leanest, but I did want a functional and pretty box as well. <img src='http://blog.danfego.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Anyway, this all correlates to a recent issue I&#8217;ve had with my music accounting system, and how I got around it with some frenzied bash scripting.  Because I&#8217;ve got a 4GB iPod Nano, I eventually came into the position of having too much music to fit on the device.  So I looked at my music and thought about compression.  Unfortunately, I couldn&#8217;t glean nearly enough space from that.  Then I realized that I <em>have</em> way more music than I actually listen to, so why not keep some music for computer listening, and some for mobile?  Well that&#8217;s a fantastic idea, but implementation gets a bit sticky.  I can try some convoluted system in which I keep a file of the unwanted files, update that manually, and&#8230; yeah, not too pretty.  Although I can&#8217;t quite say my solution was much prettier.</p>
<p>My current system involves a ~/music directory, and a ~/music-all directory.  My intention is to delete nothing from ~/music-all, ever.  ~/music contains music I actually want to listen to, and ~/music-ipod will contain music that I like enough to carry in my 4GB of space.  The key is that all the files within these three directories are hard links, so I&#8217;m not actually increasing my disk usage very much, and operations on the sets of files are much faster than if I had more than one copy of my files.  So assuming I hard link everything in ~/music-all to ~/music, I can then delete things from music at will, without losing it from my drive, but getting rid of it from listening.</p>
<p>With a schema in mind, then there&#8217;s the question of how to keep it up to date.  There are times when I want to add music to my collection, but then what do I do?  I could manually link the new files over, but&#8230; well, in retrospect, perhaps that would have been simpler.  But I decided I needed a script which would note the differences, relink ~/music-all to ~/music, then remove the files that I noted earlier (which were saved in a text file).  The benefit of all my toil was that it now makes my updates lightning fast and not tedious in the least.  I had to come up with two scripts, however: one to be run prior to changes to ~/music-all, and one once they&#8217;re made.  Below are the scripts, which probably won&#8217;t be of much use to anyone else, but they can essentially be used to keep two directories in sync, but with certain persistent changes.</p>
<p><a href="https://dl.getdropbox.com/u/221130/mtree-1">mtree-1</a><br />
<a href="https://dl.getdropbox.com/u/221130/mtree-2">mtree-2</a></p>
<p>Wow, I just spent <strong>way</strong> too much time figuring out how to post code here, and I&#8217;m still not satisfied with the result, so I ditched it.  The built-in &lt;code&gt; tag doesn&#8217;t seem to take to multiple lines all that well&#8230;  If anyone knows how to do that, do let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danfego.net/2008/10/music-syncing-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
