<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stuff &#187; Search Results  &#187;  automount</title>
	<atom:link href="http://stuff.iain.cx/search/automount/feed/rss2/" rel="self" type="application/rss+xml" />
	<link>http://stuff.iain.cx</link>
	<description>Dumenil said I should write a blog</description>
	<lastBuildDate>Sun, 22 Feb 2015 12:25:36 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>Automount trickery, submounts, cross-platform stuff etc</title>
		<link>http://stuff.iain.cx/2010/05/12/automount-trickery-submounts-cross-platform-stuff-etc/</link>
		<comments>http://stuff.iain.cx/2010/05/12/automount-trickery-submounts-cross-platform-stuff-etc/#comments</comments>
		<pubDate>Wed, 12 May 2010 21:48:23 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/?p=250</guid>
		<description><![CDATA[Hands up if your home directory is full of crap. Mine is. It has junk going back to 1999. As a measure of just how much junk I have let me tell you that at time of writing my home directory is 20Gb in size. In addition to having eleven years&#8217; worth of files that [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Hands up if your home directory is full of crap.  Mine is.  It has junk going back to 1999.  As a measure of just how much junk I have let me tell you that at time of writing my home directory is 20Gb in size.  In addition to having eleven years&#8217; worth of files that I never got round to deleting, a large chunk of that disk usage comes from my Mac in the form of the <em>Library</em> subdirectory which contains pretty much everything Macs need in a user account as well as my Firefox and Thunderbird profiles.  Needless to say these are huge.</p>
<p>In fact my home directory is only as small as it is because I moved a wodge of files to a separate storage area.  The Documents directory, in which my Mac wants to save &#8230; pretty much anything &#8230; is actually a symlink to <em>/files/iain/Documents</em> which is automounted from somewhere else.  And since my documents are the kind of things which I like to have available all over the place, that same directory is also shared by Samba and my Windows roaming profile knows to go there when I try to open (My) Documents.  Some other directories are similarly shared across operating systems, including Desktop, Pictures and Movies.</p>
<p>I&#8217;d been thinking for a while that it might be better to move these well-known file stores into their own separate ZFS filesystems on my fileserver.  Things came to a head this very evening when I downloaded <a href="http://steampowered.com/">Steam</a> for Mac only to have it refuse to install because <em>Library/Application Support/Steam</em> wasn&#8217;t on a case-insensitive filesystem.  It occurred to me that if <em>Library</em> were its own filesystem as I&#8217;d been considering, I could make it case-insensitive <em>and</em> trim the size of my home directory by a considerable margin.  Although I wouldn&#8217;t advocate actually doing it in so crude a way, I believe that a home directory should be small enough that if you were given a UNIX account on a new system you should be able to get yourself up to speed by quickly transferring your entire home area from another environment.  A home directory should be for dotfiles, SSH keys and the like.  Everything else (real documents) should go Somewhere Else.</p>
<p>Since I use the <a href="/index.php?s=automount">automounter</a> for everything I figured this would be pretty simple.  As it turns out it actually is.  The syntax works with Mac, Solaris and Linux as is documented to a greater or lesser extent in each system&#8217;s AutoFS manpages.  The only potential stumbling block was getting it to work with LDAP but ended up being just as simple as you might hope.</p>
<p>The syntax to have the automounter mount a subdirectory of a configured mount is as follows, in <em>auto.home</em> for instance:</p>
<p>
<pre>    * / files:/export/home/&#038; /Library files:/export/library/&#038;</pre>
</p>
<p>So for all x <em>/home/x</em> will be mounted from <em>fileserver:/export/home/x</em> and <em>/home/x/Library</em> will be mounted from <em>fileserver:/export/library/x</em>.</p>
<p>On Linux I found I didn&#8217;t need the initial / by itself but both Mac and Solaris didn&#8217;t work without it.  Another gotcha was that the <em>Library</em> directory had to actually exist in the original directory for it to be mounted from the specified location.  In other words it wasn&#8217;t sufficient to export <em>/export/home/iain</em> and <em>/export/library/iain</em> from my file server.  I also needed to create <em>/export/home/iain/Library</em> for it to be mounted.</p>
<p>In LDAP speak my <em>auto.home</em> became:</p>
<p>
<pre>    dn: cn=/,ou=auto.home,ou=mounts,dc=iain,dc=cx
    objectClass: automount
    cn: /
    automountInformation: -fstype=nfs,tcp,rw,intr / files:/export/home/&#038;
     /Library files:/export/library/&#038;</pre>
</p>
<p>To automount more subdirectories it suffices to add more bits to the automount entry.</p>
<p>
<pre>    dn: cn=/,ou=auto.home,ou=mounts,dc=iain,dc=cx
    objectClass: automount
    cn: /
    automountInformation: -fstype=nfs,tcp,rw,intr / files:/export/home/&#038;
     /Library files:/export/library/&#038; /Documents files:/export/documents/&#038;</pre>
</p>
<p>And by redirecting my Windows shell folders to point to these filesystems in their CIFS form I can share them between operating systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2010/05/12/automount-trickery-submounts-cross-platform-stuff-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More on Leopard&#8217;s automounter</title>
		<link>http://stuff.iain.cx/2008/01/20/more-on-leopards-automounter/</link>
		<comments>http://stuff.iain.cx/2008/01/20/more-on-leopards-automounter/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 11:58:09 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2008/01/20/more-on-leopards-automounter/</guid>
		<description><![CDATA[I had the Leopard automounter more or less working happily but there was one setback. A combination of Finder&#8217;s and Office&#8217;s braindead behaviour was triggering many many automount lookups which showed in the LDAP logs: filter="(&#038;(&#124;(objectClass=automount))(&#124;(automountKey=.DS_Store)))" filter="(&#038;(&#124;(objectClass=automount))(&#124;(automountKey=.hidden)))" filter="(&#038;(&#124;(objectClass=automount))(&#124;(automountKey=\2A)))" filter="(&#038;(&#124;(objectClass=automount))(&#124;(automountKey=\2A)))" This was because the Mac wanted to see what was under /home, on which home directories [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I had the Leopard automounter more or less working happily but there was one setback.  A combination of Finder&#8217;s and Office&#8217;s braindead behaviour was triggering many many automount lookups which showed in the LDAP logs:</p>
<p>
<pre>    filter="(&#038;(|(objectClass=automount))(|(automountKey=.DS_Store)))"
    filter="(&#038;(|(objectClass=automount))(|(automountKey=.hidden)))"
    filter="(&#038;(|(objectClass=automount))(|(automountKey=\2A)))"
    filter="(&#038;(|(objectClass=automount))(|(automountKey=\2A)))"</pre>
</p>
<p>This was because the Mac wanted to see what was under <code>/home</code>, on which home directories were automounted.  It would be annoying if all it did was fill my LDAP logs with this spam.  When the automounter causes Rebecca&#8217;s machine to kernel panic once every few days, it gets extremely tiresome.</p>
<p>My response to this was to change the automount rules so that <code>/home</code> was managed by <em>auto_static</em> instead of <em>auto_home</em>.</p>
<p>
<pre>    dn: automountKey=/home,automountMapName=auto_static,ou=mounts,dc=iain,dc=cx
    objectClass: top
    objectClass: automount
    automountKey: /home
    automountInformation: -fstype=nfs,tcp,rw,intr files:/home</pre>
</p>
<p>On the Linux clients this worked.  The Macs, however, were having none of it.  With this setup <code>/home</code> was completely inaccessible.  All attempts to look at the directory, even <em>ls -ld</em> failed with Permission Denied.  The solution is to <a href="http://discussions.apple.com/thread.jspa?messageID=5665487">comment out the /home line</a> in <code>/etc/auto_master</code>.</p>
<p>As a poster in the above thread puts it, <em>sigh</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2008/01/20/more-on-leopards-automounter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AutoFS and NFS improvements in Leopard</title>
		<link>http://stuff.iain.cx/2007/12/22/autofs-and-nfs-improvements-in-leopard/</link>
		<comments>http://stuff.iain.cx/2007/12/22/autofs-and-nfs-improvements-in-leopard/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 10:45:12 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2007/12/22/autofs-and-nfs-improvements-in-leopard/</guid>
		<description><![CDATA[It&#8217;s fair to say that I&#8217;ve been disenchanted with my Leopard upgrades. My gripes are documented in these very pages. Recently, though, I&#8217;ve found some stuff in which Leopard is a real improvement over Tiger. NFS NFS support is much improved. NFSv3 with options tcp,rw,intr is massively more reliable. I don&#8217;t remember the last time [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s fair to say that I&#8217;ve been disenchanted with my Leopard upgrades.  My gripes are documented in these very pages.  Recently, though, I&#8217;ve found some stuff in which Leopard is a real improvement over Tiger.</p>
<p><span id="more-95"></span></p>
<h3>NFS</h3>
<p>NFS support is <em>much</em> improved.  NFSv3 with options  <code>tcp,rw,intr</code> is massively more reliable.  I don&#8217;t remember the last time the system completely hung and while it&#8217;s still possible to upset a Mac by killing its NFS server, a Leopard machine can now actually recover &#8211; perhaps with the help of a <code>umount -f</code> &#8211; when the file server comes back.</p>
<p>Leopard even has rudimentary NFSv4 support but this is little more than a novelty given that it has no <em>idmapd</em>, Kerberos doesn&#8217;t appear to work (at least for me, against a known working Red Hat system) and Apple force you to use ridiculous syntax to mount.</p>
<p>
<pre>    # mkdir nfsv4
    # mount -o nfsvers=4 filer:/stuff nfsv4
    mount_nfs: sorry, you must specify vers=4.0alpha to use the alpha-quality NFSv4 support
    # mount -o nfsvers=4.0alpha filer:/stuff nfsv4
    #</pre>
</p>
<h3>AutoFS</h3>
<p>The Leopard automounter is also much better.  Apple&#8217;s proprietary nonsense has been replaced with a real RFC2307bis implementation which is compatible with your existing LDAP rules.</p>
<p>Leopard&#8217;s stock <em>/etc/auto_master</em> looks like this:</p>
<p>
<pre>    #
    # Automounter master map
    #
    +auto_master                # Use directory service
    /net                        -hosts          -nobrowse,nosuid
    /home                       auto_home       -nobrowse
    /Network/Servers    -fstab
    /-                  -static</pre>
</p>
<p>This is interesting for a number of reasons.  First of all it includes a <em>/net</em> entry allowing you to do something like the following, just like on a Linux or Solaris system:</p>
<p>
<pre>    # cd /net/filer/share</pre>
</p>
<p>Secondly you&#8217;ll notice the <em>/Network/Servers</em> entry which ensures back-compatibility with your Tiger mounts.  There&#8217;s also a <em>/home</em> rule which is unexciting in itself but which influenced my choice of mount rules when I was configuring this.</p>
<p>The most important entry in the file is the first one.</p>
<p>
<pre>    +auto_master</pre>
</p>
<p>This tells the automounter to look for a map called <em>auto_master</em> in the directory service.  Let&#8217;s call this the <code>map_name</code>.  Leopard will therefore go and make the following LDAP query:</p>
<p>
<pre>    base="automountMapName=&lt;map_name&gt;,&lt;mount_base&gt;" filter="(&amp;(|(objectClass=automount)))"</pre>
</p>
<p>We&#8217;ve already seen that the <code>map_name</code> is <em>auto_master</em>.  By default the thing I&#8217;ve called <code>mount_base</code> is just the search base configured when the LDAP server was added with <em>Directory Utility</em>.  So on my network that would mean a search base of <strong>automountMapName=auto_master,dc=iain,dc=cx</strong>.</p>
<p>This wasn&#8217;t what I wanted.  My AutoFS mounts were all under <strong>ou=mounts,dc=iain,dc=cx</strong>.  Luckily you can change this in <em>Directory Utility</em> by editing the search base for the <em>Automount</em> and <em>AutomountMap</em> record types.</p>
<h3>Gotcha!</h3>
<p>Now&#8217;s probably a good time to mention that if you configure your LDAP server with <em>macosxodconfig</em>, ie <em>From Server</em> and it was last configured from Tiger, you won&#8217;t have the automount record types and AutoFS won&#8217;t work at all!  It took me a while to figure this one out.  Depending on how many tweaks you&#8217;ve made to the stock mappings you might find it easier to create a brand new LDAP server configuration and re-apply your changes than to retrofit these mappings.</p>
<p>
<pre>    Automount =&gt; automount
        AutomountInformation =&gt; automountInformation
        Comment =&gt; description
        RecordName =&gt; automountKey

    AutomountMap =&gt; automountMap
        Comment =&gt; description
        RecordName =&gt; automountMapName</pre>
</p>
<h3>Another gotcha!</h3>
<p>The AutoFS schema that ships with Linux AutoFS5 has different OIDs for the automount objects to the ones in Apple&#8217;s schema.  I had to <em>slapcat</em> my directory, delete the database, remove the <code>autofs.schema</code> from <em>slapd.conf</em> and <em>slapadd</em> the database so that the entries were catalogued correctly.</p>
<p>Furthermore the <code>apple.schema</code> in Leopard no longer has <em>apple-user-homeDirectory</em> but that&#8217;s OK because you&#8217;ll want to revert the mapping of NFSHomeDirectory to <em>homeDirectory</em> once you have AutoFS working properly.</p>
<h3>Sharing automount entries with Linux</h3>
<p>Now that OS X understands the same mount syntax as everyone else and we have it looking in the same search base, we can ditch (almost) the two copies of every map and share things.  I decided to map <code>/home</code> to <code>auto_home</code> instead of <code>auto.home</code> as I had been, because that way it will actually work out of the box on Leopard even if <code>auto.master</code> doesn&#8217;t.</p>
<p>See, I told you the <code>auto_home</code> line in <em>/etc/auto_master</em> was interesting.</p>
<p>Here&#8217;s my schema.</p>
<p>
<pre>    dn: automountMapName=auto_master,ou=mounts,dc=iain,dc=cx
    automountMapName: auto_master
    objectClass: top
    objectClass: automountMap

    dn: automountKey=/home,automountMapName=auto_master,ou=mounts,dc=iain,dc=cx
    objectClass: top
    objectClass: automount
    automountKey: /home
    automountInformation: auto_home

    dn: automountMapName=auto_home,ou=mounts,dc=iain,dc=cx
    automountMapName: auto_home
    objectClass: top
    objectClass: automountMap

    dn: automountKey=/,automountMapName=auto_home,ou=mounts,dc=iain,dc=cx
    objectClass: top
    objectClass: automount
    automountKey: /
    automountInformation: -fstype=nfs,rw,intr files:/home/&#038;

    dn: automountKey=*,automountMapName=auto_home,ou=mounts,dc=iain,dc=cx
    objectClass: top
    objectClass: automount
    automountKey: *
    automountInformation: -fstype=nfs,tcp,rw,intr files:/home/&#038;</pre>
</p>
<p>Note I have two wildcard rules (hence the comment about <em>almost</em> ditching duplicate entries.  Leopard understands <strong>*</strong> as a wildcard, like in flat files, but my Fedora 7 test clients still want <strong>/</strong> as a wildcard.  In the future they might not need the workaround.</p>
<p>The final step on my Fedora clients was to play with <em>/etc/sysconfig/autofs</em> to uncomment the record mappings corresponding to this schema.  But they might actually be the default on Fedora.  I probably already changed them last time!</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2007/12/22/autofs-and-nfs-improvements-in-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Macs at home; part 7: AFP vs NFS</title>
		<link>http://stuff.iain.cx/2007/09/16/macs-at-home-part-7-afp-vs-nfs/</link>
		<comments>http://stuff.iain.cx/2007/09/16/macs-at-home-part-7-afp-vs-nfs/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 20:47:31 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2007/09/16/macs-at-home-part-7-afp-vs-nfs/</guid>
		<description><![CDATA[See the introduction to this post. It&#8217;s been an eventful day which started and ended with frustration but finishes with a greater understanding of network home directories, a working AFP server and cleartext passwords finally banished. I sent my fileserver down for reboot to install the latest Linux kernel. At this point my iMac, on [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>See the <a href="/2007/08/13/macs-at-home-introduction/">introduction</a> to this post.</p>
<p>It&#8217;s been an eventful day which started and ended with frustration but finishes with a greater understanding of network home directories, a working AFP server and cleartext passwords finally banished.</p>
<p>I sent my fileserver down for reboot to install the latest Linux kernel.  At this point my iMac, on which I had a desktop session, became very very upset.  My home directory is NFS mounted and when the server went away the client became totally unusable.  Even when the server came back up it wouldn&#8217;t re-establish the mounts.</p>
<p>UNIX machines traditionally tend to choke when NFS servers go away but the Mac automounter absolutely refused to come back to life and I had no option but the reboot the machine.  I wondered if AFP home directories would be more reliable.</p>
<p>It turns out they are but there&#8217;s a fatal flaw.  An ssh connection to the machine won&#8217;t mount the AFP home which means they&#8217;re only useful for a desktop session.  At least I did get them working though.</p>
<p><span id="more-67"></span></p>
<h3>Netatalk</h3>
<p>The <em>netatalk</em> software suite contains the AFP server <em>afpd</em> and it was actually very simple to set up.  Two config files were all that were needed.</p>
<p><strong>/etc/netatalk/afpd.conf:</strong></p>
<p>
<pre>    - -noddp -uamlist uams_dhx_pam.so,uams_gss.so \\
      -k5service afpserver -k5keytab /etc/krb5.keytab \\
      -k5realm IAIN.CX -fqdn files.iain.cx:548</pre>
</p>
<p><strong>/etc/netatalk/AppleVolumes.default:</strong></p>
<p>
<pre>    ~ "home" adouble:v2</pre>
</p>
<p>The only daemon that needs to be started is <em>afpd</em> which, with the above configuration, advertises a share called <em>home</em> which maps to the connecting user&#8217;s home directory.</p>
<p>The prerequisites for this are a working <em>/etc/pam.d/netatalk</em> configuration and an entry in <em>/etc/krb5.keytab</em> for <em>afpserver/files.iain.cx</em>.  Users can then authenticate either with PAM (passing a username and password) or Kerberos.</p>
<h3>LDAP configuration</h3>
<p>Users need an <em>apple-user-homeurl</em> entry (mapped to <strong>HomeDirectory</strong> in DirectoryService) of the form:</p>
<p>
<pre>    &lt;home_dir&gt;&lt;url&gt;afp://<em>server</em>/<em>share</em>&lt;/url&gt;&lt;path&gt;<em>username</em>&lt;path&gt;&lt;home_dir&gt;</pre>
</p>
<p>For example:</p>
<p>
<pre>    &lt;home_dir&gt;&lt;url&gt;afp://files/home</em>&lt;/url&gt;&lt;path&gt;iain&lt;path&gt;&lt;home_dir&gt;</pre>
</p>
<p>They still need the <em>apple-user-homeDirectory</em> entry which refers to where the share will be mounted.  If NFS automounts are in use (as they are in my network) you can&#8217;t reuse <em>/Network/Servers</em> so <em>/home/</em>username is a good choice (it will be automatically created as needed).  This, I suppose, is why the default LDAP mappings have NFSHomeDirectory in DirectoryServices mapping to homeDirectory in LDAP&#8230;</p>
<h3>Plaintext passwords banished</h3>
<p>You may recall that I stated that passwords needed to be stored in plaintext because Mac clients tried a CRAM-MD5 bind to the directory server in order to validate a user&#8217;s logon credentials.</p>
<p>This is actually a fallback.  The clients first attempt to authenticate with Kerberos.  The only problem was that I&#8217;m using the Heimdal implementation because of its seamless integration with Samba and by default principals are not allowed to get proxiable tickets.  I tried setting <em>proxiable = false</em> in <em>/Library/Preferences/edu.mit.Kerberos</em> but this flag was not honoured (although it is if you run <em>kinit</em> on the command line).</p>
<p>Heimdal is great because if you tell it you are <em>joebloggs</em> it looks for a user in LDAP with the <em>sambaSamAccount</em> objectClass and compares the password you provide against the NTLM credentials stored for that user.  Effectively this means that you get Kerberos for free when you set up Samba with an LDAP backend.</p>
<p>But if you don&#8217;t also add the <em>krb5KDCEntry</em> objectClass you won&#8217;t be able to change the principal&#8217;s flags which means that the default <em>disallow-proxiable</em> flag will be set for the user and when the Mac comes along and asks for a proxiable ticket the request will be denied.  You won&#8217;t be able to log on even though you got the right password.  And then the Mac tries CRAM-MD5 instead.</p>
<p>The fix was to add some attributes to my user entries.</p>
<p>
<pre>    dn: cn=iain,ou=users,dc=iain,dc=cx
    objectClass: krb5KDCEntry
    krb5PrincipalName: iain@IAIN.CX
    krb5KeyVersionNumber: 1
    krb5KDCFlags: 70</pre>
</p>
<p><em>krb5KDCFlags=70</em> happens to be the default set of flags minus <em>disallow-proxiable</em>.</p>
<p>Now I can authenticate with Kerberos and I don&#8217;t need to store my passwords in plaintext.  Hurrah.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2007/09/16/macs-at-home-part-7-afp-vs-nfs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Macs at home; Part 4: AutoFS</title>
		<link>http://stuff.iain.cx/2007/08/19/macs-at-home-part-4-autofs/</link>
		<comments>http://stuff.iain.cx/2007/08/19/macs-at-home-part-4-autofs/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 21:04:09 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2007/08/19/macs-at-home-part-4-autofs/</guid>
		<description><![CDATA[See the introduction to this post. Last time I hinted at getting automount and DHCP-supplied LDAP settings working. I gave up on DHCP since a) I tried to get it working last year at CacheLogic and failed; b) I couldn&#8217;t find much documentation on it; c) the documentation I did find suggested that it only [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>See the <a href="/2007/08/13/macs-at-home-introduction/">introduction</a> to this post.</p>
<p>Last time I hinted at getting automount and DHCP-supplied LDAP settings working.  I gave up on DHCP since a) I tried to get it working last year at CacheLogic and failed; b) I couldn&#8217;t find much documentation on it; c) the documentation I did find suggested that it only provides an LDAP server and base, which wouldn&#8217;t be sufficient on my network because of the attribute mappings needed to placate DirectoryService.</p>
<p>I did get automount working, however.  And as a special bonus I got it working on a Linux machine too.  Since there isn&#8217;t a massive amount of useful documentation out there for AutoFS and LDAP, I&#8217;ll talk about the Linux configuration here as well as the Mac configuration.</p>
<p><span id="more-54"></span></p>
<p>Automounted home directories are typically used on big networks with many users.  The idea is that you define a mountpoint, say <em>/home</em> and when a user process tries to access a subdirectory of that mountpoint, the automounter dynamically mounts it according to a mapping stored in NIS, flat files (boo, hiss!) or LDAP.  The subdirectory is unmounted again a short time after the last process finishes with it.  In big networks you can use this functionality to have certain users&#8217; home directories stored on different file servers from other users&#8217;.  In smaller networks you might just mount the whole of <em>/home</em> from one server (the benefit of automounting being that you don&#8217;t need to edit the fstab on each client).  And in networks with two clients and two users, automounting redefines overkill.</p>
<p>Sounds like my network!</p>
<h3>Automounting on Mac</h3>
<p>Our old friend the Apple schema defines the <em>mount</em> objectclass which contains the same details we previously stuck in NetInfo.  The schema is fairly self-explanatory if you read Part 2.</p>
<p>
<pre>    dn: cn=files:/home,ou=mounts,dc=iain,dc=cx
    objectClass: mount
    cn: files:/home
    mountType: nfs
    mountOption: net
    mountOption: -P</pre>
</p>
<p>Really quite simple.  The <em>cn</em> is the exported share we&#8217;ll be mounting and since the <em>net</em> option is defined, the place we&#8217;ll be mounting it in is <em>/Network/Servers/files/home</em>.</p>
<p>If you wanted to do a per-user mapping you could have individual entries viz:</p>
<p>
<pre>    dn: cn=files1:/home/user1,ou=mounts,dc=iain,dc=cx
    objectClass: mount
    cn: files1:/home/user1
    mountType: nfs
    mountOption: net
    mountOption: -P</pre>
</p>
<p>
<pre>    dn: cn=files2:/vol/vol1/home/user2,ou=mounts,dc=iain,dc=cx
    objectClass: mount
    cn: files2:/vol/vol1/home/user2
    mountType: nfs
    mountOption: net
    mountOption: -P</pre>
</p>
<p>And so on&#8230;</p>
<h3>Automounting on Linux</h3>
<p>The AutoFS package installed with modern Linux distributions uses a different schema.  Actually it understands two schemas, one being an older format that Solaris used to use.  The one I used is the <em>automountMap</em> type.  Configuring it is a bit more of a black art than the simple Mac way described above.</p>
<p>On the client you edit <em>/etc/nsswitch.conf</em> and set</p>
<p>
<pre>    automount: ldap</pre>
</p>
<p>You also make sure that <em>/etc/ldap.conf</em> is set up correctly.</p>
<p>Upon startup the <em>automount</em> searches for <strong>(&amp;(objectClass=automountMap)(ou=auto.master))</strong> and, assuming such an entry exists, <strong>(objectClass=automount)</strong> under the base it found.  This means that the client requires zero configuration if you create the correct objects in LDAP.</p>
<p>Here&#8217;s the schema I set up:</p>
<p>
<pre>    dn: ou=auto.master,ou=mounts,dc=iain,dc=cx
    ou: auto.master
    objectClass: automountMap

    dn: cn=/home,ou=auto.master,ou=mounts,dc=iain,dc=cx
    cn: /home
    objectClass: automount
    automountInformation: ldap:ou=auto.home,ou=mounts,dc=iain,dc=cx</pre>
</p>
<p>This tells the automounter that it should handle <em>/home</em> and that it should consult <strong>ou=auto.home,ou=mounts,dc=iain,dc=cx</strong> to find out what to do with it.</p>
<p>
<pre>    dn: ou=auto.home,ou=mounts,dc=iain,dc=cx
    ou: auto.home
    objectClass: automountMap

    dn: cn=/,ou=auto.home,ou=mounts,dc=iain,dc=cx
    objectClass: automount
    cn: /
    automountInformation: -fstype=nfs,tcp,rw,intr files:/home/&amp;</pre>
</p>
<p>Here <em>cn=/</em> is a wildcard, meaning whatever is requested under the mapping, and the ampersand in <em>files:/home/&amp;</em> is substituted with the value of the wildcard.</p>
<p>In flat file terms it&#8217;s equivalent to:</p>
<p>
<pre>    * -fstype=nfs,tcp,rw,intr files:/home/&amp;</pre>
</p>
<p>This means that whenever I try to access <em>/home/iain</em>, the automounter will try to mount <em>files:/home/iain</em> and show me what&#8217;s there.</p>
<p>A per-user configuration would, as I&#8217;m sure you can guess, require an LDAP entry such as this:</p>
<p>
<pre>    dn: cn=iain,ou=auto.home,ou=mounts,dc=iain,dc=cx
    objectClass: automount
    cn: iain
    automountInformation: files:/home/iain</pre>
</p>
<p>You&#8217;ll notice that the Mac and Linux configurations aren&#8217;t strictly speaking the same.  The Mac configuration mounts <em>files:/home</em> directly whereas the Linux configuration mounts <em>files:/home/X</em> on demand for all X.  In a large network you&#8217;d want to do things the way I&#8217;ve set up Linux.  On my network I want to do things the way I&#8217;ve set up the Mac.</p>
<p>Ways to get around this:</p>
<ul>
<li>Remove <em>/home</em> and symlink it to <em>/net/files/home</em>.   This would work out of the box with AutoFS.</li>
<li>Undo the NFSHomeDirectory mapping from Part 3 and set up an automount entry for <em>/Network/Servers/files/home</em>; set users&#8217; home directories under there.  In other words adapt the UNIX environment to the Mac, not the other way round.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2007/08/19/macs-at-home-part-4-autofs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macs at home; Part 3: LDAP</title>
		<link>http://stuff.iain.cx/2007/08/17/macs-at-home-part-3-ldap/</link>
		<comments>http://stuff.iain.cx/2007/08/17/macs-at-home-part-3-ldap/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 19:06:41 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2007/08/17/macs-at-home-part-3-ldap/</guid>
		<description><![CDATA[See the introduction to this post. Now I had belsunce and maling configured so that Rebecca and I could log on at either machine and get the same UID and GID for our accounts. Additionally, maling was set up so that users could have NFS home directories. Rebecca&#8217;s account was set up to take advantage [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>See the <a href="/2007/08/13/macs-at-home-introduction/">introduction</a> to this post.</p>
<p>Now I had belsunce and maling configured so that Rebecca and I could log on at either machine and get the same UID and GID for our accounts.  Additionally, maling was set up so that users could have NFS home directories.  Rebecca&#8217;s account was set up to take advantage of this.</p>
<p>The next step is to do away with local accounts on maling altogether (remember that for the moment I&#8217;m keeping local details on the laptop; it could be an LDAP secondary I suppose).  Users there will authenticate against LDAP instead.</p>
<p><span id="more-53"></span></p>
<p>I&#8217;m going to deviate a little from the &quot;this is how to do it on the command line&quot; side of things this time because these steps are a bit of a hassle to do at the terminal.  You can put the configuration in DHCP, apparently, so maybe there will be further episodes with an easier way of doing this stuff.</p>
<p>And in fact I&#8217;m going to deviate a little from the client side altogether.  The stuff below will make more sense with the correct Apple schema installed on our LDAP server.  Any Mac has the latest schema installed in <em>/etc/openldap/schema/apple.schema</em> which just happens to be the default OpenLDAP schema directory.  Copy the schema file into the right place on your LDAP server.  Beware that you might need to edit the file to keep <em>slapd</em> happy.  Perhaps Apple turn off schema checking because the version on belsunce didn&#8217;t actually work.  This was because the <em>apple-user</em> objectclass which it defines referenced some attributes which were commented out or defined later in the file (and hence strictly unavailable).  After sorting all the objectclass definitions to the end of the file and uncommenting attributes I was able to satisfy <em>slapd</em>.  Don&#8217;t forget to check your configuration with <em>slaptest</em>!</p>
<p>Back on the client, the first thing to do is to open <em>Directory Access.app</em> and enable LDAPv3.  Click the Configure button and authenticate.  You&#8217;ll need to click New to tell the tool about the new LDAP server.  At this point a box pops up for you to enter the server details.  With my setup this just hangs forever after entering the LDAP address so I would hit Manual.</p>
<p>You then have the chance to enter a Configuration Name which can be anything.  Use your domain name or something.  The Server Name or IP Address is the name or IP of the LDAP server.  The LDAP Mappings is interesting.  Choose RFC2307 for now.  You&#8217;re prompted for your search base which you should now enter.  If you don&#8217;t know what to put here you shouldn&#8217;t be reading this post.</p>
<p>Click OK and fire up a terminal to see what we&#8217;ve done so far.</p>
<p>Readers who&#8217;ve been following this series might expect that the details of the server you just added will be visible to <em>dscl</em>.  In the output below I&#8217;m going to substitute the actual names with the headings from the <em>Directory Access.app</em> configuration to show how they&#8217;re mapped.</p>
<p>
<pre>    $ dscl localhost -read LDAPv3/<em>Server Name or IP Address</em>
    TrustInformation: Anonymous Encryption
    AuthMethod: dsAuthCrypt dsAuthClearText dsAuthNodeNativeCanUseClearText dsAuthNodeNativeCannotUseClearText
    AccountName: No Account Name
    NodePath: LDAPv3 <em>Server Name or IP Address</em>
    ReadOnlyNode: ReadWrite
    RecordType: Groups CertificateAuthorities Mounts Users People
    RealName: <em>Configuration Name</em></pre>
</p>
<p>You can now also search for LDAP users.  Let&#8217;s assume from now on that my LDAPv3 <em>Server Name or IP Address</em> was ldap.iain.cx.</p>
<p>
<pre>    $ dscl localhost -list /LDAPv3/ldap.iain.cx/Users
    iain
    maling
    ...</pre>
</p>
<p>These users are, however, not yet accessible to DirectoryService and hence cannot authenticate.  Back in <em>Directory Access.app</em> you can select the Authentication pane, set Search to Custom path and Add the NetInfo path /LDAPv3/ldap.iain.cx.</p>
<p>By the way the file changed is <em>/Library/Preferences/DirectoryService/SearchNodeConfig.plist</em>.</p>
<p>After applying the configuration you should be able to see the users.</p>
<p>
<pre>    $ dscl localhost -read /Search/Users/maling
    cn: maling
    description: Rebecca Ma
    displayName: Rebecca Ma
    gecos: Rebecca Ma
    gidNumber: 100
    homeDirectory: /home/maling
    loginShell: /bin/bash
    objectClass: person inetOrgPerson posixAccount shadowAccount sambaSamAccount
    sn: Ma
    uid: maling
    uidNumber: 314
    AppleMetaNodeLocation: /LDAPv3/ldap.iain.cx
    Comment: Rebecca Ma
    NFSHomeDirectory: /home/maling
    PasswordPlus: ********
    PrimaryGroupID: 100
    RealName: maling
    RecordName: maling
    RecordType: dsRecTypeStandard:Users
    UniqueID: 314
    UserShell: /bin/bash</pre>
</p>
<p>
<pre>    $ id maling
    uid=314(maling) gid=100(users) groups=100(users)</pre>
</p>
<p>This looks mostly OK but if you read Part 2 you might guess what&#8217;s bad about the following:</p>
<p>
<pre>    NFSHomeDirectory: /home/maling</pre>
</p>
<p>NFSHomeDirectory is actually the local mountpoint, not the server export of the home directory.  This isn&#8217;t going to work because there is no <em>/home/maling</em> on the Mac.</p>
<p>
<pre>    ls ~maling
    ls: /home/maling: No such file or directory</pre>
</p>
<p>The fix for this is to set up an attribute mapping which will translate attributes  in the LDAP schema to key names as understood by DirectoryService.</p>
<p>Back in <em>Directory Access.app</em>, Edit the LDAPv3 you added and open the Search &amp; Mappings pane.  It should still say Access this LDAPv3 server using RFC2307 (Unix) because no changes have been made.</p>
<p>Below are two columns.  On the left, Record Types and Attributes; these are the DirectoryService names for things.  On the right, the items Map to their LDAP equivalents.</p>
<p>Expand Users and find NFSHomeDirectory.  This maps to homeDirectory in LDAP.  Well it shouldn&#8217;t do.  According to the Apple documentation, the correct attribute in their schema is <em>apple-user-homeDirectory</em>.  We Delete homeDirectory from the mapping and Add apple-user-homeDirectory in its stead.  Notice that RFC2307 is now Custom after making the change.</p>
<p>Incidentally the file that is edited by playing with this graphical tool is <em>/Library/Preferences/DirectoryService/DSLDAPv3PlugInConfig.plist</em>.</p>
<p>Of course we still need to add this information to Rebecca&#8217;s user information in LDAP.  This means adding the following attributes.</p>
<p>
<pre>    dn: cn=maling,ou=users,dc=iain,dc=cx
    objectclass: <strong>apple-user</strong>
    apple-user-homeDirectory: <strong>/Network/Servers/files/home/maling</strong></pre>
</p>
<p>Go back and read Part 2 if you are wondering where I got the path from.</p>
<p>Now things look better.</p>
<p>
<pre>    $ dscl localhost -read /Search/Users/maling NFSHomeDirectory
    NFSHomeDirectory: /Network/Servers/files/home/maling</pre>
</p>
<p>Rebecca should be able to log on.  But note that the Mac will attempt to verify her password by making a SASL bind to the LDAP server using the CRAM-MD5 mech.  This means you need a line in <em>slapd.conf</em>:</p>
<p>
<pre>    sasl-regexp ^uid=(.*),cn=cram-md5,cn=auth$ cn=$1,ou=users,dc=iain,dc=cx</pre>
</p>
<p>And since CRAM-MD5 requires a plaintext password in the directory, she needs a <em>userPassword</em> in clear text.</p>
<h3>Some more tricks</h3>
<p>You can set a user picture in LDAP.  This is used in the fast user switching menu and for the default Mail, Address Book and iChat avatar.  The picture must be in TIFF format and the attribute to set is <strong>apple-user-picture</strong>.  It should be mapped to the <strong>Picture</strong> attribute.  Because Rebecca had previously set a user picture for her NetInfo account, I was able to copy it from <em>maling:/Library/Caches/com.apple.user501pictureCache.tiff</em> to <em>files:/home/shared/maling.tiff</em> and set:</p>
<p>
<pre>    dn: cn=maling,ou=users,dc=iain,dc=cx
    apple-user-picture: /Network/Servers/files/home/shared/maling.tiff</pre>
</p>
<p>Kerberos works more or less out of the box.  Copy your UNIX <em>/etc/krb5.conf</em> to <em>/Library/Preferences/edu.mit.Kerberos</em> (the file is called edu.mit.Kerberos).  If DNS works the file can be as simple as:</p>
<p>
<pre>    [libdefaults]
      default_realm = IAIN.CX</pre>
</p>
<p>And install a server keytab in <em>/etc/krb5.keytab</em> as usual.</p>
<p><em>sshd</em> works with no changes needed.  I haven&#8217;t looked at <em>LoginWindow</em> yet (<em>/etc/authorization</em>).</p>
<p>Assuming I get it working, I&#8217;ll post about DHCP and LDAP automounts next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2007/08/17/macs-at-home-part-3-ldap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macs at home; Part 2: NFSHomeDirectory</title>
		<link>http://stuff.iain.cx/2007/08/13/macs-at-home-part-2-nfshomedirectory/</link>
		<comments>http://stuff.iain.cx/2007/08/13/macs-at-home-part-2-nfshomedirectory/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 21:55:18 +0000</pubDate>
		<dc:creator><![CDATA[iain]]></dc:creator>
				<category><![CDATA[Geekiness]]></category>

		<guid isPermaLink="false">http://stuff.iain.cx/2007/08/13/macs-at-home-part-2-nfshomedirectory/</guid>
		<description><![CDATA[See the introduction to this post. Since I sometimes take my MacBookPro out with me it makes sense that I have a local user account to log on. Rebecca&#8217;s Mac Mini, on the other hand, never leaves the house. It&#8217;s a prime candidate for mounting user home directories over NFS. To do this we need [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>See the <a href="/2007/08/13/macs-at-home-introduction/">introduction</a> to this post.</p>
<p>Since I sometimes take my MacBookPro out with me it makes sense that I have a local user account to log on.  Rebecca&#8217;s Mac Mini, on the other hand, never leaves the house.  It&#8217;s a prime candidate for mounting user home directories over NFS.</p>
<p>To do this we need our friend the automounter.  Automounts <em>can</em> be configured in old-skool flat files.  They <em>can</em> be imported from LDAP or NIS with the DirectoryService.  Or they can be taken direct from NetInfo.  That&#8217;s what we&#8217;ll use here.</p>
<p><span id="more-51"></span></p>
<p>Automounts go into NetInfo (under /mounts) as a record whose name is the path to the export, in the form <em>server:/path</em>.  You can create them with <em>/Applications/Utilities/Directory Access.app</em> (I believe this is due to be renamed in OS X 10.5) and there are several documents floating around the internet describing how to use that tool.  If you understood <a href="/2007/08/13/macs-at-home-part-1-three-ways-to-do-the-same-thing/">Macs at home; Part 1</a> you will probably have guessed that it&#8217;s pretty simple to use <em>nicl</em> to set up an automount.</p>
<p>The homedirectories on files are exported as /home so our automount is created like so:</p>
<p>
<pre>    # nicl -create . /mounts/files:\\\\/home</pre>
</p>
<p>Note the double backslash between files: and /home.  This is to escape the / lest  <em>nicl</em> interpret it as a separator in the NetInfo hierarchy.  The second backslash protects the first from being eaten by the shell.</p>
<p>
<pre>    # nicl . -append /mounts/files:\\\\/home vfstype nfs</pre>
</p>
<p>This defines the mount as an NFS share.</p>
<p>
<pre>    # nicl . -append /mounts/files:\\\\/home opts -P</pre>
</p>
<p>This line instructs <em>automount</em> to add the <em>-P</em>option to mount calls when trying to mount the share.  The <em>-P</em> option specifies that a privileged local port should be used.  This is required by the NFS daemon on files.  It might not be needed on your network.  Try it if your NFS server gives a permission denied error when you try to mount the share.</p>
<p>
<pre>    # nicl . -append /mounts/files:\\\\/home opts net</pre>
</p>
<p>The <em>net</em> option instructs <em>automount</em> to mount the share under <em>/Network/Servers</em>.  Since the share is <em>files:/home</em> it will be mounted at <em>/Network/Servers/files/home</em>.</p>
<p>Without the <em>net</em> option you would need to add a <em>dir</em> option with the key being the local mountpoint where the share should be mounted.  The problem in this situation is that you then have to choose between mounting <em>/home</em> over <em>/Users</em> &#8211; thus trashing local home directories &#8211; or adding one automount for each user.</p>
<p>The only remaining step is to restart <em>automount</em>.</p>
<p>
<pre>    # killall -HUP automount</pre>
</p>
<p>The contents of <em>/home</em> on files will now be available at <em>/Network/Servers/files/home</em> and in particular Rebecca&#8217;s home directory is at <em>/Network/Servers/files/home/maling</em>.</p>
<p>There is one sticking point, however.  The system expects Rebecca&#8217;s home directory to be at <em>/Users/maling</em>.  This can be fixed with our old friend <em>dscl</em>.</p>
<p>
<pre>    # dscl localhost -create /NetInfo/Users/maling NFSHomeDirectory /Network/Servers/files/home/maling</pre>
</p>
<p><strong>Update 2007-10-31:</strong> On Leopard the syntax is:</p>
<p>
<pre>    # dscl localhost -create /Local/Default/Users/maling NFSHomeDirectory /Network/Servers/files/home/maling</pre>
</p>
<h3>Auto login</h3>
<p>I did have Rebecca&#8217;s Mac Mini set up to automatically log on her user account without requiring a password.  This won&#8217;t work with an NFS home directory, presumably because the LoginWindow races with <em>automount</em> and starts the window manager before the NFS share is mounted.  The Mini now boots up to a username and password prompt.</p>
<p>This isn&#8217;t a massive issue.  After all we now have a machine that is only a few steps away from being usable by multiple users so it makes sense that you&#8217;d have to specify <em>which</em> user was at the console.  Speaking of which, my next post will discuss LDAP authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuff.iain.cx/2007/08/13/macs-at-home-part-2-nfshomedirectory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
