13.07.2015 Views

Hacking the Linux Automounter

Hacking the Linux Automounter

Hacking the Linux Automounter

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Proceedings of <strong>the</strong><strong>Linux</strong> SymposiumVolume TwoJuly 19th–22nd, 2006Ottawa, OntarioCanada


Conference OrganizersAndrew J. Hutton, Steamballoon, Inc.C. Craig Ross, <strong>Linux</strong> SymposiumReview CommitteeJeff Garzik, Red Hat SoftwareGerrit Huizenga, IBMDave Jones, Red Hat SoftwareBen LaHaise, Intel CorporationMatt Mackall, Selenic ConsultingPatrick Mochel, Intel CorporationC. Craig Ross, <strong>Linux</strong> SymposiumAndrew Hutton, Steamballoon, Inc.Proceedings Formatting TeamJohn W. Lockhart, Red Hat, Inc.David M. Fellows, Fellows and Carr, Inc.Kyle McMartinAuthors retain copyright to all submitted papers, but have granted unlimited redistribution rightsto all as a condition of submission.


<strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitationsand Future DirectionsIan Maxwell KentRed Hat, Inc.ikent@redhat.comJeff MoyerRed Hat, Inc.jmoyer@redhat.comAbstractThe IT industry is experiencing a considerableshift from proprietary operating systemsto <strong>Linux</strong>. As a result, <strong>the</strong> features and functionalitythat people have come to expect of<strong>the</strong>se systems now must be provided for on<strong>Linux</strong>. An automounter provides a mechanismfor automatically mounting file systems uponaccess, and umounting <strong>the</strong>m when <strong>the</strong>y are nolonger referenced. The <strong>Linux</strong> automounter isnot feature-complete and <strong>the</strong>re are cases where<strong>Linux</strong> autofs is just plain incompatible with implementationsfrom o<strong>the</strong>r proprietary vendors.In order to solve <strong>the</strong> current automounter limitations,we start by developing an understandingof how things work today. We explain<strong>the</strong> basic configuration of autofs for a clientmachine using simple examples. Then walkthrough <strong>the</strong> <strong>the</strong> internals for basic operations,such as <strong>the</strong> mounting, or lookup, of a directoryand <strong>the</strong> umounting, or expiry, of a directory.This includes a description of where autofsfits into <strong>the</strong> VFS layer. Next we discuss<strong>the</strong> two main deployment difficulties. The firstis that <strong>the</strong> <strong>Linux</strong> automounter implements directmount maps in a way that is incompatiblewith that of every o<strong>the</strong>r implementation.We discuss <strong>the</strong> desired behavior and compareit with that of <strong>the</strong> <strong>Linux</strong> automounter. We will<strong>the</strong>n discuss <strong>the</strong> current development effort toovercome this by extending autofs and its kernelinterface. The second major problem surrounds<strong>the</strong> use of multi-mount entries for <strong>the</strong>/net, or -hosts mount maps. Because of<strong>the</strong> nature of multi-mount maps, <strong>the</strong> <strong>Linux</strong> implementationmounts and umounts <strong>the</strong>se directoryhierarchies as a single unit. This meansthat clients mounting exported filesystems fromlarge servers can experience resource starvation,causing failed mounts. The root problemis described and we show how <strong>the</strong> kernel and<strong>Linux</strong> automounter can be modified to addressthis issue also. We conclude with a review of<strong>the</strong> progress of <strong>the</strong> work outlined above andgive a summary of future directions.1 IntroductionWith even a modest amount of information,network clients often need many mount entriesin <strong>the</strong>ir tables to make <strong>the</strong> organization’s informationavailable. To make matters worse, <strong>the</strong>mount tables often change. The administrativeoverhead is not workable. This leads to heavyuse of an automounter in many enterprises.An automounter provides <strong>the</strong> ability to managemount tables centrally, automatically mountingentries on demand and umounting <strong>the</strong>m aftera predefined period of inactivity. In addition to<strong>the</strong> reduction in administrative overhead, an automounterprovides a dramatic reduction in <strong>the</strong>


