Документ взят из кэша поисковой машины. Адрес оригинального документа : http://hea-www.harvard.edu/~fine/OSX/autofs-repl-fix.html
Дата изменения: Unknown
Дата индексирования: Sun Apr 10 09:01:01 2016
Кодировка:

Поисковые слова: clouds
Fixing Leopard Autofs for NIS Replicated Servers April 14, 2008

NOTE (December 2009): This bug has been fixed in Snow Leopard (10.6)

Fixing Leopard Autofs for NIS Replicated Servers

Replicated servers are autofs map entries that list multiple locations from which a resource can be mounted. These are some examples:
foo	-ro,hard,intr	host1:/path1/& host2:path2/& host3:path3/foo_orig
bar	-ro,hard,intr	host1,host2,host3:/path/&
baz	-ro,hard,intr	host1,host2:/path1/& host3:path3/baz_orig

When the automounter sees an entry like this and tires to mount it, it's supposed to figure out which host is the "closest" and mount from that one. If that host is unavailable, it tries the next closest one. Furthermore, once filesystem is mounted, if the server has a problem and goes offline, the kernel has a mechanism by which it can fail over to another server, seamlessly.

[As of June '08 it's been reported to me (by an apparently reliable source) that OS X does not support this failover, which isn't surprising (I don't know of Linux versions that do either). But failing to failover isn't a showstopper, just a nuisance.]

Under Leopard 10.5.1 and 10.5.2 (so far), this does not work. Fortunately, Apple graciously makes portions of their code available, including autofs, so we were able to fix this problem. You'll need to become an Apple Developer Connection member to download autofs, but this is free. We downloaded the autofs-109 tarball (you can also browse the files) from under the 10.5.2 tree, and our patches are based on this version.

(Note that the information below has been passed on to Apple, so in theory a future release of OS X will not have these bugs!)

Fixing

What we found in the source code is that whoever wrote the replicated server code was a bit confused about the difference between the simple internet address format found in a hostent structure, and the more complicated internet address information of a sockaddr structure. We fixed two bugs springing from this misunderstanding, one in nfs_cast.c, and one in autod_nfs.c. We have two patch files available for patching these: nfs_cast.patch and autod_nfs.patch.

Apply these patches to the files in autofs-109/automountd/, and then rebuild.

Building

You'll need to have Xcode installed on your Mac to build this. autofs-109 does include autofs.xcode in the top directory that you can use for the build, however there are some outside components missing, so the build won't work out of the box. There are several components missing, but you don't have to build all of autofs; you'll only need to build a new automountd (/usr/libexec/automountd), and for this you only need an extra include file, mntopts.h, which can be found in another Apple open source package, libutil (we used libutil-11 under 10.5.2 -- download tarball or browse).

I'm not much of an Xcode guru, but by hacking and thrashing about a bit I got it to compile. What I did is stick mntopts.h into the autofs-109/header directory. Then I edited the files that used to instead use "mntopts.h". This wasn't quite sufficient. I also had to add this file to the project -- under Project menu, select "Add to Project", and select this file.

The Xcode build still fails, but it gets past automountd, which is successfully built. You can then copy it out of the build directory (build/Development/automountd, in our case since we had it set up for a Development build) and into /usr/libexec/automountd. I suggest you save a copy of the original automountd in case something goes horribly wrong.

Using

It's worked great for us so far. If you have replicated server entries in your NIS maps, it should work for you too.

We haven't tested if there is any kind of failover [reportedly, no, see above], so for us that remains to be seen. However getting the Leopard OS X to use our maps in the general case has made it all worth while.


More Mac OS X Stuff


Tom Fine's Home Send Me Email