* autofs {3, 4, 5} and bind mounts which point to other automount points
@ 2006-08-24 14:44 Matt Bernstein
2006-08-25 1:29 ` Ian Kent
2006-08-25 14:46 ` Ian Kent
0 siblings, 2 replies; 32+ messages in thread
From: Matt Bernstein @ 2006-08-24 14:44 UTC (permalink / raw)
To: autofs
Hi,
We like to preconfigure an number of our (1000ish) users' applications.
Typically, this might necessitate hard-coding their home directories in
dot-files, so we specify their home directory in the passwd map as
/homes/$LOGNAME, and make this an (LDAP) automount map which might point
to ":/server/{servername}/{volumename}/$LOGNAME" (via a bind mount), where
/server/{servername}/{volumename} would be the "real" NFS mount.
This allows us to move the physical location of any user's home directory
without upsetting their application settings. (Some applications seem to
prefer using full paths.)
Our scheme all worked fine in autofs 3.
In autofs 4, it worked but with a 10 or 15s delay which we got around via
the following patch:
--- modules/mount_bind.c.orig 2004-10-29 14:46:11.000000000 +0100
+++ modules/mount_bind.c 2004-11-01 12:49:54.000000000 +0000
@@ -126,7 +126,10 @@
}
debug(MODPREFIX "calling mount --bind %s %s", what, fullpath);
-
+/* 'what' may itself be on an automounted file system so we need to access it */
+/* to ensure it gets mounted before calling wait_for_lock() inorder to avoid a*/
+/* long delay */
+ (void)access(what,F_OK);
wait_for_lock();
err = spawnl(LOG_NOTICE, MOUNTED_LOCK,
PATH_MOUNT, PATH_MOUNT, "--bind",
In autofs 5, it doesn't work at all, claiming no hostname was supplied. Is
there any way we can achieve what we want? I can't find any documentation.
Matt
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-24 14:44 Matt Bernstein
@ 2006-08-25 1:29 ` Ian Kent
2006-08-25 6:45 ` Matt Bernstein
2006-08-25 14:46 ` Ian Kent
1 sibling, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 1:29 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Thu, 24 Aug 2006, Matt Bernstein wrote:
> Hi,
>
> We like to preconfigure an number of our (1000ish) users' applications.
> Typically, this might necessitate hard-coding their home directories in
> dot-files, so we specify their home directory in the passwd map as
> /homes/$LOGNAME, and make this an (LDAP) automount map which might point
> to ":/server/{servername}/{volumename}/$LOGNAME" (via a bind mount), where
> /server/{servername}/{volumename} would be the "real" NFS mount.
>
> This allows us to move the physical location of any user's home directory
> without upsetting their application settings. (Some applications seem to
> prefer using full paths.)
>
> Our scheme all worked fine in autofs 3.
>
> In autofs 4, it worked but with a 10 or 15s delay which we got around via
> the following patch:
>
> --- modules/mount_bind.c.orig 2004-10-29 14:46:11.000000000 +0100
> +++ modules/mount_bind.c 2004-11-01 12:49:54.000000000 +0000
> @@ -126,7 +126,10 @@
> }
>
> debug(MODPREFIX "calling mount --bind %s %s", what, fullpath);
> -
> +/* 'what' may itself be on an automounted file system so we need to access it */
> +/* to ensure it gets mounted before calling wait_for_lock() inorder to avoid a*/
> +/* long delay */
> + (void)access(what,F_OK);
That can lead to corruption of /etc/mtab.
That's why the lock was introduced.
In v5 the locking can be disabled as most people have updated mount(8)
these days.
> wait_for_lock();
> err = spawnl(LOG_NOTICE, MOUNTED_LOCK,
> PATH_MOUNT, PATH_MOUNT, "--bind",
>
>
> In autofs 5, it doesn't work at all, claiming no hostname was supplied. Is
> there any way we can achieve what we want? I can't find any documentation.
Someone else has reported that bind mounts aren't working with v5.
It would be good to resolve this but I need more info.
A debug log would be best.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 1:29 ` Ian Kent
@ 2006-08-25 6:45 ` Matt Bernstein
2006-08-25 6:58 ` Ian Kent
2006-08-25 7:07 ` Ian Kent
0 siblings, 2 replies; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 6:45 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 09:29 +0800 Ian Kent wrote:
>On Thu, 24 Aug 2006, Matt Bernstein wrote:
>> +/* 'what' may itself be on an automounted file system so we need to access it */
>> +/* to ensure it gets mounted before calling wait_for_lock() inorder to avoid a*/
>> +/* long delay */
>> + (void)access(what,F_OK);
>
>That can lead to corruption of /etc/mtab.
>That's why the lock was introduced.
>
>In v5 the locking can be disabled as most people have updated mount(8)
>these days.
Thanks--is the locking disabled, or do we need to patch the source? (I
haven't looked at it yet.)
>Someone else has reported that bind mounts aren't working with v5.
>It would be good to resolve this but I need more info.
>A debug log would be best.
I set DEFAULT_LOGGING="debug" in /etc/sysconfig/autofs (this is
autofs-5.0.1-0.rc1.16.x86_64 in FC6test), and I got this in /var/log/messages:
Aug 25 07:31:29 laurel automount[17274]: attempting to mount entry /homes/mb
Aug 25 07:31:29 laurel automount[17274]: mount_mount: mount(nfs): no hosts available
Aug 25 07:31:29 laurel automount[17274]: failed to mount /homes/mb
Aug 25 07:31:30 laurel automount[17274]: attempting to mount entry /homes/mb
Aug 25 07:31:30 laurel automount[17274]: failed to mount /homes/mb
..with the last two lines repeated 19 times. Is that helpful?
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 6:45 ` Matt Bernstein
@ 2006-08-25 6:58 ` Ian Kent
2006-08-25 7:07 ` Ian Kent
1 sibling, 0 replies; 32+ messages in thread
From: Ian Kent @ 2006-08-25 6:58 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 25 Aug 2006, Matt Bernstein wrote:
> At 09:29 +0800 Ian Kent wrote:
>
> > On Thu, 24 Aug 2006, Matt Bernstein wrote:
> > > +/* 'what' may itself be on an automounted file system so we need to
> > > access it */
> > > +/* to ensure it gets mounted before calling wait_for_lock() inorder to
> > > avoid a*/
> > > +/* long delay */
> > > + (void)access(what,F_OK);
> >
> > That can lead to corruption of /etc/mtab.
> > That's why the lock was introduced.
> >
> > In v5 the locking can be disabled as most people have updated mount(8) these
> > days.
>
> Thanks--is the locking disabled, or do we need to patch the source? (I haven't
> looked at it yet.)
Yes it is in the FC6 packages.
mount(8) has been patches to fix the locking in FC.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 6:45 ` Matt Bernstein
2006-08-25 6:58 ` Ian Kent
@ 2006-08-25 7:07 ` Ian Kent
2006-08-25 11:18 ` Ian Kent
1 sibling, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 7:07 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 25 Aug 2006, Matt Bernstein wrote:
> At 09:29 +0800 Ian Kent wrote:
>
> > On Thu, 24 Aug 2006, Matt Bernstein wrote:
> > > +/* 'what' may itself be on an automounted file system so we need to
> > > access it */
> > > +/* to ensure it gets mounted before calling wait_for_lock() inorder to
> > > avoid a*/
> > > +/* long delay */
> > > + (void)access(what,F_OK);
> >
> > That can lead to corruption of /etc/mtab.
> > That's why the lock was introduced.
> >
> > In v5 the locking can be disabled as most people have updated mount(8) these
> > days.
>
> Thanks--is the locking disabled, or do we need to patch the source? (I haven't
> looked at it yet.)
>
> > Someone else has reported that bind mounts aren't working with v5.
> > It would be good to resolve this but I need more info.
> > A debug log would be best.
>
> I set DEFAULT_LOGGING="debug" in /etc/sysconfig/autofs (this is
> autofs-5.0.1-0.rc1.16.x86_64 in FC6test), and I got this in /var/log/messages:
>
> Aug 25 07:31:29 laurel automount[17274]: attempting to mount entry /homes/mb
> Aug 25 07:31:29 laurel automount[17274]: mount_mount: mount(nfs): no hosts
> available
Mmmm ... I shouldn't be defaulting to NFS for a ":" escaped mount.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 7:07 ` Ian Kent
@ 2006-08-25 11:18 ` Ian Kent
2006-08-25 13:09 ` Matt Bernstein
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 11:18 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 25 Aug 2006, Ian Kent wrote:
> On Fri, 25 Aug 2006, Matt Bernstein wrote:
>
> > At 09:29 +0800 Ian Kent wrote:
> >
> > > On Thu, 24 Aug 2006, Matt Bernstein wrote:
> > > > +/* 'what' may itself be on an automounted file system so we need to
> > > > access it */
> > > > +/* to ensure it gets mounted before calling wait_for_lock() inorder to
> > > > avoid a*/
> > > > +/* long delay */
> > > > + (void)access(what,F_OK);
> > >
> > > That can lead to corruption of /etc/mtab.
> > > That's why the lock was introduced.
> > >
> > > In v5 the locking can be disabled as most people have updated mount(8) these
> > > days.
> >
> > Thanks--is the locking disabled, or do we need to patch the source? (I haven't
> > looked at it yet.)
> >
> > > Someone else has reported that bind mounts aren't working with v5.
> > > It would be good to resolve this but I need more info.
> > > A debug log would be best.
> >
> > I set DEFAULT_LOGGING="debug" in /etc/sysconfig/autofs (this is
> > autofs-5.0.1-0.rc1.16.x86_64 in FC6test), and I got this in /var/log/messages:
> >
> > Aug 25 07:31:29 laurel automount[17274]: attempting to mount entry /homes/mb
> > Aug 25 07:31:29 laurel automount[17274]: mount_mount: mount(nfs): no hosts
> > available
>
> Mmmm ... I shouldn't be defaulting to NFS for a ":" escaped mount.
Could you try this patch please.
Ian
--
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index c132422..190499c 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -508,25 +508,35 @@ static int sun_mount(struct autofs_point
mountpoint = alloca(namelen + 1);
sprintf(mountpoint, "%.*s", namelen, name);
- what = alloca(loclen + 1);
- if (*loc == ':') {
- memcpy(what, loc + 1, loclen - 1);
- what[loclen - 1] = '\0';
- } else {
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
+ if (!strcmp(fstype, "nfs")) {
+ what = alloca(loclen + 1);
memcpy(what, loc, loclen);
what[loclen] = '\0';
- }
- debug(ap->logopt,
- MODPREFIX
- "mounting root %s, mountpoint %s, what %s, fstype %s, options %s",
- root, mountpoint, what, fstype, options);
+ debug(ap->logopt, MODPREFIX
+ "mounting root %s, mountpoint %s, "
+ "what %s, fstype %s, options %s",
+ root, mountpoint, what, fstype, options);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
- if (!strcmp(fstype, "nfs")) {
rv = mount_nfs->mount_mount(ap, root, mountpoint, strlen(mountpoint),
what, fstype, options, mount_nfs->context);
} else {
+ what = alloca(loclen + 1);
+ if (*loc == ':') {
+ loclen--;
+ memcpy(what, loc + 1, loclen);
+ what[loclen] = '\0';
+ } else {
+ memcpy(what, loc, loclen);
+ what[loclen] = '\0';
+ }
+
+ debug(ap->logopt, MODPREFIX
+ "mounting root %s, mountpoint %s, "
+ "what %s, fstype %s, options %s",
+ root, mountpoint, what, fstype, options);
+
/* Generic mount routine */
rv = do_mount(ap, root, mountpoint, strlen(mountpoint), what, fstype,
options);
diff --git a/modules/replicated.c b/modules/replicated.c
index aa484b3..7558383 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -587,14 +587,16 @@ int prune_host_list(struct host **list,
while (this && this->proximity == proximity) {
struct host *next = this->next;
- status = get_vers_and_cost(this, vers);
- if (!status) {
- if (this == first) {
- first = next;
- if (next)
- proximity = next->proximity;
+ if (this->name) {
+ status = get_vers_and_cost(this, vers);
+ if (!status) {
+ if (this == first) {
+ first = next;
+ if (next)
+ proximity = next->proximity;
+ }
+ delete_host(list, this);
}
- delete_host(list, this);
}
this = next;
}
@@ -674,11 +676,15 @@ int prune_host_list(struct host **list,
this = first;
while (this) {
struct host *next = this->next;
- status = get_supported_ver_and_cost(this, selected_version);
- if (status) {
- this->version = selected_version;
- remove_host(list, this);
+ if (!this->name)
add_host(&new, this);
+ else {
+ status = get_supported_ver_and_cost(this, selected_version);
+ if (status) {
+ this->version = selected_version;
+ remove_host(list, this);
+ add_host(&new, this);
+ }
}
this = next;
}
@@ -775,6 +781,34 @@ static int add_path(struct host *hosts,
return 1;
}
+static int add_local_path(struct host **hosts, const char *path)
+{
+ struct host *new;
+ char *tmp;
+
+ tmp = strdup(path);
+ if (!tmp)
+ return 0;
+
+ new = malloc(sizeof(struct host));
+ if (!new) {
+ free(tmp);
+ return 0;
+ }
+
+ memset(new, 0, sizeof(struct host));
+
+ new->path = tmp;
+ new->proximity = PROXIMITY_LOCAL;
+ new->version = NFS_VERS_MASK;
+ new->name = new->addr = NULL;
+ new->weight = new->cost = 0;
+
+ add_host(hosts, new);
+
+ return 1;
+}
+
int parse_location(struct host **hosts, const char *list)
{
char *str, *p, *delim;
@@ -829,18 +863,25 @@ int parse_location(struct host **hosts,
*next++ = '\0';
}
- if (!add_host_addrs(hosts, p, weight)) {
- if (empty) {
+ if (p != delim) {
+ if (!add_host_addrs(hosts, p, weight)) {
+ if (empty) {
+ p = next;
+ continue;
+ }
+ }
+
+ if (!add_path(*hosts, path, strlen(path))) {
+ free_host_list(hosts);
+ free(str);
+ return 0;
+ }
+ } else {
+ if (!add_local_path(hosts, path)) {
p = next;
continue;
}
}
-
- if (!add_path(*hosts, path, strlen(path))) {
- free_host_list(hosts);
- free(str);
- return 0;
- }
} else if (*delim != '\0') {
*delim = '\0';
next = delim + 1;
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 11:18 ` Ian Kent
@ 2006-08-25 13:09 ` Matt Bernstein
2006-08-25 13:22 ` Matt Bernstein
2006-08-25 14:29 ` Ian Kent
0 siblings, 2 replies; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 13:09 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 19:18 +0800 Ian Kent wrote:
>>> Aug 25 07:31:29 laurel automount[17274]: attempting to mount entry /homes/mb
>>> Aug 25 07:31:29 laurel automount[17274]: mount_mount: mount(nfs): no hosts
>>> available
>>
>> Mmmm ... I shouldn't be defaulting to NFS for a ":" escaped mount.
>
> Could you try this patch please.
Thanks.. now my messages are slightly different (though it still fails).
Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
Aug 25 14:07:19 laurel automount[17416]: failed to mount /homes/mb
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 13:09 ` Matt Bernstein
@ 2006-08-25 13:22 ` Matt Bernstein
2006-08-25 14:37 ` Ian Kent
2006-08-25 14:29 ` Ian Kent
1 sibling, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 13:22 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 14:09 +0100 Matt Bernstein wrote:
> At 19:18 +0800 Ian Kent wrote:
>
>> Could you try this patch please.
>
> Thanks.. now my messages are slightly different (though it still fails).
>
> Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
> Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
> Aug 25 14:07:19 laurel automount[17416]: failed to mount /homes/mb
Actually, this only happens when the target isn't already mounted. It does
perform a bind mount if there's something to bind to. Now what we need to
do (I think) is tickle the target in case it's another automount point, a
la our-bad-patch-for-autofs4.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 13:09 ` Matt Bernstein
2006-08-25 13:22 ` Matt Bernstein
@ 2006-08-25 14:29 ` Ian Kent
2006-08-25 14:49 ` Matt Bernstein
1 sibling, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 14:29 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-08-25 at 14:09 +0100, Matt Bernstein wrote:
> At 19:18 +0800 Ian Kent wrote:
>
> >>> Aug 25 07:31:29 laurel automount[17274]: attempting to mount entry /homes/mb
> >>> Aug 25 07:31:29 laurel automount[17274]: mount_mount: mount(nfs): no hosts
> >>> available
> >>
> >> Mmmm ... I shouldn't be defaulting to NFS for a ":" escaped mount.
> >
> > Could you try this patch please.
>
> Thanks.. now my messages are slightly different (though it still fails).
>
> Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
> Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
This was broken for sure but I tested the usual cases.
Did the patch apply cleanly?
And where's the rest of the output that will tell us the mount command
that was actually used.
Send daemon.* to a log and run with debug enabled.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 13:22 ` Matt Bernstein
@ 2006-08-25 14:37 ` Ian Kent
2006-08-27 7:52 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 14:37 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-08-25 at 14:22 +0100, Matt Bernstein wrote:
> At 14:09 +0100 Matt Bernstein wrote:
>
> > At 19:18 +0800 Ian Kent wrote:
> >
> >> Could you try this patch please.
> >
> > Thanks.. now my messages are slightly different (though it still fails).
> >
> > Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
> > Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
> > Aug 25 14:07:19 laurel automount[17416]: failed to mount /homes/mb
>
> Actually, this only happens when the target isn't already mounted. It does
> perform a bind mount if there's something to bind to. Now what we need to
> do (I think) is tickle the target in case it's another automount point, a
> la our-bad-patch-for-autofs4.
Shouldn't need to do that.
This my be due to changes in the lookup flags in the kernel over time.
I haven't reviewed that for some time now.
I'll see if I can duplicate your situation.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-24 14:44 Matt Bernstein
2006-08-25 1:29 ` Ian Kent
@ 2006-08-25 14:46 ` Ian Kent
2006-08-25 14:47 ` Matt Bernstein
1 sibling, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 14:46 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Thu, 2006-08-24 at 15:44 +0100, Matt Bernstein wrote:
> Hi,
>
> We like to preconfigure an number of our (1000ish) users' applications.
> Typically, this might necessitate hard-coding their home directories in
> dot-files, so we specify their home directory in the passwd map as
> /homes/$LOGNAME, and make this an (LDAP) automount map which might point
> to ":/server/{servername}/{volumename}/$LOGNAME" (via a bind mount), where
> /server/{servername}/{volumename} would be the "real" NFS mount.
So you have another automount map for the server entries, right?
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 14:46 ` Ian Kent
@ 2006-08-25 14:47 ` Matt Bernstein
2006-08-25 15:55 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 14:47 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 22:46 +0800 Ian Kent wrote:
> On Thu, 2006-08-24 at 15:44 +0100, Matt Bernstein wrote:
>> Hi,
>>
>> We like to preconfigure an number of our (1000ish) users' applications.
>> Typically, this might necessitate hard-coding their home directories in
>> dot-files, so we specify their home directory in the passwd map as
>> /homes/$LOGNAME, and make this an (LDAP) automount map which might point
>> to ":/server/{servername}/{volumename}/$LOGNAME" (via a bind mount), where
>> /server/{servername}/{volumename} would be the "real" NFS mount.
>
> So you have another automount map for the server entries, right?
Yup. Actually it's even more indirect. I'm about to hit send on my other
mail which describes it.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 14:29 ` Ian Kent
@ 2006-08-25 14:49 ` Matt Bernstein
0 siblings, 0 replies; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 14:49 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 22:29 +0800 Ian Kent wrote:
>> Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
>> Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
>
> This was broken for sure but I tested the usual cases.
>
> Did the patch apply cleanly?
Yup :) (see my update)
> And where's the rest of the output that will tell us the mount command
> that was actually used.
>
> Send daemon.* to a log and run with debug enabled.
Aug 25 15:42:18 laurel automount[22501]: handle_packet: type = 3
Aug 25 15:42:18 laurel automount[22501]: handle_packet_missing_indirect: token 3489, name mb, request pid 22628
Aug 25 15:42:18 laurel automount[22501]: attempting to mount entry /homes/mb
Aug 25 15:42:18 laurel automount[22501]: lookup_mount: lookup(ldap): looking up mb
Aug 25 15:42:18 laurel automount[22501]: lookup_one: lookup(ldap): searching for "(&(objectclass=automount)(|(cn=mb)(cn=/)))" under "ou=auto.homes,dc=dcs,dc=qmul,dc=ac,dc=uk"
Aug 25 15:42:18 laurel automount[22501]: do_connect: auth_required: 1, sasl_mech (null)
Aug 25 15:42:18 laurel automount[22501]: do_connect: lookup(ldap): ldap anonymous bind returned 0
Aug 25 15:42:18 laurel automount[22501]: lookup_one: lookup(ldap): getting first entry for cn="mb"
Aug 25 15:42:18 laurel automount[22501]: lookup_one: lookup(ldap): examining first entry
Aug 25 15:42:18 laurel automount[22501]: unbind_ldap_connection: use_tls: 2
Aug 25 15:42:18 laurel automount[22501]: lookup_mount: lookup(ldap): mb -> :/home/cream/home71/mb
Aug 25 15:42:18 laurel automount[22501]: parse_mount: parse(sun): expanded entry: :/home/cream/home71/mb
Aug 25 15:42:18 laurel automount[22501]: parse_mount: parse(sun): gathered options:
Aug 25 15:42:18 laurel automount[22501]: parse_mount: parse(sun): dequote(":/home/cream/home71/mb") -> :/home/cream/home71/mb
Aug 25 15:42:18 laurel automount[22501]: parse_mount: parse(sun): core of entry: options=, loc=:/home/cream/home71/mb
Aug 25 15:42:18 laurel automount[22501]: sun_mount: parse(sun): mounting root /homes, mountpoint mb, what :/home/cream/home71/mb, fstype nfs, options (null)
Aug 25 15:42:18 laurel automount[22501]: mount_mount: mount(nfs): root=/homes name=mb what=:/home/cream/home71/mb, fstype=nfs, options=(null)
Aug 25 15:42:18 laurel automount[22501]: mount_mount: mount(nfs): calling mkdir_path /homes/mb
Aug 25 15:42:18 laurel automount[22501]: mount_mount: mount(nfs): mb is local, attempt bind mount
Aug 25 15:42:18 laurel automount[22501]: mount_mount: mount(bind): calling mkdir_path /homes/mb
Aug 25 15:42:18 laurel automount[22501]: mount_mount: mount(bind): calling mount --bind -s -o defaults /home/cream/home71/mb /homes/mb
Aug 25 15:42:18 laurel automount[22501]: >> mount: special device /home/cream/home71/mb does not exist
Aug 25 15:42:18 laurel automount[22501]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
Aug 25 15:42:18 laurel automount[22501]: send_fail: token = 3489
Aug 25 15:42:18 laurel automount[22501]: failed to mount /homes/mb
The desired "nested" behaviour is:
/homes/mb binds /home/cream/home71/mb
/home/cream/home71 binds /server/cream/export71
/server/cream/export71 nfsmounts cream:/export71
This way:
- my apps always use /homes/mb
- my infrastructure db knows I'm /home/x/y/mb
- the actual nfs server can also be looked up
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 14:47 ` Matt Bernstein
@ 2006-08-25 15:55 ` Ian Kent
2006-08-25 16:19 ` Matt Bernstein
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-25 15:55 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-08-25 at 15:47 +0100, Matt Bernstein wrote:
> At 22:46 +0800 Ian Kent wrote:
>
> > On Thu, 2006-08-24 at 15:44 +0100, Matt Bernstein wrote:
> >> Hi,
> >>
> >> We like to preconfigure an number of our (1000ish) users' applications.
> >> Typically, this might necessitate hard-coding their home directories in
> >> dot-files, so we specify their home directory in the passwd map as
> >> /homes/$LOGNAME, and make this an (LDAP) automount map which might point
> >> to ":/server/{servername}/{volumename}/$LOGNAME" (via a bind mount), where
> >> /server/{servername}/{volumename} would be the "real" NFS mount.
> >
> > So you have another automount map for the server entries, right?
>
> Yup. Actually it's even more indirect. I'm about to hit send on my other
> mail which describes it.
I think I know why this isn't working.
It's due to the conversion to a threaded model.
And I fairly sure it can't work within v5 if we don't make changes.
It's actually quite difficult.
Basically, the daemon doesn't ever trigger a mount itself and since
there is only one daemon now you can't cause a mount to happen in
another mount point.
I'll have to think about how we can do this.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
@ 2006-08-25 16:18 Joe Pruett
2006-08-25 17:25 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Joe Pruett @ 2006-08-25 16:18 UTC (permalink / raw)
To: raven; +Cc: autofs
The ability to have automount point to automount is something I use heavily as well. Otherwise I end up with many hundreds of nfs mounts on the server at a time. having hundreds of bind mounts on the client is preferrable. The old sun method of doing this was:
host:/path/name:dir
which would mount host:/path/name and then symlink dir. Now we' d use bind/loopback mounts. But that syntax has been gone a long time.
It doesn't seem like threading should inherently cause a problem. Each request should be a new thread and wait for the underlying mount (which might be recursive) to finish.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 15:55 ` Ian Kent
@ 2006-08-25 16:19 ` Matt Bernstein
2006-08-26 3:24 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-25 16:19 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 23:55 +0800 Ian Kent wrote:
> I think I know why this isn't working.
> It's due to the conversion to a threaded model.
> And I fairly sure it can't work within v5 if we don't make changes.
> It's actually quite difficult.
I appreciate this--thanks for taking the time to understand it :)
> Basically, the daemon doesn't ever trigger a mount itself and since
> there is only one daemon now you can't cause a mount to happen in
> another mount point.
Yes.. (that's why the accept() patch doesn't help); it may need some kind
of ability to recurse.
For bonus points, the following scenario is a quick route to a nasty
deadlock in autofs{3,4}: /a/1 binds to :/b/2; /b/2 binds to :/a/1. Having
some kind of cycle-detection might prevent some difficult-to-diagnose
crashes. (It happened to us..)
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 16:18 autofs {3, 4, 5} and bind mounts which point to other automount points Joe Pruett
@ 2006-08-25 17:25 ` Ian Kent
0 siblings, 0 replies; 32+ messages in thread
From: Ian Kent @ 2006-08-25 17:25 UTC (permalink / raw)
To: Joe Pruett; +Cc: autofs
On Fri, 2006-08-25 at 09:18 -0700, Joe Pruett wrote:
> The ability to have automount point to automount is something I use heavily as well. Otherwise I end up with many hundreds of nfs mounts on the server at a time. having hundreds of bind mounts on the client is preferrable. The old sun method of doing this was:
> host:/path/name:dir
> which would mount host:/path/name and then symlink dir. Now we' d use bind/loopback mounts. But that syntax has been gone a long time.
>
> It doesn't seem like threading should inherently cause a problem. Each request should be a new thread and wait for the underlying mount (which might be recursive) to finish.
>
It does cause a problem.
The process group is used by the kernel module to prevent the daemon
itself from triggering mounts. In the threaded environment there is
currently one program group so one thread cannot cause another thread to
trigger a mount.
I'll have to fix it.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 16:19 ` Matt Bernstein
@ 2006-08-26 3:24 ` Ian Kent
0 siblings, 0 replies; 32+ messages in thread
From: Ian Kent @ 2006-08-26 3:24 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-08-25 at 17:19 +0100, Matt Bernstein wrote:
> At 23:55 +0800 Ian Kent wrote:
>
> > I think I know why this isn't working.
> > It's due to the conversion to a threaded model.
> > And I fairly sure it can't work within v5 if we don't make changes.
> > It's actually quite difficult.
>
> I appreciate this--thanks for taking the time to understand it :)
>
> > Basically, the daemon doesn't ever trigger a mount itself and since
> > there is only one daemon now you can't cause a mount to happen in
> > another mount point.
>
> Yes.. (that's why the accept() patch doesn't help); it may need some kind
> of ability to recurse.
>
> For bonus points, the following scenario is a quick route to a nasty
> deadlock in autofs{3,4}: /a/1 binds to :/b/2; /b/2 binds to :/a/1. Having
> some kind of cycle-detection might prevent some difficult-to-diagnose
> crashes. (It happened to us..)
That's really hard to detect.
Mainly because of the autofs4 kernel module doesn't know much about the
user space daemon context and visa versa.
I'll think about that one.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-25 14:37 ` Ian Kent
@ 2006-08-27 7:52 ` Ian Kent
2006-08-29 11:11 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-27 7:52 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 25 Aug 2006, Ian Kent wrote:
> On Fri, 2006-08-25 at 14:22 +0100, Matt Bernstein wrote:
> > At 14:09 +0100 Matt Bernstein wrote:
> >
> > > At 19:18 +0800 Ian Kent wrote:
> > >
> > >> Could you try this patch please.
> > >
> > > Thanks.. now my messages are slightly different (though it still fails).
> > >
> > > Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
> > > Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
> > > Aug 25 14:07:19 laurel automount[17416]: failed to mount /homes/mb
> >
> > Actually, this only happens when the target isn't already mounted. It does
> > perform a bind mount if there's something to bind to. Now what we need to
> > do (I think) is tickle the target in case it's another automount point, a
> > la our-bad-patch-for-autofs4.
>
> Shouldn't need to do that.
> This my be due to changes in the lookup flags in the kernel over time.
> I haven't reviewed that for some time now.
And that seems OK.
Can you try this patch in addition to the previous patch please.
Ian
--
diff --git a/daemon/direct.c b/daemon/direct.c
index 9a1cd59..cfa13ad 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -273,8 +273,7 @@ static int unlink_mount_tree(struct auto
continue;
if (strcmp(mnt->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", mnt->path, NULL);
+ rv = spawn_umount(log_debug, "-l", mnt->path, NULL);
else
rv = umount2(mnt->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 38d0b7a..9ceb015 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -95,8 +95,7 @@ static int unlink_mount_tree(struct auto
}
if (strcmp(this->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", this->path, NULL);
+ rv = spawn_umount(log_debug, "-l", this->path, NULL);
else
rv = umount2(this->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/spawn.c b/daemon/spawn.c
index 7dc4a81..84df3b9 100644
--- a/daemon/spawn.c
+++ b/daemon/spawn.c
@@ -20,6 +20,7 @@ #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <dirent.h>
#include <unistd.h>
#include <time.h>
#include <sys/wait.h>
@@ -27,9 +28,11 @@ #include <sys/stat.h>
#include "automount.h"
-#ifdef ENABLE_MOUNT_LOCKING
static pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
+
+#define SPAWN_OPT_NONE 0x0000
+#define SPAWN_OPT_LOCK 0x0001
+#define SPAWN_OPT_OPENDIR 0x0002
inline void dump_core(void)
{
@@ -83,26 +86,15 @@ void reset_signals(void)
#define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
-#ifdef ENABLE_MOUNT_LOCKING
-void spawn_unlock(void *arg)
-{
- int *use_lock = (int *) arg;
-
- if (*use_lock) {
- if (pthread_mutex_unlock(&spawn_mutex))
- warn(LOGOPT_NONE, "failed to unlock spawn_mutex");
- }
- return;
-}
-#endif
-
-static int do_spawn(logger *log, int use_lock, const char *prog, const char *const *argv)
+static int do_spawn(logger *log, unsigned int options, const char *prog, const char *const *argv)
{
pid_t f;
int status, pipefd[2];
char errbuf[ERRBUFSIZ + 1], *p, *sp;
int errp, errn;
int cancel_state;
+ unsigned int use_lock = options & SPAWN_OPT_LOCK;
+ unsigned int use_opendir = options & SPAWN_OPT_OPENDIR;
sigset_t allsigs, tmpsig, oldsig;
if (pipe(pipefd))
@@ -113,16 +105,11 @@ static int do_spawn(logger *log, int use
sigfillset(&allsigs);
pthread_sigmask(SIG_BLOCK, &allsigs, &oldsig);
-#ifdef ENABLE_MOUNT_LOCKING
if (use_lock) {
- if (pthread_mutex_lock(&spawn_mutex)) {
- log(LOGOPT_ANY, "failed to lock spawn_mutex");
- pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
- pthread_setcancelstate(cancel_state, NULL);
- return -1;
- }
+ status = pthread_mutex_lock(&spawn_mutex);
+ if (status)
+ fatal(status);
}
-#endif
f = fork();
if (f == 0) {
@@ -132,6 +119,26 @@ #endif
dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]);
+ /* Bind mount - check target exists */
+ if (use_opendir) {
+ char **pargv = (char **) argv;
+ int argc = 0;
+ pid_t pgrp = getpgrp();
+ DIR *dfd;
+
+ /* what to mount must always be second last */
+ while (*pargv++)
+ argc++;
+ argc -= 2;
+
+ /* Set non-autofs program group to trigger mount */
+ setpgrp();
+ if ((dfd = opendir(argv[argc])) == NULL)
+ _exit(errno);
+ closedir(dfd);
+ setpgid(0, pgrp);
+ }
+
execv(prog, (char *const *) argv);
_exit(255); /* execv() failed */
} else {
@@ -144,10 +151,12 @@ #endif
if (f < 0) {
close(pipefd[0]);
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return -1;
}
@@ -193,10 +202,12 @@ #endif
if (waitpid(f, &status, 0) != f)
status = -1; /* waitpid() failed */
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return status;
@@ -205,7 +216,7 @@ #endif
int spawnv(logger *log, const char *prog, const char *const *argv)
{
- return do_spawn(log, 0, prog, argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, argv);
}
int spawnl(logger *log, const char *prog, ...)
@@ -226,28 +237,114 @@ int spawnl(logger *log, const char *prog
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 0, prog, (const char **) argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, (const char **) argv);
}
+int spawn_mount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ unsigned int options;
+
+ /* If we use mount locking we can't validate the location */
#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...)
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
+#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
+/*
+ * For bind mounts that depend on the target being mounted (possibly
+ * itself an automount) we attempt to mount the target using an opendir
+ * call. For this to work the location must be the second last arg.
+ *
+ * NOTE: If mount locking is enabled this type of recursive mount cannot
+ * work.
+ */
+int spawn_bind_mount(logger *log, ...)
{
va_list arg;
int argc;
char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ char bind[] = "--bind";
+ unsigned int options;
- va_start(arg, prog);
+ /* If we use mount locking we can't validate the location */
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_OPENDIR;
+#endif
+
+ va_start(arg, log);
for (argc = 1; va_arg(arg, char *); argc++);
va_end(arg);
- if (!(argv = alloca(sizeof(char *) * argc)))
+ if (!(argv = alloca(sizeof(char *) * argc + 2)))
return -1;
- va_start(arg, prog);
- p = argv;
+ argv[0] = arg0;
+ argv[1] = bind;
+
+ va_start(arg, log);
+ p = argv + 2;
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 1, prog, (const char **) argv);
+ return do_spawn(log, options, prog, (const char **) argv);
}
+
+int spawn_umount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_UMOUNT;
+ char arg0[] = PATH_UMOUNT;
+ unsigned int options;
+
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
diff --git a/include/automount.h b/include/automount.h
index 1f4fc6b..9c2de00 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -195,12 +195,10 @@ inline void dump_core(void);
int aquire_lock(void);
void release_lock(void);
int spawnl(logger *log, const char *prog, ...);
-#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...);
-#else
-#define spawnll spawnl
-#endif
int spawnv(logger *log, const char *prog, const char *const *argv);
+int spawn_mount(logger *log, ...);
+int spawn_bind_mount(logger *log, ...);
+int spawn_umount(logger *log, ...);
void reset_signals(void);
int do_mount(struct autofs_point *ap, const char *root, const char *name,
int name_len, const char *what, const char *fstype,
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
index b584250..a6a6f18 100644
--- a/lib/parse_subs.c
+++ b/lib/parse_subs.c
@@ -304,9 +304,9 @@ int umount_ent(struct autofs_point *ap,
* and EBADSLT relates to CD changer not responding.
*/
if (!status && (S_ISDIR(st.st_mode) && st.st_dev != ap->dev)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_mount(log_debug, path, NULL);
} else if (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_umount(log_debug, path, NULL);
}
/* We are doing a forced shutcwdown down so unlink busy mounts */
@@ -324,7 +324,7 @@ int umount_ent(struct autofs_point *ap,
if (ap->state == ST_SHUTDOWN_FORCE) {
msg("forcing umount of %s", path);
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, "-l", path, NULL);
+ rv = spawn_umount(log_debug, "-l", path, NULL);
}
/*
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 96ca29b..1cdb1c6 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -56,9 +56,7 @@ int mount_init(void **context)
if (lstat(tmp1, &st1) == -1)
goto out;
- err = spawnl(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL);
-
+ err = spawn_mount(log_debug, "-n", "--bind", tmp1, tmp2, NULL);
if (err == 0 &&
lstat(tmp2, &st2) == 0 &&
st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
@@ -67,8 +65,7 @@ int mount_init(void **context)
debug(LOGOPT_NONE, MODPREFIX "bind_works = %d", bind_works);
- spawnl(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL);
+ spawn_umount(log_debug, "-n", tmp2, NULL);
out:
rmdir(tmp2);
@@ -149,10 +146,8 @@ int mount_mount(struct autofs_point *ap,
"calling mount --bind " SLOPPY " -o %s %s %s",
options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "--bind",
- SLOPPYOPT "-o", options,
- what, fullpath, NULL);
+ err = spawn_bind_mount(log_debug,
+ SLOPPYOPT "-o", options, what, fullpath, NULL);
if (err) {
if (ap->type != LKP_INDIRECT)
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index eb29c8c..b817d36 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -80,8 +80,7 @@ int mount_mount(struct autofs_point *ap,
debug(ap->logopt, MODPREFIX "calling umount %s", what);
- err = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, what, NULL);
+ err = spawn_umount(log_debug, what, NULL);
if (err) {
error(ap->logopt,
MODPREFIX
@@ -116,16 +115,14 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug, PATH_MOUNT, PATH_MOUNT,
- "-t", fstype, what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 7774adf..45f0615 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -132,16 +132,13 @@ #endif
debug(ap->logopt,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index ad726e7..1f43baa 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -93,15 +93,12 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 8b4ddac..55e4f98 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -225,17 +225,15 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t nfs " SLOPPY
"-o %s %s %s", nfsoptions, loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", SLOPPYOPT "-o", nfsoptions,
- loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", SLOPPYOPT "-o",
+ nfsoptions, loc, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t nfs %s %s",
loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", loc, fullpath, NULL);
}
if (!err) {
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-27 7:52 ` Ian Kent
@ 2006-08-29 11:11 ` Ian Kent
2006-08-30 19:44 ` Matt Bernstein
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-29 11:11 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Sun, 2006-08-27 at 15:52 +0800, Ian Kent wrote:
> On Fri, 25 Aug 2006, Ian Kent wrote:
>
> > On Fri, 2006-08-25 at 14:22 +0100, Matt Bernstein wrote:
> > > At 14:09 +0100 Matt Bernstein wrote:
> > >
> > > > At 19:18 +0800 Ian Kent wrote:
> > > >
> > > >> Could you try this patch please.
> > > >
> > > > Thanks.. now my messages are slightly different (though it still fails).
> > > >
> > > > Aug 25 14:07:19 laurel automount[17416]: attempting to mount entry /homes/mb
> > > > Aug 25 14:07:19 laurel automount[17416]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
> > > > Aug 25 14:07:19 laurel automount[17416]: failed to mount /homes/mb
> > >
> > > Actually, this only happens when the target isn't already mounted. It does
> > > perform a bind mount if there's something to bind to. Now what we need to
> > > do (I think) is tickle the target in case it's another automount point, a
> > > la our-bad-patch-for-autofs4.
> >
> > Shouldn't need to do that.
> > This my be due to changes in the lookup flags in the kernel over time.
> > I haven't reviewed that for some time now.
>
> And that seems OK.
>
> Can you try this patch in addition to the previous patch please.
There was a mistake in this patch.
Use this one instead please.
--
diff --git a/daemon/direct.c b/daemon/direct.c
index 9a1cd59..cfa13ad 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -273,8 +273,7 @@ static int unlink_mount_tree(struct auto
continue;
if (strcmp(mnt->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", mnt->path, NULL);
+ rv = spawn_umount(log_debug, "-l", mnt->path, NULL);
else
rv = umount2(mnt->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 38d0b7a..9ceb015 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -95,8 +95,7 @@ static int unlink_mount_tree(struct auto
}
if (strcmp(this->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", this->path, NULL);
+ rv = spawn_umount(log_debug, "-l", this->path, NULL);
else
rv = umount2(this->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/spawn.c b/daemon/spawn.c
index 7dc4a81..84df3b9 100644
--- a/daemon/spawn.c
+++ b/daemon/spawn.c
@@ -20,6 +20,7 @@ #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <dirent.h>
#include <unistd.h>
#include <time.h>
#include <sys/wait.h>
@@ -27,9 +28,11 @@ #include <sys/stat.h>
#include "automount.h"
-#ifdef ENABLE_MOUNT_LOCKING
static pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
+
+#define SPAWN_OPT_NONE 0x0000
+#define SPAWN_OPT_LOCK 0x0001
+#define SPAWN_OPT_OPENDIR 0x0002
inline void dump_core(void)
{
@@ -83,26 +86,15 @@ void reset_signals(void)
#define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
-#ifdef ENABLE_MOUNT_LOCKING
-void spawn_unlock(void *arg)
-{
- int *use_lock = (int *) arg;
-
- if (*use_lock) {
- if (pthread_mutex_unlock(&spawn_mutex))
- warn(LOGOPT_NONE, "failed to unlock spawn_mutex");
- }
- return;
-}
-#endif
-
-static int do_spawn(logger *log, int use_lock, const char *prog, const
char *const *argv)
+static int do_spawn(logger *log, unsigned int options, const char
*prog, const char *const *argv)
{
pid_t f;
int status, pipefd[2];
char errbuf[ERRBUFSIZ + 1], *p, *sp;
int errp, errn;
int cancel_state;
+ unsigned int use_lock = options & SPAWN_OPT_LOCK;
+ unsigned int use_opendir = options & SPAWN_OPT_OPENDIR;
sigset_t allsigs, tmpsig, oldsig;
if (pipe(pipefd))
@@ -113,16 +105,11 @@ static int do_spawn(logger *log, int use
sigfillset(&allsigs);
pthread_sigmask(SIG_BLOCK, &allsigs, &oldsig);
-#ifdef ENABLE_MOUNT_LOCKING
if (use_lock) {
- if (pthread_mutex_lock(&spawn_mutex)) {
- log(LOGOPT_ANY, "failed to lock spawn_mutex");
- pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
- pthread_setcancelstate(cancel_state, NULL);
- return -1;
- }
+ status = pthread_mutex_lock(&spawn_mutex);
+ if (status)
+ fatal(status);
}
-#endif
f = fork();
if (f == 0) {
@@ -132,6 +119,26 @@ #endif
dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]);
+ /* Bind mount - check target exists */
+ if (use_opendir) {
+ char **pargv = (char **) argv;
+ int argc = 0;
+ pid_t pgrp = getpgrp();
+ DIR *dfd;
+
+ /* what to mount must always be second last */
+ while (*pargv++)
+ argc++;
+ argc -= 2;
+
+ /* Set non-autofs program group to trigger mount */
+ setpgrp();
+ if ((dfd = opendir(argv[argc])) == NULL)
+ _exit(errno);
+ closedir(dfd);
+ setpgid(0, pgrp);
+ }
+
execv(prog, (char *const *) argv);
_exit(255); /* execv() failed */
} else {
@@ -144,10 +151,12 @@ #endif
if (f < 0) {
close(pipefd[0]);
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return -1;
}
@@ -193,10 +202,12 @@ #endif
if (waitpid(f, &status, 0) != f)
status = -1; /* waitpid() failed */
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return status;
@@ -205,7 +216,7 @@ #endif
int spawnv(logger *log, const char *prog, const char *const *argv)
{
- return do_spawn(log, 0, prog, argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, argv);
}
int spawnl(logger *log, const char *prog, ...)
@@ -226,28 +237,114 @@ int spawnl(logger *log, const char *prog
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 0, prog, (const char **) argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, (const char **) argv);
}
+int spawn_mount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ unsigned int options;
+
+ /* If we use mount locking we can't validate the location */
#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...)
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
+#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
+/*
+ * For bind mounts that depend on the target being mounted (possibly
+ * itself an automount) we attempt to mount the target using an opendir
+ * call. For this to work the location must be the second last arg.
+ *
+ * NOTE: If mount locking is enabled this type of recursive mount
cannot
+ * work.
+ */
+int spawn_bind_mount(logger *log, ...)
{
va_list arg;
int argc;
char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ char bind[] = "--bind";
+ unsigned int options;
- va_start(arg, prog);
+ /* If we use mount locking we can't validate the location */
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_OPENDIR;
+#endif
+
+ va_start(arg, log);
for (argc = 1; va_arg(arg, char *); argc++);
va_end(arg);
- if (!(argv = alloca(sizeof(char *) * argc)))
+ if (!(argv = alloca(sizeof(char *) * argc + 2)))
return -1;
- va_start(arg, prog);
- p = argv;
+ argv[0] = arg0;
+ argv[1] = bind;
+
+ va_start(arg, log);
+ p = argv + 2;
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 1, prog, (const char **) argv);
+ return do_spawn(log, options, prog, (const char **) argv);
}
+
+int spawn_umount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_UMOUNT;
+ char arg0[] = PATH_UMOUNT;
+ unsigned int options;
+
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
diff --git a/include/automount.h b/include/automount.h
index 1f4fc6b..9c2de00 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -195,12 +195,10 @@ inline void dump_core(void);
int aquire_lock(void);
void release_lock(void);
int spawnl(logger *log, const char *prog, ...);
-#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...);
-#else
-#define spawnll spawnl
-#endif
int spawnv(logger *log, const char *prog, const char *const *argv);
+int spawn_mount(logger *log, ...);
+int spawn_bind_mount(logger *log, ...);
+int spawn_umount(logger *log, ...);
void reset_signals(void);
int do_mount(struct autofs_point *ap, const char *root, const char
*name,
int name_len, const char *what, const char *fstype,
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
index b584250..fbbc515 100644
--- a/lib/parse_subs.c
+++ b/lib/parse_subs.c
@@ -304,9 +304,9 @@ int umount_ent(struct autofs_point *ap,
* and EBADSLT relates to CD changer not responding.
*/
if (!status && (S_ISDIR(st.st_mode) && st.st_dev != ap->dev)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_umount(log_debug, path, NULL);
} else if (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_umount(log_debug, path, NULL);
}
/* We are doing a forced shutcwdown down so unlink busy mounts */
@@ -324,7 +324,7 @@ int umount_ent(struct autofs_point *ap,
if (ap->state == ST_SHUTDOWN_FORCE) {
msg("forcing umount of %s", path);
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, "-l", path, NULL);
+ rv = spawn_umount(log_debug, "-l", path, NULL);
}
/*
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 96ca29b..1cdb1c6 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -56,9 +56,7 @@ int mount_init(void **context)
if (lstat(tmp1, &st1) == -1)
goto out;
- err = spawnl(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL);
-
+ err = spawn_mount(log_debug, "-n", "--bind", tmp1, tmp2, NULL);
if (err == 0 &&
lstat(tmp2, &st2) == 0 &&
st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
@@ -67,8 +65,7 @@ int mount_init(void **context)
debug(LOGOPT_NONE, MODPREFIX "bind_works = %d", bind_works);
- spawnl(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL);
+ spawn_umount(log_debug, "-n", tmp2, NULL);
out:
rmdir(tmp2);
@@ -149,10 +146,8 @@ int mount_mount(struct autofs_point *ap,
"calling mount --bind " SLOPPY " -o %s %s %s",
options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "--bind",
- SLOPPYOPT "-o", options,
- what, fullpath, NULL);
+ err = spawn_bind_mount(log_debug,
+ SLOPPYOPT "-o", options, what, fullpath, NULL);
if (err) {
if (ap->type != LKP_INDIRECT)
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index eb29c8c..b817d36 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -80,8 +80,7 @@ int mount_mount(struct autofs_point *ap,
debug(ap->logopt, MODPREFIX "calling umount %s", what);
- err = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, what, NULL);
+ err = spawn_umount(log_debug, what, NULL);
if (err) {
error(ap->logopt,
MODPREFIX
@@ -116,16 +115,14 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug, PATH_MOUNT, PATH_MOUNT,
- "-t", fstype, what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 7774adf..45f0615 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -132,16 +132,13 @@ #endif
debug(ap->logopt,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index ad726e7..1f43baa 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -93,15 +93,12 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 8b4ddac..55e4f98 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -225,17 +225,15 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t nfs " SLOPPY
"-o %s %s %s", nfsoptions, loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", SLOPPYOPT "-o", nfsoptions,
- loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", SLOPPYOPT "-o",
+ nfsoptions, loc, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t nfs %s %s",
loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", loc, fullpath, NULL);
}
if (!err) {
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-29 11:11 ` Ian Kent
@ 2006-08-30 19:44 ` Matt Bernstein
2006-08-31 3:18 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-30 19:44 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
On Aug 29 Ian Kent wrote:
>> Can you try this patch in addition to the previous patch please.
>
> There was a mistake in this patch.
> Use this one instead please.
Sorry for the delay, I've been away singing..
Your patch applied cleanlyish (just line wrapping to deal with), and now
it does *most* of the right things.
Aug 30 20:09:31 laurel automount[12035]: handle_packet: type = 3
Aug 30 20:09:31 laurel automount[12035]: handle_packet_missing_indirect: token 1, name mb, request pid 12055
Aug 30 20:09:31 laurel automount[12035]: attempting to mount entry /homes/mb
Aug 30 20:09:31 laurel automount[12035]: lookup_mount: lookup(ldap): looking up mb
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): searching for "(&(objectclass=automount)(|(cn=mb)(cn=/)))" under "ou=auto.homes,dc=dcs,dc=qmul,dc=ac,dc=uk"
Aug 30 20:09:31 laurel automount[12035]: do_connect: auth_required: 1, sasl_mech (null)
Aug 30 20:09:31 laurel automount[12035]: do_connect: lookup(ldap): ldap anonymous bind returned 0
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): getting first entry for cn="mb"
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): examining first entry
Aug 30 20:09:31 laurel automount[12035]: unbind_ldap_connection: use_tls: 2
Aug 30 20:09:31 laurel automount[12035]: lookup_mount: lookup(ldap): mb -> :/home/cream/home71/mb
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): expanded entry: :/home/cream/home71/mb
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): gathered options:
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): dequote(":/home/cream/home71/mb") -> :/home/cream/home71/mb
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): core of entry: options=, loc=:/home/cream/home71/mb
Aug 30 20:09:31 laurel automount[12035]: sun_mount: parse(sun): mounting root /homes, mountpoint mb, what :/home/cream/home71/mb, fstype nfs, options (null)
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): root=/homes name=mb what=:/home/cream/home71/mb, fstype=nfs, options=(null)
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): calling mkdir_path /homes/mb
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): mb is local, attempt bind mount
[so far, so good]
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(bind): calling mkdir_path /homes/mb
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(bind): calling mount --bind -s -o defaults /home/cream/home71/mb /homes/mb
Aug 30 20:09:31 laurel automount[12035]: handle_packet: type = 3
Aug 30 20:09:31 laurel automount[12035]: handle_packet_missing_indirect: token 2, name home71, request pid 12057
Aug 30 20:09:31 laurel automount[12035]: attempting to mount entry /home/cream/home71
Aug 30 20:09:31 laurel automount[12035]: lookup_mount: lookup(ldap): looking up home71
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): searching for "(&(objectclass=automount)(|(cn=home71)(cn=/)))" under "ou=auto.home.cream,dc=dcs,dc=qmul,dc=ac,dc=uk"
Aug 30 20:09:31 laurel automount[12035]: do_connect: auth_required: 1, sasl_mech (null)
Aug 30 20:09:31 laurel automount[12035]: do_connect: lookup(ldap): ldap anonymous bind returned 0
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): getting first entry for cn="home71"
Aug 30 20:09:31 laurel automount[12035]: lookup_one: lookup(ldap): examining first entry
Aug 30 20:09:31 laurel automount[12035]: unbind_ldap_connection: use_tls: 2
Aug 30 20:09:31 laurel automount[12035]: lookup_mount: lookup(ldap): home71 -> :/server/cream/export71/users
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): expanded entry: :/server/cream/export71/users
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): gathered options:
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): dequote(":/server/cream/export71/users") -> :/server/cream/export71/users
Aug 30 20:09:31 laurel automount[12035]: parse_mount: parse(sun): core of entry: options=, loc=:/server/cream/export71/users
Aug 30 20:09:31 laurel automount[12035]: sun_mount: parse(sun): mounting root /home/cream, mountpoint home71, what :/server/cream/export71/users, fstype nfs, options (null)
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): root=/home/cream name=home71 what=:/server/cream/export71/users, fstype=nfs, options=(null)
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): calling mkdir_path /home/cream/home71
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(nfs): home71 is local, attempt bind mount
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(bind): calling mkdir_path /home/cream/home71
Aug 30 20:09:31 laurel automount[12035]: mount_mount: mount(bind): calling mount --bind -s -o defaults /server/cream/export71/users /home/cream/home71
Aug 30 20:09:31 laurel automount[12035]: handle_packet: type = 3
Aug 30 20:09:31 laurel automount[12035]: handle_packet_missing_indirect: token 3, name export71, request pid 12059
Aug 30 20:09:31 laurel automount[12035]: attempting to mount entry /server/cream/export71
Aug 30 20:09:32 laurel automount[12035]: lookup_mount: lookup(ldap): looking up export71
Aug 30 20:09:32 laurel automount[12035]: lookup_one: lookup(ldap): searching for "(&(objectclass=automount)(|(cn=export71)(cn=/)))" under "ou=auto.server.cream,dc=dcs,dc=qmul,dc=ac,dc=uk"
Aug 30 20:09:32 laurel automount[12035]: do_connect: auth_required: 1, sasl_mech (null)
Aug 30 20:09:32 laurel automount[12035]: do_connect: lookup(ldap): ldap anonymous bind returned 0
Aug 30 20:09:32 laurel automount[12035]: lookup_one: lookup(ldap): getting first entry for cn="export71"
Aug 30 20:09:32 laurel automount[12035]: lookup_one: lookup(ldap): examining first entry
Aug 30 20:09:32 laurel automount[12035]: unbind_ldap_connection: use_tls: 2
Aug 30 20:09:32 laurel automount[12035]: lookup_mount: lookup(ldap): export71 -> -rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3 cream:/export71
Aug 30 20:09:32 laurel automount[12035]: parse_mount: parse(sun): expanded entry: -rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3 cream:/export71
Aug 30 20:09:32 laurel automount[12035]: parse_mount: parse(sun): gathered options: rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3
Aug 30 20:09:32 laurel automount[12035]: parse_mount: parse(sun): dequote("cream:/export71") -> cream:/export71
Aug 30 20:09:32 laurel automount[12035]: parse_mount: parse(sun): core of entry: options=rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3, loc=cream:/export71
Aug 30 20:09:32 laurel automount[12035]: sun_mount: parse(sun): mounting root /server/cream, mountpoint export71, what cream:/export71, fstype nfs, options rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3
Aug 30 20:09:32 laurel automount[12035]: mount_mount: mount(nfs): root=/server/cream name=export71 what=cream:/export71, fstype=nfs, options=rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3
Aug 30 20:09:32 laurel automount[12035]: mount_mount: mount(nfs): nfs options="rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3", nosymlink=0, ro=0
Aug 30 20:09:32 laurel automount[12035]: mount_mount: mount(nfs): calling mkdir_path /server/cream/export71
Aug 30 20:09:32 laurel automount[12035]: mount_mount: mount(nfs): calling mount -t nfs -s -o rw,rsize=8192,wsize=8192,nosuid,hard,intr,lock,proto=udp,nfsvers=3 cream:/export71 /server/cream/export71
Aug 30 20:09:32 laurel automount[12035]: mount(nfs): mounted cream:/export71 on /server/cream/export71
Aug 30 20:09:32 laurel automount[12035]: send_ready: token = 3
Aug 30 20:09:32 laurel automount[12035]: mounted /server/cream/export71
Aug 30 20:09:32 laurel automount[12035]: mount_mount: mount(bind): mounted /server/cream/export71/users type bind on /home/cream/home71
Aug 30 20:09:32 laurel automount[12035]: send_ready: token = 2
Aug 30 20:09:32 laurel automount[12035]: mounted /home/cream/home71
[so far, so good, I think]
Aug 30 20:09:32 laurel automount[12035]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
Aug 30 20:09:32 laurel automount[12035]: send_fail: token = 1
Aug 30 20:09:32 laurel automount[12035]: failed to mount /homes/mb
Not sure why it wants to nfs-mount something it previously thought should
be a bind mount. Hope the log is useful, though.
Thanks
Matt
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-30 19:44 ` Matt Bernstein
@ 2006-08-31 3:18 ` Ian Kent
2006-08-31 9:45 ` Matt Bernstein
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-31 3:18 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Wed, 2006-08-30 at 20:44 +0100, Matt Bernstein wrote:
> On Aug 29 Ian Kent wrote:
>
> >> Can you try this patch in addition to the previous patch please.
> >
> > There was a mistake in this patch.
> > Use this one instead please.
>
> Sorry for the delay, I've been away singing..
>
> Your patch applied cleanlyish (just line wrapping to deal with), and now
> it does *most* of the right things.
My mistake, must have broken the patch when I sent it.
I was able to duplicate the setup reflected in the log and the mount
succeeded.
How about we try the patch again but properly formatted.
diff --git a/daemon/direct.c b/daemon/direct.c
index 9a1cd59..cfa13ad 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -273,8 +273,7 @@ static int unlink_mount_tree(struct auto
continue;
if (strcmp(mnt->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", mnt->path, NULL);
+ rv = spawn_umount(log_debug, "-l", mnt->path, NULL);
else
rv = umount2(mnt->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 38d0b7a..9ceb015 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -95,8 +95,7 @@ static int unlink_mount_tree(struct auto
}
if (strcmp(this->fs_type, "autofs"))
- rv = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-l", this->path, NULL);
+ rv = spawn_umount(log_debug, "-l", this->path, NULL);
else
rv = umount2(this->path, MNT_DETACH);
if (rv == -1) {
diff --git a/daemon/spawn.c b/daemon/spawn.c
index 7dc4a81..84df3b9 100644
--- a/daemon/spawn.c
+++ b/daemon/spawn.c
@@ -20,6 +20,7 @@ #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <dirent.h>
#include <unistd.h>
#include <time.h>
#include <sys/wait.h>
@@ -27,9 +28,11 @@ #include <sys/stat.h>
#include "automount.h"
-#ifdef ENABLE_MOUNT_LOCKING
static pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
+
+#define SPAWN_OPT_NONE 0x0000
+#define SPAWN_OPT_LOCK 0x0001
+#define SPAWN_OPT_OPENDIR 0x0002
inline void dump_core(void)
{
@@ -83,26 +86,15 @@ void reset_signals(void)
#define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
-#ifdef ENABLE_MOUNT_LOCKING
-void spawn_unlock(void *arg)
-{
- int *use_lock = (int *) arg;
-
- if (*use_lock) {
- if (pthread_mutex_unlock(&spawn_mutex))
- warn(LOGOPT_NONE, "failed to unlock spawn_mutex");
- }
- return;
-}
-#endif
-
-static int do_spawn(logger *log, int use_lock, const char *prog, const char *const *argv)
+static int do_spawn(logger *log, unsigned int options, const char *prog, const char *const *argv)
{
pid_t f;
int status, pipefd[2];
char errbuf[ERRBUFSIZ + 1], *p, *sp;
int errp, errn;
int cancel_state;
+ unsigned int use_lock = options & SPAWN_OPT_LOCK;
+ unsigned int use_opendir = options & SPAWN_OPT_OPENDIR;
sigset_t allsigs, tmpsig, oldsig;
if (pipe(pipefd))
@@ -113,16 +105,11 @@ static int do_spawn(logger *log, int use
sigfillset(&allsigs);
pthread_sigmask(SIG_BLOCK, &allsigs, &oldsig);
-#ifdef ENABLE_MOUNT_LOCKING
if (use_lock) {
- if (pthread_mutex_lock(&spawn_mutex)) {
- log(LOGOPT_ANY, "failed to lock spawn_mutex");
- pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
- pthread_setcancelstate(cancel_state, NULL);
- return -1;
- }
+ status = pthread_mutex_lock(&spawn_mutex);
+ if (status)
+ fatal(status);
}
-#endif
f = fork();
if (f == 0) {
@@ -132,6 +119,26 @@ #endif
dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]);
+ /* Bind mount - check target exists */
+ if (use_opendir) {
+ char **pargv = (char **) argv;
+ int argc = 0;
+ pid_t pgrp = getpgrp();
+ DIR *dfd;
+
+ /* what to mount must always be second last */
+ while (*pargv++)
+ argc++;
+ argc -= 2;
+
+ /* Set non-autofs program group to trigger mount */
+ setpgrp();
+ if ((dfd = opendir(argv[argc])) == NULL)
+ _exit(errno);
+ closedir(dfd);
+ setpgid(0, pgrp);
+ }
+
execv(prog, (char *const *) argv);
_exit(255); /* execv() failed */
} else {
@@ -144,10 +151,12 @@ #endif
if (f < 0) {
close(pipefd[0]);
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return -1;
}
@@ -193,10 +202,12 @@ #endif
if (waitpid(f, &status, 0) != f)
status = -1; /* waitpid() failed */
+ if (use_lock) {
+ status = pthread_mutex_unlock(&spawn_mutex);
+ if (status)
+ fatal(status);
+ }
pthread_sigmask(SIG_SETMASK, &oldsig, NULL);
-#ifdef ENABLE_MOUNT_LOCKING
- spawn_unlock(&use_lock);
-#endif
pthread_setcancelstate(cancel_state, NULL);
return status;
@@ -205,7 +216,7 @@ #endif
int spawnv(logger *log, const char *prog, const char *const *argv)
{
- return do_spawn(log, 0, prog, argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, argv);
}
int spawnl(logger *log, const char *prog, ...)
@@ -226,28 +237,114 @@ int spawnl(logger *log, const char *prog
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 0, prog, (const char **) argv);
+ return do_spawn(log, SPAWN_OPT_NONE, prog, (const char **) argv);
}
+int spawn_mount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ unsigned int options;
+
+ /* If we use mount locking we can't validate the location */
#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...)
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
+#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
+/*
+ * For bind mounts that depend on the target being mounted (possibly
+ * itself an automount) we attempt to mount the target using an opendir
+ * call. For this to work the location must be the second last arg.
+ *
+ * NOTE: If mount locking is enabled this type of recursive mount cannot
+ * work.
+ */
+int spawn_bind_mount(logger *log, ...)
{
va_list arg;
int argc;
char **argv, **p;
+ char prog[] = PATH_MOUNT;
+ char arg0[] = PATH_MOUNT;
+ char bind[] = "--bind";
+ unsigned int options;
- va_start(arg, prog);
+ /* If we use mount locking we can't validate the location */
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_OPENDIR;
+#endif
+
+ va_start(arg, log);
for (argc = 1; va_arg(arg, char *); argc++);
va_end(arg);
- if (!(argv = alloca(sizeof(char *) * argc)))
+ if (!(argv = alloca(sizeof(char *) * argc + 2)))
return -1;
- va_start(arg, prog);
- p = argv;
+ argv[0] = arg0;
+ argv[1] = bind;
+
+ va_start(arg, log);
+ p = argv + 2;
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(log, 1, prog, (const char **) argv);
+ return do_spawn(log, options, prog, (const char **) argv);
}
+
+int spawn_umount(logger *log, ...)
+{
+ va_list arg;
+ int argc;
+ char **argv, **p;
+ char prog[] = PATH_UMOUNT;
+ char arg0[] = PATH_UMOUNT;
+ unsigned int options;
+
+#ifdef ENABLE_MOUNT_LOCKING
+ options = SPAWN_OPT_LOCK;
+#else
+ options = SPAWN_OPT_NONE;
#endif
+
+ va_start(arg, log);
+ for (argc = 1; va_arg(arg, char *); argc++);
+ va_end(arg);
+
+ if (!(argv = alloca(sizeof(char *) * argc + 1)))
+ return -1;
+
+ argv[0] = arg0;
+
+ va_start(arg, log);
+ p = argv + 1;
+ while ((*p++ = va_arg(arg, char *)));
+ va_end(arg);
+
+ return do_spawn(log, options, prog, (const char **) argv);
+}
+
diff --git a/include/automount.h b/include/automount.h
index 1f4fc6b..9c2de00 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -195,12 +195,10 @@ inline void dump_core(void);
int aquire_lock(void);
void release_lock(void);
int spawnl(logger *log, const char *prog, ...);
-#ifdef ENABLE_MOUNT_LOCKING
-int spawnll(logger *log, const char *prog, ...);
-#else
-#define spawnll spawnl
-#endif
int spawnv(logger *log, const char *prog, const char *const *argv);
+int spawn_mount(logger *log, ...);
+int spawn_bind_mount(logger *log, ...);
+int spawn_umount(logger *log, ...);
void reset_signals(void);
int do_mount(struct autofs_point *ap, const char *root, const char *name,
int name_len, const char *what, const char *fstype,
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
index b584250..fbbc515 100644
--- a/lib/parse_subs.c
+++ b/lib/parse_subs.c
@@ -304,9 +304,9 @@ int umount_ent(struct autofs_point *ap,
* and EBADSLT relates to CD changer not responding.
*/
if (!status && (S_ISDIR(st.st_mode) && st.st_dev != ap->dev)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_umount(log_debug, path, NULL);
} else if (is_smbfs && (sav_errno == EIO || sav_errno == EBADSLT)) {
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, path, NULL);
+ rv = spawn_umount(log_debug, path, NULL);
}
/* We are doing a forced shutcwdown down so unlink busy mounts */
@@ -324,7 +324,7 @@ int umount_ent(struct autofs_point *ap,
if (ap->state == ST_SHUTDOWN_FORCE) {
msg("forcing umount of %s", path);
- rv = spawnll(log_debug, PATH_UMOUNT, PATH_UMOUNT, "-l", path, NULL);
+ rv = spawn_umount(log_debug, "-l", path, NULL);
}
/*
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 96ca29b..1cdb1c6 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -56,9 +56,7 @@ int mount_init(void **context)
if (lstat(tmp1, &st1) == -1)
goto out;
- err = spawnl(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL);
-
+ err = spawn_mount(log_debug, "-n", "--bind", tmp1, tmp2, NULL);
if (err == 0 &&
lstat(tmp2, &st2) == 0 &&
st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
@@ -67,8 +65,7 @@ int mount_init(void **context)
debug(LOGOPT_NONE, MODPREFIX "bind_works = %d", bind_works);
- spawnl(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL);
+ spawn_umount(log_debug, "-n", tmp2, NULL);
out:
rmdir(tmp2);
@@ -149,10 +146,8 @@ int mount_mount(struct autofs_point *ap,
"calling mount --bind " SLOPPY " -o %s %s %s",
options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "--bind",
- SLOPPYOPT "-o", options,
- what, fullpath, NULL);
+ err = spawn_bind_mount(log_debug,
+ SLOPPYOPT "-o", options, what, fullpath, NULL);
if (err) {
if (ap->type != LKP_INDIRECT)
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
index eb29c8c..b817d36 100644
--- a/modules/mount_changer.c
+++ b/modules/mount_changer.c
@@ -80,8 +80,7 @@ int mount_mount(struct autofs_point *ap,
debug(ap->logopt, MODPREFIX "calling umount %s", what);
- err = spawnll(log_debug,
- PATH_UMOUNT, PATH_UMOUNT, what, NULL);
+ err = spawn_umount(log_debug, what, NULL);
if (err) {
error(ap->logopt,
MODPREFIX
@@ -116,16 +115,14 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug, PATH_MOUNT, PATH_MOUNT,
- "-t", fstype, what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
index 7774adf..45f0615 100644
--- a/modules/mount_ext2.c
+++ b/modules/mount_ext2.c
@@ -132,16 +132,13 @@ #endif
debug(ap->logopt,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
index ad726e7..1f43baa 100644
--- a/modules/mount_generic.c
+++ b/modules/mount_generic.c
@@ -93,15 +93,12 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
+ err = spawn_mount(log_debug, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(ap->logopt, MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t", fstype,
- what, fullpath, NULL);
+ err = spawn_mount(log_debug, "-t", fstype, what, fullpath, NULL);
}
if (err) {
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 8b4ddac..55e4f98 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -225,17 +225,15 @@ int mount_mount(struct autofs_point *ap,
MODPREFIX "calling mount -t nfs " SLOPPY
"-o %s %s %s", nfsoptions, loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", SLOPPYOPT "-o", nfsoptions,
- loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", SLOPPYOPT "-o",
+ nfsoptions, loc, fullpath, NULL);
} else {
debug(ap->logopt,
MODPREFIX "calling mount -t nfs %s %s",
loc, fullpath);
- err = spawnll(log_debug,
- PATH_MOUNT, PATH_MOUNT, "-t",
- "nfs", loc, fullpath, NULL);
+ err = spawn_mount(log_debug,
+ "-t", "nfs", loc, fullpath, NULL);
}
if (!err) {
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 3:18 ` Ian Kent
@ 2006-08-31 9:45 ` Matt Bernstein
2006-08-31 10:25 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-31 9:45 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 11:18 +0800 Ian Kent wrote:
> On Wed, 2006-08-30 at 20:44 +0100, Matt Bernstein wrote:
>>
>> Your patch applied cleanlyish (just line wrapping to deal with), and now
>> it does *most* of the right things.
>
> My mistake, must have broken the patch when I sent it.
> I was able to duplicate the setup reflected in the log and the mount
> succeeded.
>
> How about we try the patch again but properly formatted.
Same deal, I think :-\
Aug 31 10:37:39 laurel automount[20951]: mount(nfs): mounted cream:/export71 on /server/cream/export71
Aug 31 10:37:39 laurel automount[20951]: send_ready: token = 2135
Aug 31 10:37:39 laurel automount[20951]: mounted /server/cream/export71
Aug 31 10:37:39 laurel automount[20951]: mount_mount: mount(bind): mounted /server/cream/export71/users type bind on /home/cream/home71
^^^^^^^^^^^^^^^^^^^^^^^^
looks good
Aug 31 10:37:39 laurel automount[20951]: send_ready: token = 2134
Aug 31 10:37:39 laurel automount[20951]: mounted /home/cream/home71
Aug 31 10:37:39 laurel automount[20951]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
^^^^^^^^^^^^^^^
looks less good
Aug 31 10:37:39 laurel automount[20951]: send_fail: token = 2133
Aug 31 10:37:39 laurel automount[20951]: failed to mount /homes/mb
Maybe my auto.master is not right? Here are the relevant entries:
/server/cream ldap:ou=auto.server.cream,dc=dcs,dc=qmul,dc=ac,dc=uk -t 0
/home/cream ldap:ou=auto.home.cream,dc=dcs,dc=qmul,dc=ac,dc=uk
/homes ldap:ou=auto.homes,dc=dcs,dc=qmul,dc=ac,dc=uk
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 9:45 ` Matt Bernstein
@ 2006-08-31 10:25 ` Ian Kent
2006-08-31 11:18 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-31 10:25 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Thu, 2006-08-31 at 10:45 +0100, Matt Bernstein wrote:
> At 11:18 +0800 Ian Kent wrote:
>
> > On Wed, 2006-08-30 at 20:44 +0100, Matt Bernstein wrote:
> >>
> >> Your patch applied cleanlyish (just line wrapping to deal with), and now
> >> it does *most* of the right things.
> >
> > My mistake, must have broken the patch when I sent it.
> > I was able to duplicate the setup reflected in the log and the mount
> > succeeded.
> >
> > How about we try the patch again but properly formatted.
>
> Same deal, I think :-\
>
> Aug 31 10:37:39 laurel automount[20951]: mount(nfs): mounted cream:/export71 on /server/cream/export71
> Aug 31 10:37:39 laurel automount[20951]: send_ready: token = 2135
> Aug 31 10:37:39 laurel automount[20951]: mounted /server/cream/export71
> Aug 31 10:37:39 laurel automount[20951]: mount_mount: mount(bind): mounted /server/cream/export71/users type bind on /home/cream/home71
> ^^^^^^^^^^^^^^^^^^^^^^^^
> looks good
>
> Aug 31 10:37:39 laurel automount[20951]: send_ready: token = 2134
> Aug 31 10:37:39 laurel automount[20951]: mounted /home/cream/home71
> Aug 31 10:37:39 laurel automount[20951]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
> ^^^^^^^^^^^^^^^
> looks less good
That's just because the nfs mount module calls the bind mount module.
If it gets a fail return from the bind mount it reports it itself.
But I don't see any fails so I don't understand where this is comming
from.
>
> Aug 31 10:37:39 laurel automount[20951]: send_fail: token = 2133
> Aug 31 10:37:39 laurel automount[20951]: failed to mount /homes/mb
>
> Maybe my auto.master is not right? Here are the relevant entries:
Don't this this has anything to do with this.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 10:25 ` Ian Kent
@ 2006-08-31 11:18 ` Ian Kent
2006-08-31 11:54 ` Matt Bernstein
2006-08-31 11:57 ` Ian Kent
0 siblings, 2 replies; 32+ messages in thread
From: Ian Kent @ 2006-08-31 11:18 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Thu, 2006-08-31 at 18:25 +0800, Ian Kent wrote:
> >
> > Same deal, I think :-\
And I've been able to duplicate this on fc6-test2 with exactly the same
rpm. I'm beginning to think that it is mount(8) that's at fault here.
Maybe it's yet another attempt to remove support for the "-s" option.
We'll see.
I'd be interested to know if it works for an NFS mount entry with no
mount options.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 11:18 ` Ian Kent
@ 2006-08-31 11:54 ` Matt Bernstein
2006-09-03 21:31 ` autofs {3, 4, 5} and bind mounts which point to therr " Matt Bernstein
2006-08-31 11:57 ` Ian Kent
1 sibling, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-08-31 11:54 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 19:18 +0800 Ian Kent wrote:
> On Thu, 2006-08-31 at 18:25 +0800, Ian Kent wrote:
>>>
>>> Same deal, I think :-\
>
> And I've been able to duplicate this on fc6-test2 with exactly the same
> rpm. I'm beginning to think that it is mount(8) that's at fault here.
I can traverse /home/cream/home72/ correctly, which does appear to mount
cream:/export72 as /server/cream/export72 and then bind
/server/cream/export72/users to /home/cream/home72.
> Maybe it's yet another attempt to remove support for the "-s" option.
> We'll see.
>
> I'd be interested to know if it works for an NFS mount entry with no
> mount options.
Bizarrely, I've seen it work for some users now, eg:
cream:/export73 /server/cream/export73 nfs rw,nosuid,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,sec=sys,addr=cream 0 0
cream:/export73 /home/cream/home73 nfs rw,nosuid,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,sec=sys,addr=cream 0 0
cream:/export73 /homes/melanie nfs rw,nosuid,vers=3,rsize=8192,wsize=8192,hard,intr,proto=udp,timeo=11,retrans=2,sec=sys,addr=cream 0 0
I think it's working on some NFS volumes and not on others, even
though they're identically configured. I'll have to have a dig further.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 11:18 ` Ian Kent
2006-08-31 11:54 ` Matt Bernstein
@ 2006-08-31 11:57 ` Ian Kent
2006-08-31 12:10 ` Matt Bernstein
1 sibling, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-08-31 11:57 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Thu, 2006-08-31 at 19:18 +0800, Ian Kent wrote:
> On Thu, 2006-08-31 at 18:25 +0800, Ian Kent wrote:
> > >
> > > Same deal, I think :-\
>
> And I've been able to duplicate this on fc6-test2 with exactly the same
> rpm. I'm beginning to think that it is mount(8) that's at fault here.
>
> Maybe it's yet another attempt to remove support for the "-s" option.
> We'll see.
>
> I'd be interested to know if it works for an NFS mount entry with no
> mount options.
And it won't work
It's selinux again.
I'll bet your FC6 install has selinux in enforcing mode.
I'll bet that if you enable auditing of the "dontaudit" rules:
semodule -b /usr/share/selinux/targeted/enableaudit.pp
you'll get a message like:
audit(1157054094.219:95): avc: denied { read } for pid=9255
comm="automount" name="users" dev=0:18 ino=19065
scontext=user_u:system_r:automount_t:s0
tcontext=system_u:object_r:nfs_t:s0 tclass=dir
in your logs.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-08-31 11:57 ` Ian Kent
@ 2006-08-31 12:10 ` Matt Bernstein
0 siblings, 0 replies; 32+ messages in thread
From: Matt Bernstein @ 2006-08-31 12:10 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 19:57 +0800 Ian Kent wrote:
>> I'd be interested to know if it works for an NFS mount entry with no
>> mount options.
>
> And it won't work
>
> It's selinux again.
> I'll bet your FC6 install has selinux in enforcing mode.
[root@laurel ~]# getenforce
Permissive
So.. I believe I'm not affected.
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-09-03 21:31 ` autofs {3, 4, 5} and bind mounts which point to therr " Matt Bernstein
@ 2006-09-15 9:57 ` Matt Bernstein
2006-09-15 11:54 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-09-15 9:57 UTC (permalink / raw)
Cc: autofs, Ian Kent
On Sep 3 Matt Bernstein wrote:
> Further archaeology suggests that traversing home directories only works
> if they have 755 permissions.
>
> I've no idea why.
Just to clarify, the "they" refers to the NFS-mounted directory. We try
not to create home directories with 755 perms.
/server/cream/export71/users/mb and /home/cream/home71/mb traverse
correctly, saying "Permission denied". The former is the NFS mount, and
the latter a bind mount. They both work irrespective of whether the other
is mounted or not.
/homes/mb says "No such file or directory". The log suggests it's trying
to do an NFS mount, when it should be another bind mount.
/homes/dave (cream:/export74/users/dave having 755 perms) works perfectly,
with two bind mounts and one NFS mount.
Me and my layers of indirection... I suppose I could solve it by making
/homes/mb bind straight to :/server/cream/export71/users/mb, but that
wouldn't stop the bug from being there.
Matt
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-09-15 9:57 ` autofs {3, 4, 5} and bind mounts which point to other " Matt Bernstein
@ 2006-09-15 11:54 ` Ian Kent
2006-09-15 12:06 ` Matt Bernstein
0 siblings, 1 reply; 32+ messages in thread
From: Ian Kent @ 2006-09-15 11:54 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-09-15 at 10:57 +0100, Matt Bernstein wrote:
> On Sep 3 Matt Bernstein wrote:
>
> > Further archaeology suggests that traversing home directories only works
> > if they have 755 permissions.
> >
> > I've no idea why.
>
> Just to clarify, the "they" refers to the NFS-mounted directory. We try
> not to create home directories with 755 perms.
>
> /server/cream/export71/users/mb and /home/cream/home71/mb traverse
> correctly, saying "Permission denied". The former is the NFS mount, and
> the latter a bind mount. They both work irrespective of whether the other
> is mounted or not.
>
> /homes/mb says "No such file or directory". The log suggests it's trying
> to do an NFS mount, when it should be another bind mount.
>
> /homes/dave (cream:/export74/users/dave having 755 perms) works perfectly,
> with two bind mounts and one NFS mount.
Can you send the log please.
>
> Me and my layers of indirection... I suppose I could solve it by making
> /homes/mb bind straight to :/server/cream/export71/users/mb, but that
> wouldn't stop the bug from being there.
Yep.
Ian
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-09-15 11:54 ` Ian Kent
@ 2006-09-15 12:06 ` Matt Bernstein
2006-09-16 6:13 ` Ian Kent
0 siblings, 1 reply; 32+ messages in thread
From: Matt Bernstein @ 2006-09-15 12:06 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
At 19:54 +0800 Ian Kent wrote:
> On Fri, 2006-09-15 at 10:57 +0100, Matt Bernstein wrote:
>>
>> Just to clarify, the "they" refers to the NFS-mounted directory. We try
>> not to create home directories with 755 perms.
>>
>> /homes/mb says "No such file or directory". The log suggests it's trying
>> to do an NFS mount, when it should be another bind mount.
>>
>> /homes/dave (cream:/export74/users/dave having 755 perms) works perfectly,
>> with two bind mounts and one NFS mount.
>
> Can you send the log please.
Sep 15 12:59:31 laurel automount[7808]: attempting to mount entry /homes/mb
Sep 15 12:59:31 laurel automount[7808]: attempting to mount entry /home/cream/home71
Sep 15 12:59:32 laurel automount[7808]: attempting to mount entry /server/cream/export71
Sep 15 12:59:32 laurel automount[7808]: mount(nfs): mounted cream:/export71 on /server/cream/export71
Sep 15 12:59:32 laurel automount[7808]: mounted /server/cream/export71
Sep 15 12:59:32 laurel automount[7808]: mounted /home/cream/home71
Sep 15 12:59:32 laurel automount[7808]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
Sep 15 12:59:32 laurel automount[7808]: failed to mount /homes/mb
Sep 15 12:59:38 laurel automount[7808]: attempting to mount entry /homes/dave
Sep 15 12:59:39 laurel automount[7808]: attempting to mount entry /home/cream/home74
Sep 15 12:59:39 laurel automount[7808]: attempting to mount entry /server/cream/export74
Sep 15 12:59:39 laurel automount[7808]: mount(nfs): mounted cream:/export74 on /server/cream/export74
Sep 15 12:59:39 laurel automount[7808]: mounted /server/cream/export74
Sep 15 12:59:39 laurel automount[7808]: mounted /home/cream/home74
Sep 15 12:59:39 laurel automount[7808]: mounted /homes/dave
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: autofs {3, 4, 5} and bind mounts which point to other automount points
2006-09-15 12:06 ` Matt Bernstein
@ 2006-09-16 6:13 ` Ian Kent
0 siblings, 0 replies; 32+ messages in thread
From: Ian Kent @ 2006-09-16 6:13 UTC (permalink / raw)
To: Matt Bernstein; +Cc: autofs
On Fri, 2006-09-15 at 13:06 +0100, Matt Bernstein wrote:
> At 19:54 +0800 Ian Kent wrote:
>
> > On Fri, 2006-09-15 at 10:57 +0100, Matt Bernstein wrote:
> >>
> >> Just to clarify, the "they" refers to the NFS-mounted directory. We try
> >> not to create home directories with 755 perms.
> >>
> >> /homes/mb says "No such file or directory". The log suggests it's trying
> >> to do an NFS mount, when it should be another bind mount.
> >>
> >> /homes/dave (cream:/export74/users/dave having 755 perms) works perfectly,
> >> with two bind mounts and one NFS mount.
> >
> > Can you send the log please.
>
>
> Sep 15 12:59:31 laurel automount[7808]: attempting to mount entry /homes/mb
> Sep 15 12:59:31 laurel automount[7808]: attempting to mount entry /home/cream/home71
> Sep 15 12:59:32 laurel automount[7808]: attempting to mount entry /server/cream/export71
> Sep 15 12:59:32 laurel automount[7808]: mount(nfs): mounted cream:/export71 on /server/cream/export71
> Sep 15 12:59:32 laurel automount[7808]: mounted /server/cream/export71
> Sep 15 12:59:32 laurel automount[7808]: mounted /home/cream/home71
> Sep 15 12:59:32 laurel automount[7808]: mount(nfs): nfs: mount failure :/home/cream/home71/mb on /homes/mb
Ya .. but I think this message is sensible as the mount itself is
initiated from the mount_nfs.c module. Why it's failing is the question!
I'll see if I can duplicate this here, when I get a chance.
> Sep 15 12:59:32 laurel automount[7808]: failed to mount /homes/mb
>
> Sep 15 12:59:38 laurel automount[7808]: attempting to mount entry /homes/dave
> Sep 15 12:59:39 laurel automount[7808]: attempting to mount entry /home/cream/home74
> Sep 15 12:59:39 laurel automount[7808]: attempting to mount entry /server/cream/export74
> Sep 15 12:59:39 laurel automount[7808]: mount(nfs): mounted cream:/export74 on /server/cream/export74
> Sep 15 12:59:39 laurel automount[7808]: mounted /server/cream/export74
> Sep 15 12:59:39 laurel automount[7808]: mounted /home/cream/home74
> Sep 15 12:59:39 laurel automount[7808]: mounted /homes/dave
^ permalink raw reply [flat|nested] 32+ messages in thread
end of thread, other threads:[~2006-09-16 6:13 UTC | newest]
Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-25 16:18 autofs {3, 4, 5} and bind mounts which point to other automount points Joe Pruett
2006-08-25 17:25 ` Ian Kent
-- strict thread matches above, loose matches on Subject: below --
2006-08-24 14:44 Matt Bernstein
2006-08-25 1:29 ` Ian Kent
2006-08-25 6:45 ` Matt Bernstein
2006-08-25 6:58 ` Ian Kent
2006-08-25 7:07 ` Ian Kent
2006-08-25 11:18 ` Ian Kent
2006-08-25 13:09 ` Matt Bernstein
2006-08-25 13:22 ` Matt Bernstein
2006-08-25 14:37 ` Ian Kent
2006-08-27 7:52 ` Ian Kent
2006-08-29 11:11 ` Ian Kent
2006-08-30 19:44 ` Matt Bernstein
2006-08-31 3:18 ` Ian Kent
2006-08-31 9:45 ` Matt Bernstein
2006-08-31 10:25 ` Ian Kent
2006-08-31 11:18 ` Ian Kent
2006-08-31 11:54 ` Matt Bernstein
2006-09-03 21:31 ` autofs {3, 4, 5} and bind mounts which point to therr " Matt Bernstein
2006-09-15 9:57 ` autofs {3, 4, 5} and bind mounts which point to other " Matt Bernstein
2006-09-15 11:54 ` Ian Kent
2006-09-15 12:06 ` Matt Bernstein
2006-09-16 6:13 ` Ian Kent
2006-08-31 11:57 ` Ian Kent
2006-08-31 12:10 ` Matt Bernstein
2006-08-25 14:29 ` Ian Kent
2006-08-25 14:49 ` Matt Bernstein
2006-08-25 14:46 ` Ian Kent
2006-08-25 14:47 ` Matt Bernstein
2006-08-25 15:55 ` Ian Kent
2006-08-25 16:19 ` Matt Bernstein
2006-08-26 3:24 ` Ian Kent
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.