2006 <strong>Linux</strong> Symposium, Volume Two • 47mount-optionsmount-options is an optional comma separatedlist of mount options to be applied to<strong>the</strong> entries in <strong>the</strong> map unless entries in <strong>the</strong>map specify <strong>the</strong>ir own options.Lines beginning with a # are comments and areignored. Long lines may be broken by quoting<strong>the</strong> new line character with a backslash, as iscommon practice in configuration files.The special mount point /- is reserved to indicatethat <strong>the</strong> map is a direct mount map and isnot associated with any specific top-level directory.2.2 Mount mapsMount maps consist of two types—indirect anddirect—and have <strong>the</strong> following basic format:keykey [mount-options] locationkey is <strong>the</strong> name used to look up mount tableentries in <strong>the</strong> map. For indirect mountentries, this is <strong>the</strong> name of <strong>the</strong> directoryupon which <strong>the</strong> mount will be made. Fordirect mount entries, this is <strong>the</strong> full pathleading to <strong>the</strong> directory upon which <strong>the</strong>mount will be made.mount-optionsmount-options is an optional commaseparatedlist of mount options to be appliedto <strong>the</strong> map entry.locationlocation specifies <strong>the</strong> file system that is tobe mounted on key. It can be a single filesystem or a number of file systems to selectfrom using availability and proximitymetrics. It may also consist of multiplekey [mount-options] locationoffsets that each must start with a slash (/).If <strong>the</strong> first offset is /, <strong>the</strong>n it is optional.These offset mount entries are referred toas multi-mount entries in <strong>Linux</strong> autofs.There are a number of standard macro substitutionsavailable for use in location specifications.They are commonly used in multiple architectureenvironments. A description of thosenormally available can be found in [2] on page190. For those understood by <strong>Linux</strong> autofs, seeautofs(5).As in <strong>the</strong> master map, lines beginning with a #are comments and are ignored, and long linesmay be broken by quoting <strong>the</strong> new line characterwith a backslash.A map key of * denotes a wild-card entry. Thisentry is consulted if <strong>the</strong> specified key does notexist in <strong>the</strong> map. A typical wild-card entrylooks like this:* server:/export/home/&The special character & will be replaced by <strong>the</strong>provided key. So, in <strong>the</strong> example above, alookup for <strong>the</strong> key foo would yield a mount ofserver:/export/home/foo.The timeout on mounts points defaults to tenminutes and can be changed using a commandline option when <strong>the</strong> service is started.3 <strong>Linux</strong> automounter—autofsThe <strong>Linux</strong> automounter differs in relatively fewways from traditional Unix automounter implementations.In fact, all of <strong>the</strong> information providedin <strong>the</strong> last sections regarding configurationdata apply to <strong>the</strong> <strong>Linux</strong> automounter as


48 • <strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitations and Future Directionswell. This section begins with a description of<strong>the</strong> <strong>Linux</strong>-specific details of <strong>the</strong> master map,and <strong>the</strong>n moves on to <strong>the</strong> architecture of <strong>the</strong><strong>Linux</strong> automounter.3.1 <strong>Linux</strong> autofs master mapThe <strong>Linux</strong> autofs master map syntax is a superset of <strong>the</strong> standard automount master map syntax.This is partly because <strong>Linux</strong> autofs doesnot utilize <strong>the</strong> name service switch to locate <strong>the</strong>source of maps and so must allow it to be specified.The syntax is:mount-point \[maptype:]map-name \[mount-options]The fields above are <strong>the</strong> same as those describedin Section 2.1 (“The master map”), exceptfor <strong>the</strong> maptype, which can be one offile, program, yp, nisplus, hesiod orldap. The daemon supports <strong>the</strong> specificationof a map format within <strong>the</strong> maptype parameter.It can be sun or hesiod, but <strong>the</strong> initscript doesn’t cater for it. The default formatis sun, and it is a subset of <strong>the</strong> standard sunautomount map format. <strong>Linux</strong> autofs understandsmuch of this map format, and when a fullimplementation of direct mounts is added, <strong>the</strong>only things missing will be special maps suchas <strong>the</strong> -hosts and -null.3.2 ArchitectureThe automounter is implemented in two mainparts: a user-space daemon, which is responsiblefor parsing map options and issuing mountand umount commands, and a filesystem, implementedin <strong>the</strong> kernel. The daemon is fur<strong>the</strong>rbroken up into <strong>the</strong> daemon proper and a set ofloadable modules. To understand how <strong>the</strong> daemonoperates, we will walk through <strong>the</strong> daemonstartup for a minimal setup.Consider <strong>the</strong> following auto.master map:/net/etc/auto.netWe will not show <strong>the</strong> contents of <strong>the</strong> programmap, auto.net, as it is shipped with autofs.Autofs startup begins with <strong>the</strong> init script.This script parses <strong>the</strong> auto.master map andspawns one automount daemon for each mountpoint listed. The example given above will resultin an automount command with <strong>the</strong> followingparameters:/usr/sbin/automount \/net program /etc/auto.netAs shown above, <strong>the</strong> daemon takes as its optionsa mount point, <strong>the</strong> type of <strong>the</strong> map to beloaded, and <strong>the</strong> name of <strong>the</strong> map to be loaded.Now we will look at <strong>the</strong> loadable modules.There are three types of modules: lookup,parse, and mount. Lookup modules are usedto look up a given key in a map. The lookupmodule has code that understands how to getinformation from a map source. For example,lookup_file.so is able to read in entriesfrom a file map. Map entries are storedas a key value pair. The key, as noted above,corresponds to a directory. The parse moduleis <strong>the</strong>n responsible for parsing <strong>the</strong> value part of<strong>the</strong> key value pair. Finally, <strong>the</strong> mount moduletakes care of doing <strong>the</strong> actual mounting. Thismodule has to know how to pass arguments onto <strong>the</strong> mount command. In <strong>the</strong> case of NFS, thismodule is also responsible for parsing replicatedserver entries.Returning to <strong>the</strong> example above, <strong>the</strong> daemonknows that it needs to load <strong>the</strong> lookup_


