<?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>cyberz.org &#187; Unix</title>
	<atom:link href="http://www.cyberz.org/blog/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberz.org/blog</link>
	<description>Andrea Leofreddi's homepage</description>
	<lastBuildDate>Tue, 10 Aug 2010 17:19:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Bacula mail changer script (aka poor man&#8217;s autoloader)</title>
		<link>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/</link>
		<comments>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 22:16:32 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Bacula]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=24</guid>
		<description><![CDATA[I enjoy Bacula for automated]]></description>
			<content:encoded><![CDATA[<p>I enjoy Bacula for automated home backups on DLT and DDS tape drives. Being used at home there&#8217;s no &#8211; obviously &#8211; big-dollar-company-manager to ask for an autoloader; and when the time of a tape change comes bacula lacks a simple way to request a manual tape change and just hangs up. So I managed to build a fake autoloader shell script, which, using emails, would emulate a real autoloader. This script, which I baptised <em>mail-changer</em>, features:</p>
<ul>
<li>email support</li>
<li>periodic email resend when tape change is needed</li>
<li>tape detection and check (if you&#8217;re supposed to insert tape 4 and you enter 5, the script will kindly refuse the tape, unload it and send a warning email message asking for the right one)</li>
</ul>
<p><span id="more-24"></span>To implement the third point (tape detection and check), it was necessary to extract the tape id from the bacula tape. That can be done looking at the bacula&#8217;s tape header structure:</p>
<p>The first structure stored is called &#8220;Block Header&#8221; and is 24 bytes long:</p>
<pre>   uint32_t CheckSum;                /* Block check sum */
   uint32_t BlockSize;               /* Block byte size including the header */
   uint32_t BlockNumber;             /* Block number */
   char ID[4] = "BB02";              /* Identification and block level */
   uint32_t VolSessionId;            /* Session Id for Job */
   uint32_t VolSessionTime;          /* Session Time for Job */</pre>
<p>Then a &#8220;Record Header&#8221; follows (12 bytes):</p>
<pre>  int32_t FileIndex;   /* File index supplied by File daemon */
  int32_t Stream;      /* Stream number supplied by File daemon */
  uint32_t DataSize;   /* size of following data record in bytes */</pre>
<p>Then a structure which is interesting for us, called &#8220;Volume Label&#8221; follows:</p>
<pre>  char Id[32];              /* Bacula 1.0 Immortal\n */
  uint32_t VerNum;          /* Label version number */
  /* VerNum 11 and greater Bacula 1.27 and later */
  btime_t   label_btime;    /* Time/date tape labeled */
  btime_t   write_btime;    /* Time/date tape first written */
  /* The following are 0 in VerNum 11 and greater */
  float64_t write_date;     /* Date this label written */
  float64_t write_time;     /* Time this label written */
  char VolName[128];        /* Volume name */
  char PrevVolName[128];    /* Previous Volume Name */
  char PoolName[128];       /* Pool name */
  char PoolType[128];       /* Pool type */
  char MediaType[128];      /* Type of this media */
  char HostName[128];       /* Host name of writing computer */
  char LabelProg[32];       /* Label program name */
  char ProgVersion[32];     /* Program version */
  char ProgDate[32];        /* Program build date/time */</pre>
<p>What is really important for us is the VolName field, which is at relative offset +56 from the beginning of the <em>Volume Label</em>. Adding 12 bytes of <em>Record Header</em> and 24 of <em>Block Header</em> makes 92 bytes.</p>
<p>Please note that mail-changer has been developed on Solaris 10 using CSW&#8217;s Bacula, you may need to work a bit to adapt it to your unix.</p>
<p>You can <a title="mail-changer script" href="/projects/mail-changer/mail-changer" target="_blank">download mail-changer here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/06/08/bacula-mail-changer-script-aka-poor-mans-autoloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios nrpe and sudo: &#8220;NRPE: Unable to read output&#8221;</title>
		<link>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/</link>
		<comments>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:21:21 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Sudo]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=49</guid>
		<description><![CDATA[On CentOS 5 (and RedHat]]></description>
			<content:encoded><![CDATA[<p>On CentOS 5 (and RedHat EL as well), you can encounter the following behaviour when configuring an nrpe plugin with sudo:<br />
<code><br />
[andrea@feyd ~]$ /usr/lib/nagios/plugins/check_nrpe  -H 1.2.3.4 -c check_md_raid<br />
NRPE: Unable to read output<br />
</code><br />
<span id="more-49"></span><br />
Given that check_md_raid is defined as follows, in nrpe.conf:<br />
<code><br />
command[check_md_raid]=sudo /usr/local/bin/nagios_check_md_raid<br />
</code><br />
And given (for completeness) its relative /etc/sudoers line as follows:<br />
<code><br />
nagios    ALL=(ALL)   NOPASSWD:/usr/local/bin/nagios_check_md_raid<br />
</code><br />
Then the problem is in the requiretty options in /etc/sudoers, enabled by default on CentOS. Simply comment it as follows:<br />
<code><br />
#Defaults    requiretty<br />
</code><br />
After that the plugin should work as expected:<br />
<code><br />
[andrea@feyd ~]$ /usr/lib/nagios/plugins/check_nrpe  -H 1.2.3.4 -c check_md_raid<br />
RAID OK: All arrays OK [1 array checked]<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2009/01/03/nagios-nrpe-and-sudo-nrpe-unable-to-read-output/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SSH X11 forwarding issue</title>
		<link>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/</link>
		<comments>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 21:38:53 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[All/News]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/</guid>
		<description><![CDATA[Recently I&#8217;ve been in an]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been in an awkward situation with ssh and X11 forwarding, where ssh using the classic -Y (or -X) switch wasn&#8217;t working (DISPLAY was not set):</p>
<p><code>[andrea@duncan ~]$ ssh -Y root@thufir<br />
root@thufir's password:<br />
Last login: Sat Apr 12 23:30:09 2008 from ***<br />
[root@thufir ~]# echo $DISPLAY<br />
[root@thufir ~]#</code></p>
<p>If you are experiencing the same and your <em>sshd_config</em> looks fine (which means TCP and X11 forwarding is already enabled) then the answer is missing <em>xauth</em>!</p>
<p>On RedHat <code>yum install xauth</code> will do the trick</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2008/04/12/ssh-x11-forwarding-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>seq equivalent</title>
		<link>http://www.cyberz.org/blog/2008/02/27/seq-equivalent-on-solarismacosx/</link>
		<comments>http://www.cyberz.org/blog/2008/02/27/seq-equivalent-on-solarismacosx/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 19:19:28 +0000</pubDate>
		<dc:creator>andrea</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[Solaris]]></category>

		<guid isPermaLink="false">http://www.cyberz.org/blog/?p=9</guid>
		<description><![CDATA[On platforms without seq (MacOSX,]]></description>
			<content:encoded><![CDATA[<p>On platforms without seq (MacOSX, Solaris), you can emulate it using dc as follows (note the upper bound and the lower bound):</p>
<p><code>echo '[1+pd<em>upper bound</em>&gt;aq]sa<em>lower bound</em> 1-lax' | dc</code></p>
<p>For example:</p>
<p><code>alia:~ andrea$ echo '[1+pd5&gt;aq]sa0 1-lax' | dc<br />
0<br />
1<br />
2<br />
3<br />
4<br />
5<br />
alia:~ andrea$</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberz.org/blog/2008/02/27/seq-equivalent-on-solarismacosx/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
