<?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>harski.org</title>
	<atom:link href="http://harski.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://harski.org</link>
	<description>Bloggin&#039; away</description>
	<lastBuildDate>Mon, 04 Mar 2013 12:20:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>urxvt urlLauncher stopped working</title>
		<link>http://harski.org/2013/03/04/urxvt-urllauncher-stopped-working/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=urxvt-urllauncher-stopped-working</link>
		<comments>http://harski.org/2013/03/04/urxvt-urllauncher-stopped-working/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 12:20:51 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[rxvt-unicode]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://harski.org/?p=157</guid>
		<description><![CDATA[A while back urlLauncher suddently and silently stopped working after an update to version 9.16, and I&#8217;m sure I&#8217;m not alone with this. The culprit is the upstream itself, as can be seen in their changelog: - INCOMPATIBLE CHANGE: renamed &#8230; <a href="http://harski.org/2013/03/04/urxvt-urllauncher-stopped-working/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A while back urlLauncher suddently and silently stopped working after an update to version 9.16, and I&#8217;m sure I&#8217;m not alone with this. The culprit is the upstream itself, as can be seen in their <a title="Changelog" href="http://cvs.schmorp.de/rxvt-unicode/Changes">changelog</a>:</p>
<blockquote><p>- INCOMPATIBLE CHANGE: renamed urlLauncher resource to url-launcher.</p></blockquote>
<p>So, to fix this just change <em>URxvt.urlLauncher: browser</em> line to <em>URxvt.url-launcher: browser</em> in your <strong>~/.Xdefaults</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2013/03/04/urxvt-urllauncher-stopped-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git: delete remote branch</title>
		<link>http://harski.org/2013/01/10/git-delete-remote-branch/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-delete-remote-branch</link>
		<comments>http://harski.org/2013/01/10/git-delete-remote-branch/#comments</comments>
		<pubDate>Thu, 10 Jan 2013 14:23:02 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://harski.org/?p=150</guid>
		<description><![CDATA[I&#8217;ve been using a git for a good while now, and whenever I have had to remove a branch on a remote server I have logged into that machine and deleted the branch like I would on my local machine. &#8230; <a href="http://harski.org/2013/01/10/git-delete-remote-branch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been using a git for a good while now, and whenever I have had to remove a branch on a remote server I have logged into that machine and deleted the branch like I would on my local machine. In some remotes, like <a title="github.com" href="https://github.com">github</a>, this is not possible. Instead you can remove the remote branches with:</p>
<pre class="wp-code-highlight prettyprint">$ git push remote-name :branch-to-be-deleted</pre>
<p>or alternatively with</p>
<pre class="wp-code-highlight prettyprint">$ git push remote-name --delete branch-to-be-deleted</pre>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2013/01/10/git-delete-remote-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling dwm and missing libraries</title>
		<link>http://harski.org/2012/11/13/compiling-dwm-and-missing-libraries/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=compiling-dwm-and-missing-libraries</link>
		<comments>http://harski.org/2012/11/13/compiling-dwm-and-missing-libraries/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 09:30:48 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[dwm]]></category>

		<guid isPermaLink="false">http://harski.org/?p=146</guid>
		<description><![CDATA[During the last weekend I did a fresh install of Debian to my netbook, using the netinstall image. For this particular machine, dwm is my WM of choice. However, compiling the latest dwm I got from the suckless site didn&#8217;t compile &#8230; <a href="http://harski.org/2012/11/13/compiling-dwm-and-missing-libraries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>During the last weekend I did a fresh install of Debian to my netbook, using the netinstall image. For this particular machine, dwm is my WM of choice. However, compiling the latest dwm I got from the <a title="DWM home" href="http://dwm.suckless.org" target="_blank">suckless site</a> didn&#8217;t compile straight away.</p>
<p>With the first try I got the compiling errors</p>
<blockquote><p>dwm.c:33:28: fatal error: X11/cursorfont.h: No such file or directory<br />
compilation terminated.<br />
make: *** [dwm.o] Error 1</p></blockquote>
<p>and</p>
<blockquote><p>dwm.c:40:37: fatal error: X11/extensions/Xinerama.h: No such file or directory<br />
compilation terminated.<br />
make: *** [dwm.o] Error 1</p></blockquote>
<p>In the dwm README it says:</p>
<blockquote><p>Requirements: In order to build dwm you need the Xlib header files.</p></blockquote>
<p>so that&#8217;s where the rub is. The particular  packages you need in Debian are libx11-dev and libxinerama-dev, install them with</p>
<blockquote><p>$ sudo apt-get install libx11-dev libxinerama-dev</p></blockquote>
<p>and you&#8217;re set.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/11/13/compiling-dwm-and-missing-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>urxvt leaving ncurses content drawn on screen detach</title>
		<link>http://harski.org/2012/10/10/urxvt-leaving-ncurses-content-drawn-on-screen-detach/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=urxvt-leaving-ncurses-content-drawn-on-screen-detach</link>
		<comments>http://harski.org/2012/10/10/urxvt-leaving-ncurses-content-drawn-on-screen-detach/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 09:02:24 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ncurses]]></category>
		<category><![CDATA[rxvt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://harski.org/?p=142</guid>
		<description><![CDATA[For a while now I&#8217;ve had this issue with urxvt, when I detach screen the terminal remains garbled with the content the screen had before I detached. This, I guess, is because there is something funny going on in urxvt&#8217;s &#8230; <a href="http://harski.org/2012/10/10/urxvt-leaving-ncurses-content-drawn-on-screen-detach/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For a while now I&#8217;ve had this issue with urxvt, when I detach screen the terminal remains garbled with the content the screen had before I detached. This, I guess, is because there is something funny going on in urxvt&#8217;s terminfo. As a workaround one can fake urxvt being actually rxvt by defining termName in ~/.Xdefaults:</p>
<pre class="wp-code-highlight prettyprint">urxvt*termName: rxvt-256color</pre>
<p>or</p>
<pre class="wp-code-highlight prettyprint">urxvt*termName: rxvt</pre>
<p>or whatever. The terminal acts nicely with screen and ncurses, and I haven&#8217;t run into any problems thus far. But note that generally speaking lying about your terminal&#8217;s capabilities is a <strong>stupid</strong> idea.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/10/10/urxvt-leaving-ncurses-content-drawn-on-screen-detach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding another &#8220;address&#8221; to a gpg key</title>
		<link>http://harski.org/2012/09/26/adding-another-address-to-a-gpg-key/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adding-another-address-to-a-gpg-key</link>
		<comments>http://harski.org/2012/09/26/adding-another-address-to-a-gpg-key/#comments</comments>
		<pubDate>Wed, 26 Sep 2012 08:38:49 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[gpg]]></category>
		<category><![CDATA[public-key]]></category>

		<guid isPermaLink="false">http://harski.org/?p=134</guid>
		<description><![CDATA[When I last time set my gpg key up I thought I&#8217;d associate more than one email address with it like I&#8217;ve seen people on the mailing lists do. I tried looking into it but as it didn&#8217;t seem trivial &#8230; <a href="http://harski.org/2012/09/26/adding-another-address-to-a-gpg-key/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When I last time set my gpg key up I thought I&#8217;d associate more than one email address with it like I&#8217;ve seen people on the mailing lists do. I tried looking into it but as it didn&#8217;t seem trivial I got distracted and forgot all about it.</p>
<p>A while back I remembered I still hadn&#8217;t done it and decided it was about time to get my hands dirty. It turned out to be quite trivial, after all.</p>
<p>If you don&#8217;t already have a gpg key you should probably find another resource on how they work, but in short you can get one by having gpg installed and running</p>
<pre class="wp-code-highlight prettyprint">gpg --gen-keys</pre>
<p>and following the instructions.</p>
<p>Once you have the key associated with that one email address (or identity) you can add another one simply by first issuing</p>
<pre class="wp-code-highlight prettyprint">gpg --edit-key &lt;key-id&gt;</pre>
<p>If you don&#8217;t know what your key-id is, you can see it in the output of</p>
<pre class="wp-code-highlight prettyprint">gpg --list-secret-keys</pre>
<p>You should now be looking at a gpg&gt; prompt. Command</p>
<pre class="wp-code-highlight prettyprint">gpg&gt; adduid</pre>
<p>and go through similar process as you initially did when creating the key. After you&#8217;re done and back at the gpg&gt; prompt it should list both of your identities. If there isn&#8217;t an asterisk beside your new key, set it with</p>
<pre class="wp-code-highlight prettyprint">gpg&gt; uid #</pre>
<p>where # is the number of the new uid in your list. The asterisk indicates that the commands you take next operate on that uid. Now, say</p>
<pre class="wp-code-highlight prettyprint">gpg&gt; trust</pre>
<p>and assign the new key to be ultimately trusted (you&#8217;re a decent fellow, aren&#8217;t you?!). Now all there is to do is to exit with</p>
<pre class="wp-code-highlight prettyprint">gpg&gt; save</pre>
<p>and you&#8217;re all done.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/09/26/adding-another-address-to-a-gpg-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git tag sign misbehaving</title>
		<link>http://harski.org/2012/07/19/git-tag-sign-misbehaving/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-tag-sign-misbehaving</link>
		<comments>http://harski.org/2012/07/19/git-tag-sign-misbehaving/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 10:36:06 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://harski.org/?p=128</guid>
		<description><![CDATA[Git tagging is somewhat broken for me. If I want to sign the tag the password prompt wont appear, and instead I&#8217;m seeing the following error multiple times: pinentry-curses: no LC_CTYPE known - assuming UTF-8 It has probably something to &#8230; <a href="http://harski.org/2012/07/19/git-tag-sign-misbehaving/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Git tagging is somewhat broken for me. If I want to sign the tag the password prompt wont appear, and instead I&#8217;m seeing the following error multiple times:</p>
<pre class="wp-code-highlight prettyprint">pinentry-curses: no LC_CTYPE known - assuming UTF-8</pre>
<p>It has probably something to do with me not running gpg-agent daemon, or something. Anyway, setting GPG_TTY with</p>
<pre class="wp-code-highlight prettyprint">export GPG_TTY=$(tty)</pre>
<p>fixes the issue, and the ncurses prompt for the password appears as it is intended.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/07/19/git-tag-sign-misbehaving/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Urllogpg.pl, irssi script for logging URLs to postgresql database</title>
		<link>http://harski.org/2012/05/27/urllogpg-pl-irssi-script-for-logging-urls-to-postgresql-database/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=urllogpg-pl-irssi-script-for-logging-urls-to-postgresql-database</link>
		<comments>http://harski.org/2012/05/27/urllogpg-pl-irssi-script-for-logging-urls-to-postgresql-database/#comments</comments>
		<pubDate>Sun, 27 May 2012 17:37:27 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[irssi]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://harski.org/?p=118</guid>
		<description><![CDATA[I like logging stuff. Usually I don&#8217;t do much of anything with the data I log, but every once in a while I might accidentally find some use for some of the data. Recently I&#8217;ve migrated away from MySQL, into &#8230; <a href="http://harski.org/2012/05/27/urllogpg-pl-irssi-script-for-logging-urls-to-postgresql-database/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I like logging stuff. Usually I don&#8217;t do much of anything with the data I log, but every once in a while I might accidentally find some use for some of the data.</p>
<p>Recently I&#8217;ve migrated away from MySQL, into PostgreSQL. For logging links to a MySQL database there was Riku Voipio&#8217;s srcipt, <a title="mysqlurllogger.pl" href="http://scripts.irssi.org/scripts/mysqlurllogger.pl">mysqlurllogger.pl</a>, but I couldn&#8217;t find a ready-made script for logging them to PostgreSQL database so I rolled one myself.</p>
<p>The script isn&#8217;t very feature-rich, but it gets the job done. It has one twist, though, it fetches the title of the linked page. The feature comes with a cost, as it needs the LWP perl module to be installed. Another requirement for the script is naturally the PostgreSQL database driver, DBI. <strong>Also, see the edit below.</strong></p>
<p>The script expects a table called &#8220;links&#8221; defined more or less like this:</p>
<pre class="wp-code-highlight prettyprint">id: integer primary key, with a sequence for auto-increment
channel: text
time: timestamp
nick: text
link: text
title: text</pre>
<p>Once you&#8217;ve created the database and meet the requirements, drop the script to you script folder (most likely ~/.irssi/scripts/),  insert your database name, username and password in and load the script in irssi with /load urllogpg.pl.</p>
<p>The script can be found <del datetime="2013-02-04T09:53:19+00:00">here</del>*. It is released under simplified BSD-licence, so&#8230; As RMS would put it, happy hacking!</p>
<p><strong>Edit:</strong> Actually now, after a bit more testing, it seems automatically fetching the page titles may not a good idea. Irssi handles scripts in the same thread as the core logic, so while waiting for the scripts to be run irssi otherwise stops any other activity. For title fetching this means that if the connection to host of the web page times out (or the page is huge/the connection is poor) the script takes an awful lot of time to return. During this time irssi is unsable and the connection to the irc server may even time out.</p>
<p>I&#8217;ve now disabled the feature by default, but it&#8217;s very easy to enable in the script.</p>
<p>tl;dr: think if you really want to enable the title fetching.</p>
<p><strong>* Edit 2:</strong> This is now moved to <a title="github.com" href="https://github.com/harski/urllogpg" target="_blank">github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/05/27/urllogpg-pl-irssi-script-for-logging-urls-to-postgresql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Fork Bomb and what to do about it</title>
		<link>http://harski.org/2012/05/09/the-fork-bomb-and-what-to-do-about-it/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-fork-bomb-and-what-to-do-about-it</link>
		<comments>http://harski.org/2012/05/09/the-fork-bomb-and-what-to-do-about-it/#comments</comments>
		<pubDate>Wed, 09 May 2012 15:26:48 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fork-bomb]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://harski.org/?p=108</guid>
		<description><![CDATA[Last night on #crunchbang @Freenode the infamous fork bomb came up. Some people didn&#8217;t know what it was and what it did, and some people knew what it&#8217;s &#8220;side effect&#8221; was but didn&#8217;t know how it works, so I thought &#8230; <a href="http://harski.org/2012/05/09/the-fork-bomb-and-what-to-do-about-it/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Last night on #crunchbang @Freenode the infamous fork bomb came up. Some people didn&#8217;t know what it was and what it did, and some people knew what it&#8217;s &#8220;side effect&#8221; was but didn&#8217;t know how it works, so I thought I&#8217;d break it down here and give a hint what you can do to prevent someone freezing your machine up with it.</p>
<p>The most common form of the fork bomb is</p>
<pre class="wp-code-highlight prettyprint">:(){ :|:&amp;};:</pre>
<p>Entering that to your terminal most likely will cause your machine to freeze as it chokes on insane amount of processes.  Despite of looking a bit cryptic to untrained eye, it&#8217;s really a very simple piece of shell script. Let&#8217;s take it apart, now.</p>
<pre class="wp-code-highlight prettyprint">:() { ... }</pre>
<p>This construct is used to define a function. A function also needs a name, which comes before the parenthesis i.e. my_awesome_function() { return 0 }. So in this case, where we have <strong>:(){ &#8230;}</strong> we define a function called <strong>:</strong>.</p>
<pre class="wp-code-highlight prettyprint">:|:&amp;</pre>
<p>Now, this is the contents of the function. What it does is call the function <strong>:</strong> (itself) and pipe the result to the function <strong>:</strong>. So in effect the the function calls itself twice. The ampersand means the function call is moved to background so the child processes couldn&#8217;t get killed.</p>
<pre class="wp-code-highlight prettyprint">;:</pre>
<p><strong>;</strong> is there only to tell the parser that the function definition ends here, and what follows is a new command. It&#8217;s only needed because we want to keep the bomb as a one-liner. The last character, <strong>:</strong> is of course the command to start the bomb: call the function we just defined.</p>
<p>There&#8217;s no magic there, it&#8217;s just a regular recursive function. Only that it doesn&#8217;t terminate, but starts instantly eating up more and more of your system&#8217;s resources until the machine freezes. To make it look more like regular shell script it could be re-written for example like this:</p>
<pre class="wp-code-highlight prettyprint">bomb() {
    bomb | bomb &amp;
}
bomb</pre>
<p>I don&#8217;t recommend running that on your local machine. Even if a hard reset wouldn&#8217;t harm your machine it never does any good, either.</p>
<h3>Protective measures</h3>
<p>Since the fork bomb works by spawning processes, you can shield your system against it by limiting the amount of processes a user can simultaneously have.</p>
<p>On a Linux system you can do this by editing your /etc/security/limits.conf file. There&#8217;s probably some kind of template for you to take example of. What you want to limit is nproc:</p>
<pre class="wp-code-highlight prettyprint">harski hard nproc 100
@users hard nproc 50</pre>
<p>The target whose attributes you want to target can be a single user (like on the first line) or a group (the second line). If it&#8217;s a group, you need to indicate it by prepending the group name by @. &#8220;hard&#8221; on that line means it&#8217;s a hard limit. The other possible value would be soft limit (only warns about having too many processes).</p>
<p>It also takes wildcards and can enforce limits to many more resources than just the number of processes, take a look at its man page for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/05/09/the-fork-bomb-and-what-to-do-about-it/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to recover a root password</title>
		<link>http://harski.org/2012/04/05/how-to-recover-a-root-password/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-recover-a-root-password</link>
		<comments>http://harski.org/2012/04/05/how-to-recover-a-root-password/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 10:48:03 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://harski.org/?p=94</guid>
		<description><![CDATA[&#8230;after the death of the admin was more or less the title of a thread I read a while ago in reddit. The thread was about this one guy being the admin of his houses machines and would would happen &#8230; <a href="http://harski.org/2012/04/05/how-to-recover-a-root-password/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>&#8230;<em>after the death of the admin</em> was more or less the title of a thread I read a while ago in <a title="Reddit homepage" href="http://reddit.com">reddit</a>. The thread was about this one guy being the admin of his houses machines and would would happen to the data on them if he suddenly died.</p>
<p>Besides the question of how to recover the password of a local machine this in my community spawned also discussion on how would one distribute for example his email password to someone else if he died. Email in particular would be a resource that would be valuable to have an access to after its primary user is gone, to shut down it and other services linked to it, if for nothing else. (Turns out there are services for distributing your passwords [for example <a title="Dead man's switch" href="http://www.deadmansswitch.net/">deadmansswitch</a>], if you trust them enough.)</p>
<p>Anyway, this post is about recovering root password in case you forgot it or happen to acquire dead man&#8217;s laptop or whatever. I have collected here four different ways to possibly gain root access to the machine without relying on any software exploits, some of them more convenient than others. After you have a root (or in some cases just write) access to the disk, you can go and edit /etc/shadow manually, or change it with passwd.</p>
<p>Note that all these rely on the fact that the media the target system is on is <strong>unencrypted</strong>. If the disk is encrypted and you don&#8217;t have the password, getting the data out is pretty much a lost cause.</p>
<h3>Runlevel 1</h3>
<p>Probably the easiest way to go about this is booting straight to runlevel one. It is a single user mode for admin tasks. Booting a linux kernel to runlevel one is as easy as appending &#8220;1&#8243; (without the quotes) to your kernel parameters in your bootloader.</p>
<p>This method is very easy to do, but in practice it has a couple of &#8220;defects&#8221;. Defects as in security measures involved. Firstly, on some systems booting the kernel in to runlevel one doesn&#8217;t drop you immediately to a root console, but instead prompts you for the root password which makes this approach a dead-end. This is the case in for example my <a title="Arch Linux Home" href="http://www.archlinux.org/">Arch Linux</a> install.</p>
<p>The second problem can be giving the kernel the &#8220;1&#8243; -option. If the bootloader is locked for editing you simply can&#8217;t hand it to the kernel and the system will boot up as it always does. In this case the only way to edit the boot menu you&#8217;d need to log in as root and then edit the menu&#8230; which again puts us to a dead-end.</p>
<h3>init=/bin/bash</h3>
<p>Trying this method out is pretty similar to runlevel one trick above, but circumvents the first problem in it. Adding init=/bin/bash (or init=/bin/sh or whatever) to the kernel options in you bootloader instructs the kernel to run the specified command first, instead of the usual /sbin/init. This drops you straight into a root shell, and you should see your filesystem just fine. One thing to note here is that the filesystem is now mounted as read only, so to change the root password you first need to remount the fs with read/write access:</p>
<pre class="wp-code-highlight prettyprint">mount -o remount,rw / </pre>
<p>You are now ready to modify /etc/shadow. As you can see, this too relies on being able to edit the kernel options in your boot loader, which can potentially render this method useless.</p>
<h3>Booting a live-cd</h3>
<p>Pretty trivial, eh? Insert the media containing the live os, boot it, mount the disk in the machine and edit it accordingly. But! For this to work you need to be able to select the first boot device. If the order is set and BIOS is password protected, you have a minor bump on the road. &#8220;Fortunately&#8221; as this method already assumes physical access you can open the case and remove the BIOS battery. This should reset the BIOS and you are free to edit it again!</p>
<h3>Taking the disk out and modifying it on another system</h3>
<p>The title says it all. Since we already have access to the machine physically, and don&#8217;t want to bother ourselves with downloading live systems and burning CDs, simply:</p>
<ul>
<li>take out the disk</li>
<li>plug it in your own machine</li>
<li>boot the system normally</li>
<li>mount the foreign disk</li>
<li>edit disk accordingly</li>
</ul>
<h2>What can we learn from all this from security&#8217;s point of view?</h2>
<p>We can turn this whole scene upside down, and take a look at what measures you could take to <em>prevent</em> someone from gaining root access to you box.</p>
<p>The first two methods relied on being able to modify the kernel boot parameters. There&#8217;s a simple solution for that: lock it from modifying. There almost certainly is an option for that somewhere in the configs.</p>
<p>The first one also relied on being able to enter runlevel 1 without prompting the root password. In Arch asking for password is achieved by having &#8220;su:S:wait:/sbin/sulogin -p&#8221; in /etc/inittab, but I don&#8217;t dare even try giving a general instructions on how you should do this. Consult your OS manual or so ;) Besides, locking the boot loader prevents also entering to runlevel 1 in the first place so this isn&#8217;t an issue, and not locking it still makes it possible to use the init=/bin/bash -parameter instead of this.</p>
<p>Now that the bootloader is secure, let&#8217;s move on to BIOS. Set a password for it, and see that the first device the machine looks for something bootable isn&#8217;t a removable media like a cd-device or USB port. Some BIOS&#8217; have a function for selecting the bootable device just for that time, by hitting some key before POSTing. Disable this, too.</p>
<p>All in all: physical access is a bitch. If you have a machine you want to keep safe? Don&#8217;t let anyone near it. All the tricks above rely on getting physical access to the machine. If your disk is not encrypted and someone gets close enough to touch your machine there&#8217;s <strong>nothing</strong> that will protect your data from being compromised.</p>
<p>So as the last point: encrypt the disks on machines that other people might get to. Laptops are prone to stealing and it would be a child&#8217;s play to get your data from there if the disks are unencrypted.</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/04/05/how-to-recover-a-root-password/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Homework template for LaTeX</title>
		<link>http://harski.org/2012/03/11/homework-template-for-latex/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=homework-template-for-latex</link>
		<comments>http://harski.org/2012/03/11/homework-template-for-latex/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 16:31:37 +0000</pubDate>
		<dc:creator>harski</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[homework]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://harski.org/?p=86</guid>
		<description><![CDATA[Since I couldn&#8217;t find a suitable homework template, I decided to hack one together myself. It is based on the exam document class, so one can quite neatly present both the questions and their solutions. As I am a computer &#8230; <a href="http://harski.org/2012/03/11/homework-template-for-latex/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Since I couldn&#8217;t find a suitable homework template, I decided to hack one together myself. It is based on the <a title="The exam document class" href="http://www.ctan.org/tex-archive/macros/latex/contrib/exam">exam document class</a>, so one can quite neatly present both the questions and their solutions. As I am a computer science student, I also took special care to make sure both pseudocode and freely formatted text work properly.</p>
<p>The pseudocode is formatted with <strong>algorithm</strong>, <strong>algorithmicx</strong> and <strong>algpseudocode</strong> packages. The non-formatted text is achieved with <strong>alltt</strong> and <del>striked out text</del> with <strong>ulem</strong> package (\sout command). And who could do without <strong>amsmath</strong>. Get the packages somewhere if you lack them.</p>
<p>The exam document class didn&#8217;t support leaving some of the questions out (a feature not really needed while making exams), so I included a hack for it, \skipquestion. It allows you to answer questions 1 and 4 while keeping the question numbering sane. See the template for example, it&#8217;s all there.</p>
<p>Example of what the result pdf could look like is <a title="Example pdf" href="http://cs.uef.fi/~thartika/hw-template/hw.pdf">here</a>, and the template can be found <a title="Tex template" href="http://cs.uef.fi/~thartika/hw-template/hw.tex">here</a>.</p>
<p>Note: To get the page numbering right you might need to run latex a couple of times.</p>
<h3>Update</h3>
<p>Documentation for the algorithms package (usable commands, examples etc.) can be found at <a href="http://mirrors.ctan.org/macros/latex/contrib/algorithms/algorithms.pdf">http://mirrors.ctan.org/macros/latex/contrib/algorithms/algorithms.pdf</a>.</p>
<p>Also, as discussed in the comments, the linked template is designed for version 2.4 of the exam package and might not even compile with older version (Debian stable users beware! ;).</p>
]]></content:encoded>
			<wfw:commentRss>http://harski.org/2012/03/11/homework-template-for-latex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