2006 <strong>Linux</strong> Symposium, Volume Two • 49program module, since <strong>the</strong> program map typewas specified in <strong>the</strong> command line. It calls<strong>the</strong> module’s lookup_init routine, passing amap format (or none, in this case), and all argumentsthat <strong>the</strong> daemon itself did not process.These leftover arguments are considered to bemap arguments.The lookup module will perform its initializationand hand a context pointer back to <strong>the</strong>caller. Before returning, though, it loads <strong>the</strong>parse module, calling its parse_init function.It <strong>the</strong>n passes <strong>the</strong> map format down, aswell as any options it did not handle. The parsemodule will load <strong>the</strong> mount_nfs module, if ithasn’t already been loaded. This module is alwaysloaded, since <strong>the</strong> primary file system typemounted via autofs has historically been NFS.3.3 Multi-mountsMulti-mount entries allow <strong>the</strong> user to specify adirectory hierarchy that will be mounted. Forexample:net generates multi-mount entries on <strong>the</strong>fly, and <strong>the</strong> daemon mounts <strong>the</strong>m when/net/ is accessed. The is used as <strong>the</strong> key.3.4 VFS interfaceTo understand <strong>the</strong> kernel interface used by autofs,it is necessary to know a little about <strong>the</strong>Virtual Filesystem Switch (VFS). The VFS is asoftware layer that handles all system calls relatedto standard Unix file systems. It does thisby defining several data structures that containinformation about <strong>the</strong> file system and objectsthat provide callback functions. The VFS uses<strong>the</strong> callback functions to carry out standard filesystem operations. The primary objects are <strong>the</strong>superblock, <strong>the</strong> inode, <strong>the</strong> dentry, and <strong>the</strong> fileobject. For <strong>the</strong> interested reader, a descriptionof <strong>the</strong> VFS, its data structures, and <strong>the</strong> operations<strong>the</strong>y define can be found in Chapter 12 of[7].mydir -rw \/ server:/export/mydir \/src server2:/export/home/src \/tmp :/usr/tmpThis example demonstrates how to cobble toge<strong>the</strong>ra single directory structure from multipleservers. One point to note here is that<strong>the</strong> mydir directory contains both an NFSmountedfile system, and mount points beneathit.Currently, when any directory in this hierarchyis accessed, <strong>the</strong> automount daemon mounts everyentry in <strong>the</strong> directory hierarchy. The expiryof a multi-mount entry also happens atomically.This is <strong>the</strong> mechanism used to implement-hosts. The program map auto.The dentry object represents a single componentof a directory path. One of <strong>the</strong> main functionsof <strong>the</strong> VFS is to resolve a given file systempath to its dentry by walking each of its pathcomponents.The VFS kernel interface of autofs is conceptuallystraightforward. The automount functionalityis provided largely in <strong>the</strong> inode operationlookup to lookup a new dentry, <strong>the</strong> dentry operationrevalidate to revalidate an existing dentry,<strong>the</strong> file operation readdir to read a dentrydirectory, and with a file system specific ioctlto check for dentrys that have not been used fora given timeout.The bulk of <strong>the</strong> work done in autofs is <strong>the</strong>mounting and expiring of file systems.


