<?xml version="1.0" encoding="utf-8" ?>

<rdf:RDF 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns="http://my.netscape.com/rdf/simple/0.9/">
<channel>
    <title>For the good of all of us</title>
    <link>http://www.skytale.net/blog/</link>
    <description></description>
    <dc:language>en</dc:language>

    <image rdf:resource="http://www.skytale.net/blog/templates/default/img/s9y_banner_small.png" />

    <items>
      <rdf:Seq>
        <rdf:li resource="http://www.skytale.net/blog/archives/33-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/32-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/31-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/28-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/27-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/26-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/25-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/24-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/23-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/22-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/21-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/20-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/19-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/18-guid.html" />
        <rdf:li resource="http://www.skytale.net/blog/archives/17-guid.html" />
      </rdf:Seq>
    </items>
</channel>

<image rdf:about="http://www.skytale.net/blog/templates/default/img/s9y_banner_small.png">
        <url>http://www.skytale.net/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: For the good of all of us - </title>
        <link>http://www.skytale.net/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>


<item rdf:about="http://www.skytale.net/blog/archives/33-guid.html">
    <title>Building a multi OS USB boot stick, Part 1 (Windows)</title>
    <link>http://www.skytale.net/blog/archives/33-Building-a-multi-OS-USB-boot-stick,-Part-1-Windows.html</link>
    <description>
    	&lt;p&gt;Among the things I carry around is always a collection of &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; sticks, for various purposes. One of those is usually dedicated to a Linux rescue system, in order to get somehow broken systems back on their feet.&lt;/p&gt;

	&lt;p&gt;While it is possible these days to access non Linux systems from a booted Linux system any repair work beyond simple text file editing and file copying usually requires OS specific tools to get the job done. Thus it would be nice not only to have a Linux rescue system at hand, but a Windows one as well. And Solaris, while we&amp;#8217;re at it. And possibly some more.&lt;/p&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; sticks are cheap, at least in this part of the world. 10EUR will get you 4GB off the shelf in almost any electronics store, a little more money will get you 8GB ordered online. So space is not really an issue.&lt;/p&gt;

	&lt;p&gt;Actually installing an operating system in a way that allows it to boot off a removable media requires some specific preparations and tools in each case. This means that a running instance of that specific OS is needed to prepare the installation. This means that to get Windows to boot of an &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick a running Windows installation is needed. The same goes for Solaris and Linux.&lt;/p&gt;

	&lt;h3&gt;Preparations&lt;/h3&gt;

	&lt;p&gt;The &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick used for this exercise is a 4G Sandisk. This procedure will &lt;strong&gt;delete all data&lt;/strong&gt; currently on the stick, so either make sure there is nothing of any interest on it, or just get a new one.&lt;/p&gt;

	&lt;p&gt;The initial plan is to have Windows, Linux and Solaris boot off the stick. Each OS will get it&amp;#8217;s own partition, to keep possible clashes between the files of each system to a minimum (and because Solaris wants and &lt;span class=&quot;caps&quot;&gt;UFS&lt;/span&gt; partition, but more on that later).&lt;/p&gt;

	&lt;h3&gt;Installing Windows on &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt;&lt;/h3&gt;

	&lt;p&gt;The standard Windows installer does not allow for installation on &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; devices. The standard tool for those tasks is &lt;a href=&quot;http://www.nu2.nu/pebuilder/&quot;&gt;BartPE&lt;/a&gt;, a free tool to create so-called Preinstalled Environments. Those are actually a Microsoft supported way to preinstall an operating system on a PC, which is used by system builders to deliver machines with the OS already installed but not registered. The Microsoft tools to create these environments are not easily available, though, and this is where BartPE came in a few years ago. It&amp;#8217;s original purpose was to create Live CDs of Windows, but booting from &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; was added (experimentally) later.&lt;/p&gt;

	&lt;p&gt;While BartPE is a very valuable tool there is an even better one for this special purpose: &lt;a href=&quot;http://www.ubcd4win.com/&quot;&gt;The Ultimate Boot CD for Windows&lt;/a&gt;, which is basically a BartPE with a lot of useful tools already tacked to the side, and a completely reworked &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; installer.&lt;/p&gt;

	&lt;p&gt;To use &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; the following is needed:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;The &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; installer, which weighs in at 255MB and is available from the projects site&lt;/li&gt;
		&lt;li&gt;A Windows XP install CD (32 bit)&lt;/li&gt;
		&lt;li&gt;Service Pack 3 for XP, if the Windows CD does not already include it&lt;/li&gt;
		&lt;li&gt;A license for the Windows version (this is more a legal than a technical problem, but the Windows install on the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick needs a separate license to be legal)&lt;/li&gt;
		&lt;li&gt;Drivers&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;The last point is especially interesting. &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; will take all drivers whichare contained in the Windows XP install CD, which, as everyone knows who tried to install XP on a reasonably recent machine, is not exactly much. While the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; installed will boot (hopefully), access to hard disk drives on the machine or access to network interfaces may be severely limited due to missing drivers.&lt;/p&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; already comes with a largeish selection of updated drivers for mass storage, &lt;span class=&quot;caps&quot;&gt;LAN&lt;/span&gt; and &lt;span class=&quot;caps&quot;&gt;WLAN&lt;/span&gt;, so simply building an image with the default settings has a good chance of working on a large number of modern machines (although the &lt;span class=&quot;caps&quot;&gt;WLAN&lt;/span&gt; drivers are disabled by default).&lt;/p&gt;

	&lt;h4&gt;Install procedure&lt;/h4&gt;

	&lt;ul&gt;
		&lt;li&gt;Make a copy of the Windows XP CD (that is, just copy all the files on it into a folder on the hard disk drive)&lt;/li&gt;
		&lt;li&gt;If the CD did not already contain a Windows copy patched to SP3 download the SP3 install package from Microsoft, and &lt;a href=&quot;http://www.howtohaven.com/system/slipstream-xp-service-pack-3.shtml&quot;&gt;slipstream the Service Pack into the copied files&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Install &lt;span class=&quot;caps&quot;&gt;UBDC&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Start &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; and enter the path to the copied Windows CD in the first field&lt;/li&gt;
		&lt;li&gt;Set Media Output to None&lt;/li&gt;
		&lt;li&gt;Click &amp;#8220;Build&amp;#8221;&lt;/li&gt;
	&lt;/ul&gt;

&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 509px&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:31 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;509&quot; height=&quot;421&quot;  src=&quot;http://www.skytale.net/blog/uploads/ubcd1.png&quot;  alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;The &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; main screen&lt;/div&gt;&lt;/div&gt;

	&lt;p&gt;This will start a build process with the default settings, which are reasonable for a first build. &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; is very customizable, most of the options are available by clicking the &amp;#8220;Plugins&amp;#8221; button on the main screen. Describing the various things that can be done here is beyond this text, but the &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; home page has details on this.&lt;/p&gt;

	&lt;p&gt;After the build has finished plug in the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick and start &lt;code&gt;ubusb.exe&lt;/code&gt; from the &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; install folder. To make things easier make sure no other &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; mass storage devices are connected. Set the options to match those in the screenshot below. Specifically:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Make sure the right &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; device is selected&lt;/li&gt;
		&lt;li&gt;Set the partition size to 2048MB (or 2GB)&lt;/li&gt;
		&lt;li&gt;Set the file system to FAT32-&lt;span class=&quot;caps&quot;&gt;LBA&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;Set the Boot Loader to grub4dos&lt;/li&gt;
		&lt;li&gt;Select the right BartPE folder (although it should pick up the correct one automatically)&lt;/li&gt;
		&lt;li&gt;Don&amp;#8217;t create a CD image&lt;/li&gt;
	&lt;/ul&gt;

&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 583px&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:32 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;583&quot; height=&quot;554&quot;  src=&quot;http://www.skytale.net/blog/uploads/ubcd2.png&quot;  alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;&lt;span class=&quot;caps&quot;&gt;UBUSB&lt;/span&gt; main screen&lt;/div&gt;&lt;/div&gt;

	&lt;p&gt;Clicking &amp;#8220;Go&amp;#8221; will start the process of repartitioning, formattingand copying of data to the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick. This may take a while.&lt;/p&gt;

	&lt;p&gt;After the process has finished (hopefully successful) the resulting &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick can immediately be tested, because &lt;span class=&quot;caps&quot;&gt;UBCD&lt;/span&gt; comes with a copy of &lt;a href=&quot;http://www.qemu.org&quot;&gt;qemu&lt;/a&gt;, which can emulate a PC. Just click the &amp;#8220;Test USB&amp;#8221; button, and a virtual PC will try to boot off the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick just created.&lt;/p&gt;

