NIS netgroup support

38 views
Skip to first unread message

Matthias Witte

unread,
Feb 15, 2011, 7:53:53 AM2/15/11
to parallel-ssh
Hi!

I extended pssh to support NIS netgroups since we organize our hosts
in netgroups.

The patch contains these features:

* if you prefix a '-H' argument with '@' it is taken as netgroup and
the hostnames from
the netgroup triples are extracted. The resulting list ist uniqd
with regard to hostnames.
* there is an additional option '-E' which lets you exclude certain
hosts from the
resulting hostlist.

Is anyone interested?

Andrew McNabb

unread,
Feb 15, 2011, 10:45:50 AM2/15/11
to parall...@googlegroups.com
On Tue, Feb 15, 2011 at 04:53:53AM -0800, Matthias Witte wrote:
>
> I extended pssh to support NIS netgroups since we organize our hosts
> in netgroups.

This sounds like a very helpful feature.


> The patch contains these features:
>
> * if you prefix a '-H' argument with '@' it is taken as netgroup and
> the hostnames from
> the netgroup triples are extracted. The resulting list ist uniqd
> with regard to hostnames.

The "@" symbol is also used for specifying "user@host". Are there any
potential problems from overloading the symbol?

> * there is an additional option '-E' which lets you exclude certain
> hosts from the
> resulting hostlist.
>
> Is anyone interested?

Would you consider posting the patch on the issue tracker?

http://code.google.com/p/parallel-ssh/issues/list

Thanks for your help with PSSH.

--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

Matthias Witte

unread,
Feb 15, 2011, 11:27:08 AM2/15/11
to parall...@googlegroups.com
Hallo,

> On Tue, Feb 15, 2011 at 04:53:53AM -0800, Matthias Witte wrote:
> >
> > I extended pssh to support NIS netgroups since we organize our hosts
> > in netgroups.
>
> This sounds like a very helpful feature.

Since it uses ctypes and libc.6 I am not sure if that is a portable
solution.


> The "@" symbol is also used for specifying "user@host". Are there any
> potential problems from overloading the symbol?

I do not think so, since '@' must be the first character to identify a
netgroup.

> Would you consider posting the patch on the issue tracker?
>
> http://code.google.com/p/parallel-ssh/issues/list

It's done. Sorry I labelled the issue as defect.

maz

Andrew McNabb

unread,
Feb 15, 2011, 12:41:26 PM2/15/11
to parall...@googlegroups.com
On Tue, Feb 15, 2011 at 05:27:08PM +0100, Matthias Witte wrote:
>
> Since it uses ctypes and libc.6 I am not sure if that is a portable
> solution.

If we're careful, then I don't think this should be a problem.
Specifically, it should be possible to import ctypes at the exact time
that it's needed (in a local scope) and to give a helpful error message
when ctypes is missing and when libc.6 can't be loaded.

> > The "@" symbol is also used for specifying "user@host". Are there any
> > potential problems from overloading the symbol?
>
> I do not think so, since '@' must be the first character to identify a
> netgroup.

You're probably right. I just like to be paranoid. :)

> > Would you consider posting the patch on the issue tracker?
> >
> > http://code.google.com/p/parallel-ssh/issues/list
>
> It's done. Sorry I labelled the issue as defect.

Google's Issue Tracker seems to make it impossible to get everything
right the first time. :)

Matthias Witte

unread,
Feb 16, 2011, 2:39:54 AM2/16/11
to parall...@googlegroups.com
Hallo,

> If we're careful, then I don't think this should be a problem.
> Specifically, it should be possible to import ctypes at the exact time
> that it's needed (in a local scope) and to give a helpful error message
> when ctypes is missing and when libc.6 can't be loaded.

At the moment I am not aware how to do that. From a brief google it
seems you would use imp for that?

> > > The "@" symbol is also used for specifying "user@host". Are there any
> > > potential problems from overloading the symbol?
> >
> > I do not think so, since '@' must be the first character to identify a
> > netgroup.
>
> You're probably right. I just like to be paranoid. :)

The '@' seems to be the customary character to denote a netgroup, sudo
uses the '+'.

