line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Privilege::Reader; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
98302
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
101
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1020
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MySQL::Privilege::Reader - Determines which privileges are valid for a given MySQL Database Connection |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.01 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This modules reads, parses and returns a convenient (*) data structure with all |
21
|
|
|
|
|
|
|
the available access privileges found in a given MySQL database connection. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
(*) Convenient for me. If this is not exactly convenient for you, please feel |
24
|
|
|
|
|
|
|
free to write me and ask for a more convenient data structure, and I will be |
25
|
|
|
|
|
|
|
happy to build it into this module. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 get_privileges |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_privileges { |
34
|
6
|
|
|
6
|
1
|
5925
|
my ( $class, $dbi ) = @_; |
35
|
6
|
50
|
100
|
|
|
89
|
die q{Not a DBI object} |
|
|
|
66
|
|
|
|
|
36
|
|
|
|
|
|
|
unless defined $dbi |
37
|
|
|
|
|
|
|
and ref $dbi |
38
|
|
|
|
|
|
|
and $dbi->isa('DBI::db'); |
39
|
0
|
|
|
|
|
|
my %privileges; |
40
|
0
|
|
|
|
|
|
my @privileges = |
41
|
0
|
|
|
|
|
|
@{ $dbi->selectall_arrayref( 'SHOW PRIVILEGES', { Slice => {} } ) }; |
42
|
0
|
|
|
|
|
|
foreach my $privilege (@privileges) { |
43
|
0
|
|
|
|
|
|
my @contexts = split qr{,}, $$privilege{Context}; |
44
|
0
|
|
|
|
|
|
foreach my $context (@contexts) { |
45
|
0
|
|
|
|
|
|
push @{ $privileges{__PRIVILEGES_BY_CONTEXT}->{$context} }, |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
Privilege => uc $$privilege{Privilege}, |
48
|
|
|
|
|
|
|
Comment => $$privilege{Comment} |
49
|
|
|
|
|
|
|
}; |
50
|
0
|
|
|
|
|
|
push @{ $privileges{__CONTEXT_BY_PRIVILEGE} |
|
0
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
->{ uc $$privilege{Privilege} } }, $context; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
$privileges{__CONTEXTS} = [ |
55
|
0
|
|
|
|
|
|
sort grep { !m{^__.*} } |
|
0
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
keys %{ $privileges{__PRIVILEGES_BY_CONTEXT} } |
57
|
|
|
|
|
|
|
]; |
58
|
0
|
|
|
|
|
|
return bless \%privileges, $class; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 AUTHOR |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Luis Motta Campos, C<< >> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 BUGS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Please report any bugs or feature requests to C
|
68
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
69
|
|
|
|
|
|
|
L. I |
70
|
|
|
|
|
|
|
will be notified, and then you'll automatically be notified of progress on your |
71
|
|
|
|
|
|
|
bug as I make changes. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SUPPORT |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
perldoc MySQL::Privilege::Reader |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
You can also look for information at: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over 4 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * CPAN Ratings |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * Search CPAN |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright 2010 Luis Motta Campos. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
109
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
110
|
|
|
|
|
|
|
Foundation; version 2 dated June, 1991 or at your option any later version. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
113
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
114
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
A copy of the GNU General Public License is available in the source tree; if |
117
|
|
|
|
|
|
|
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
118
|
|
|
|
|
|
|
Boston, MA 02111-1307, USA. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; # End of MySQL::Privilege::Reader |