On Mon, 23 Jun 2008, Anton Altaparmakov wrote:
> On 23 Jun 2008, at 02:08, H. Peter Anvin wrote:
> > This sounds like a perfect use of an executable map to me.
>
> Sounds like something that is certainly worth investigating.
> ......
> This is what ours look like at present. When a user logs in we
> generate two files (below $user is the user name of the user logging
> in):
This problem is interesting: how would you do this while using the
multi-thread capability of autofs version 5? Here's how far I got. First,
we're not going to mount anything at login time; we're going to mount the
homedir the first time it's referenced, which on my system would be
slightly before logging in is finished (to check the ssh key in the
homedir). Similarly, we're going to rely on automount's normal expiration
behavior to get rid of mounts after logout.
/etc/auto.master would say:
/server /etc/auto.per-user
/etc/auto.per-user says:
* -fstype=autofs,-DNCP_USER=& program:/etc/auto.userdirs
(this is bogus, see below)
/etc/auto.userdirs is executable and goes something like this: (I modified
it so it reports something that can be mounted on my system, and it
actually happens.)
#!/bin/sh
# $1 is the map key, i.e. on access to /server/$user/$share, $1 would be
# $share. Translate the key into the server's IP address. Likely this
# is waaaaay different on an authentic Novell network.
ip=`dig +short +search $1 A`
# Emit the map row (leaving off the key). Bogus \'s supplied for
# readability.
echo -fstype=ncp,ipserver=$ip,owner=$NCP_USER,uid=$NCP_USER,gid=$NCP_USER,\
hard,nodev,nosuid,nfsextras,strong,codepage=cp850,iocharset=utf8,\
filemode=640,dirmode=750,a=/authcon/$NCP_USER :$1/$NCP_USER.Aliases
Now, what's the right way to get the NCP user available to the program
map? In a file map -DNCP_USER (as shown, with the hyphen) will propagate
this variable into the map rows, so the whole thing could have been
handled in a file map... except for the IP address in the mount options.
If ipserver could possibly be a FQDN rather than a numeric IP address, I
would be very, very tempted to create a massive DNS map that has "A"
records for PWF-HOME$N.$user.ncp-xlate.cam.ac.uk (to give an example domain
structure). This would be updated, perhaps by dynamic DNS updates,
whenever a user's server assignment changed.
Returning to the question that most interests me, in the submount I tried
these variants:
* -fstype=autofs,-DNCP_USER=& program:/etc/auto.userdirs
(NCP_USER was not defined as an environment variable; neither was USER)
* -fstype=autofs program:/etc/auto.userdirs &
(The extra arg to the program map was ignored with no error message)
What do people think would be the best way to get the containing map key
into the program map? Not the key to be translated by the map (in our
case PWF-HOME1 etc.), but the key that caused the submount to be created,
or any of the other environment variables of the submount, such as $USER,
which is probably what you really want to use here.
Warning: before deploying a submount-based scheme in production, watch for
a resolution of the internal locking (mutex) issue that's so bedeviling me.
James F. Carter Voice 310 825 2897 FAX 310 206 6673
UCLA-Mathnet; 6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: [EMAIL PROTECTED] http://www.math.ucla.edu/~jimc (q.v. for PGP key)
_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs