Skip to contentSkip to conversation

getting parameters to executable maps

DISCUSSION aptosca 3 participants 10 messages Jun 8, 2006 – Jun 21, 2006 Kernel automounter

lore
Share & tools
lore

aptosca

author
#0 lore raw

I've been looking for a way to get a parameter to an executable being used as a map and have so far failed to come up with anything that will work. Has this issue ever arisen? As far as I can tell, the exec of the program gets nothing except the key being looked up. The program I'd like to have exec'd needs just a little bit of context. It could be passed in through arguments specified in the calling map, but autofs doesn't, for example, break the string up at spaces for the exec call. Alternatively, if there were a way to get at the args that were passed in the options string, that would work, too, but again, I don't see anyway of making that happen.

Ideas?
Comments?

maintainer
#1 lore raw
Quoted 9 lines · aptosca

I've been looking for a way to get a parameter to an executable being used as a map and have so far failed to come up with anything that will work. Has this issue ever arisen? As far as I can tell, the exec of the program gets nothing except the key being looked up. The program I'd like to have exec'd needs just a little bit of context. It could be passed in through arguments specified in the calling map, but autofs doesn't, for example, break the string up at spaces for the exec call. Alternatively, if there were a way to get at the args that were passed in the options string, that would work, too, but again, I don't see anyway of making that happen.

Can you give a little more information please.

A simple example of what your program needs and where it comes from would be good.

Ian

author
#2 lore raw

I have a network service that defines a filesystem namespace. I'd like to write an executable map that uses that service to return map entries to automount. Abstractly, the executable map takes the namespace path, queries the web service, and returns a map entry to automount. The map entry is either a pointer to a real filesystem or an -fstype=autofs entry that causes the executable map to be executed again when/if an entry in the directory is touched.

The only hole in this is that the program being executed needs the entire namespace path (or something with the same information) in order to do the lookup. The autofs API only gives the map the key, making the context implicit in the map itself.

Here's an example, if executable maps could take arguments:

Auto.master would have something like

/net /etc/autofs/nsmap

Then doing a cd /net/a, nsmap would get called with argument a.

Nsmap, not seeing only one argument, would return something like

-fstype=autofs program:/etc/autofs/nsmap /a

Which would get an automount started on /net/a. Then, doing a

	Cd /net/a/b

Nsmap would get called with /etc/autofs/nsmap /a b, for which it could return

-fstype=autofs program:/etc/autofs/nsmap /a/b

Etc.

Arguably, this isn't the best way to do this since. An alternative would be to pass some of the options to the executable maps, so you could do something like

-fstype=autofs,-ns=/a/b program:/etc/autofs/nsmap

Is this any clearer? Any worse or better an idea?

I could possibly do the same thing if I could wrap the web service in an LDAP or NIS service. That would have the advantage of not requiring code on the client. Or, I could add XMLRPC as a map type to automount ... Neither LDAP nor NIS seem easy to wrap ...

maintainer
#3 lore raw
Quoted 7 lines · aptosca

I have a network service that defines a filesystem namespace. I'd like to write an executable map that uses that service to return map entries to automount. Abstractly, the executable map takes the namespace path, queries the web service, and returns a map entry to automount. The map entry is either a pointer to a real filesystem or an -fstype=autofs entry that causes the executable map to be executed again when/if an entry in the directory is touched.

I've thought about this and I can't think of any easy way to achieve this.

I don't like the idea of changing the internals of the way program maps are called.

One way to do this would be to write an autofs lookup module to handle this map source rather than use a program map.

Ian

#4 lore raw

==> Regarding RE: [autofs] getting parameters to executable maps; Ian Kent <[email protected]> adds:

Quoted 7 lines · aptosca
Quoted 7 lines

I have a network service that defines a filesystem namespace. I'd like to write an executable map that uses that service to return map entries to automount. Abstractly, the executable map takes the namespace path, queries the web service, and returns a map entry to automount. The map entry is either a pointer to a real filesystem or an -fstype=autofs entry that causes the executable map to be executed again when/if an entry in the directory is touched.

raven> I've thought about this and I can't think of any easy way to achieve raven> this.

raven> I don't like the idea of changing the internals of the way program raven> maps are called.

raven> One way to do this would be to write an autofs lookup module to raven> handle this map source rather than use a program map.

Is there any way we could achieve this via setting some environment variables?

-Jeff

maintainer
#5 lore raw
Quoted 14 lines · Jeff Moyer

==> Regarding RE: [autofs] getting parameters to executable maps; Ian Kent <[email protected]> adds:

Quoted 7 lines · aptosca
Quoted 7 lines

I have a network service that defines a filesystem namespace. I'd like to write an executable map that uses that service to return map entries to automount. Abstractly, the executable map takes the namespace path, queries the web service, and returns a map entry to automount. The map entry is either a pointer to a real filesystem or an -fstype=autofs entry that causes the executable map to be executed again when/if an entry in the directory is touched.

raven> I've thought about this and I can't think of any easy way to achieve raven> this.

Quoted 8 lines

raven> I don't like the idea of changing the internals of the way program raven> maps are called.

raven> One way to do this would be to write an autofs lookup module to raven> handle this map source rather than use a program map.

Is there any way we could achieve this via setting some environment variables?

I've been thinking about that but I'm not sure about it. Mainly because the information flow is from autofs to the program and autofs can't know what environment to set.

Are you perhaps suggesting we define one or so?

Ian

#6 lore raw

==> Regarding Re: [autofs] getting parameters to executable maps; Ian Kent <[email protected]> adds:

Quoted 3 lines · Jeff Moyer
Quoted 3 lines

==> Regarding RE: [autofs] getting parameters to executable maps; Ian Kent <[email protected]> adds:

Quoted 8 lines · aptosca
Quoted 8 lines
Quoted 1 line
Quoted 1 line

I have a network service that defines a filesystem namespace. I'd

like >> to write an executable map that uses that service to return map entries >> to automount. Abstractly, the executable map takes the namespace path, >> queries the web service, and returns a map entry to automount. The map >> entry is either a pointer to a real filesystem or an -fstype=autofs >> entry that causes the executable map to be executed again when/if an >> entry in the directory is touched.

raven> I've thought about this and I can't think of any easy way to achieve raven> this.

Quoted 1 line
Quoted 1 line

raven> I don't like the idea of changing the internals of the way program raven> maps are called.

Quoted 1 line
Quoted 1 line

raven> One way to do this would be to write an autofs lookup module to raven> handle this map source rather than use a program map.

Quoted 2 lines
Quoted 2 lines

Is there any way we could achieve this via setting some environment variables?

raven> I've been thinking about that but I'm not sure about it. Mainly raven> because the information flow is from autofs to the program and raven> autofs can't know what environment to set.

raven> Are you perhaps suggesting we define one or so?

Yeah, could be part of the API, if you will. If we do that, then it wouldn't require changing existing program maps, either. It's just a thought. I'd like to hear from the reporter (aptosca, no name specified, who are you?) if it would help in his/her situation.

-Jeff

author
#7 lore raw
In reply to Ian Kent

I've been thinking about that but I'm not sure about it. Mainly because the information flow is from autofs to the program
and
autofs can't know what environment to set.

Are you perhaps suggesting we define one or so?

That's what I was thinking of. I kinda thought the command line option would be too messy. But adding a variable to the environment (either after the fork before the exec or before the fork and retracting it, depending on the impact on COW paging stuff?) would seem pretty benign.

I can imagine AUTOFS_OPTIONS having the whole options string, or AUTOFS_OPTIONS being just a new program_map option, depending on whether it was considered bad to let the map see all the options or not. Since it's all new stuff, it shouldn't break any existing code.

Having brought this all up, I'm not really sure how much I care now, though. It would have been nice, but even if it went in, we won't be able expect everybody we need to support to have a new version of autofs very soon, so we'll probably have to do something else. We're looking at pushing all the information into an ldap server since (I think) all the clients we care about support that. I need to double back and check that that's a sufficiently flexible solution. It has the great benefit of not requiring custom code on the client.

I did like Ian's idea of a new lookup method. I'd love autofs to support an xmlrpc lookup. Much easier to implement a dynamic xmlrpc server than one that has a NIS or ldap interface. Would that be of interest to others?

steven

maintainer
#8 lore raw
Quoted 26 lines · aptosca

I've been thinking about that but I'm not sure about it. Mainly because the information flow is from autofs to the program
and
autofs can't know what environment to set.

Are you perhaps suggesting we define one or so?

That's what I was thinking of. I kinda thought the command line option would be too messy. But adding a variable to the environment (either after the fork before the exec or before the fork and retracting it, depending on the impact on COW paging stuff?) would seem pretty benign.

I can imagine AUTOFS_OPTIONS having the whole options string, or AUTOFS_OPTIONS being just a new program_map option, depending on whether it was considered bad to let the map see all the options or not. Since it's all new stuff, it shouldn't break any existing code.

Having brought this all up, I'm not really sure how much I care now, though. It would have been nice, but even if it went in, we won't be able expect everybody we need to support to have a new version of autofs very soon, so we'll probably have to do something else. We're looking at pushing all the information into an ldap server since (I think) all the clients we care about support that. I need to double back and check that that's a sufficiently flexible solution. It has the great benefit of not requiring custom code on the client.

Quoted 3 lines

I did like Ian's idea of a new lookup method. I'd love autofs to support an xmlrpc lookup. Much easier to implement a dynamic xmlrpc server than one that has a NIS or ldap interface. Would that be of interest to others?

Possibly, but someone who needs it and has access to an environment to test it would need to write it. And then there's the issue of ongoing support for me since I don't have such a setup. So kinda good idea but kinda difficult to get exited about.

Ian

maintainer
#9 lore raw
In reply to aptosca
Quoted 11 lines · aptosca

I've been thinking about that but I'm not sure about it. Mainly because the information flow is from autofs to the program
and
autofs can't know what environment to set.

Are you perhaps suggesting we define one or so?

That's what I was thinking of. I kinda thought the command line option would be too messy. But adding a variable to the environment (either after the fork before the exec or before the fork and retracting it, depending on the impact on COW paging stuff?) would seem pretty benign.

Mind you we have code that constructs the argument array for passing to submounts. Very similar code to the program map.

Maybe that is the way to do it after all.

Ian