52 • <strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitations and Future Directionsoption [4]. A code review is needed to establishwhe<strong>the</strong>r o<strong>the</strong>r services, such as mountd andportmap, can be configured to allow insecureports for <strong>the</strong>ir connections. But of course, usinginsecure ports is generally not a good idea.Autofs and mount also perform RPC probing todiscover whe<strong>the</strong>r <strong>the</strong> target server is availablebefore performing a mount. This process leadsto as many as nine ports per mount being usedduring a mount, which causes rapid exhaustionof reserved port space. The RPC port allocationalgorithm allows for a maximum of 800concurrently mounted file systems when usingUDP.The situation is somewhat different with TCP.For each TCP mount attempt, a client usesmultiple reserved ports, and each TCP socketmust transition through <strong>the</strong> TIME_WAIT stateto ensure <strong>the</strong> completion of <strong>the</strong> TCP three-wayhandshake. This process ensures that lost duplicatesdon’t cause errors on subsequent connections.The TIME_WAIT state is 2*MSL (maximumsegment lifetime) [3, Ch. 2, Sec. 7],which is 60 seconds for <strong>the</strong> <strong>Linux</strong> TCP stack.After this timeout, <strong>the</strong>se reserved ports are freefor use again.This leads to a practical limit of around 100TCP protocol mounts performed in rapid succession.If <strong>the</strong> mounts are performed muchmore slowly, as is expected in normal operation,this number is somewhat larger. Never<strong>the</strong>less,it generally falls somewhat short of <strong>the</strong><strong>the</strong>oretical limit of 800 before port allocationproblems appear.4.4 Handling multi-mountsMulti-mounts were discussed in Section 3.3.These map entries must be handled atomically,mounted and umounted as a single unit. Problemsarise when using <strong>the</strong> auto.net programmap if <strong>the</strong> servers have a large number of exports,or if <strong>the</strong>re are a large number of mountpoint offsets in a multi-mount entry. They mustbe handled as a single unit due to possible nestingdependencies within <strong>the</strong> mount hierarchy.The anonymous device and reserved port exhaustiondescribed in previous sections are <strong>the</strong>source of <strong>the</strong> problem. We will present a partialsolution to this problem in Section 6, wherelazy mount/umount of multi-mount map entriesis described. Even with <strong>the</strong> improvements <strong>the</strong>reis still a limit on <strong>the</strong> total number of mounts thatcan be active at any one time due to resourceexhaustion. The only real solution to this problemis multiplexing of RPC connections.4.5 Parsing nsswitch.confCurrently, <strong>the</strong> <strong>Linux</strong> automounter does onlylimited parsing of <strong>the</strong> nsswitch.conf file. Itis only referenced when trying to locate <strong>the</strong>master map during startup. The script justchecks what sources are present in <strong>the</strong> automountentry in nsswitch.conf, and looks for<strong>the</strong> auto.master map in each location.There are a couple of reasons for this. First, allo<strong>the</strong>r consumers of <strong>the</strong> nsswitch.conf fileuse <strong>the</strong> standard glibc interfaces for accessing<strong>the</strong> nsswitch.conf file. This interface is notconducive to <strong>the</strong> use that automount makes ofit.The format is described in <strong>the</strong> nsswitch.conf(5) man page. It includes basic usage,such as:subsystem: lookup_listIt also contains some more complex usages,such as:


