<?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>Niels Horn&#039;s Blog &#187; Sem categoria</title>
	<atom:link href="http://blog.nielshorn.net/category/sem-categoria/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nielshorn.net</link>
	<description>Random thoughts, tips &#38; tricks about Slackware-Linux, Lego and Star Wars</description>
	<lastBuildDate>Thu, 05 Jan 2012 02:40:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Service interruptions</title>
		<link>http://blog.nielshorn.net/2010/03/service-interruptions/</link>
		<comments>http://blog.nielshorn.net/2010/03/service-interruptions/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 16:34:34 +0000</pubDate>
		<dc:creator>Niels Horn</dc:creator>
				<category><![CDATA[Sem categoria]]></category>

		<guid isPermaLink="false">http://blog.nielshorn.net/?p=259</guid>
		<description><![CDATA[My hosting provider is updating its MySQL boxes, so some services might suffer small periods of unavailability. If you have problems accessing one of these services, please try again some time later:

This blog
Downloading Slackware packages, page statistics, etc. from my main site
My TRS-80 Wiki

These interruptions will occur during the coming week and should last a [...]]]></description>
			<content:encoded><![CDATA[<p>My hosting provider is updating its MySQL boxes, so some services might suffer small periods of unavailability. If you have problems accessing one of these services, please try again some time later:</p>
<ul>
<li>This <a href="http://blog.nielshorn.net/">blog</a></li>
<li><a href="http://www.nielshorn.net/slackware/slack_pkg.php">Downloading Slackware packages</a>, <a href="http://www.nielshorn.net/_lib/stats.php">page statistics</a>, etc. from my <a href="http://www.nielshorn.net/">main site</a></li>
<li>My <a href="http://www.nielshorn.net/trs-wiki/">TRS-80 Wiki</a></li>
</ul>
<p>These interruptions will occur during the coming week and should last a couple of hours at the most. Sorry for the inconvenience!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nielshorn.net/2010/03/service-interruptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting a text-based program on a headless box at boot time</title>
		<link>http://blog.nielshorn.net/2010/02/starting-a-text-based-program-on-a-headless-box-at-boot-time/</link>
		<comments>http://blog.nielshorn.net/2010/02/starting-a-text-based-program-on-a-headless-box-at-boot-time/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 16:23:40 +0000</pubDate>
		<dc:creator>Niels Horn</dc:creator>
				<category><![CDATA[Sem categoria]]></category>

		<guid isPermaLink="false">http://blog.nielshorn.net/?p=212</guid>
		<description><![CDATA[Imagine yourself in the following situation:
You have a &#8220;headless&#8221; (this means: without a monitor attached) server that boots nicely, starts all the services you configured, like dns, ntp, nfs, samba, httpd, mysql, etc. But &#8211; since it has processing power left and stays on 24&#215;7, you decide that it could do something extra that you [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine yourself in the following situation:<br />
You have a &#8220;headless&#8221; (this means: without a monitor attached) server that boots nicely, starts all the services you configured, like dns, ntp, nfs, samba, httpd, mysql, etc. But &#8211; since it has processing power left and stays on 24&#215;7, you decide that it could do something extra that you run on your desktop now and so you have to keep that running 24&#215;7 as well.</p>
<p>Some examples:
<ol>
<li>a torrent program to download all those Linux ISOs (you&#8217;re not downloading anything illegal, are you? <img src='http://blog.nielshorn.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</li>
<li>an irc program so that you can log all conversations while you&#8217;re away</li>
<li>a mainframe emulator (well, this was <i>my</i> main reason)</li>
</ol>
<p>For (1) there is <a href="http://libtorrent.rakshasa.no/">rTorrent</a> and for (2) there is irssi, included in Slackware. For (3) I use <a href="http://www.hercules-390.org/">Hercules</a> that runs in a terminal screen.<br />
Now services you can start in /etc/rc.d/rc.local, as they do not need a terminal to show output and run as daemons. But these three programs need to show their output on a terminal screen to be useful, and a user that is logged in.<br />
The standard solution for these cases is using &#8220;screen&#8221;, that lets programs run on &#8220;virtual terminal&#8221; you can &#8220;attach&#8221; to.</p>
<p>Since an easy-to-use and still relatively safe setup is a bit tricky, here are a few simple instructions. As an example (not very useful in the real world), I will start &#8220;top&#8221; at boot time in a screen session.</p>
<p><strong>1. Defining the user that will run the program</strong><br />
First of all, I personally think it is a very bad idea to run programs as root, especially if they need access to drives, the internet, etc. So for my example, I create a user &#8220;_top&#8221; with the &#8220;adduser&#8221; command.<br />
I suggest starting the name with the &#8220;underline&#8221; character, but that&#8217;s just a habit I have for special users.<br />
I also create these special users with uid&#8217;s in a special range, like 5001-5999.</p>
<p><strong>2. Editing the ~/.screenrc file</strong><br />
After creating your _top user, you will have a file called &#8220;/home/_top/.screenrc&#8221;<br />
If your version of Linux does not copy it automatically for new users, there should be a &#8220;skeleton&#8221; version somewhere you can copy.<br />
Edit the copy of .screenrc in the user&#8217;s home directory, and add the following lines at the end:</p>
<pre>multiuser on
acladd user1,user2,user3</pre>
<p>What do these lines mean:</p>
<ul>
<li><code>multiuser on</code> will make the screen session available for other users. Without this line, it would be a &#8220;private session&#8221;, with only &#8220;_top&#8221; having access to it.</li>
<li><code>acladd user1,user2,user3</code> gives access to user1, user2 and user3. Replace these with the users you want to be able to attach to the screen session _top will start at boot time.</li>
</ul>
<p>We&#8217;ll come back to this .screenrc file later&#8230;</p>
<p><strong>3. Starting screen + the desired program at startup</strong><br />
We will start the program as usual in /etc/rc.d/rc.local by adding the following line:</p>
<pre>sudo -H -u _top screen -dmS top /usr/bin/top</pre>
<p>Let&#8217;s dissect this command:</p>
<ul>
<li><code>sudo</code> rc.local is run by root but not as a logged-in user, so with sudo we tell root that we want the program to start as another user</li>
<li><code>-H</code> This tells sudo to use the home directory of the user we choose. Without the -H option, sudo will not find the /home/_top/.screenrc file.</li>
<li><code>-u _top</code> Here we define the user &#8211; _top in our case.</li>
<li><code>screen -dmS top /usr/bin/top</code> This is the command sudo will execute, with these options:
<ul>
<li><code>-dm</code> Start screen in &#8220;detached&#8221; mode, not at the current terminal (as we do not have a current terminal, after all we&#8217;re not even logged in)</li>
<li><code>S top</code> Use the session name &#8220;top&#8221; &#8211; this is so that we can identify the screen session if we have several of them</li>
<li><code>/usr/bin/top</code> The command screen will run in the &#8220;virtual terminal&#8221;</li>
</ul>
</li>
</ul>
<p><strong>4. Trying our first setup</strong><br />
To try this setup, you do not need to boot your server yet. Simply run the <code>sudo -H -u _top screen -dmS top /usr/bin/top</code> as root. It should simply return to the prompt, but we can check if it worked with <code>ps -ef f | grep ^_top</code> that should return with:</p>
<pre>_top      1418     1  0 13:40 ?        Ss     0:00 SCREEN -dmS top /usr/bin/top
_top      1419  1418  5 13:40 pts/0    Ss+    0:00  \_ /usr/bin/top</pre>
<p>Of course the PIDs and times will be different.</p>
<p>Now log in as one of the users you defined in the acladd line in .screenrc and type <code>screen -ls _top/</code> where:</p>
<ul>
<li><code>-ls</code> is the option to list all running sessions</li>
<li><code>_top/</code> tells screen to list the sessions of user _top</li>
</ul>
<p>It should return with:</p>
<pre>There is a suitable screen on:
	1418.top	(Multi, detached)
1 Socket in /home/_top/.screen.</pre>
<ul>
<li><code>1418</code> is the pid &#8211; this will change of course</li>
<li><code>top</code> is the session name we defined</li>
<li><code>Multi</code> means that it is a multiuser session (as defined in .screenrc)</li>
<li><code>detached</code> means that no user is attached to the session</li>
</ul>
<p>So let&#8217;s attach to the session and see how &#8220;top&#8221; is doing, by typing <code>screen -r _top/top</code><br />
If everything worked fine, you should see &#8220;top&#8221; as running on your server <img src='http://blog.nielshorn.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Screen has several commands, but for now the most interesting are:</p>
<ul>
<li><code>ctrl-A d</code> &#8211; detach from the current session but let it running</li>
<li><code>ctrl-A ?</code> &#8211; show the ctrl-A commands</li>
<li><code>ctrl-A :</code> &#8211; gives the prompt in screen to enter commands</li>
</ul>
<p><strong>5. Adding some security</strong><br />
So now we have a working setup, but all the users we defined in the .screenrc file can access our session (even several at once) and input commands there.<br />
I suggest at least asking for a password before letting a user attach to a session. This is a bit tricky to set up if you have never done this, but these are the basic steps:</p>
<ol>
<li>Attach to a session normally</li>
<li>Type <code>ctrl-A c</code> to create a second screen (the first one will still be there)</li>
<li>Go to the screen prompt by typing <code>ctrl-A :</code></li>
<li>Enter <code>password</code> + enter and type your password twice</li>
<li>The encrypted password will be in screens &#8220;paste buffer&#8221;</li>
<li>Type <code>ctrl-A ]</code> to reveal the encrypted password</li>
</ol>
<p>Now edit the .screenrc file and change the lines at the end as follows:</p>
<pre>multiuser on
acladd user1,user2,user3 xxxxxxxxxxxxx
aclchg * +rwx "#?"</pre>
<p>Substitute xxxxxxxxxxxxx with your encrypted password.<br />
The last line gives full access to all users that know the password. According to the manual this should be automatic, but that is not how it worked for me. Without this line I could not even detach from a session! I simply received an error like &#8220;detached: permission denied (user: niels)&#8221; <img src='http://blog.nielshorn.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
You can change the +rwx options for some users, so that they can only &#8220;read&#8221; the session and not &#8220;write&#8221; (type) anything. This adds extra security that can be important in some cases.</p>
<p>After finishing editing the .screenrc file, you can close the second session by typing <code>exit</code> at the prompt.</p>
<p><strong>6. Advanced options</strong><br />
There are many more things you can do with screen, like having several users accessing the same session, some only reading, others typing as well. There are also many security adjustments you can configure&#8230;</p>
<p>Read the man-page for screen to study all the interesting things you can do!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nielshorn.net/2010/02/starting-a-text-based-program-on-a-headless-box-at-boot-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>inadyn, a Dynamic DNS client for Linux</title>
		<link>http://blog.nielshorn.net/2010/02/inadyn-a-dynamic-dns-client-for-linux/</link>
		<comments>http://blog.nielshorn.net/2010/02/inadyn-a-dynamic-dns-client-for-linux/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 02:42:15 +0000</pubDate>
		<dc:creator>Niels Horn</dc:creator>
				<category><![CDATA[Sem categoria]]></category>

		<guid isPermaLink="false">http://blog.nielshorn.net/?p=185</guid>
		<description><![CDATA[Whoever has an ISP that regularly changes your IP address, knows the difficulties of accessing your computer at home from remote locations. If the IP address changes all the time, how can you access your home system through a browser, ssh, etc.
There are actually several solutions for this, like DynDNS, where you can register a [...]]]></description>
			<content:encoded><![CDATA[<p>Whoever has an ISP that regularly changes your IP address, knows the difficulties of accessing your computer at home from remote locations. If the IP address changes all the time, how can you access your home system through a browser, ssh, etc.</p>
<p>There are actually several solutions for this, like <a href="http://www.dyndns.com/">DynDNS</a>, where you can register a domain like &lt;yourname&gt;.selfip.net (and many other combinations). Then you will need a &#8220;client&#8221; &#8211; a small piece of software that checks every so many minutes if your IP address has changed.</p>
<p>For Linux systems, there is <a href="http://www.inatech.eu/inadyn/">inadyn</a>. I have been using inadyn for a couple of years now and it has been extremely stable and useful for me. You can download a ready-to-use binary from their site, but it is 32-bits only.<br />
Since the sources are also available, I decided to create a SlackBuild for it, so that inadyn can be used on SlackWare64.</p>
<p>The SlackBuild has been submitted to SlackBuilds.org and is waiting for approval in the pending queue.<br />
If you can&#8217;t or don&#8217;t want to wait, the packages are also available from my <a href="http://www.nielshorn.net/slackware/slack_pkg.php">site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nielshorn.net/2010/02/inadyn-a-dynamic-dns-client-for-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