One could instead use the '-h' Option instead of '-H' and try to resolve
its arguments as netgroups if there is no corresponding file.

Another option might be to drop one of the options in general and always
try to interpret the argmument as a file and if that fails switch to
resolution via DNS and NIS. But then you would still want to be able to
enforce a certain unambiguous context.

--
maz

Andrew McNabb

unread,
Feb 16, 2011, 1:01:01 PM2/16/11
to parall...@googlegroups.com
On Wed, Feb 16, 2011 at 08:39:54AM +0100, Matthias Witte wrote:
> > If we're careful, then I don't think this should be a problem.
> > Specifically, it should be possible to import ctypes at the exact time
> > that it's needed (in a local scope) and to give a helpful error message
> > when ctypes is missing and when libc.6 can't be loaded.
>
> At the moment I am not aware how to do that. From a brief google it
> seems you would use imp for that?

It's actually not too bad. If you put "import ctypes" at the top of
your file, then the import occurs as the module is loaded. If, however,
the import line appears within a function, then the import doesn't
happen until the function is called. For example:

def do_stuff():
import ctypes
...

If do_stuff is never called, then ctypes is never imported.
Additionally, the "ctypes" name is only available within the the body of
do_stuff.

> The '@' seems to be the customary character to denote a netgroup, sudo
> uses the '+'.
>
> One could instead use the '-h' Option instead of '-H' and try to resolve
> its arguments as netgroups if there is no corresponding file.

I like the idea of sticking to whatever is customary, so the "@" sounds
good. I'm torn about whether it should be combined with the "-h", "-H",
or some new option.


> Another option might be to drop one of the options in general and always
> try to interpret the argmument as a file and if that fails switch to
> resolution via DNS and NIS. But then you would still want to be able to
> enforce a certain unambiguous context.

Yeah, it sounds like that could be ambiguous, so I'm not sure if it's
the best way to go.

By the way, would anyone ever want to specify a host along with a
netgroup? For example "-H user1@host1 -H user2@host2 -H user3@@group1"
or something like that?

Matthias Witte

unread,
Feb 17, 2011, 6:19:52 PM2/17/11
to parall...@googlegroups.com
Hallo,

> > At the moment I am not aware how to do that. From a brief google it
> > seems you would use imp for that?
>
> It's actually not too bad. If you put "import ctypes" at the top of
> your file, then the import occurs as the module is loaded. If, however,
> the import line appears within a function, then the import doesn't
> happen until the function is called. For example:
>
> def do_stuff():
> import ctypes
> ...
>
> If do_stuff is never called, then ctypes is never imported.
> Additionally, the "ctypes" name is only available within the the body of
> do_stuff.

I will try that and modify the patch. There's a busy weekend ahead so I
don't know when.

> I like the idea of sticking to whatever is customary, so the "@" sounds
> good. I'm torn about whether it should be combined with the "-h", "-H",
> or some new option.

Whatever floats your boat. At the moment I am the only one in need of
that feature. I don't know if anyone else needs NIS netgroup support so
that I cannot even be disappointed if you decide to dismiss the patch.

> By the way, would anyone ever want to specify a host along with a
> netgroup? For example "-H user1@host1 -H user2@host2 -H user3@@group1"
> or something like that?

That case should be easy to handle, I'll look into it.

--
maz

Matthias Witte

unread,
Oct 23, 2012, 1:58:18 PM10/23/12
to parall...@googlegroups.com
Hi!

I finally reworked my patch and attached it to issue #40. It's based
on the current git HEAD and split in two separate patches.

The first introduces an 'exclude' option and reorganises the '-H'
option processing to have this all in one place. It might be useful
even if you don't have NIS and spare you editing your host
lists just because a specific operation should only effect a subset.

Example:
-------------
-E foo,bar,baz  
-E foo -E bar -E baz
    will exclude all hosts matching /foo|bar|baz/

Only the second patch enables netgroup lookups. I have no
idea if this works out of the box on other Unix based systems
and severe doubt it makes sense on Windows clients at all.
-- 
maz
Reply all
Reply to author
Forward
0 new messages