in reply to Fetching groups a user is in

Not really, although the getgr* family (getgrnam(), getgrgid(), and -- especially -- getgrent()) should be a good place to start.

    --k.


Replies are listed 'Best First'.
Re: Re: Fetching groups a user is in
by belg4mit (Prior) on Oct 11, 2001 at 20:15 UTC
    Seems like there ought to be something simpler though...

    $) = &{sub{ my(@F,@G); while( @F = getgrent() ){ push(@G, $F[2]) if $F[3] =~ /\b$ENV{USER}\b/; } return join(' ', @G); } };
Re: Re: Fetching groups a user is in
by belg4mit (Prior) on Oct 11, 2001 at 20:02 UTC
    Well yeah, but I was hoping I wouldn't have to muck with getgrent... but I suppose if I did an anonymous sub...

    $) = sub { #iterate over getgrent, save gid of group that $) belongs to. return join(' ', @F); }

    Seems so unclean though

      Nope wait, doesn't like <CODE>= sub { ..}</CODE, damn!