54 • <strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitations and Future Directions6 Autofs Version 5Work is well underway to resolve most of <strong>the</strong>limitations described above. In order to implement<strong>the</strong> new functionality in a clean and sensibleway, it has been necessary to increment<strong>the</strong> kernel protocol version to 5.00. It seemedsensible <strong>the</strong>n, to avoid confusion, to increment<strong>the</strong> version of <strong>the</strong> user space daemon to 5.0.0 aswell. Given <strong>the</strong> decision to increment <strong>the</strong> majorversion, it follows that <strong>the</strong> development priorityshould be to implement missing functionalityra<strong>the</strong>r than attempt to retain compatibilitywith older versions of autofs. Hence, <strong>the</strong> newfunctionality will work only with version 5.00of <strong>the</strong> kernel module. Existing indirect mountmaps will continue to work as in previous versions.6.1 Direct mount implementationThe first and most important task has been toimplement fully functional direct mounts. Thisis particularly important because it paves <strong>the</strong>way for lazy mount/umount of multi-mountsand host map implementations.Two methods are available to do this. Thefirst is to use file system stacking similar tothat found in Wrapfs from <strong>the</strong> FiST [5] system.Although using Wrapfs from FiST wasvery compelling, in <strong>the</strong> end it was decided itwould increase <strong>the</strong> complexity too much whencompared to <strong>the</strong> chosen method.The method that has been used is to treat eachdirect mount entry as a distinct mount and takeadvantage of <strong>the</strong> VFS inode method follow_link to trigger mounts. This method is safe touse for this purpose because a directory cannotbe a symbolic link; <strong>the</strong>refore <strong>the</strong> method cannoto<strong>the</strong>rwise be in use. Since mount point directoriesare created in <strong>the</strong> host file system, <strong>the</strong> VFSdoesn’t call <strong>the</strong> autofs lookup, revalidate,or readdir methods when <strong>the</strong> directory is accessed,but calls <strong>the</strong> follow_link method(which follows <strong>the</strong> lookup during a path walk)to trigger <strong>the</strong> mount before walking into <strong>the</strong>next directory. This implementation is surprisinglysimple but effective.The changes needed in <strong>the</strong> daemon are relativelystraightforward as well. A mount optiondirect has been added so <strong>the</strong> kernel moduleknows it is a direct mount and can send mountrequests to <strong>the</strong> daemon at <strong>the</strong> right time. In<strong>the</strong> daemon an additional entry point has beenadded to each of <strong>the</strong> lookup modules to enumeratea map so that <strong>the</strong> mount triggers can beset up.The changes in <strong>the</strong> communication protocol between<strong>the</strong> kernel and <strong>the</strong> daemon also allow asingle process or thread to handle an entire directmount map.One difference comes in <strong>the</strong> expiry of directmounts. Each direct mount that has had amount triggered over mounts <strong>the</strong> direct mountpoint. Because of this it is passed over when<strong>the</strong> kernel walks <strong>the</strong> path. Therefore <strong>the</strong> busynesstimeout can only be updated during an expirerun. As a result, only truly busy mountpoints (ie. with open files or a processes workingdirectory) will prevent expiry. Changingthis expire semantic does not seem to be a problemand will hopefully help with graphical environmentspreventing mounts from expiringdue to <strong>the</strong> way <strong>the</strong>y often scan file systems forchanges.Ano<strong>the</strong>r issue is that because direct mounts aremade on directories within <strong>the</strong> underlying filesystem, changes to direct maps cannot be seenuntil <strong>the</strong> map is re-read (by sending <strong>the</strong> daemona HUP signal).It is interesting to note that existing industryimplementations implement direct mounts in a


