<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>sysadmin</title>
  <link rel="alternate" type="text/html" href="http://tumbleweed.org.za/tags/sysadmin"/>
  <link rel="self" type="application/atom+xml" href="http://tumbleweed.org.za/taxonomy/term/98/atom/feed"/>
  <id>http://tumbleweed.org.za/taxonomy/term/98/atom/feed</id>
  <updated>2008-09-19T07:59:19+00:00</updated>
  <entry>
    <title>smartmontools</title>
    <link rel="alternate" type="text/html" href="http://tumbleweed.org.za/2008/10/08/smartmontools" />
    <id>http://tumbleweed.org.za/2008/10/08/smartmontools</id>
    <published>2008-10-08T15:20:35+00:00</published>
    <updated>2008-10-08T19:56:28+00:00</updated>
    <author>
      <name>tumbleweed</name>
    </author>
    <category term="ide" />
    <category term="smart" />
    <category term="smartmontools" />
    <category term="sysadmin" />
    <category term="ubuntu" />
    <summary type="html"><![CDATA[<p>In line with my <a href="/2008/10/06/joy-sysrq">SysRq Post</a> comes another bit of assumed knowledge, <span class="caps"><span class="caps">SMART</span></span>.
Let&#8217;s begin at the beginning (and stick to the <span class="caps"><span class="caps">PC</span></span>&nbsp;world).</p>

<p>Magnetic storage is fault-prone. In the old days, when you formatted a drive, part of the formatting process was to check that each block seemed to be able to store data.
All the bad blocks would be listed in a &#8220;bad block list&#8221; and the file-system would never try to use them.
File-system checks would also be able to mark blocks as&nbsp;being&nbsp;bad.</p>

<p>As disks got bigger, this meant that formatting could take hours.
Drives had also become fancy enough that they could manage bad blocks themselves, and so a shift occured.
Disks were shipped with some extra spare space that the computer can&#8217;t see.
Should the drive controller detect that a block went bad (they had parity checks), it could re-allocate a block from the extra space to stand in for the bad block.
If it was able to recover the data from the bad block, this could be totally transparent to the file-system, if not the file-system would see a read-error and have to&nbsp;handle&nbsp;it.</p>

<p>This is where we are today.
File-systems still support the concept of bad blocks, but in practice they only occur when a disk runs out of&nbsp;spare&nbsp;blocks.</p>

<p>This came with a problem, how would you know if a disk was doing ok or not?
Well a standard was created called <span class="caps"><span class="caps">SMART</span></span>. This allows you to talk to the drive controller and (amongst other things) find out the state of the disk.
On Linux, we do this via the package <a href="http://smartmontools.sourceforge.net/">smartmontools</a>.</p>

<p>Why is this useful?
Well you can ask the disk to run a variety of tests (including a full bad block scan), these are useful for RMAing a bad drive with minimum hassle.
You can also get the drive&#8217;s error-log which can give you some indication of it&#8217;s reliability.
You can see it&#8217;s temperature, age, and Serial Number (useful when you have to know which drive to unplug).
But, most importantly, you can find out the state of bad sectors.
How many sectors does the drive think are bad, and how many has&nbsp;it&nbsp;reallocated.</p>

<p>Why is&nbsp;that&nbsp;useful?</p>

<p>In the event of a bad block, you can <a href="http://smartmontools.sourceforge.net/badblockhowto.html">manually force a re-allocation</a>.
This way it happens under your terms, and you&#8217;ll know exactly what&nbsp;got&nbsp;corrupted.</p>

<p>Next, Google published <a href="https://db.usenix.org/events/fast07/tech/full_papers/pinheiro/pinheiro_html/">a paper</a> linking non-zero bad sector values to drive failure.
Do you really want be trusting known-non-trustworthy drives with&nbsp;critical&nbsp;data?</p>

<p>Finally, there is a nasty <span class="caps"><span class="caps">RAID</span></span> situation.
If you have a <span class="caps"><span class="caps">RAID</span></span>-5 array with say 6 drives in it and one fails either the <span class="caps"><span class="caps">RAID</span></span> system will automatically select a spare drive (if it has one), or you&#8217;ll have to replace it.
The system will then re-build on the new disk, reading every sector on all the other disks, to calculate the sector contents for the new disk.
If one of those reads fails (bad sector) you&#8217;ll now be up shit-creek without a paddle.
The <span class="caps"><span class="caps">RAID</span></span> system will kick out the disk with the read failure, and you&#8217;ll have a <span class="caps"><span class="caps">RAID</span></span>-5 array with two bad disks in it &#8212; one more than <span class="caps"><span class="caps">RAID</span></span>-5 can handle.
There are tricks to get such a <span class="caps"><span class="caps">RAID</span></span>-5 array back online, and I&#8217;ve done it, but you <em>will</em> have corruption, and it&#8217;s risky&nbsp;as&nbsp;hell.</p>

<p>So, before you go replacing <span class="caps"><span class="caps">RAID</span></span>-5 member-disks, check the <span class="caps"><span class="caps">SMART</span></span> status of all the&nbsp;other&nbsp;disks.</p>

<p>Personally, I get twitchy when any of my drives have bad sectors.
I have smartd <a href="http://wiki.clug.org.za/wiki/How_do_I_monitor_my_Hard_Disks_for_errors%3F">monitoring them</a>, and I&#8217;ll attempt to <span class="caps"><span class="caps">RMA</span></span> them as soon as a sector&nbsp;goes&nbsp;bad.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>In line with my <a href="/2008/10/06/joy-sysrq">SysRq Post</a> comes another bit of assumed knowledge, <span class="caps">SMART</span>.
Let&#8217;s begin at the beginning (and stick to the <span class="caps">PC</span>&nbsp;world).</p>

<p>Magnetic storage is fault-prone. In the old days, when you formatted a drive, part of the formatting process was to check that each block seemed to be able to store data.
All the bad blocks would be listed in a &#8220;bad block list&#8221; and the file-system would never try to use them.
File-system checks would also be able to mark blocks as being&nbsp;bad.</p>

<p>As disks got bigger, this meant that formatting could take hours.
Drives had also become fancy enough that they could manage bad blocks themselves, and so a shift occured.
Disks were shipped with some extra spare space that the computer can&#8217;t see.
Should the drive controller detect that a block went bad (they had parity checks), it could re-allocate a block from the extra space to stand in for the bad block.
If it was able to recover the data from the bad block, this could be totally transparent to the file-system, if not the file-system would see a read-error and have to handle&nbsp;it.</p>

<p>This is where we are today.
File-systems still support the concept of bad blocks, but in practice they only occur when a disk runs out of spare&nbsp;blocks.</p>

<p>This came with a problem, how would you know if a disk was doing ok or not?
Well a standard was created called <span class="caps">SMART</span>. This allows you to talk to the drive controller and (amongst other things) find out the state of the disk.
On Linux, we do this via the package <a href="http://smartmontools.sourceforge.net/">smartmontools</a>.</p>

<p>Why is this useful?
Well you can ask the disk to run a variety of tests (including a full bad block scan), these are useful for RMAing a bad drive with minimum hassle.
You can also get the drive&#8217;s error-log which can give you some indication of it&#8217;s reliability.
You can see it&#8217;s temperature, age, and Serial Number (useful when you have to know which drive to unplug).
But, most importantly, you can find out the state of bad sectors.
How many sectors does the drive think are bad, and how many has it&nbsp;reallocated.</p>

<p>Why is that&nbsp;useful?</p>

<p>In the event of a bad block, you can <a href="http://smartmontools.sourceforge.net/badblockhowto.html">manually force a re-allocation</a>.
This way it happens under your terms, and you&#8217;ll know exactly what got&nbsp;corrupted.</p>

<p>Next, Google published <a href="https://db.usenix.org/events/fast07/tech/full_papers/pinheiro/pinheiro_html/">a paper</a> linking non-zero bad sector values to drive failure.
Do you really want be trusting known-non-trustworthy drives with critical&nbsp;data?</p>

<p>Finally, there is a nasty <span class="caps">RAID</span> situation.
If you have a <span class="caps">RAID</span>-5 array with say 6 drives in it and one fails either the <span class="caps">RAID</span> system will automatically select a spare drive (if it has one), or you&#8217;ll have to replace it.
The system will then re-build on the new disk, reading every sector on all the other disks, to calculate the sector contents for the new disk.
If one of those reads fails (bad sector) you&#8217;ll now be up shit-creek without a paddle.
The <span class="caps">RAID</span> system will kick out the disk with the read failure, and you&#8217;ll have a <span class="caps">RAID</span>-5 array with two bad disks in it &#8212; one more than <span class="caps">RAID</span>-5 can handle.
There are tricks to get such a <span class="caps">RAID</span>-5 array back online, and I&#8217;ve done it, but you <em>will</em> have corruption, and it&#8217;s risky as&nbsp;hell.</p>

<p>So, before you go replacing <span class="caps">RAID</span>-5 member-disks, check the <span class="caps">SMART</span> status of all the other&nbsp;disks.</p>

<p>Personally, I get twitchy when any of my drives have bad sectors.
I have smartd <a href="http://wiki.clug.org.za/wiki/How_do_I_monitor_my_Hard_Disks_for_errors%3F">monitoring them</a>, and I&#8217;ll attempt to <span class="caps">RMA</span> them as soon as a sector goes&nbsp;bad.</p>
    ]]></content>
  </entry>
  <entry>
    <title>The joy that is SysRq</title>
    <link rel="alternate" type="text/html" href="http://tumbleweed.org.za/2008/10/06/joy-sysrq" />
    <id>http://tumbleweed.org.za/2008/10/06/joy-sysrq</id>
    <published>2008-10-06T11:31:20+00:00</published>
    <updated>2008-10-09T15:14:48+00:00</updated>
    <author>
      <name>tumbleweed</name>
    </author>
    <category term="linux" />
    <category term="sysadmin" />
    <category term="sysrq" />
    <category term="technical" />
    <category term="ubuntu" />
    <summary type="html"><![CDATA[<p>I&#8217;m constantly surprised when I come across long-time Linux users who don&#8217;t know about SysRq.
The Linux Magic System Request Key Hacks are a magic set of commands that you can get the Linux kernel to follow no matter what&#8217;s going on (unless it has panicked or&nbsp;totally&nbsp;deadlocked).</p>

<p>Why is this useful? Well, there are many situations where you can&#8217;t shut a system down properly, but you need to&nbsp;reboot.&nbsp;Examples:</p>

<ul>
<li>You&#8217;ve had a kernel <span class="caps"><span class="caps">OOPS</span></span>, which is not quite a panic but there could be memory corruption in the kernel, things are getting pretty weird, and quite honestly you don&#8217;t want to be running in that condition for any longer&nbsp;than&nbsp;necessary.</li>
<li>You have reason to believe it won&#8217;t be able to shut&nbsp;down&nbsp;properly.</li>
<li>Your system is almost-locked-up (i.e. the&nbsp;above&nbsp;point)</li>
<li>Your <span class="caps"><span class="caps">UPS</span></span> has about 10 seconds worth of&nbsp;power&nbsp;left</li>
<li>Something is on fire (<span class="geshifilter"><code class="geshifilter-text">lp0</code></span>&nbsp;possibly?)</li>
<li>&#8230;Insert other esoteric failure&nbsp;modes&nbsp;here&#8230;</li>
</ul>

<p>In any of those situations, grab a console keyboard, and type Alt+SysRq+s (sync), Alt+SysRq+u (unmount), wait for it to have synced, and finally Alt+SysRq+b (reboot <span class="caps"><span class="caps">NOW</span></span>!).
If you don&#8217;t have a handy keyboard attached to said machine, or are on another continent,&nbsp;you&nbsp;can</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># echo u &gt; /proc/sysrq-trigger</div></div>

<p>In my books, the useful SysRq&nbsp;commands&nbsp;are:</p>

<dl>
<dt>b</dt>
<dd>Reboot</dd>

<dt>f</dt>
<dd>Call the oom_killer</dd>

<dt>h</dt>
<dd>Display SysRq help</dd>

<dt>l</dt>
<dd>Print a kernel stacktrace</dd>

<dt>o</dt>
<dd>Power Off</dd>

<dt>r</dt>
<dd>Set your keyboard to <span class="caps"><span class="caps">RAW</span></span> mode (required after some X breakages)</dd>

<dt>s</dt>
<dd>Sync all filesystems</dd>

<dt>u</dt>
<dd>Remount all filesystems read-only</dd>

<dt>0-9</dt>
<dd>Change console logging level</dd>
</dl>

<p>In fact, read the <a href="http://kernel.org/doc/Documentation/sysrq.txt">rest of the SysRq documentation</a>, print it out, and tape it above your bed.
Next time you reach for the reset switch on a Linux box, stop your self, type the S,U,B sequence, and watch your system come up as if nothing untoward&nbsp;has&nbsp;happened.</p>

<p><strong>Update</strong>: I previously recommended U,S,B but after a bit of digging, I think S,U,B may&nbsp;be&nbsp;correct.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I&#8217;m constantly surprised when I come across long-time Linux users who don&#8217;t know about SysRq.
The Linux Magic System Request Key Hacks are a magic set of commands that you can get the Linux kernel to follow no matter what&#8217;s going on (unless it has panicked or totally&nbsp;deadlocked).</p>

<p>Why is this useful? Well, there are many situations where you can&#8217;t shut a system down properly, but you need to reboot.&nbsp;Examples:</p>

<ul>
<li>You&#8217;ve had a kernel <span class="caps">OOPS</span>, which is not quite a panic but there could be memory corruption in the kernel, things are getting pretty weird, and quite honestly you don&#8217;t want to be running in that condition for any longer than&nbsp;necessary.</li>
<li>You have reason to believe it won&#8217;t be able to shut down&nbsp;properly.</li>
<li>Your system is almost-locked-up (i.e. the above&nbsp;point)</li>
<li>Your <span class="caps">UPS</span> has about 10 seconds worth of power&nbsp;left</li>
<li>Something is on fire (<code>lp0</code>&nbsp;possibly?)</li>
<li>&#8230;Insert other esoteric failure modes&nbsp;here&#8230;</li>
</ul>

<p>In any of those situations, grab a console keyboard, and type Alt+SysRq+s (sync), Alt+SysRq+u (unmount), wait for it to have synced, and finally Alt+SysRq+b (reboot <span class="caps">NOW</span>!).
If you don&#8217;t have a handy keyboard attached to said machine, or are on another continent, you&nbsp;can</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># echo u &gt; /proc/sysrq-trigger</div></div>

<p>In my books, the useful SysRq commands&nbsp;are:</p>

<dl>
<dt>b</dt>
<dd>Reboot</dd>

<dt>f</dt>
<dd>Call the oom_killer</dd>

<dt>h</dt>
<dd>Display SysRq help</dd>

<dt>l</dt>
<dd>Print a kernel stacktrace</dd>

<dt>o</dt>
<dd>Power Off</dd>

<dt>r</dt>
<dd>Set your keyboard to <span class="caps">RAW</span> mode (required after some X breakages)</dd>

<dt>s</dt>
<dd>Sync all filesystems</dd>

<dt>u</dt>
<dd>Remount all filesystems read-only</dd>

<dt>0-9</dt>
<dd>Change console logging level</dd>
</dl>

<p>In fact, read the <a href="http://kernel.org/doc/Documentation/sysrq.txt">rest of the SysRq documentation</a>, print it out, and tape it above your bed.
Next time you reach for the reset switch on a Linux box, stop your self, type the S,U,B sequence, and watch your system come up as if nothing untoward has&nbsp;happened.</p>

<p><strong>Update</strong>: I previously recommended U,S,B but after a bit of digging, I think S,U,B may be&nbsp;correct.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Some Wiki Updates</title>
    <link rel="alternate" type="text/html" href="http://tumbleweed.org.za/2008/01/05/some-wiki-updates" />
    <id>http://tumbleweed.org.za/2008/01/05/some-wiki-updates</id>
    <published>2008-01-05T20:55:05+00:00</published>
    <updated>2008-01-05T20:59:26+00:00</updated>
    <author>
      <name>tumbleweed</name>
    </author>
    <category term="clug" />
    <category term="geekdenner" />
    <category term="mediawiki" />
    <category term="openid" />
    <category term="sysadmin" />
    <category term="wiki" />
    <summary type="html"><![CDATA[<p>I&#8217;ve just spent an afternoon and evening on the local wikis I look after: <a href="http://wiki.clug.org.za/"><span class="caps"><span class="caps">CLUG</span></span></a>, <a href="http://ftwiki.rivera.za.net/">Freedom Toaster</a>, and <a href="http://wiki.geekdinner.org.za/">GeekDinner</a>.</p>

<p>They&#8217;ve all been upgraded to <a href="http://www.mediawiki.org/">MediaWiki</a> 1.11.0, with <a href="http://recaptcha.net/">reCAPTCHA</a> on sign-ups, and <a href="http://openid.net/">OpenID</a>&nbsp;support.</p>

<p>If you are a user of one of these wikis, you can go to Special:OpenIDConvert (<a href="http://wiki.clug.org.za/wiki/Special:OpenIDConvert"><span class="caps"><span class="caps">CLUG</span></span></a>, <a href="http://ftwiki.rivera.za.net/wiki/Special:OpenIDConvert"><span class="caps"><span class="caps">FT</span></span></a>, <a href="http://wiki.geekdinner.org.za/wiki/Special:OpenIDConvert">GeekDinner</a>) to add OpenID to&nbsp;your&nbsp;account.</p>

<p>In the past, the <span class="caps"><span class="caps">CLUG</span></span> wiki has had minimal <a href="http://en.wikipedia.org/wiki/Wiki_spam">wikispam</a>, because we thought up some clever regexes, that blocked spammers from editing. However spammers would still sign up, before they tried to edit. This has left the wiki with over a thousand bogous users. Not that that is a problem in itself, but it becomes a bore when you want to guess somebody&#8217;s wikiname to give them &#8220;Bureaucrat&#8221; status&nbsp;for&nbsp;example.</p>

<p>So <a href="http://jerith.za.net/">jerith</a> talked himself into coding up a quick <span class="caps"><span class="caps">SQL</span></span> query to find all these bogus users, and a python script to remove them. Any history they&#8217;ve had has been assigned to the &#8220;Spammer&#8221; user, and they have been wiped from the wiki. If, in our zealousness, we&#8217;ve deleted any legitimate users who&#8217;ve simply never edited the wiki, we apologise. Maybe if you contribute something, it won&#8217;t happen&nbsp;again&#8230;&nbsp;:-)</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I&#8217;ve just spent an afternoon and evening on the local wikis I look after: <a href="http://wiki.clug.org.za/"><span class="caps">CLUG</span></a>, <a href="http://ftwiki.rivera.za.net/">Freedom Toaster</a>, and <a href="http://wiki.geekdinner.org.za/">GeekDinner</a>.</p>

<p>They&#8217;ve all been upgraded to <a href="http://www.mediawiki.org/">MediaWiki</a> 1.11.0, with <a href="http://recaptcha.net/">reCAPTCHA</a> on sign-ups, and <a href="http://openid.net/">OpenID</a>&nbsp;support.</p>

<p>If you are a user of one of these wikis, you can go to Special:OpenIDConvert (<a href="http://wiki.clug.org.za/wiki/Special:OpenIDConvert"><span class="caps">CLUG</span></a>, <a href="http://ftwiki.rivera.za.net/wiki/Special:OpenIDConvert"><span class="caps">FT</span></a>, <a href="http://wiki.geekdinner.org.za/wiki/Special:OpenIDConvert">GeekDinner</a>) to add OpenID to your&nbsp;account.</p>

<p>In the past, the <span class="caps">CLUG</span> wiki has had minimal <a href="http://en.wikipedia.org/wiki/Wiki_spam">wikispam</a>, because we thought up some clever regexes, that blocked spammers from editing. However spammers would still sign up, before they tried to edit. This has left the wiki with over a thousand bogous users. Not that that is a problem in itself, but it becomes a bore when you want to guess somebody&#8217;s wikiname to give them &#8220;Bureaucrat&#8221; status for&nbsp;example.</p>

<p>So <a href="http://jerith.za.net/">jerith</a> talked himself into coding up a quick <span class="caps">SQL</span> query to find all these bogus users, and a python script to remove them. Any history they&#8217;ve had has been assigned to the &#8220;Spammer&#8221; user, and they have been wiped from the wiki. If, in our zealousness, we&#8217;ve deleted any legitimate users who&#8217;ve simply never edited the wiki, we apologise. Maybe if you contribute something, it won&#8217;t happen again&#8230;&nbsp;:-)</p>
    ]]></content>
  </entry>
  <entry>
    <title>Dovecot shared mailboxes (the correct way)</title>
    <link rel="alternate" type="text/html" href="http://tumbleweed.org.za/2007/10/03/dovecot-shared-mailboxes-the-correct-way" />
    <id>http://tumbleweed.org.za/2007/10/03/dovecot-shared-mailboxes-the-correct-way</id>
    <published>2007-10-03T20:39:30+00:00</published>
    <updated>2008-09-19T07:59:19+00:00</updated>
    <author>
      <name>tumbleweed</name>
    </author>
    <category term="debian" />
    <category term="dovecot" />
    <category term="imap" />
    <category term="imap-namespace" />
    <category term="linux" />
    <category term="shared-mailbox" />
    <category term="sysadmin" />
    <category term="ubuntu" />
    <summary type="html"><![CDATA[<p>I&#8217;ve just implemented shared mailboxes in <a href="http://www.dovecot.org/">dovecot</a> (which rocks, btw). It isn&#8217;t difficult, but I don&#8217;t think it&#8217;s very <a href="http://wiki.dovecot.org/SharedMailboxes">well documented</a>&#8230;</p>

<p>The preferred way to do this is with <span class="caps"><span class="caps">IMAP</span></span> <a href="http://wiki.dovecot.org/Namespaces">Namespaces</a>. My natural approach would be to create something like a Maildir tree <span class="geshifilter"><code class="geshifilter-text">/srv/mail/shared</code></span>, and make this the &#8220;public&#8221; namespace. Then set filesystem permissions on subtrees of that, to define who can see what. Unfortunately, dovecot uses strict Maildir++, and won&#8217;t let you create mailboxes inside each other (on the filesystem) <span class="geshifilter"><code class="geshifilter-text">/Foo/Bar</code></span> is stored as a Maildir called <span class="geshifilter"><code class="geshifilter-text">.Foo.Bar</code></span>, so subtrees don&#8217;t exist, so this isn&#8217;t an option. The up-comming <a href="http://wiki.dovecot.org/MailboxFormat/dbox">dbox</a> format should allow something like this, but it isn&#8217;t&nbsp;usable&nbsp;yet.</p>

<p>My solution was to create multiple namespaces. One for each shared mailbox. Users are given permission to use them via file-system permissions (i.e. group&nbsp;membership),&nbsp;example:</p>

<div class="geshifilter"><div class="css geshifilter-css" style="font-family:monospace;"># Default namespace<span class="sy0">,</span> needed if you add namespaces<br />
namespace private <span class="br0">&#123;</span><br />
&nbsp; &nbsp; prefix <span class="sy0">=</span><br />
&nbsp; &nbsp; separator <span class="sy0">=</span> /<br />
&nbsp; &nbsp; index <span class="sy0">=</span> <span class="kw2">yes</span><br />
<span class="br0">&#125;</span><br />
# Office inbox<span class="sy0">,</span> available to receptionists<span class="sy0">,</span> office managers<span class="sy0">,</span> and directors<span class="sy0">:</span><br />
namespace public <span class="br0">&#123;</span><br />
&nbsp; &nbsp;prefix <span class="sy0">=</span> office/<br />
&nbsp; &nbsp;separator <span class="sy0">=</span> /<br />
&nbsp; &nbsp;location <span class="sy0">=</span> maildir<span class="sy0">:</span>/srv/mail/office/<span class="re1">.Maildir</span><span class="sy0">:</span><span class="caps"><span class="caps">CONTROL</span></span><span class="sy0">=</span>~/.Maildir/control/office<span class="sy0">:</span><span class="caps"><span class="caps">INDEX</span></span><span class="sy0">=</span>~/.Maildir/index/office<br />
&nbsp; &nbsp;<span class="kw2">hidden</span> <span class="sy0">=</span> no<br />
<span class="br0">&#125;</span><br />
# Umask for shared folders<br />
umask <span class="sy0">=</span> 0007</div></div>

<p>Setting <span class="geshifilter"><code class="geshifilter-text">CONTROL</code></span> and <span class="geshifilter"><code class="geshifilter-text">INDEX</code></span> mean that dovecot&#8217;s metadata is stored in the user&#8217;s personal Maildir, so users who don&#8217;t have permission to see the shared mailbox don&#8217;t&nbsp;get&nbsp;errors.</p>

<p>The permissions of the mailbox should be done&nbsp;as&nbsp;follows:</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># touch /srv/mail/office/dovecot-shared<br />
# chown -R mail.office-mailbox /srv/mail/office<br />
# find /srv/mail/office -type d -print0 | xargs -0 chmod 2770 <br />
# find /srv/mail/office -type f -print0 | xargs -0 chmod 660 </div></div>

<p>If you want a common subscription list, you have to&nbsp;manually&nbsp;symlink:</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># ln -s /srv/mail/office/subscriptions ~luser/.Maildir/control/office/</div></div>

<p>Seems to work well. (at least&nbsp;with&nbsp;thunderbird)</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I&#8217;ve just implemented shared mailboxes in <a href="http://www.dovecot.org/">dovecot</a> (which rocks, btw). It isn&#8217;t difficult, but I don&#8217;t think it&#8217;s very <a href="http://wiki.dovecot.org/SharedMailboxes">well documented</a>&#8230;</p>

<p>The preferred way to do this is with <span class="caps">IMAP</span> <a href="http://wiki.dovecot.org/Namespaces">Namespaces</a>. My natural approach would be to create something like a Maildir tree <code>/srv/mail/shared</code>, and make this the &#8220;public&#8221; namespace. Then set filesystem permissions on subtrees of that, to define who can see what. Unfortunately, dovecot uses strict Maildir++, and won&#8217;t let you create mailboxes inside each other (on the filesystem) <code>/Foo/Bar</code> is stored as a Maildir called <code>.Foo.Bar</code>, so subtrees don&#8217;t exist, so this isn&#8217;t an option. The up-comming <a href="http://wiki.dovecot.org/MailboxFormat/dbox">dbox</a> format should allow something like this, but it isn&#8217;t usable&nbsp;yet.</p>

<p>My solution was to create multiple namespaces. One for each shared mailbox. Users are given permission to use them via file-system permissions (i.e. group membership),&nbsp;example:</p>

<div class="geshifilter"><div class="css geshifilter-css" style="font-family:monospace;"># Default namespace<span class="sy0">,</span> needed if you add namespaces<br />
namespace private <span class="br0">&#123;</span><br />
&nbsp; &nbsp; prefix <span class="sy0">=</span><br />
&nbsp; &nbsp; separator <span class="sy0">=</span> /<br />
&nbsp; &nbsp; index <span class="sy0">=</span> <span class="kw2">yes</span><br />
<span class="br0">&#125;</span><br />
# Office inbox<span class="sy0">,</span> available to receptionists<span class="sy0">,</span> office managers<span class="sy0">,</span> and directors<span class="sy0">:</span><br />
namespace public <span class="br0">&#123;</span><br />
&nbsp; &nbsp;prefix <span class="sy0">=</span> office/<br />
&nbsp; &nbsp;separator <span class="sy0">=</span> /<br />
&nbsp; &nbsp;location <span class="sy0">=</span> maildir<span class="sy0">:</span>/srv/mail/office/<span class="re1">.Maildir</span><span class="sy0">:</span><span class="caps">CONTROL</span><span class="sy0">=</span>~/.Maildir/control/office<span class="sy0">:</span><span class="caps">INDEX</span><span class="sy0">=</span>~/.Maildir/index/office<br />
&nbsp; &nbsp;<span class="kw2">hidden</span> <span class="sy0">=</span> no<br />
<span class="br0">&#125;</span><br />
# Umask for shared folders<br />
umask <span class="sy0">=</span> 0007</div></div>

<p>Setting <code>CONTROL</code> and <code>INDEX</code> mean that dovecot&#8217;s metadata is stored in the user&#8217;s personal Maildir, so users who don&#8217;t have permission to see the shared mailbox don&#8217;t get&nbsp;errors.</p>

<p>The permissions of the mailbox should be done as&nbsp;follows:</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># touch /srv/mail/office/dovecot-shared<br />
# chown -R mail.office-mailbox /srv/mail/office<br />
# find /srv/mail/office -type d -print0 | xargs -0 chmod 2770 <br />
# find /srv/mail/office -type f -print0 | xargs -0 chmod 660 </div></div>

<p>If you want a common subscription list, you have to manually&nbsp;symlink:</p>

<div class="geshifilter"><div class="text geshifilter-text" style="font-family:monospace;"># ln -s /srv/mail/office/subscriptions ~luser/.Maildir/control/office/</div></div>

<p>Seems to work well. (at least with&nbsp;thunderbird)</p>
    ]]></content>
  </entry>
</feed>
