Net::NIS::Netgroup - Interface to glibc "getdomainname" function and its family
Version 1.1
use Net::NIS::Netgroup; printf("Domain name is %s\n", getdomainname()); setdomainname("newdom.com"); printf("Is user in group? %d\n", innetgr('netgroup', 'host', 'user', 'domain')); my @result = listnetgr("some-netgroup"); foreach my $r (@result) { printf("Found entry (%s, %s, %s)\n", $r->{host}, $r->{user}, $->{domain}); } # # Return string representations instead of hashes: 2nd arg true # my @result2 = listnetgr("some-netgroup", 1); foreach my $r (@result2) { printf("Found entry %s\n", $r); }
This module provides access methods for net groups. The following functions are offered:
getdomainname()
setdomainname($domain)
innetgr($group, $host, $user, $domain)
listnetgr($group [, $bool])
Detailed information about the three functions getgroupname, setdomainname, and innetgr can be found on the man pages of the respective glibc functions.
getgroupname
setdomainname
innetgr
innetgr will happily take "undef" for one or more of its arguments, representing the same as a NULL pointer in the C equivalent.
The function listnetgr($group [, $bool]) uses the functions setnetgrent, getnetgrent, and endnetgrent to iterate over the members of a net group, returning a list of hash references
setnetgrent
getnetgrent
endnetgrent
{ host => $host, user => $user, domain => $domain }
for all found elements. If the (optional) second argument to listnetgr is a true value, string representations (host,user,domain) of all entries are returned.
listnetgr
(host,user,domain)
All functions are exported per default. Use
use Net::Nis::Netgroup ();
to not import the provided symbols.
To install Net::NIS::Netgroup, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::NIS::Netgroup
CPAN shell
perl -MCPAN -e shell install Net::NIS::Netgroup
For more information on module installation, please visit the detailed CPAN module installation guide.