2006 <strong>Linux</strong> Symposium, Volume Two • 55similar way.6.2 Lazy mount/umountLazy mount/umount of multi-mount map entrieshas been a difficult problem to solve forsome time now. But with <strong>the</strong> direct mountchanges above, we can see how it can be done.The basic problem to be solved is that of nestedmounts. Let’s revisit <strong>the</strong> example of Section 3.3on multi-mounts with a couple of small modificationsto demonstrate <strong>the</strong> problem:mydir -rw \/ server:/export/mydir \/src server2:/export/src \/src/f77 server2:/export/src/f77 \/src/c server2:/export/src/c \/tmp :/usr/tmpWhen mydir is accessed, <strong>the</strong> file system correspondingto <strong>the</strong> offset / is mounted. But now<strong>the</strong> file system is not necessarily an autofs filesystem, so we can never get a callback from <strong>the</strong>kernel. So autofs never knows ano<strong>the</strong>r mount isneeded. Therefore, we must treat <strong>the</strong> entry as asingle unit and mount everything. Clearly thisnecessity applies equally when <strong>the</strong>re is nestingat lower levels in <strong>the</strong> offsets, such as <strong>the</strong> offsetsin <strong>the</strong> src directory.We can deal with this issue by partitioning<strong>the</strong> offsets and installing direct mount triggerswithin each of <strong>the</strong> file systems. In our example,when mydir is accessed we mount <strong>the</strong> entrycorresponding to / and install direct mounttriggers for each offset within <strong>the</strong> list boundedby nesting points. In this case, we install directmounts for /src and /tmp. Similarly, whenone of <strong>the</strong>se mounts is triggered we mount itand install <strong>the</strong> corresponding triggers. In <strong>the</strong>example we mount <strong>the</strong> entry for /src and <strong>the</strong>ninstall triggers for /scr/f77 and /src/c andso on.Expiring <strong>the</strong>se is a little trickier, because formulti-mounts like <strong>the</strong>se we need to expire <strong>the</strong>direct mounts <strong>the</strong>mselves as well as <strong>the</strong> file systemsthat may be mounted on <strong>the</strong>m. To solvethis problem, we need a way for <strong>the</strong> kernel todistinguish multi-mounts from standard directmounts. The obvious way to do this is to addan additional mount option, “offset” to distinguish<strong>the</strong>m from o<strong>the</strong>r direct mounts.The interesting thing about this scenario is thatwhen a file system is mounted on a trigger thatis perhaps itself nested, it will always be seenas busy by <strong>the</strong> expire system because <strong>the</strong>re isa file handle open for communication with <strong>the</strong>mount. On <strong>the</strong> o<strong>the</strong>r hand, a direct mount triggerwithout such a mount doesn’t hold open apipe but creates it at mount time. So multimountscan expire independently in a naturalway without fur<strong>the</strong>r complication.6.3 Host mapsSince <strong>the</strong> lazy mount/umount has been implementedmany of <strong>the</strong> <strong>the</strong> resource issues withhost maps should be resolved. A separate moduleis devoted to handling host maps. The implementationamounts to little more than enumerating<strong>the</strong> local hosts table, <strong>the</strong>n enumerating<strong>the</strong>ir exports and using this informationfor lookups when <strong>the</strong>y are accessed. The currentsimple implementation will no doubt needmuch refinement, such as filtering out non-NFSservers from <strong>the</strong> local hosts list to reduce clutter.6.4 Nsswitch integrationA parser for handling /etc/nsswitch.confmap source lookups has been added. Integrating<strong>the</strong> parser amounted to adding a layer to


56 • <strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitations and Future Directionsperform lookups between <strong>the</strong> daemon and <strong>the</strong>lookup modules. The daemon now calls <strong>the</strong>common lookup module instead of calling <strong>the</strong>lookup modules directly and iterates through<strong>the</strong> list of sources found during <strong>the</strong> parseof /etc/nsswitch.conf. There where, ofcourse, a number of side affects that had to beovercome but generally it appears to work quitewell.6.5 Master map parsing6.6 Included map supportIncluded map support has also been implemented.The design fits into <strong>the</strong> map readingand lookup modules by just watching for a “+”as <strong>the</strong> first character of a map key and calling<strong>the</strong> higher common lookup function to do <strong>the</strong>work, <strong>the</strong>n continuing after it returns. This hasbeen done for both <strong>the</strong> master map and mountmaps but plus map inclusion is allowed only infile maps as is <strong>the</strong> case with o<strong>the</strong>r industry standardautomounters.Ano<strong>the</strong>r important issue is <strong>the</strong> parsing of mastermaps in <strong>the</strong> init script. The init script isclearly not <strong>the</strong> right place for parsing <strong>the</strong> mastermap. As is <strong>the</strong> case in o<strong>the</strong>r industry automountimplementations, parsing should be done in autility designed specifically for that purpose orin <strong>the</strong> automounter proper.Ano<strong>the</strong>r requirement is to use <strong>the</strong> name serviceswitch to read maps and lookup entries inmap sources. The code developed above alsoworks well for this which resolves ano<strong>the</strong>r ofour long-standing limitations.The o<strong>the</strong>r feature that is expected of an automounteris that when <strong>the</strong>re are multiple entriesfor a key in <strong>the</strong> master map, <strong>the</strong>se entries shouldbe merged as described in Section 2.1. Thishas been achieved by leveraging <strong>the</strong> functionalityimplemented for handling nsswitch semantics.It follows fairly naturally from <strong>the</strong> need tohandle multiple map sources required by nssswitch.Implementing this feature has also provideda way to implement -null map supportin a fairly straightforward way. However, <strong>the</strong>reare difficulties identifying a map that needs tobe refreshed when <strong>the</strong>re has been a change.But o<strong>the</strong>rwise this should end up working fairlywell.6.6.1 LDAP supportThe LDAP lookup module has been a concernfor a long time and it has finally got some of<strong>the</strong> attention it so badly needed. The areasthat have been improved are <strong>the</strong> ability to specify<strong>the</strong> schema used for storage of automountmaps, integration of master map parsing into<strong>the</strong> daemon, encrypted TLS connections and<strong>the</strong> ability au<strong>the</strong>nticate to <strong>the</strong> LDAP server.One long standing problem is <strong>the</strong> need to supporttwo distinct LDAP schema used to storeautomount maps as well as some variationswithin <strong>the</strong>se schema. The schema to be usedcan now be set in <strong>the</strong> autofs configuration for<strong>the</strong> five class and attribute names used to queryan LDAP server. This will reduce <strong>the</strong> over headof using an LDAP server for autofs quite a bitand allow <strong>the</strong> use of o<strong>the</strong>r schema if it is required,as long as it is consistent with <strong>the</strong> way<strong>the</strong> base schema are used.There have been a number of requests to add<strong>the</strong> ability to use encrypted connections and tobe able to use au<strong>the</strong>ntication when connectingto an LDAP server. First, encrypted and optionallycertified connections can now be madeusing <strong>the</strong> START_TLS mechanism. The configurationfor <strong>the</strong> location of certificates must be