&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 740px&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:33 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;740&quot; height=&quot;438&quot;  src=&quot;http://www.skytale.net/blog/uploads/ubcd3.png&quot;  alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;&lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; boot menu&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;serendipity_imageComment_center&quot; style=&quot;width: 821px&quot;&gt;&lt;div class=&quot;serendipity_imageComment_img&quot;&gt;&lt;!-- s9ymdb:34 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;821&quot; height=&quot;638&quot;  src=&quot;http://www.skytale.net/blog/uploads/ubcd4.png&quot;  alt=&quot;&quot; /&gt;&lt;/div&gt;&lt;div class=&quot;serendipity_imageComment_txt&quot;&gt;Windows booted off the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; stick in qemu&lt;/div&gt;&lt;/div&gt;

	&lt;p&gt;One down, two to go.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Linux, Software, Solaris, Windows, </dc:subject>
    <dc:date>2010-03-21T17:23:49Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=33</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=33</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/32-guid.html">
    <title>Outgoing TLS verification in exim</title>
    <link>http://www.skytale.net/blog/archives/32-Outgoing-TLS-verification-in-exim.html</link>
    <description>
    	&lt;p&gt;&lt;a href=&quot;http://www.exim.org&quot;&gt;Exim&lt;/a&gt; is a mail server which suports &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt; for encrypted connections. This is supported for incoming connections as well as outgoing connections.&lt;/p&gt;

	&lt;p&gt;The support for outgoing connections is a bit useless in it&amp;#8217;s default setting, though:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;If the remote server offers &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt; exim will negotiate an encrypted connection, but will not verify the certificate, rendering the encryption somewhat useless&lt;/li&gt;
		&lt;li&gt;If the remote side does not offer &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt; mail will be sent in plain text.&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;All in all this is pretty useless from a security point of view. Making exim do the right thing requires some additions to the &lt;span class=&quot;caps&quot;&gt;SMTP&lt;/span&gt; transport (the following is sufficient for the default exim configuration on &lt;a href=&quot;http://www.centos.org&quot;&gt;CentOS&lt;/a&gt; systems):&lt;/p&gt;

&lt;pre&gt;
remote_smtp:
  driver = smtp
  hosts_require_tls = *
  tls_tempfail_tryclear = false
  tls_verify_certificates = /etc/pki/tls/certs
&lt;/pre&gt;

	&lt;p&gt;This forces exim to use &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt; for every outgoing connection (&lt;code&gt;hosts_require_tls = *&lt;/code&gt;), forbids fallback to clear text if &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt; does not work, (&lt;code&gt;tls_tempfail_tryclear = false&lt;/code&gt;) and points to a directory containing a trusted certificates (&lt;code&gt;tls_verify_certificates = /etc/pki/tls/certs&lt;/code&gt;).&lt;/p&gt;

	&lt;p&gt;The last parameter is the main reason for this article, as it does not exactly do what it says on the tin. The exim in CentOS is built against OpenSSL, and the OpenSSL libraries are built with &lt;code&gt;/etc/pki/tls/certs&lt;/code&gt; as the default search path for certificates. The documentation for the parameter says:&lt;/p&gt;

	&lt;p&gt;&lt;cite&gt;The value of this option must be the absolute path to a file containing permitted server certificates, for use when setting up an encrypted connection. Alternatively, if you are using OpenSSL, you can set tls_verify_certificates to the name of a directory containing certificate files. This does not work with GnuTLS; the option must be set to the name of a single file if you are using GnuTLS. The values of $host and $host_address are set to the name and address of the server during the expansion of this option. See chapter 39 for details of &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt;.&lt;/cite&gt;&lt;/p&gt;

	&lt;p&gt;The part missing from this is that the path set with &lt;code&gt;tls_verify_certificates&lt;/code&gt; is searched &lt;strong&gt;in addition&lt;/strong&gt; to the default certificate search path configured for OpenSSL. So if the OpenSSL default search path already contains all the certificates required, &lt;code&gt;tls_verify_certificates&lt;/code&gt; must be set to force exim to verify the certificates, but the value it is set to does not matter. For security reasons it ought to be set to the default OpenSSL search path, though, to prevent someone from maliciously adding more trusted certificates.&lt;/p&gt;

	&lt;p&gt;PS:&lt;br /&gt;
Doing this for a general purpose mail server is probably not a good idea, as many mail servers do not offer &lt;span class=&quot;caps&quot;&gt;TLS&lt;/span&gt;, and even if they do, their certificate may not be signed by a trusted (by the client) certificate authority. The mail server in question here will only send mail to a single host.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, </dc:subject>
    <dc:date>2010-03-21T13:37:01Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=32</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=32</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/31-guid.html">
    <title>Cisco VPN debugging by crystal ball</title>
    <link>http://www.skytale.net/blog/archives/31-Cisco-VPN-debugging-by-crystal-ball.html</link>
    <description>
    	&lt;p&gt;In the hope that google picks this up:&lt;/p&gt;

	&lt;p&gt;The problem space is a Cisco &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt; terminating an IPSec &lt;span class=&quot;caps&quot;&gt;VPN&lt;/span&gt; tunnel with a Checkpoint firewall on the other end. The tunnel does not work (the phase 2 setup fails). The Cisco logs the following debug messages:&lt;br /&gt;
&lt;pre&gt;
ISAKMP (0): processing SA payload. message ID = 1911693629
ISAKMP : Checking IPSec proposal 1
ISAKMP: transform 1, ESP_3DES
ISAKMP:   attributes in transform:
ISAKMP:      SA life type in seconds
ISAKMP:      SA life duration (VPI) of  0x0 0x0 0xe 0x10
ISAKMP:      authenticator is HMAC-SHA
ISAKMP:      encaps is 1
ISAKMP (0): atts are acceptable.
ISAKMP : Checking IPSec proposal 1
ISAKMP (0): atts not acceptable. Next payload is 0
ISAKMP (0): SA not acceptable!
ISAKMP (0): sending NOTIFY message 14 protocol 0
return status is IKMP_ERR_NO_RETRANS
&lt;/pre&gt;&lt;/p&gt;

	&lt;p&gt;The log message above was created by an incoming proposal (the remote end proposed a connection to the Cisco &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt;). This is useless and confusing at the same time. An IPSec proposal contains a list of parameters, sent by one end of the connection, specifying the parameters it is willing to use to establish a secure connection. This proposal specifies 3DES as the encryption algorithm, &lt;span class=&quot;caps&quot;&gt;SHA&lt;/span&gt; as a hash function, and a lifetime for the connection of 3600 seconds (after which the connection has to be renegotiated).&lt;/p&gt;

	&lt;p&gt;As can be seen, the &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt; accepts this proposal (as it should), since these parameters match those configured on the &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt; for this connection. It then goes on to check the same proposal again, just to reject it this time.&lt;/p&gt;

	&lt;p&gt;The completely non-obvious solution to this is to disable compression (which the &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt; does not support) on the Checkpoint. Why the &lt;span class=&quot;caps&quot;&gt;PIX&lt;/span&gt; is unable to even give me a hexdump of the offending parameter in the proposal I&amp;#8217;ll probably never know.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Cisco, Computer, Software, </dc:subject>
    <dc:date>2010-01-18T09:37:14Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=31</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=31</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/28-guid.html">
    <title>Adding new dynamic library dependencies to an existing object</title>
    <link>http://www.skytale.net/blog/archives/28-Adding-new-dynamic-library-dependencies-to-an-existing-object.html</link>
    <description>
    	&lt;p&gt;Due to some developing I needed a &lt;a href=&quot;http://www.lighttpd.net&quot;&gt;lighttpd&lt;/a&gt; with mod_magnet enabled. mod_magnet is a module which allows inserting of lua code into the request processing stream. This is a cool feature, and I was pleased to see that&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;lighttpd is on the standard Solaris install &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;mod_magnet is provided&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;Of course there is this small problem:&lt;/p&gt;

&lt;pre&gt;
2009-12-29 23:29:31: (plugin.c.165) dlopen() failed for: /usr/lighttpd/1.4/lib/mod_magnet.soi
ld.so.1: lighttpd: fatal: relocation error: file /usr/lighttpd/1.4/lib/mod_magnet.so:
symbol luaL_checklstring: referenced symbol not found
&lt;/pre&gt;

	&lt;p&gt;What this means is that there are unresolved symbols remaining in the code after the dymanic loader has done it&amp;#8217;s work, which should not happen. Let&amp;#8217;s look a the dynamic deps of the module.&lt;/p&gt;

&lt;pre&gt;
$ ldd /usr/lighttpd/1.4/lib/mod_magnet.so
        libsendfile.so.1 =&amp;#62;      /lib/libsendfile.so.1
        libm.so.2 =&amp;#62;     /lib/libm.so.2
        libresolv.so.2 =&amp;#62;        /lib/libresolv.so.2
        libnsl.so.1 =&amp;#62;   /lib/libnsl.so.1
        libsocket.so.1 =&amp;#62;        /lib/libsocket.so.1
        libc.so.1 =&amp;#62;     /lib/libc.so.1
        libmd.so.1 =&amp;#62;    /lib/libmd.so.1
        libmp.so.2 =&amp;#62;    /lib/libmp.so.2
        libscf.so.1 =&amp;#62;   /lib/libscf.so.1
        libuutil.so.1 =&amp;#62;         /lib/libuutil.so.1
        libgen.so.1 =&amp;#62;   /lib/libgen.so.1
        libsmbios.so.1 =&amp;#62;        /usr/lib/libsmbios.so.1
&lt;/pre&gt;

	&lt;p&gt;Judging from the name of the missing symbol &lt;code&gt;luaL_checklstring&lt;/code&gt; it ought to come from some kind of lua library. But the listing above does not show any missing libraries, lest of all a lua one.&lt;/p&gt;

	&lt;p&gt;So what happened?&lt;/p&gt;

	&lt;p&gt;Somehow (and I have no idea how) Sun managed to build a mod_magnet without linking it to the lua libraries at the end. Simply speaking, this is broken.&lt;/p&gt;

	&lt;p&gt;Fortunately there is a way to fix this. Sun provides a utility called &lt;code&gt;elfedit(1)&lt;/code&gt; which allows the editing of &lt;span class=&quot;caps&quot;&gt;ELF&lt;/span&gt; file headers (like shared libraries). The lua library which provides the missing symbols is called &lt;code&gt;liblua.so&lt;/code&gt; (no version information). The type of record in an &lt;span class=&quot;caps&quot;&gt;ELF&lt;/span&gt; header which denotes the dynamic libraries needed is called DT_NEEDED. &lt;code&gt;elfedit(1)&lt;/code&gt; takes two parameters: the file to edit, and the file into which to write the modified version.&lt;/p&gt;

	&lt;p&gt;First show the existing DT_NEEDED records.&lt;/p&gt;

&lt;pre&gt;
$ elfedit mod_magnet.so mod_magnet2.so
&amp;#62; dyn:value DT_NEEDED
     index  tag                value
       [0]  NEEDED            0x5f9               libsendfile.so.1
       [1]  NEEDED            0x60a               libm.so.2
       [2]  NEEDED            0x614               libresolv.so.2
       [3]  NEEDED            0x623               libnsl.so.1
       [4]  NEEDED            0x62f               libsocket.so.1
       [5]  NEEDED            0x5d3               libc.so.1
&lt;/pre&gt;

	&lt;p&gt;This is basically the same list as above, with liblua.so notably lacking. Now add a new entry:&lt;/p&gt;

&lt;pre&gt;
&amp;#62; dyn:value -add -s DT_NEEDED liblua.so
     index  tag                value
      [34]  NEEDED            0x63e               liblua.so
&lt;/pre&gt;

	&lt;p&gt;Now look at the new table, and save it.&lt;/p&gt;

&lt;pre&gt;
&amp;#62; dyn:value DT_NEEDED
     index  tag                value
       [0]  NEEDED            0x5f9               libsendfile.so.1
       [1]  NEEDED            0x60a               libm.so.2
       [2]  NEEDED            0x614               libresolv.so.2
       [3]  NEEDED            0x623               libnsl.so.1
       [4]  NEEDED            0x62f               libsocket.so.1
       [5]  NEEDED            0x5d3               libc.so.1
      [34]  NEEDED            0x63e               liblua.so
&amp;#62; :write
&amp;#62; :quit
&lt;/pre&gt;

	&lt;p&gt;Looking at the &lt;code&gt;ldd(1)&lt;/code&gt; output, just to be sure.&lt;/p&gt;

&lt;pre&gt;
$ ldd ./mod_magnet2.so
        libsendfile.so.1 =&amp;#62;      /lib/libsendfile.so.1
        libm.so.2 =&amp;#62;     /lib/libm.so.2
        libresolv.so.2 =&amp;#62;        /lib/libresolv.so.2
        libnsl.so.1 =&amp;#62;   /lib/libnsl.so.1
        libsocket.so.1 =&amp;#62;        /lib/libsocket.so.1
        libc.so.1 =&amp;#62;     /lib/libc.so.1
        liblua.so =&amp;#62;     /usr/lib/liblua.so
        libmd.so.1 =&amp;#62;    /lib/libmd.so.1
        libmp.so.2 =&amp;#62;    /lib/libmp.so.2
        libscf.so.1 =&amp;#62;   /lib/libscf.so.1
        libdl.so.1 =&amp;#62;    /lib/libdl.so.1
        libuutil.so.1 =&amp;#62;         /lib/libuutil.so.1
        libgen.so.1 =&amp;#62;   /lib/libgen.so.1
        libsmbios.so.1 =&amp;#62;        /usr/lib/libsmbios.so.1
&lt;/pre&gt;

	&lt;p&gt;Now the linker picks up the lua libraries. If the modified mod_magnet.so is now put back into &lt;code&gt;/usr/lighttpd/1.4/lib&lt;/code&gt;, lighttpd will start and mod_magnet will work.&lt;/p&gt;

	&lt;p&gt;Now, this wasn&amp;#8217;t so hard, was it?&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-12-30T14:34:59Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=28</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/27-guid.html">
    <title>Changing the rpool disk in Solaris</title>
    <link>http://www.skytale.net/blog/archives/27-Changing-the-rpool-disk-in-Solaris.html</link>
    <description>
    	&lt;p&gt;Ever since my storage system was built there was one thing that annoyed me. The 2.5&amp;#8221; hard disk drive that houses the operating system itself was lifted from an old notebook and had the annoying property of parking it&amp;#8217;s heads after five seconds of inactivity. Since &lt;span class=&quot;caps&quot;&gt;ZFS&lt;/span&gt; writes to the disk quite often and regularily this led to a constant cycle of parking and unparking. This was certainly not helping the disks life span, it made an annoying noise and it caused small system hangs whenever the disk had to unpark it&amp;#8217;s heads to read some data.&lt;/p&gt;

	&lt;p&gt;Under Linux one could use &lt;code&gt;hdparm&lt;/code&gt; to instruct the disk to not park it&amp;#8217;s heads, but unfortunately a program mimicking this functionality seems to be absent under Solaris. Thus the plan to replace the disk with a different one which had a more sensible apporoach to head parking.&lt;/p&gt;

	&lt;p&gt;This turned out to be an interesting endeavour.&lt;/p&gt;

	&lt;p&gt;The general problem of replacing the disk holding the rpool is common enough that the excellent &lt;a href=&quot;http://www.solarisinternals.com/wiki/index.php/ZFS_Troubleshooting_Guide#Replacing.2FRelabeling_the_Root_Pool_Disk&quot;&gt;&lt;span class=&quot;caps&quot;&gt;ZFS&lt;/span&gt; troubleshooting guide&lt;/a&gt; has a section on doing this. The general plan of action is as follows:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Insert the replacement disk into an available slot&lt;/li&gt;
		&lt;li&gt;Create a partition spanning the whole disk&lt;/li&gt;
		&lt;li&gt;Create boot and data slices&lt;/li&gt;
		&lt;li&gt;Attach the new disk as a mirror to the rpool&lt;/li&gt;
		&lt;li&gt;Wait for the resilver to finish&lt;/li&gt;
		&lt;li&gt;Install grub on the new disk&lt;/li&gt;
		&lt;li&gt;Try to boot from the new disk&lt;/li&gt;
		&lt;li&gt;Detach the old disk from the rpool&lt;/li&gt;
		&lt;li&gt;Remove the old disk&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;This is all very sensible, and it all works as advertised. In my case there is, however, a last step not on the list above:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Put the new disk on the controller the old disk was attached to&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;The reason for that is that the case I used only has one internal 2.5&amp;#8221; hard disk drive slot. The new disk was prepared using an external &lt;span class=&quot;caps&quot;&gt;USB-IDE&lt;/span&gt; converter module. This worked just fine, the &lt;span class=&quot;caps&quot;&gt;BIOS&lt;/span&gt; is even able to boot from the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; disk. As long as the new disk remained attached to the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; converter everything was fine, even after the old (internal) disk was removed from the rpool. But putting the new disk into the case caused Solaris to roll over and die early in the boot process due to not finding it&amp;#8217;s rpool disk. The error message indicated that it was trying to read the pool from the external &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; device (which no longer existed at this point).&lt;/p&gt;

	&lt;p&gt;Investigation (and much swearing) turned up that this information was passed by &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; to the Solaris kernel.&lt;/p&gt;

	&lt;p&gt;Solaris uses a patched &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; version which understands &lt;span class=&quot;caps&quot;&gt;ZFS&lt;/span&gt; and has some string replacement magic built in. Every (non failsafe) boot entry contains a line similar to this:&lt;/p&gt;

&lt;pre&gt;
kernel$ /platform/i86pc/kernel/$ISADIR/unix -B $ZFS-BOOTFS
&lt;/pre&gt;

	&lt;p&gt;&lt;code&gt;$ZFS-BOOTFS&lt;/code&gt; is replaced by &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; with the following information:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;The name of the root pool (usually rpool) and the number of the dataset that contains the root file system (there may be several BEs)&lt;/li&gt;
		&lt;li&gt;The device path of the disk this &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; instance was read from&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;The actual command line that is executed by &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; thus looks something like this:&lt;/p&gt;

&lt;pre&gt;
kernel /platform/i86pc/kernel/$ISADIR/unix -B zfs-bootfs=rpool/328 \
bootpath=&amp;#34;/pci@0,0/pci8086,2942@1c,1/pci-ide@0/ide@0/cmdk@0,0:a&amp;#34;
&lt;/pre&gt;

	&lt;p&gt;The interesting part here is the &lt;code&gt;bootpath&lt;/code&gt; parameter. This is the device that Solaris will try to mount the rpool from. Even if the rpool consists of several mirror devices, only one is used in the initial boot process. Where does &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; get the device path from? It&amp;#8217;s read from the rpool header, from the disk &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; was loaded from. Every &lt;span class=&quot;caps&quot;&gt;ZFS&lt;/span&gt; pool disk contains the device path it was last found under. This usually does not matter much, a &lt;span class=&quot;caps&quot;&gt;RAIDZ&lt;/span&gt; will still mount if you swap the disks around when the machine is off, but the boot process relies on the rpool disks not wandering around. My new disk still had the &lt;span class=&quot;caps&quot;&gt;USB&lt;/span&gt; device path embedded, which &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt; read and passed to the kernel, which then failed to find the disk.&lt;/p&gt;

	&lt;p&gt;Fixing this turns out to be easy: boot into failsafe mode with the new disk on it&amp;#8217;s final connector. This will search for rpools and BEs on the system and offer to mount one of them. Pick the right one, reboot. This is enough to get the current (and correct) device path embedded into the rpool. The next (non failsafe) boot will thus pick up the correct device path and allow the boot to continue.&lt;/p&gt;

	&lt;p&gt;The morale of an afternoon thus spent in the innards of the Solaris boot process is thus: do not swap your rpool disk around.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-12-25T15:01:53Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=27</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=27</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/26-guid.html">
    <title>Creating a write only directory with SAMBA and ZFS</title>
    <link>http://www.skytale.net/blog/archives/26-Creating-a-write-only-directory-with-SAMBA-and-ZFS.html</link>
    <description>
    	&lt;p&gt;One of the intended uses of my OpenSolaris storage server was to serve as a &lt;a href=&quot;http://www.samba.org&quot;&gt;SAMBA&lt;/a&gt; accessible data store. Part of that role was the wish to have an &lt;code&gt;incoming&lt;/code&gt; directory modeled after similar directories found on many &lt;span class=&quot;caps&quot;&gt;FTP&lt;/span&gt; servers. In detail this meant a share with the following properties:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Readable for everyone (including unauthenticated users, i.e. guests)&lt;/li&gt;
		&lt;li&gt;Everyone can create new files and directories on the share&lt;/li&gt;
		&lt;li&gt;Only certain users can delete files and directories from the share&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;So everyone can add files to the share, but removing them requires special privileges.&lt;/p&gt;

	&lt;p&gt;It turns out that this is impossible to do with normal &lt;span class=&quot;caps&quot;&gt;UNIX&lt;/span&gt; file system permissions, as for &lt;span class=&quot;caps&quot;&gt;UNIX&lt;/span&gt; creating a file (which is a write operation on a directory) is much the same as deleting one (which is a write operation on a directory).&lt;/p&gt;

	&lt;p&gt;Fortunately OpenSolaris supports a much more powerful file operation permission language in the form of NFSv4 permissions.&lt;/p&gt;

	&lt;p&gt;It has been said that the NFSv4 permission system has been modeled after a smudged copy of the Windows &lt;span class=&quot;caps&quot;&gt;NTFS&lt;/span&gt; permission system, and there is certainly merit to that claim, which is not a bad thing. The &lt;span class=&quot;caps&quot;&gt;NTFS&lt;/span&gt; permission system is much more expressive than the standard &lt;span class=&quot;caps&quot;&gt;UNIX&lt;/span&gt; system, as it has more actions (besides writing, reading and executing it also knows about deleting, for example), can support a large number of principals with different permissions and can actively deny an action (which is different from &amp;#8220;not allowing&amp;#8221;).&lt;/p&gt;

	&lt;h3&gt;NFSv4 permissions&lt;/h3&gt;

	&lt;p&gt;The NFSv4 system knows about the following actions:&lt;/p&gt;

	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Action &lt;/th&gt;
			&lt;th&gt;Description for files &lt;/th&gt;
			&lt;th&gt;Description for directories &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; read data &lt;/td&gt;
			&lt;td&gt; Read file contents &lt;/td&gt;
			&lt;td&gt; List directory contents &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; write data &lt;/td&gt;
			&lt;td&gt; Write file contents (anywhere in the file) &lt;/td&gt;
			&lt;td&gt; Create new files &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; execute &lt;/td&gt;
			&lt;td&gt; Execute file &lt;/td&gt;
			&lt;td&gt; Change into directory &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; append &lt;/td&gt;
			&lt;td&gt; Append data to file &lt;/td&gt;
			&lt;td&gt; Create new directories &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; delete &lt;/td&gt;
			&lt;td&gt; Delete the file &lt;/td&gt;
			&lt;td&gt; &amp;#8211; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; delete child &lt;/td&gt;
			&lt;td&gt; &amp;#8211; &lt;/td&gt;
			&lt;td&gt; Delete a file in the directory &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; read/write attributes &lt;/td&gt;
			&lt;td&gt; Read/write basic attributes &lt;/td&gt;
			&lt;td&gt; (same as file) &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; read/write xattrs &lt;/td&gt;
			&lt;td&gt; Read/write extended attributes &lt;/td&gt;
			&lt;td&gt; (same as file) &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; read/write &lt;span class=&quot;caps&quot;&gt;ACL&lt;/span&gt; &lt;/td&gt;
			&lt;td&gt; Read/write ACLs &lt;/td&gt;
			&lt;td&gt; (same as file) &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; change owner &lt;/td&gt;
			&lt;td&gt; Change the owner &lt;/td&gt;
			&lt;td&gt; (same as file) &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; sync &lt;/td&gt;
			&lt;td&gt; Use syncronous file access &lt;/td&gt;
			&lt;td&gt; &amp;#8211; &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;

	&lt;p&gt;NFSv4 also contains a mechanism to specify actions that apply to a file or directory, and actions that are inherited to child objects of a directory (i.e. files or subdirectories). This allows very fine grained control of file system access.&lt;/p&gt;

	&lt;p&gt;Of special interest here are the bits about writing, appending and deleting files and folders.&lt;/p&gt;

	&lt;p&gt;The ACLs are maintained in a list of entries, each entry mapping a username/action pair to a verdict (allow/deny). Each access is matched against each entry in&lt;br /&gt;
turn, and the verdict is taken from the first entry to match. So the order of entries is important.&lt;/p&gt;

	&lt;p&gt;Solaris&amp;#8217; &lt;code&gt;ls&lt;/code&gt; has two extensions to list those ACLs: &lt;code&gt;-v&lt;/code&gt; for a verbose listing and &lt;code&gt;-V&lt;/code&gt; for a concise listing. The format used by &lt;code&gt;-V&lt;/code&gt; can be passed to &lt;code&gt;chmod&lt;/code&gt; to change ACLs.&lt;/p&gt;

	&lt;p&gt;The permissions corresponding to the list of requirements stated above are as follows (&lt;code&gt;/tank/share/incoming&lt;/code&gt; is the directory associated with the &lt;code&gt;incoming&lt;/code&gt; share in &lt;code&gt;smb.conf&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;
# ls -lVd /tank/share/incoming
drwxrwxrwx+  5 root     root           6 Dec 12 16:49 /tank/share/incoming
               user:sun:-w--dD--------:fdi----:allow
               user:sun:-w--dD--------:-------:allow
              everyone@:-w--dD--------:f-i----:deny
              everyone@:----dD--------:-di----:deny
              everyone@:----dD--------:-------:deny
              everyone@:rwxp--a-R-c--s:-di----:allow
              everyone@:r-xp--a-R-c--s:f-i----:allow
              everyone@:rwxp--a-R-c--s:-------:allow
#
&lt;/pre&gt;

	&lt;p&gt;There are two kinds of entries in this list. Those with an &lt;code&gt;i&lt;/code&gt; in the second part of the action list and those without. The entries with an &lt;code&gt;i&lt;/code&gt; are so called &amp;#8220;inherit only&amp;#8221; entries. They do not apply to the file or directory they are associated with, but are only inherited to new child entries. The other entries apply to the file/directory they are associated with. &lt;/p&gt;

	&lt;p&gt;This list can be read in three blocks:&lt;/p&gt;

	&lt;p&gt;The first block consists of the first two lines. The first line specifies that the right to delete files (&lt;code&gt;d&lt;/code&gt;), delete child entries (&lt;code&gt;D&lt;/code&gt;) and create new files/write file content (&lt;code&gt;w&lt;/code&gt;) for the user named &lt;code&gt;sun&lt;/code&gt; is inherited to new files and directories (&lt;code&gt;fdi&lt;/code&gt;). This makes sure that this user can always remove files and directories, and overwrite existing file content in newly created files. The second line applies the same rights to the &lt;code&gt;incoming&lt;/code&gt; directory itself.&lt;/p&gt;

	&lt;p&gt;The second block consists of lines 3 to 5 and contains only deny statements. They apply to &lt;code&gt;everyone@&lt;/code&gt;, which means exactly what it says on the box. Lines 3 and 4 again deal with rights that are to be inherited to child objects, but the rights inherited to files and directories are different this time. Files inherit a deny to write anywhere in the file (&lt;code&gt;w&lt;/code&gt;) and file deletion (&lt;code&gt;dD&lt;/code&gt;). Directories just inherit the deletion part, otherwise new files could not be created in subdirectories (which needs the &lt;code&gt;w&lt;/code&gt; right). The &lt;code&gt;incoming&lt;/code&gt; directory itself gets the &amp;#8220;no deletion&amp;#8221; treatment as well.&lt;/p&gt;

	&lt;p&gt;The third block consists of the last three lines and restores some rights to non privileged users. Directories inherit the right to be read (&lt;code&gt;r&lt;/code&gt;), changed though (&lt;code&gt;x&amp;#60;/code), new files and subdirectories can be created (&amp;#60;code&amp;#62;rp&amp;#60;/code), and attributes of all sorts can be read (&amp;#60;code&amp;#62;aRc&lt;/code&gt;). We also allow synchronous file access (&lt;code&gt;s&lt;/code&gt;). Files are much the same, except that the write anywhere right is missing. Not that it would matter much if that were allowed here, since it has been explicitly denied earlier. Note that the right to append to a file (&lt;code&gt;p&lt;/code&gt;) is explicity allowed. The rights for the &lt;code&gt;incoming&lt;/code&gt; directory itself (last line) again match those inherited to subdirectories.&lt;/p&gt;

	&lt;p&gt;Let&amp;#8217;s see if that works out.&lt;/p&gt;

&lt;pre&gt;
$ id
uid=60003(smbnobody) gid=60003(smbnobody)
$ touch /tank/share/incoming/foo
$ ls -V /tank/share/incoming/foo
-r-xr-xr-x+  1 smbnobody   smbnobody         0 Dec 12 18:33 /tank/share/incoming/foo
               user:sun:-w--dD--------:------I:allow
              everyone@:-w--dD--------:------I:deny
              everyone@:r-xp--a-R-c--s:------I:allow
&lt;/pre&gt;

	&lt;p&gt;The unprivileged user &lt;code&gt;smbnobody&lt;/code&gt; (&lt;span class=&quot;caps&quot;&gt;SMB&lt;/span&gt; guest access is mapped to this uid) can create a new file in the incoming directory, and the file inherits the rights mentioned above (&lt;code&gt;I&lt;/code&gt; signifies an inherited right).&lt;/p&gt;

&lt;pre&gt;
$ cat /etc/passwd &amp;#62; /tank/share/incoming/foo
bash: /tank/share/incoming/foo: Permission denied
$ cat /etc/passwd &amp;#62;&amp;#62; /tank/share/incoming/foo
$
&lt;/pre&gt;

	&lt;p&gt;The user cannot overwrite the file (even though it is empty), but he can append to it.&lt;/p&gt;

&lt;pre&gt;
$ rm /tank/share/incoming/foo
rm: /tank/share/incoming/foo: override protection 555 (yes/no)? y
rm: /tank/share/incoming/foo not removed: Permission denied
$
&lt;/pre&gt;

	&lt;p&gt;Deletion is also denied. Good.&lt;/p&gt;

&lt;pre&gt;
$ id
uid=500(sun) gid=100(users)
$ cat /etc/passwd &amp;#62; /tank/share/incoming/foo
$ rm /tank/share/incoming/foo
$
&lt;/pre&gt;

	&lt;p&gt;However, the privileged user &lt;code&gt;sun&lt;/code&gt; can overwrite and delete the file.&lt;/p&gt;

	&lt;h3&gt;Samba configuration&lt;/h3&gt;

	&lt;p&gt;Samba also needs configuration to recognize and use the extended parmission system. The following is an excerpt from &lt;code&gt;smb.conf&lt;/code&gt;, describing the &lt;code&gt;incoming&lt;/code&gt; share:&lt;/p&gt;

&lt;pre&gt;
[incoming]
        path = /tank/share/incoming
        writable = yes
        guest ok = yes
        browseable = yes
        public = yes
        acl check permissions = False
        ea support = yes
        store dos attributes = no
        map readonly = no
        map archive = no
        map system = no
        map hidden = no
        vfs objects = zfsacl
        nfs4: mode = simple
        nfs4: acedup = dontcare
&lt;/pre&gt;

	&lt;p&gt;This configures Samba to use extended ACLs using the &lt;span class=&quot;caps&quot;&gt;ZFS&lt;/span&gt; (NFSv4) permission system.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-12-12T17:57:28Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=26</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=26</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/25-guid.html">
    <title>Access problems with Apache server-status</title>
    <link>http://www.skytale.net/blog/archives/25-Access-problems-with-Apache-server-status.html</link>
    <description>
    	&lt;p&gt;Since I have twice now spent considerable time on debugging this:&lt;/p&gt;

	&lt;p&gt;If you have configured an Apache &lt;code&gt;server-status&lt;/code&gt; handler, but retrieving the &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; bound to this handler results in access denied even though there are no access restrictions configured on the container (bad idea, by the way), or the connecting IP is allowed access, make sure that the webserver can access it&amp;#8217;s document root.&lt;/p&gt;

	&lt;p&gt;This may seem obvious, but if the Apache is configured as a reverse proxy there may not be any files in the document root, because all content is created by the backend servers (or virtual handlers, like &lt;code&gt;server-status&lt;/code&gt;). Nonetheless the Apache server must be able to change into the document root, or the virtual handlers will fail (reverse proxy access will work, however).&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, </dc:subject>
    <dc:date>2009-12-02T13:17:15Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=25</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=25</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/24-guid.html">
    <title>Resetting SATA devices under Linux</title>
    <link>http://www.skytale.net/blog/archives/24-Resetting-SATA-devices-under-Linux.html</link>
    <description>
    	&lt;p&gt;Note: this was tested only on &lt;span class=&quot;caps&quot;&gt;SATA&lt;/span&gt; attached optical drives, not on hard disks. Removing a hard disk with mounted partitions on it (directly or indirectly) is probably not a very smart idea.&lt;/p&gt;

	&lt;p&gt;A device name of &lt;code&gt;/dev/sr0&lt;/code&gt; is assumed.&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Find out which controller the device is attached to (we&amp;#8217;ll need this later):&lt;/li&gt;
	&lt;/ul&gt;

&lt;pre&gt;
# readlink /sys/block/sr0
../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
&lt;/pre&gt;

	&lt;p&gt;The interesting part if the answer is &lt;code&gt;host1&lt;/code&gt;, which identifies the controller.&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Disconnect the device&lt;/li&gt;
	&lt;/ul&gt;

&lt;pre&gt;
# echo 1 &amp;#62; /sys/block/sr0/device/delete
&lt;/pre&gt;

	&lt;p&gt;This will remove the device from the bus (logically). Look in &lt;code&gt;dmesg&lt;/code&gt; for confirmation.&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Rescan the controller&lt;/li&gt;
	&lt;/ul&gt;

&lt;pre&gt;
# echo &amp;#34;- - -&amp;#34; &amp;#62; /sys/class/scsi_host/host1/scan
&lt;/pre&gt;

	&lt;p&gt;&lt;code&gt;host1&lt;/code&gt; is the identifier from step one. Again, &lt;code&gt;dmesg&lt;/code&gt; should show the device being rediscovered.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Hardware, Linux, </dc:subject>
    <dc:date>2009-11-18T12:36:49Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=24</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=24</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/23-guid.html">
    <title>Manual IMAP</title>
    <link>http://www.skytale.net/blog/archives/23-Manual-IMAP.html</link>
    <description>
    	&lt;p&gt;From time to time I am in the unfortunate situation of having to manually communicate with an &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; server (in other words: reading mail via telnet).&lt;/p&gt;

	&lt;p&gt;Due to the nature of &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; this is not remotely as simple as reading mail via telnet using the POP3 protocol, however, as &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; is a very rich and powerful protocol with a quirky syntax.&lt;/p&gt;

	&lt;p&gt;As I tend to forget the commands for the most important tasks it might be a good idea to write them down.&lt;/p&gt;

	&lt;p&gt;Some definitions:&lt;/p&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; handles &lt;strong&gt;messages&lt;/strong&gt;. Messages live in &lt;strong&gt;folders&lt;/strong&gt;, which can have &lt;strong&gt;subfolders&lt;/strong&gt;. Folders are separated by &lt;strong&gt;separators&lt;/strong&gt;. Multiple groups of folders can exist, those groups are called &lt;strong&gt;namespaces&lt;/strong&gt;. At least one namespace always exists. Within every folder each message has two &lt;strong&gt;identifiers&lt;/strong&gt; (both are positive integers). The first (the &lt;strong&gt;sequence number&lt;/strong&gt;) is valid only as long as the current folder is &lt;strong&gt;selected&lt;/strong&gt; (or open, in other words), and ranges from 1 to N, N being the number of messages in the folder. The second (the &lt;strong&gt;UID&lt;/strong&gt;) does not change from one selection to the next, and usually not between connects. Ideally, the &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; for a message never changes once it has been assigned. The &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; server is free to assign a new &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; to a message, but it must tell the client if it does so.&lt;/p&gt;

	&lt;p&gt;Each &lt;strong&gt;request&lt;/strong&gt; from a client starts with a &lt;strong&gt;tag&lt;/strong&gt;, which is a group of characters consisting of letters, numbers and the dot (&amp;#8221;.&amp;#8221;). The server &lt;strong&gt;reply&lt;/strong&gt; consists of at least one line, but may consist of several. In the latter case, each line starts with an asterisk (*), except for the last, which starts with the tag chosen by the client. This signals the completion of the command. If the server reply is one lined, only the line starting with the client tag is sent. The client may reuse tags if it wishes. The protocol is not synchronous, the client can send several requests without waiting for the server to complete the preceding command.&lt;/p&gt;

	&lt;p&gt;Unless the client or the server indicate otherwise the default character set for &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; is UTF7 (which, as long as you keep to the first 128 characters of the &lt;span class=&quot;caps&quot;&gt;ASCII&lt;/span&gt; character set, is exactly the same as &lt;span class=&quot;caps&quot;&gt;ASCII&lt;/span&gt; or UTF8).&lt;/p&gt;

	&lt;p&gt;Requests and replies consist of a space separated list of keywords and &lt;strong&gt;strings&lt;/strong&gt;. Strings can be written in two forms, &lt;strong&gt;quoted&lt;/strong&gt; and &lt;strong&gt;literal&lt;/strong&gt;. Quoted strings can consist of any 7-bit-characters, except &lt;code&gt;CR&lt;/code&gt; and &lt;code&gt;LF&lt;/code&gt;, enclosed by &lt;code&gt;&amp;#34;&lt;/code&gt;. If the quoted string contains the character &lt;code&gt;&amp;#34;&lt;/code&gt; itself it&lt;br /&gt;
must be quoted as &lt;code&gt;\&amp;#34;&lt;/code&gt;.&lt;/p&gt;

	&lt;p&gt;Literal strings start with the number of characters in the string, enclosed by curly braces, and a &lt;code&gt;CRLF&lt;/code&gt;. The string characters then follow.&lt;/p&gt;

	&lt;p&gt;That ought to be enough to make sense of the following:&lt;/p&gt;

	&lt;h3&gt;Login&lt;/h3&gt;

	&lt;p&gt;Assuming the server supports plain text logins (indicated by &lt;code&gt;AUTH=LOGIN&lt;/code&gt; in the server greeting:&lt;/p&gt;

&lt;pre&gt;
$ telnet mailserver 143
[...]
* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=LOGIN AUTH=PLAIN AUTH=CRAM-MD5 SASL-IR]
mailserver Cyrus IMAP4 v2.3.7-Invoca-RPM-2.3.7-7.el5_4.3 server ready
foo login user password
foo OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS
NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ
THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE LISTEXT
LIST-SUBSCRIBED X-NETSCAPE URLAUTH] User logged in
&lt;/pre&gt;

	&lt;p&gt;In this example the login user name was &lt;code&gt;user&lt;/code&gt; and the password was &lt;code&gt;password&lt;/code&gt;. The tag chosen by the client (i.e. the person using telnet) was &lt;code&gt;foo&lt;/code&gt;, which was echoed by the server in the login response. From now on the tag used will be the dot (&amp;#8221;.&amp;#8221;), unless specified otherwise.&lt;/p&gt;

	&lt;h3&gt;Namespaces&lt;/h3&gt;

	&lt;p&gt;Several groups of folders can exists, these groups are called namespaces. One use is the implementation of shared folders such that the private folders of a user live in one namespace, and the shared folders in another. To list the available namespaces:&lt;/p&gt;

&lt;pre&gt;
. NAMESPACE
* NAMESPACE ((&amp;#34;INBOX.&amp;#34; &amp;#34;.&amp;#34;)) ((&amp;#34;user.&amp;#34; &amp;#34;.&amp;#34;)) ((&amp;#34;&amp;#34; &amp;#34;.&amp;#34;))
. OK Completed
&lt;/pre&gt;

	&lt;p&gt;This user has access to three namespaces: &lt;code&gt;INBOX&lt;/code&gt;, &lt;code&gt;user&lt;/code&gt; and a namespace without a name. The latter is the default name space. The dot (&amp;#8221;.&amp;#8221;) after the name is the separator used in this namespace.&lt;/p&gt;

	&lt;h3&gt;Listing folders&lt;/h3&gt;

	&lt;p&gt;Listing folders within a namespace requires the namespace to be listed, and a pattern describing the required names. The pattern supports wildcards, especially &amp;#8220;*&amp;#8221; (list subfolders, recursively) and &amp;#8220;%&amp;#8221; (list subfolders, not recursively).&lt;/p&gt;

&lt;pre&gt;
. LIST &amp;#34;&amp;#34; &amp;#34;INBOX.%&amp;#34;
* LIST (\HasNoChildren) &amp;#34;.&amp;#34; &amp;#34;INBOX.Folder1&amp;#34;
* LIST (\HasNoChildren) &amp;#34;.&amp;#34; &amp;#34;INBOX.Folder2&amp;#34;
* LIST (\HasChildren) &amp;#34;.&amp;#34; &amp;#34;INBOX.Folder3&amp;#34;
. OK Completed
&lt;/pre&gt;

	&lt;p&gt;This &lt;code&gt;INBOX&lt;/code&gt; folder has three subfolders: &lt;code&gt;Folder1&lt;/code&gt; and &lt;code&gt;Folder2&lt;/code&gt;, both of which have no subfolders, as indicated by the &lt;code&gt;\HasNoChildren&lt;/code&gt; flag, and one (&lt;code&gt;Folder3&lt;/code&gt;) which has. Because of the &amp;#8220;%&amp;#8221; wildcard the subfolders of &lt;code&gt;Folder3&lt;/code&gt; are not shown in this listing.&lt;/p&gt;

	&lt;p&gt;In general, it is usually not a good idea to list folders using &amp;#8220;*&amp;#8221;. This may return a list containing potentially thousands of folders (think of systems redistributing Usenet news via &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt;). Instead use &amp;#8220;%&amp;#8221; to descend the folders considered interesting.&lt;/p&gt;

	&lt;h3&gt;Selecting folders&lt;/h3&gt;

	&lt;p&gt;In order to read messages the folder containing those must be activated first. This requires the full folder name as returned by &lt;code&gt;LIST&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;
. SELECT &amp;#34;INBOX&amp;#34;
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk Junk $NotJunk $Junk $Forwarded)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen NonJunk Junk $NotJunk $Junk $Forwarded \*)]  
* 5966 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1136990532]
* OK [UIDNEXT 12498]
* OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
. OK [READ-WRITE] Completed
&lt;/pre&gt;

	&lt;p&gt;This folder contains 5966 messages (&lt;code&gt;5966 EXISTS&lt;/code&gt;), zero of which are unread (&lt;code&gt;0 RECENT&lt;/code&gt;). The &lt;code&gt;UIDVALIDITY&lt;/code&gt; parameter is an integer describing the validity of the &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; numbers assigned to the messages. As long as this number does not change the mapping from message to &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; has not changed.&lt;/p&gt;

	&lt;h3&gt;Finding messages&lt;/h3&gt;

	&lt;p&gt;Unlike POP3 &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; servers actually try to parse the messages stored in the folders in order to extract some information from the headers, such as sender address, recipient address, messageid and general message structure (such as attachments). The reason and upshot of this is that the server can search for messages having certain properties (for example, all messages by a certain sender) without having the client download all messages and doing the search itself. There are two search commands (&lt;code&gt;SEARCH&lt;/code&gt; and &lt;code&gt;UID SEARCH&lt;/code&gt;) which differ in the results they return. The first command returns sequence numbers, the second returns message UIDs.&lt;/p&gt;

	&lt;p&gt;Multiple search conditions can be used in one search request, those are ANDed (i.e., all have to be satisfied).&lt;/p&gt;

	&lt;p&gt;A small table of possible search conditions:&lt;/p&gt;

	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Query &lt;/th&gt;
			&lt;th&gt;Looking for &lt;/th&gt;
			&lt;th&gt;Example &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;FROM &amp;#34;&amp;#60;mailaddress&amp;#62;&amp;#34;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mail from that sender &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;FROM &amp;#34;user@example.org&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;TO &amp;#34;&amp;#60;mailaddress&amp;#62;&amp;#34;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mail to that recipient &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;TO &amp;#34;user@example.org&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;SINCE &amp;#60;date&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mail received after this date &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;SINCE 1-Nov-2009&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BEFORE &amp;#60;date&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mail received before this date &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;BEFORE 1-Nov-2009&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;DELETED&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mails marked as deleted &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;DELETED&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;SUBJECT &amp;#60;string&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mails containing string in the subject &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;SUBJECT &amp;#34;Proposal&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY &amp;#60;string&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mails containing string in the body &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;BODY &amp;#34;Hello Greg&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;NOT &amp;#60;key&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mails which do not match the key &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;NOT FROM &amp;#34;user@example.org&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;OR &amp;#60;key1&amp;#62; &amp;#60;key2&amp;#62;&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Mails which match either of key1 or key2 &lt;/td&gt;
			&lt;td&gt; &lt;code&gt;OR FROM &amp;#34;user@example.org&amp;#34; FROM &amp;#34;user2@example.org&amp;#34;&lt;/code&gt; &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;

	&lt;p&gt;There are quite a bit more of these, &lt;a href=&quot;http://www.faqs.org/rfcs/rfc2060.html&quot;&gt;RfC 2060&lt;/a&gt; lists all possible options. But the ones above are probably the most commonly used.&lt;/p&gt;

	&lt;p&gt;Please be aware that the full text searches (&lt;code&gt;TEXT&lt;/code&gt; and &lt;code&gt;BODY&lt;/code&gt;) can be probibitively expensive if the server does not keep a full text search database of the messages. Getting an answer to such a query may take a very long time.&lt;/p&gt;

&lt;pre&gt;
. SEARCH FROM &amp;#34;user@example.org&amp;#34; BEFORE 1-Nov-2009
* SEARCH 5 10 456
. OK Completed
&lt;/pre&gt;

	&lt;h3&gt;Fetching messages&lt;/h3&gt;

	&lt;p&gt;Now that &lt;code&gt;SEARCH&lt;/code&gt; has turned up some messages it might be a good idea to take a look at the contents. The &lt;code&gt;FETCH&lt;/code&gt; command takes a list of sequence numbers or UIDs (as with &lt;code&gt;SEARCH&lt;/code&gt; there are two variants, &lt;code&gt;FETCH&lt;/code&gt; and &lt;code&gt;UID FETCH&lt;/code&gt;) and a list of the information we are interested in. The most commonly used parts are:&lt;/p&gt;

	&lt;table&gt;
		&lt;tr&gt;
			&lt;th&gt;Part name &lt;/th&gt;
			&lt;th&gt;Part description &lt;/th&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY[TEXT]&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Just the mail body, without the headers &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY[HEADER]&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; The mail headers &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY[HEADER.FIELDS (&amp;#60;list&amp;#62;)]&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Just the header fields indicated in list &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY[]&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; The entire mail text, header and body &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;BODY.PEEK&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Works as &lt;code&gt;BODY&lt;/code&gt; does, but does not mark the mail as seen &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;FLAGS&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; Flags set for the message &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt; &lt;code&gt;UID&lt;/code&gt; &lt;/td&gt;
			&lt;td&gt; The &lt;span class=&quot;caps&quot;&gt;UID&lt;/span&gt; of the message &lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;

	&lt;p&gt;As above, RfC 2060 has all the gory details.&lt;/p&gt;

&lt;pre&gt;
. FETCH 5 (FLAGS BODY[HEADER.FIELDS (To)])
* 5 FETCH (FLAGS (\Seen) BODY[HEADER.FIELDS (To)] {24}
To: user@example.com
)
. OK Completed
&lt;/pre&gt;

	&lt;h3&gt;Deleting messages&lt;/h3&gt;

	&lt;p&gt;Deleting messages in &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt; is a bit tricky, as there is no explicit delete command. Instead, a flag is set on the message marking it as deleted. This, by itself, does nothing to get the message removed. Just when a special command is called all messages in the current folder marked as to be deleted are removed&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn3482962234c53a24d062b2&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;pre&gt;
. UID SEARCH ALL
* 1 EXISTS
* 1 RECENT
* SEARCH 1814
. OK Completed
. UID STORE 1814 +FLAGS (\Deleted)
* 1 FETCH (FLAGS (\Recent \Deleted \Seen) UID 1814)
. OK Completed
. EXPUNGE
* 1 EXPUNGE
* 0 EXISTS
* 0 RECENT
. OK Completed
. UID SEARCH ALL
* SEARCH
. OK Completed
&lt;/pre&gt;

	&lt;p&gt;The above is executed in a folder containing just a single message (see the result of the &lt;code&gt;UID SEARCH ALL&lt;/code&gt;). The flag &lt;code&gt;\Deleted&lt;/code&gt; is then added to flag list of the message (&lt;code&gt;UID STORE 1814 +FLAGS (\Deleted)&lt;/code&gt;). The &lt;code&gt;STORE&lt;/code&gt; command returns the new flag list. The  &lt;code&gt;EXPUNGE&lt;/code&gt; command then removes the message.&lt;/p&gt;

	&lt;h3&gt;Leaving &lt;span class=&quot;caps&quot;&gt;IMAP&lt;/span&gt;&lt;/h3&gt;

	&lt;p&gt;When finished with the session the last thing to do is to leave:&lt;/p&gt;

&lt;pre&gt;
. logout
Connection closed by foreign host
$
&lt;/pre&gt;

	&lt;p id=&quot;fn3482962234c53a24d062b2&quot; class=&quot;footnote&quot;&gt;&lt;sup&gt;1&lt;/sup&gt; The manual page for the rather excellent perl module &lt;code&gt;Mail::IMAPClient&lt;/code&gt; had the following to say about this:&lt;/p&gt;

	&lt;blockquote&gt;
		&lt;p&gt; In case you’re curious, expunging a folder deletes the messages that you thought were already deleted via &amp;#8220;delete_message&amp;#8221; but really weren&amp;#8217;t, which means you have to use a method that doesn&amp;#8217;t exist to delete messages that you thought didn&amp;#8217;t exist.  (Seriously, I&amp;#8217;m not making any of this stuff up.)&lt;/p&gt;
	&lt;/blockquote&gt;

	&lt;p&gt;Unfortunately this gem has disappeared from newer versions of the manual page.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, </dc:subject>
    <dc:date>2009-11-05T19:45:25Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=23</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=23</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/22-guid.html">
    <title>SSL cipher settings</title>
    <link>http://www.skytale.net/blog/archives/22-SSL-cipher-settings.html</link>
    <description>
    	&lt;h3&gt;The Problem&lt;/h3&gt;

	&lt;p&gt;Securing network services with &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; is, in general, a good idea, if you can spare the &lt;span class=&quot;caps&quot;&gt;CPU&lt;/span&gt; cycles. Especially personal data should always be protected while in transit via the network. But it may not be enough to simply enable &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; in the service (be it Apache, Lighttpd, Cyrus &lt;span class=&quot;caps&quot;&gt;IMAPD&lt;/span&gt; or something else) to get a reasonably secure connection.&lt;/p&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; is a cover phrase for a wide collection of protocols and crypto algorithms. There are at least three protocol suites in use (SSLv2, SSLv3 and TLSv1), which between them support tens of different crypto algorithms with different strengths. Not all of those are still suitable for serious use today.&lt;/p&gt;

	&lt;p&gt;A list of the ciphers supported by the popular &lt;a href=&quot;http://openssl.org&quot;&gt;OpenSSL library&lt;/a&gt;, which is used by many projects to handle &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt;, can be obtained with the following command:&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;ALL:COMPLEMENTOFALL&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
$
&lt;/pre&gt;

	&lt;p&gt;On my notebook (running Fedora 11) this produces a list of 62 ciphers. The number of ciphers supported changes with the version of OpenSSL, so other&lt;br /&gt;
systems may display a different list.&lt;/p&gt;

	&lt;p&gt;During an &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; handshake between a client and a server the cipher to use is negotiated between the two machines. In practical terms this means that the client send list of ciphers it is able and willing to use to the server, the server compares this list with it&amp;#8217;s own list of supported ciphers and, if a cipher supported by both sides is found returns it&amp;#8217;s choice to the client.&lt;/p&gt;

	&lt;h3&gt;Defaults&lt;/h3&gt;

	&lt;p&gt;Unless something else is configured, a server using OpenSSL uses the &amp;#8220;DEFAULT&amp;#8221; group of ciphers. The content of this group can also change between versions of OpenSSL. The value for the installed version can be queried:&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;DEFAULT&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
$
&lt;/pre&gt;

	&lt;p&gt;This list is shorter than the list of all ciphers above, containing 44 ciphers on my notebook. This list is not entirely nonsensical. It does not contain ciphers without encryption (yes, that is a valid mode of operation for &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt;), it does not contain ciphers without authentication (which would allow for Man-in-the-middle attacks). It does, however, contain ciphers whose strength in this day and age must be questioned. These include the so called &amp;#8220;export&amp;#8221; ciphers.&lt;/p&gt;

	&lt;p&gt;These ciphers stem from a time when it was illegal to export software from the United States which supported strong encryption. So software supporting encryption (for example web browsers, like the venerable Netscape Nagivator) destined for export only supported watered down versions of the strong encryption variants, mostly by supporting shorter keys. Fortunately it is no longer illegal to export strong crypto from the United States, and hasn&amp;#8217;t been for years, but for compatibility reasons OpenSSL is still willing to negotiate these weak ciphers with a client.&lt;/p&gt;

	&lt;p&gt;Another weak candidate is the &lt;a href=&quot;http://en.wikipedia.org/wiki/Data_Encryption_Standard&quot;&gt;&lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; algorithm&lt;/a&gt;. It was made a standard in 1976 (which is an eternity ago in IT terms). Although it was never cryptographically broken, it&amp;#8217;s key length of 56 bits made it increasingly more vulnerable to brute force attacks as faster CPUs became available. Since the &lt;a href=&quot;http://www.eff.org&quot;&gt;Electronic Frontier Foundation&lt;/a&gt; demonstrated a custom-built &lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; cracker in 1998, built for $250.000 and able to brute-force a &lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; key in under two days, &lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; has been effectively dead. But, for compatibility reasons, OpenSSL is, by default, willing to negotiate &lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; as a cipher.&lt;/p&gt;

	&lt;p&gt;OpenSSL can be told which ciphers to offer in an &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; negotiation, and thankfully most programs using OpenSSL offer configuration statements so the admin can change the default settings.&lt;/p&gt;

	&lt;h3&gt;Selections&lt;/h3&gt;

	&lt;p&gt;Which ciphers should be used then? Let&amp;#8217;s start with all the ciphers supported by the SSLv3/TLSv1 cipher suite (which every program offering &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; should support, the use of SSLv2 is strongly discouraged due to vulnerabilities). And we only want ciphers which offer high security (which in OpenSSL terms means more than 128 bits key length, plus some ciphers with 128 bit keys). To be on the safe side we also explicitly disable SSLv2 ciphers, so they cannot be reintroduced later:&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;TLSv1+HIGH:!SSLv2&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
$
&lt;/pre&gt;

	&lt;p&gt;25 ciphers match this list, but it also contains ciphers without authentication. These have to go, along with all ciphers without encryption (there should not be any, but better save than sorry):&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;TLSv1+HIGH:!SSLv2:!aNULL:!eNULL&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
$
&lt;/pre&gt;

	&lt;p&gt;20 remain. It&amp;#8217;s my personal preference to disable ciphers based on triple-&lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; (3DES), so these are removed, too. There is no technical reason for this, 3DES is still considered secure.&lt;/p&gt;

	&lt;p&gt;Finally, the remaining ciphers are sorted by strength, the most secure first, which will make OpenSSL prefer those.&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
&lt;/pre&gt;

	&lt;p&gt;On my notebook 14 ciphers remain. For comparison, on my web server (running CentOS 5) this selection only produces 6 ciphers, due to an older version of OpenSSL.&lt;/p&gt;

	&lt;p&gt;There is, however, two problem with this list. First, it does no longer contain the export or simple &lt;span class=&quot;caps&quot;&gt;DES&lt;/span&gt; ciphers (which was kind of the point). This means that &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; services secured with this selection are no longer available to &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; client which only support export grade ciphers. This is a good thing, as these clients are insecure and need to be replaced with something more recent. Depending on the details of the service this option may not be available, though. Please check if these old ciphers must be supprted further before turning them off.&lt;/p&gt;

	&lt;p&gt;The second problem is Windows. In detail, Windows versions before and including Windows XP. The crypto libraries shipped with these versions do not support newer crypto algorithms (like &lt;span class=&quot;caps&quot;&gt;AES&lt;/span&gt;), so there is no overlap between the set of algorithms supported by the server and those supported by the client. These crypto libraries are primarily used by Internet Explorer, Outlook and Outlook Express, so these programs on Windows XP and earlier will not be able to negotiate an &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; connection to a web or mail server. Other web browsers and mail clients (like Firefox and Thunderbird) usually ship with their own crypto libraries which do support modern algorithms, and are not&lt;br /&gt;
affected. The system crypto libraries in Windows Vista and Windows 7 are also not affected.&lt;/p&gt;

	&lt;p&gt;If support for older Windows versions cannot be dropped (likely), the cipher list needs to be extended by some RC4 ciphers (which Windows does support):&lt;/p&gt;

&lt;pre&gt;
$ openssl ciphers -v &amp;#39;TLSv1+HIGH:!SSLv2:RC4+MEDIUM:!aNULL:!eNULL:!3DES:@STRENGTH&amp;#39;
DHE-RSA-AES256-SHA      SSLv3 Kx=DH       Au=RSA  Enc=AES(256)  Mac=SHA1
DHE-DSS-AES256-SHA      SSLv3 Kx=DH       Au=DSS  Enc=AES(256)  Mac=SHA1
...
$
&lt;/pre&gt;

	&lt;p&gt;This brings the number of ciphers up to 19, the new RC4 ciphers are added at the end of the sorted list.&lt;/p&gt;

	&lt;h3&gt;Configuration&lt;/h3&gt;

	&lt;p&gt;Now that the cipher list is complete the various services that use &lt;span class=&quot;caps&quot;&gt;SSL&lt;/span&gt; need to be configured to use it. Instructions how to do this can be found in the documentation, examples for some services are below.&lt;/p&gt;

	&lt;h4&gt;Exim&lt;/h4&gt;

	&lt;p&gt;Add the following line to the global (first) configuration section and restart Exim:&lt;/p&gt;

&lt;pre&gt;
tls_require_ciphers = TLSv1+HIGH : !SSLv2 : RC4+MEDIUM : !aNULL : !eNULL : !3DES : @STRENGTH
&lt;/pre&gt;

	&lt;h4&gt;Lighttpd&lt;/h4&gt;

	&lt;p&gt;Add the following line to the configuration section containing &lt;code&gt;ssl.engine = &amp;#34;enable&amp;#34;&lt;/code&gt; and restart Lighttpd:&lt;/p&gt;

&lt;pre&gt;
ssl.cipher-list = &amp;#34;TLSv1+HIGH !SSLv2 RC4+MEDIUM !aNULL !eNULL !3DES @STRENGTH&amp;#34;
&lt;/pre&gt;

	&lt;h4&gt;Cyrus &lt;span class=&quot;caps&quot;&gt;IMAPD&lt;/span&gt;&lt;/h4&gt;

	&lt;p&gt;Add the following line in &lt;code&gt;imapd.conf&lt;/code&gt; and restart Cyrus:&lt;/p&gt;

&lt;pre&gt;
tls_cipher_list: TLSv1+HIGH:!SSLv2:RC4+MEDIUM:!aNULL:!eNULL:!3DES:@STRENGTH
&lt;/pre&gt;

	&lt;h3&gt;Testing&lt;/h3&gt;

	&lt;p&gt;In order to test the new settings, a connection attempt using an excluded cipher can be made (which should fail, of course):&lt;/p&gt;

&lt;pre&gt;
$ openssl s_client -host www.skytale.net -port 443 -cipher 3DES
CONNECTED(00000003)
140209911707464:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:s23_clnt.c:672:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 58 bytes
---
New, (NONE), Cipher is (NONE)
Compression: NONE
Expansion: NONE
---
&lt;/pre&gt;

	&lt;p&gt;A successful attempt (letting openssl select the best cipher) negotiates &lt;span class=&quot;caps&quot;&gt;AES&lt;/span&gt; with a 256 bit key:&lt;/p&gt;

&lt;pre&gt;
$ openssl s_client -host www.skytale.net -port 443
CONNECTED(00000003)
...
---
SSL handshake has read 1281 bytes and written 309 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Compression: zlib compression
Expansion: zlib compression
SSL-Session:
Protocol  : TLSv1
Cipher    : AES256-SHA
Session-ID: --removed--
Session-ID-ctx:
Master-Key: --removed--
Key-Arg   : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
Compression: 1 (zlib compression)
Start Time: 1252852959
Timeout   : 300 (sec)
Verify return code: 21 (unable to verify the first certificate)
---
&lt;/pre&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, </dc:subject>
    <dc:date>2009-09-13T14:45:35Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=22</wfw:comment>
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=22</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/21-guid.html">
    <title>Running RivaTuner without Administrator rights</title>
    <link>http://www.skytale.net/blog/archives/21-Running-RivaTuner-without-Administrator-rights.html</link>
    <description>
    	&lt;p&gt;&lt;a href=&quot;http://www.guru3d.com/rivatuner&quot;&gt;RivaTuner&lt;/a&gt; is a tweaking program for Windows used to change some more obscure parameters of modern GPUs. It&amp;#8217;s main uses are overclocking and monitoring, but it&amp;#8217;s feature list is truly impressive. I mainly use it to change the fan speed settings on the &lt;span class=&quot;caps&quot;&gt;GTX&lt;/span&gt; 260 in my gaming rig (the default profile is not aggressive enough for my taste, letting the &lt;span class=&quot;caps&quot;&gt;GPU&lt;/span&gt; temperature run up to 85 degrees before the fan starts to kick in in ernest).&lt;/p&gt;

	&lt;p&gt;One problem I always had with RivaTuner is that it requires Administrator privileges to run. It needs those to load a device driver that is then used to communicate (and manipulate) the &lt;span class=&quot;caps&quot;&gt;GPU&lt;/span&gt; driver and some parts of the graphic card. Since my normal user account does not have administrative privileges I had to use the &amp;#8220;Run As&amp;#8221; feature to start RivaTuner to allow it to set my fan parameters.&lt;/p&gt;

	&lt;p&gt;It turns out this is not really necessary, and that there is a way to run the RivaTuner frontend as a normal user. Here&amp;#8217;s how.&lt;/p&gt;

	&lt;h3&gt;&lt;span class=&quot;caps&quot;&gt;WARNING&lt;/span&gt;&lt;/h3&gt;

	&lt;p&gt;The following instructions involve editing sensitive parts of the Windows registry. Getting this wrong may render your Windows installation unbootable or harm your system in other ways. If you are not comfortable with the registry editor do not attempt to do this.&lt;/p&gt;

	&lt;h3&gt;Instructions&lt;/h3&gt;

	&lt;ul&gt;
		&lt;li&gt;Install RivaTuner (well, duh).&lt;/li&gt;
		&lt;li&gt;Start RivaTuner at least once (as an Administrator)&lt;/li&gt;
		&lt;li&gt;Log in as a user with administrative rights&lt;/li&gt;
		&lt;li&gt;Start the registry editor&lt;/li&gt;
		&lt;li&gt;Navigate to the following key:&lt;/li&gt;
	&lt;/ul&gt;
&lt;pre&gt;
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RivaTuner32
&lt;/pre&gt;
	&lt;ul&gt;
		&lt;li&gt;Change the key &lt;code&gt;Start&lt;/code&gt; to &lt;code&gt;1&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Reboot&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;What this does is to instruct Windows to load the RivaTuner device driver during system startup, so it is already loaded when a user logs in. Seeing this, RivaTuner will not attempt to load the driver again, but connect to the driver as a normal user (which works).&lt;/p&gt;

	&lt;h3&gt;Advantages&lt;/h3&gt;

	&lt;p&gt;With this change RivaTuner can be run as a normal user&lt;/p&gt;

	&lt;h3&gt;Disadvantages&lt;/h3&gt;

	&lt;p&gt;The RivaTuner device driver will always be loaded, even when RivaTuner will not be used. This may lead to problems with other drivers, and disabling the device driver again requires another go at the registry.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Windows, </dc:subject>
    <dc:date>2009-09-03T19:59:36Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=21</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=21</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/20-guid.html">
    <title>Tracing errors through the code</title>
    <link>http://www.skytale.net/blog/archives/20-Tracing-errors-through-the-code.html</link>
    <description>
    	&lt;p&gt;Open source is a great thing. This becomes especially obvious if one is confronted with a program that refuses to work, and furthermore refuses to yield any kind of helpful error message. Reading the source may be the only way to determine what is actually going on.&lt;/p&gt;

	&lt;p&gt;Sadly I&amp;#8217;ve been doing rather a lot of that lately, This post shall serve as an example how to navigate the Open Solaris source code in search of an answer.&lt;/p&gt;

	&lt;h3&gt;The problem&lt;/h3&gt;

	&lt;p&gt;This specific problem arose during my experiments to create a small Solaris installation for use in an embedded system (small in this context means around 60MB used disk space). More details on this later.&lt;/p&gt;

	&lt;p&gt;The system has a &lt;code&gt;cfgadm(1M)&lt;/code&gt; binary, but it does not work:&lt;/p&gt;

&lt;pre&gt;
# cfgadm
cfgadm: Library error: Device library initialize failed: Facility is not active
&lt;/pre&gt;

	&lt;p&gt;As error messages go this only marginally better that &amp;#8220;Failed&amp;#8221;, but not by much. Telling the user which exact facility is not active would have been helpful.&lt;/p&gt;

	&lt;p&gt;But at least there are some search friendly strings in there that may help to determine the source code responsible for this message.&lt;/p&gt;

	&lt;h3&gt;The source&lt;/h3&gt;

	&lt;p&gt;One thing the classical &lt;span class=&quot;caps&quot;&gt;UNIX&lt;/span&gt; source approach of &amp;#8220;all the source in one tree&amp;#8221; has going for it is that it makes searching in the source relatively easy. The Open Solaris web site has build a search engine above the source tree which automatically cross-references symbols in the code and has some other nice features. &lt;a href=&quot;http://src.opensolaris.org/source&quot;&gt;The entry page to the search engine is here.&lt;/a&gt;&lt;/p&gt;

	&lt;p&gt;Searching for &amp;#8220;Facility is not active&amp;#8221; (note the quotes) yields just a handful of hits. One of those (in &lt;code&gt;/onnv/onnv-gate/usr/src/uts/common/sys/errno.h&lt;/code&gt;) hints that there is a system error (and corresponding symbol) called &lt;code&gt;ENOTACTIVE&lt;/code&gt; which belongs to this error message.&lt;/p&gt;

	&lt;p&gt;Running &lt;code&gt;cfgadm&lt;/code&gt; under &lt;code&gt;truss(1)&lt;/code&gt; confirms this:&lt;/p&gt;

&lt;pre&gt;
# truss cfgadm
execve(&amp;#34;/usr/sbin/cfgadm&amp;#34;, 0x08047E24, 0x08047E2C)  argc = 1
[...]
sysconfig(_CONFIG_PAGESIZE)                     = 4096
open(&amp;#34;/devices/pseudo/devinfo@0:devinfo&amp;#34;, O_RDONLY) = 3
ioctl(3, DINFOIDENT, 0x00000000)                = 57311
ioctl(3, 0x10DF00, 0x08047460)                  Err#73 ENOTACTIVE
close(3)                                        = 0
[...]
&lt;/pre&gt;

	&lt;p&gt;Things go kind of downhill from there. So some code opens the devinfo device, runs two IOCTLs on in and the second one fails. Furthermore, &lt;code&gt;truss&lt;/code&gt; only knows the first &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; by name, not the actually failing one.&lt;/p&gt;

	&lt;p&gt;Searching for the first name turns up &lt;code&gt;/onnv/onnv-gate/usr/src/uts/common/sys/devinfo_impl.h&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
#define DINFOIDENT (DIIOC | 0x82) /* identify the driver */
&lt;/pre&gt;

	&lt;p&gt;Looking around in this file some more yields two other definitions:&lt;/p&gt;

&lt;pre&gt;
#define  DIIOC       (0xdf&amp;#60;&amp;#60;8)
[...]
#define DINFOCACHE  (DIIOC | 0x100000) /* use cached data  */
&lt;/pre&gt;

	&lt;p&gt;So the second &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; is actually called &lt;code&gt;DINFOCACHE&lt;/code&gt;. Tracing IOCTLs through the code is, unfortunately, a bit tricky, because the routine that handles the &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; depends on the passed file descriptor (the first parameter to the &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; call). The file associated with the &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; in this case belongs to the file &lt;code&gt;/devices/pseudo/devinfo@0:devinfo&lt;/code&gt; (see the &lt;code&gt;open&lt;/code&gt; call directly above the two IOCTLs).&lt;/p&gt;

	&lt;p&gt;But since the &lt;span class=&quot;caps&quot;&gt;IOCTL&lt;/span&gt; handling code most likely contains the symbol &lt;code&gt;DINFOCACHE&lt;/code&gt; as well (that&amp;#8217;s what constants are for, after all) searching for the name will turn up the correct file, possibly buried among others.&lt;/p&gt;

	&lt;p&gt;Armed this knowledge the search results for &lt;code&gt;DINFOCACHE&lt;/code&gt; can be narrowed down to one likely candidate: &lt;code&gt;/onnv/onnv-gate/usr/src/uts/common/io/devinfo.c&lt;/code&gt;. This file belongs to the kernel code (it lives in &lt;code&gt;usr/src/uts&lt;/code&gt;), and the name fits the name of the device opened above.&lt;/p&gt;

	&lt;p&gt;&lt;code&gt;DINFOCACHE&lt;/code&gt; appears twice in a function called &lt;code&gt;di_ioctl&lt;/code&gt;, which sounds good. Following the code flow through this function (&lt;code&gt;DINFOCACHE&lt;/code&gt; is passed in the &lt;code&gt;cmd&lt;/code&gt; parameter), the first relevant code part reads as follows:&lt;/p&gt;

&lt;pre&gt;
if ((st-&amp;#62;command &amp;#38; DINFOCACHE) &amp;#38;&amp;#38; !cache_args_valid(st, &amp;#38;error)) {
        di_freemem(st);
        (void) di_setstate(st, IOC_IDLE);
        return (error);
}
&lt;/pre&gt;

	&lt;p&gt;(By the time execution reaches this code the &lt;code&gt;cmd&lt;/code&gt; variable has been copied to &lt;code&gt;st-&amp;#62;command&lt;/code&gt;, more or less). &lt;code&gt;cache_valid_args&lt;/code&gt;, among other things, does the following:&lt;/p&gt;

&lt;pre&gt;
if (!modrootloaded || !i_ddi_io_initialized()) {
       CACHE_DEBUG((DI_ERR,
       &amp;#34;cache lookup failure: I/O subsystem not inited&amp;#34;));
       *error = ENOTACTIVE;
       return (0);
}
&lt;/pre&gt;

	&lt;p&gt;That looks pretty promising, as it sets the right error code if the condition holds. &lt;code&gt;modrootloadied&lt;/code&gt; is a kernel symbol, so &lt;code&gt;mdb(1)&lt;/code&gt; can be used to inspect this value in a running kernel.&lt;/p&gt;

&lt;pre&gt;
# mdb -k
Loading modules: [ unix genunix specfs mac cpu.generic uppc pcplusmp scsi_vhci
ufs sockfs ip hook neti sctp arp usba uhci sd lofs logindmux ptm random crypto
zfs ipc ]
&amp;#62; modrootloaded/X
modrootloaded:
modrootloaded:  1
&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s not the culprit. &lt;code&gt;i_ddi_io_initialized()&lt;/code&gt; basically returns the value of &lt;code&gt;sysevent_daemon_init&lt;/code&gt;, so what about that?&lt;/p&gt;

&lt;pre&gt;
# mdb -k
Loading modules: [ unix genunix specfs mac cpu.generic uppc pcplusmp scsi_vhci
ufs sockfs ip hook neti sctp arp usba uhci sd lofs logindmux ptm random crypto
zfs ipc ]
&amp;#62; modrootloaded/X
modrootloaded:
modrootloaded:  1
&amp;#62; sysevent_daemon_init/X
sysevent_daemon_init:
sysevent_daemon_init:           0
&lt;/pre&gt;

	&lt;p&gt;Bingo. From the name of the variable the probable name of the not running facility (remember the original error message?) can be deduced: &lt;code&gt;svc:/system/sysevent:default&lt;/code&gt;, which, indeed, is not running on the minimal system. Starting it makes &lt;code&gt;cfgadm&lt;/code&gt; work.&lt;/p&gt;

	&lt;p&gt;That wasn&amp;#8217;t so hard, now was it?&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-05-29T14:50:12Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=20</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=20</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/19-guid.html">
    <title>Login via serial console</title>
    <link>http://www.skytale.net/blog/archives/19-Login-via-serial-console.html</link>
    <description>
    	&lt;p&gt;Getting a serial console (for login purposes) on OpenSolaris seems to be a two-sided operation. Either it is insultingly simple, or a convoluted mess. The two options I&amp;#8217;ve discovered so far, in order of difficulty.&lt;/p&gt;

	&lt;h3&gt;The easy way&lt;/h3&gt;

	&lt;p&gt;By default Solaris starts a login console on &lt;code&gt;/dev/console&lt;/code&gt;, whatever that happens to be at a given moment. Passing &lt;code&gt;-B console=ttya&lt;/code&gt; on the kernel command line (via &lt;span class=&quot;caps&quot;&gt;GRUB&lt;/span&gt;) will change the primary system console to the first serial port in the system (what Linux calls &lt;code&gt;ttyS0&lt;/code&gt;), automagically creating a login prompt there when the system has finished booting.&lt;/p&gt;

	&lt;h3&gt;The hard way&lt;/h3&gt;

	&lt;p&gt;Assuming that for whatever reason &lt;code&gt;/dev/console&lt;/code&gt; is not supposed to be on &lt;code&gt;ttya&lt;/code&gt;, things move into twilight territory.&lt;/p&gt;

	&lt;p&gt;Historically a &lt;code&gt;getty&lt;/code&gt; was spawned from inittab, and that was it. Sometime in the past Solaris changed this behaviour to a more complicated scheme.&lt;/p&gt;

	&lt;p&gt;Login processes are handled by the Service Access Controller (&lt;code&gt;sac(1M)&lt;/code&gt;), which handles port monitors. Port monitors bind services to ports, for example &lt;code&gt;ttymon(1M)&lt;/code&gt;, which handles baud rates and spawning the login process. I have to admin that I have not completely understood the architectural design behind all this. As far as I was able to deduce from the manual pages for &lt;code&gt;pmadm(1M)&lt;/code&gt;, &lt;code&gt;ttyadm(1M)&lt;/code&gt; and &lt;code&gt;sacadm(1M)&lt;/code&gt; the default setting ought to produce a login prompt on the first two serial ports. Alas, it does not.&lt;/p&gt;

	&lt;p&gt;It looks like &lt;code&gt;ttymon&lt;/code&gt;s are no longer handled by &lt;span class=&quot;caps&quot;&gt;SAC&lt;/span&gt;, no matter what the documentation says, but are instead spawned directly by &lt;span class=&quot;caps&quot;&gt;SMF&lt;/span&gt;, specifically by &lt;code&gt;svc:/system/console-login&lt;/code&gt;. This &lt;span class=&quot;caps&quot;&gt;SVC&lt;/span&gt; has several instances that handle the login prompts on the virtual consoles for &lt;span class=&quot;caps&quot;&gt;VGA&lt;/span&gt;. Adding an instance for &lt;code&gt;ttya&lt;/code&gt; makes a login prompt appear on the first serial port. The following creates and activates this instance:&lt;/p&gt;

&lt;pre&gt;
# svccfg -f - &amp;#60;&amp;#60;EOF
select svc:/system/console-login
add ttya
select svc:/system/console-login:ttya
addpg ttymon application
setprop ttymon/device = astring: /dev/term/a
setprop ttymon/label = astring: console
setprop ttymon/modules = astring: ldterm,ttcompat
setprop ttymon/nohangup = boolean: true
setprop ttymon/prompt = astring: &amp;#34;`uname -n` ttya login:&amp;#34;
addpg general framework
setprop general/enabled = boolean: true
EOF
#
&lt;/pre&gt;

	&lt;p&gt;Please note that due to the default settings in &lt;code&gt;/etc/security/login&lt;/code&gt; root logins are not possible on this terminal.&lt;/p&gt;

	&lt;p&gt;Now I am waiting for one of two things to happen:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Someone telling me that I&amp;#8217;ve got it all wrong and that there&amp;#8217;s a better way to do things&lt;/li&gt;
		&lt;li&gt;Someone telling me that this is the official way to do it and that it is documented somwhere.&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;I&amp;#8217;m not holding my breath on either one.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-03-28T13:35:04Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=19</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=19</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/18-guid.html">
    <title>iSCSI: Opensolaris target, Fedora initiator, with CHAP</title>
    <link>http://www.skytale.net/blog/archives/18-iSCSI-Opensolaris-target,-Fedora-initiator,-with-CHAP.html</link>
    <description>
    	&lt;p&gt;For some reason or another finding instructions on how to actually configure iSCSI for a rather simple and common use case (one target on Solaris, one initiator on Fedora, &lt;span class=&quot;caps&quot;&gt;CHAP&lt;/span&gt; authentication) seems to be pretty hard.&lt;/p&gt;

	&lt;p&gt;Either my google-fu is seriously broken today, or everyone except for me considers this to be so easy and obvious that it does not warrant documentation. Which, having done this for the last three hours, I seriously doubt. The Solaris side is actually documented quite well (I primarily used &lt;a href=&quot;http://blogs.everycity.co.uk/alasdair/2008/11/solaris-as-an-iscsi-server-with-zfs/&quot;&gt; this blog entry by alasdair&lt;/a&gt;), the Linux side is lacking. It does not help matters that both sides use identically named tools that work in completely different ways.&lt;/p&gt;

	&lt;p&gt;So, the deal is as follows:&lt;/p&gt;

	&lt;p&gt;One OpenSolaris system, acting as iSCSI target (that is the system presenting the storage space).&lt;/p&gt;

	&lt;p&gt;One Fedora Linux system, acting as iSCSI initiator (that is the system that wants to use the storage space)&lt;/p&gt;

	&lt;p&gt;Create 100GB storage space on the target and let the initiator connect to this storage space and create a filesystem on in. The connection has to be authenticated one way (the initiator presents credentials to the target).&lt;/p&gt;

	&lt;h3&gt;The Solaris side&lt;/h3&gt;

	&lt;p&gt;The system is running Nevada, the configuration here was done with build snv_110.&lt;/p&gt;

	&lt;p&gt;First, the iSCSI target software needs to be installed and enabled:&lt;/p&gt;

&lt;pre&gt;
# gkp.pl -d /mnt/Solaris_11/Product SUNWiscsitgtu
# svcadm enable iscsitgt:default
#
&lt;/pre&gt;

	&lt;p&gt;The backing store for the iSCSI volumes shall be provided by ZFS:&lt;/p&gt;

&lt;pre&gt;
# zfs create -o canmount=off tank/iscsi
# zfs create -V 100G -o shareiscsi=on tank/iscsi/vol001
# iscsitadm list target -v
Target: tank/iscsi/vol001
    iSCSI Name: iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8
    Alias: tank/iscsi/vol001
[...]
#
&lt;/pre&gt;

	&lt;p&gt;The &lt;code&gt;iSCSI Name&lt;/code&gt; will be different for each created volume. Per default this target will be available via all interfaces and IPs of the machine. Since this is not what I want in this special case the target is bound to a fixed IP by a construct called a Target Port Group Tag. The &lt;span class=&quot;caps&quot;&gt;TPGT&lt;/span&gt; used here has the number 1.&lt;/p&gt;

&lt;pre&gt;
# iscsitadm create tpgt 1
# iscsitadm modify tpgt -i 212.51.12.90 1
# iscsitadm list tpgt -v 1
TPGT: 1
    IP Address: 212.51.12.90
# iscsitadm modify target -p 1 tank/iscsi/vol001
# iscsitadm list target -v
Target: tank/iscsi/vol001
[...]
    TPGT list:
            TPGT: 1
[...]
#
&lt;/pre&gt;

	&lt;p&gt;In order to secure access to this volume some more the initiator is required to authenticate itself using &lt;span class=&quot;caps&quot;&gt;CHAP&lt;/span&gt; before access is granted. To do this three pieces of information are needed:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;The iqn (basically a unique name) of the initiator&lt;/li&gt;
		&lt;li&gt;A username&lt;/li&gt;
		&lt;li&gt;A password&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;The initiator used here has an iqn of &lt;code&gt;iqn.2005-03.com.max:01.cb5c4c&lt;/code&gt; (see below for the source of this information). The username is &lt;code&gt;lain&lt;/code&gt; and the password is &lt;code&gt;iscsipassword&lt;/code&gt; for the purpose of this demonstration. The password has to be between 12 and 16 charcters in length and should definitely be something stronger for production purposes.&lt;/p&gt;

&lt;pre&gt;
# iscsitadm create initiator -n iqn.2005-03.com.max:01.cb5c4c lain
# iscsitadm modify initiator --chap-name lain lain
# iscsitadm modify initiator --chap-secret lain
[...]
# iscsitadm list initiator -v
Initiator: lain
    iSCSI Name: iqn.2005-03.com.max:01.cb5c4c
    CHAP Name: lain
    CHAP Secret: Set
# iscsitadm modify target --acl lain tank/iscsi/vol001
# iscsitadm list target -v
Target: tank/iscsi/vol001
[...]
    ACL list:
            Initiator: lain
[...]
#
&lt;/pre&gt;

	&lt;p&gt;This concludes the Solaris side of things.&lt;/p&gt;

	&lt;h3&gt;The Fedora side&lt;/h3&gt;

	&lt;p&gt;The system is running Fedora Rawhide, close to the Fedora 11 Beta release at the time of this writing.&lt;/p&gt;

	&lt;p&gt;On the Linux side iSCSI is handled by the open-iscsi toolchain, packaged as &lt;code&gt;iscsi-initiator-utils&lt;/code&gt; in Fedora. To install it:&lt;/p&gt;

&lt;pre&gt;
# yum install iscsi-initiator-utils
[...]
#
&lt;/pre&gt;

	&lt;p&gt;Since the system in question is a notebook, and the iSCSI target may not be available at all times, the iSCSI service must be instructed not to connect to configured devices automatically:&lt;/p&gt;

&lt;pre&gt;
# perl -pi -e &amp;#39;s/node.startup.*/node.startup = manual/&amp;#39; /etc/iscsi/iscsid.conf
#
&lt;/pre&gt;

	&lt;p&gt;The initiator name mentioned in the Solaris section above can be configured freely on the system. A random value is created during package installation and saved in &lt;code&gt;/etc/iscsi/initiatorname.iscsi&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2005-03.com.max:01.cb5c4c
#
&lt;/pre&gt;

	&lt;p&gt;Be sure the name configured there matches the name defined in the initiator on the Solaris side. Even though a username/password pair was defined on the target credentials are not needed for target discovery (the process by which an initiator asks a target which iSCSI volumes are available):&lt;/p&gt;

&lt;pre&gt;
# iscsiadm -m discovery -t st -p 212.51.12.90
212.51.12.90:3260,1 iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8
# iscsiadm -m node
212.51.12.90:3260,1 iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8
#
&lt;/pre&gt;

	&lt;p&gt;The discovery process has found a single volume exported by the target and added it to the local node list. The iqn matches the value shown above in the Solaris section. Now the &lt;span class=&quot;caps&quot;&gt;CHAP&lt;/span&gt; credentials have to be added to the node so the initiator can actually connect to the volume:&lt;/p&gt;

&lt;pre&gt;
# iscsiadm -m node --target &amp;#39;iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8&amp;#39; \
--name &amp;#39;node.session.auth.authmethod&amp;#39; -v &amp;#39;CHAP&amp;#39;
# iscsiadm -m node --target &amp;#39;iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8&amp;#39; \
--name &amp;#39;node.session.auth.username&amp;#39; -v &amp;#39;lain&amp;#39;
# iscsiadm -m node --target &amp;#39;iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8&amp;#39; \
--name &amp;#39;node.session.auth.password&amp;#39; -v &amp;#39;iscsipassword&amp;#39;
# iscsiadm -m node --target &amp;#39;iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8&amp;#39;
node.name = iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8
node.tpgt = 1
node.startup = manual
[...]
node.session.auth.authmethod = CHAP
node.session.auth.username = lain
node.session.auth.password = ********
[...]
#
&lt;/pre&gt;

	&lt;p&gt;Now the volume can finally be accessed:&lt;/p&gt;

&lt;pre&gt;
# iscsiadm -m node --target &amp;#39;iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8&amp;#39; --login
Logging in to [iface: default, target: iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8,
portal: 212.51.12.90,3260]
Login to [iface: default, target: iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8,
portal: 212.51.12.90,3260]: successful
#
&lt;/pre&gt;

	&lt;p&gt;After some seconds a device node for this volume should appear in &lt;code&gt;/dev/disk/by-path&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
# ls /dev/disk/by-path/
ip-212.51.12.90:3260-iscsi-iqn.1986-03.com.sun:02:218c35e0-0881-cb4f-d6bd-80e08bdc98d8-lun-0
[...]
#
&lt;/pre&gt;

	&lt;p&gt;The disk is ready to be used.&lt;/p&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Linux, Software, Solaris, </dc:subject>
    <dc:date>2009-03-24T00:16:10Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=18</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=18</wfw:commentRss>
    
    
</item>
<item rdf:about="http://www.skytale.net/blog/archives/17-guid.html">
    <title>Using pkgsrc on Opensolaris, Part 3</title>
    <link>http://www.skytale.net/blog/archives/17-Using-pkgsrc-on-Opensolaris,-Part-3.html</link>
    <description>
    	&lt;h3&gt;Initial install&lt;/h3&gt;

	&lt;p&gt;&lt;code&gt;pkgsrc&lt;/code&gt; can be obtained in two main ways. The first is via anonymous &lt;span class=&quot;caps&quot;&gt;CVS&lt;/span&gt; checkout, the second is via quarterly tarball releases. Since the whole tree is several hundred megabytes (even without sources) and the NetBSD &lt;span class=&quot;caps&quot;&gt;CVS&lt;/span&gt; servers are permanently overloaded a tarball is the way to go for the initial install. The tarballs can be found in the NetBSD mirror structure, &lt;a href=&quot;ftp://ftp.netbsd.org/pub/pkgsrc/current&quot;&gt;the main mirror being here&lt;/a&gt;. At the time of this writing pkgsrc-2008Q4 is current.&lt;/p&gt;

	&lt;p&gt;The tarball already contains a pkgsrc directory at the top level, so it has to be unpacked under &lt;code&gt;/usr&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;
# wget ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz
# gtar -xzf pkgsrc.tar.gz -C /usr
# chown -R builder: /usr/pkgsrc
&lt;/pre&gt;

	&lt;p&gt;This will unpack the tarball into the filesystem mounted at &lt;code&gt;/usr/pkgsrc&lt;/code&gt; and change the ownership to the build user created earlier.&lt;/p&gt;

	&lt;h3&gt;Patching gcc&lt;/h3&gt;

	&lt;p&gt;Unfortunately the gcc suite as delivered with Solaris has a small flaw, which will cause some packages to be built incorrectly (the most famous example is openssl, which will build but not work afterwards). Fortunately the bug has been tracked down &lt;a href=&quot;http://www.openssl.org/%7Eappro/values.c&quot;&gt;and a bandaid is available here&lt;/a&gt;.&lt;/p&gt;

	&lt;p&gt;This file is a nice little hack in itself as it is a shell script and a C source file at the same time. If executed by a shell this file will be put though gcc three times to produce three object files, which are placed into a directory where the compiler can find them and use them instead of files that were delivered with the compiler.&lt;/p&gt;

&lt;pre&gt;
# bash ./values.c /usr/sfw/bin/gcc
[....]
# ls -l $(dirname $(/usr/sfw/bin/gcc -print-libgcc-file-name))
[...]
-rw-r--r-- 1 root root    763 2009-02-21 17:34 values-Xa.o
-rw-r--r-- 1 root root    763 2009-02-21 17:34 values-Xc.o
-rw-r--r-- 1 root root    763 2009-02-21 17:34 values-Xt.o
#
&lt;/pre&gt;

	&lt;h3&gt;Bootstrapping&lt;/h3&gt;

	&lt;p&gt;With this particular bug out of the way &lt;code&gt;pkgsrc&lt;/code&gt; needs to be bootstrapped. This means that the initial set of programs needed to build further packages (the package management itself and some helper programs) need to be built and installed on the host system. This has to be done as root. In order to find some programs it is necessary to expand the &lt;code&gt;$PATH&lt;/code&gt; a bit.&lt;/p&gt;

&lt;pre&gt;
# cd /usr/pkgsrc/bootstrap
# PATH=&amp;#34;$PATH:/usr/sfw/bin:/usr/xpg4/bin&amp;#34; ./bootstrap
[....]
#
&lt;/pre&gt;

	&lt;p&gt;Bootstrapping will take a while, but it should run though cleanly. Afterwards there should be some files in &lt;code&gt;/usr/pkg&lt;/code&gt; and running &lt;code&gt;/usr/pkg/sbin/pkg_info&lt;/code&gt; should list a handful of installed packages.&lt;/p&gt;

	&lt;h3&gt;Vulnerabilities and updates&lt;/h3&gt;

	&lt;p&gt;Packages need to be kept up-to-date, for new features as much as for possible vulnerabilites. In the latter department the bootstrap installed two programs to help with identifying such programs.&lt;/p&gt;

	&lt;p&gt;&lt;code&gt;/usr/pkg/sbin/download-vulnerability-list&lt;/code&gt; will fetch a list of vulnerable program versions. Builds of such versions will fail, unless explicitly requested otherwise. For already installed programs there is &lt;code&gt;/usr/sbin/pkg/audit-packages&lt;/code&gt; which will identify and list installed vulnerable versions.&lt;/p&gt;

	&lt;p&gt;Both programs should be used on a regular basis.&lt;/p&gt;

	&lt;p&gt;Updates of packages (whether due to a vulnerability or not) are best done via &lt;span class=&quot;caps&quot;&gt;CVS&lt;/span&gt;. Updates can be done on the whole package tree or on individual subtrees, as needed. Assuming an older installed version the following command will update the whole tree to 2008Q4:&lt;/p&gt;

&lt;pre&gt;
# su - builder
$ cd /usr/pkgsrc
$ cvs up -dPR -rpkgsrc-2008Q4
[...]
$
&lt;/pre&gt;

	&lt;p&gt;It&amp;#8217;s important to check the output of the &lt;span class=&quot;caps&quot;&gt;CVS&lt;/span&gt; command for eventual problems, especially if local modifications to packages have been done.&lt;/p&gt;

	&lt;h3&gt;Host tools&lt;/h3&gt;

	&lt;p&gt;There are a number of tools that are used by a large number of packages during the build process. &lt;code&gt;pkgsrc&lt;/code&gt; will build all of these from source if necessary, but most of them can be supplied by the host system instead.&lt;/p&gt;

	&lt;p&gt;Among these tools are&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; m4&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; make&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; gettext&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; tar&lt;/li&gt;
		&lt;li&gt;Perl&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; patch&lt;/li&gt;
		&lt;li&gt;unzip&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;BISON&lt;/span&gt; &amp;amp; &lt;span class=&quot;caps&quot;&gt;FLEX&lt;/span&gt;&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; make and &lt;span class=&quot;caps&quot;&gt;GNU&lt;/span&gt; tar are already installed, the rest of the packages can be found on the Solaris install media. The rest can easily be installed:&lt;/p&gt;

&lt;pre&gt;
# gkp.pl -d /mnt/Solaris_11/Product SUNWgm4 SUNWgnu-gettext SUNWgpch SUNWunzip \
SUNWbison SUNWflexlex
[...]
#
&lt;/pre&gt;

	&lt;p&gt;Now &lt;code&gt;pkgsrc&lt;/code&gt; has to be made aware of these tools in order to use them. The main config file is &lt;code&gt;/usr/pkg/etc/mk.conf&lt;/code&gt;. Adding the following statements somewhere above the final &lt;code&gt;.endif&lt;/code&gt; will make &lt;code&gt;pkgsrc&lt;/code&gt; use the host version of the above mentioned tools instead of building it&amp;#8217;s own:&lt;/p&gt;

&lt;pre&gt;
# SUNWgm4
TOOLS_PLATFORM.m4=              /usr/bin/gm4
TOOLS_PLATFORM.gm4=             /usr/bin/gm4
# SUNWgmake
TOOLS_PLATFORM.gmake=           /usr/bin/gmake
# SUNWgnu-gettext
TOOLS_PLATFORM.msgfmt=          /usr/bin/gmsgfmt
# SUNWgtar
TOOLS_PLATFORM.tar=             /usr/bin/gtar
TOOLS_PLATFORM.bsdtar=          /usr/bin/gtar
# SUNWgpch
TOOLS_PLATFORM.patch=           /usr/bin/gpatch
TOOLS_PLATFORM.gpatch=          /usr/bin/gpatch
#
TOOLS_PLATFORM.perl=            /usr/bin/perl
# SUNWunzip
TOOLS_PLATFORM.unzip=           /usr/bin/unzip
# SUNWbison
TOOLS_PLATFORM.bison=           /usr/bin/bison
TOOLS_PLATFORM.bison-yacc=      /usr/bin/bison -y
# SUNWflexlex
TOOLS_PLATFORM.lex=             /usr/bin/flex
&lt;/pre&gt; 
    </description>

    <dc:publisher>For the good of all of us</dc:publisher>
    <dc:creator>nospam@example.com (Ralf Ertzinger)</dc:creator>
    <dc:subject>
    Computer, Software, Solaris, </dc:subject>
    <dc:date>2009-03-23T01:47:00Z</dc:date>
    <wfw:comment>http://www.skytale.net/blog/wfwcomment.php?cid=17</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.skytale.net/blog/rss.php?version=1.0&amp;type=comments&amp;cid=17</wfw:commentRss>
    
    
</item>

</rdf:RDF>
