line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
2
|
|
48708
|
use 5.006001; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
68
|
|
6
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
225
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
require DynaLoader; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter DynaLoader); |
12
|
|
|
|
|
|
|
our @EXPORT = qw ( getdomainname setdomainname innetgr listnetgr ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=back |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Detailed information about the three functions C, |
69
|
|
|
|
|
|
|
C, and C can be found on the man pages of the |
70
|
|
|
|
|
|
|
respective glibc functions. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
C 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 uses the functions C, |
76
|
|
|
|
|
|
|
C, and C 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 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
|
|
|
|
|
|
|
1; |