2006 <strong>Linux</strong> Symposium, Volume Two • 57done using <strong>the</strong> method required by <strong>the</strong> clientLDAP library and settings in an autofs au<strong>the</strong>nticationconfiguration must be used to enableit. Au<strong>the</strong>ntication uses <strong>the</strong> SASL library and<strong>the</strong> au<strong>the</strong>ntication method to use along with<strong>the</strong> login name and secret are also held in <strong>the</strong>same file as <strong>the</strong> TLS options above. So far<strong>the</strong> only method tested has been DIGEST-MD5but o<strong>the</strong>r common methods available in SASLshould work or be relatively straightforward toadd.7 Concluding remarksThe astute reader will have noticed that <strong>the</strong>above implementation of direct mounts andlazy mount/umount of multi-mount maps willuse a lot of anonymous devices. This use hasbecome possible since <strong>the</strong> limit on <strong>the</strong> numberof <strong>the</strong>se devices was greatly increased in <strong>the</strong>early stable release cycle of <strong>the</strong> 2.6 kernel. Itcould be possible for this to function with a 2.4kernel, but no work has been done to estimate<strong>the</strong> effort to back port <strong>the</strong> anonymous devicechanges. So initially at least, direct mounts willonly be available for 2.6 kernels.This paper has described a good number ofachievements and identified <strong>the</strong> challenges inrounding out <strong>the</strong> <strong>Linux</strong> automount implementation.We don’t mean to say that <strong>the</strong>se challengesare <strong>the</strong> only ones we face—just <strong>the</strong> mostdifficult to address, as well as those that are fundamentalto having a functional automounteron <strong>Linux</strong>.some challenging problems with respect to maprefresh.References[1] <strong>Linux</strong> Kernel source, Versions 2.4 and2.6, http://www.kernel.org/.[2] Hal Stern, Mike Eisler and RichardoLabiaga, Managing NFS and NIS, 2ndEdition, O’Reilly, June 2001.[3] W. Richard Stevens, Bill Fenner, andAndrew M. Rudoff, UNIX NetworkProgramming, The Sockets NetworkingAPI, Volume 1, Third Edition,Addison-Wesley Professional ComputingPress, 2004.[4] Travis Bar, Nicolai Langfeldt, Seth Vidaland Tom McNeal, <strong>Linux</strong> NFS-HOWTO,http://nfs.sourceforge.net/nfs-howto/, 2002-08-25.[5] FiST: Stackable File System Languageand Templates, Eraz Zadok et al.,http://www.filesystems.org/.[6] Sun TM Microsystems NFSAdministration Guide, Chapter 5,http://docs.sun.com/, 1995.[7] Robert Love, <strong>Linux</strong> Kernel Development,Second Edition, Novell Press, 2005.The current status of <strong>the</strong> changes outlinedabove for autofs version 5 is that <strong>the</strong> directmounts, nsswitch handling, lazy mount/umount, integration of master parsing, nsswitchintegration and <strong>the</strong> LDAP improvements haveall been done but have seen limited testing. Theplus map inclusion has also been done but has


58 • <strong>Hacking</strong> <strong>the</strong> <strong>Linux</strong> <strong>Automounter</strong>—Current Limitations and Future Directions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!