blib/lib/Net/NIS/Netgroup.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Netgroup.xs ↑ Summary
1 # $Id: Netgroup.pm,v 1.4 2010/08/12 14:06:14 bastian Exp $
2 # Copyright (c) 2007 Collax GmbH
3 package Net::NIS::Netgroup;
4  
5 2 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 require Exporter;
9 2 require DynaLoader;
10  
11 2 our @ISA = qw(Exporter DynaLoader);
12 2 our @EXPORT = qw ( getdomainname setdomainname innetgr listnetgr );
13  
14 2 our $VERSION = "1.1";
15  
16 =head1 NAME
17  
18 Net::NIS::Netgroup - Interface to glibc "getdomainname" function and its family
19  
20 =head1 VERSION
21  
22 Version 1.1
23  
24 =cut
25  
26 2 bootstrap Net::NIS::Netgroup;
27  
28 =head1 SYNOPSIS
29  
30 use Net::NIS::Netgroup;
31  
32 printf("Domain name is %s\n", getdomainname());
33 setdomainname("newdom.com");
34  
35 printf("Is user in group? %d\n",
36 innetgr('netgroup', 'host', 'user', 'domain'));
37  
38 my @result = listnetgr("some-netgroup");
39 foreach my $r (@result) {
40 printf("Found entry (%s, %s, %s)\n",
41 $r->{host}, $r->{user}, $->{domain});
42 }
43  
44 #
45 # Return string representations instead of hashes: 2nd arg true
46 #
47 my @result2 = listnetgr("some-netgroup", 1);
48 foreach my $r (@result2) {
49 printf("Found entry %s\n", $r);
50 }
51  
52 =head1 DESCRIPTION
53  
54 This module provides access methods for net groups. The following functions are offered:
55  
56 =over
57  
58 =item C<getdomainname()>
59  
60 =item C<setdomainname($domain)>
61  
62 =item C<innetgr($group, $host, $user, $domain)>
63  
64 =item C<listnetgr($group [, $bool])>
65  
66 =back
67  
68 Detailed information about the three functions C<getgroupname>,
69 C<setdomainname>, and C<innetgr> can be found on the man pages of the
70 respective glibc functions.
71  
72 C<innetgr> will happily take "undef" for one or more of its arguments,
73 representing the same as a NULL pointer in the C equivalent.
74  
75 The function C<listnetgr($group [, $bool])> uses the functions C<setnetgrent>,
76 C<getnetgrent>, and C<endnetgrent> to iterate over the members of a net group,
77 returning a list of hash references
78  
79 {
80 host => $host,
81 user => $user,
82 domain => $domain
83 }
84  
85 for all found elements. If the (optional) second argument to C<listnetgr> is a true value,
86 string representations C<(host,user,domain)> of all entries are returned.
87  
88 =head1 EXPORTED FUNCTIONS
89  
90 All functions are exported per default. Use
91  
92 use Net::Nis::Netgroup ();
93  
94 to not import the provided symbols.
95  
96 =cut
97  
98 2 1;
« Netgroup.xs ↑ Summary