]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl -w | |
2 | ||
3 | use strict; | |
4 | use PVE::RPCEnvironment; | |
5 | use Getopt::Long; | |
6 | use Data::Dumper; | |
7 | ||
8 | # example: | |
9 | # dump-perm.pl -f myuser.cfg root / | |
10 | ||
11 | my $opt_file; | |
12 | if (!GetOptions ("file=s" => \$opt_file)) { | |
13 | exit (-1); | |
14 | } | |
15 | ||
16 | my $username = shift; | |
17 | my $path = shift; | |
18 | ||
19 | if (!($username && $path)) { | |
20 | print "usage: $0 <username> <path>\n"; | |
21 | exit (-1); | |
22 | } | |
23 | ||
24 | my $cfg; | |
25 | ||
26 | my $rpcenv = PVE::RPCEnvironment->init('cli'); | |
27 | if ($opt_file) { | |
28 | $rpcenv->init_request(userconfig => $opt_file); | |
29 | } else { | |
30 | $rpcenv->init_request(); | |
31 | } | |
32 | ||
33 | my $perm = $rpcenv->permissions($username, $path); | |
34 | ||
35 | print "permission for user '$username' on '$path':\n"; | |
36 | print join(',', keys %$perm) . "\n"; | |
37 | ||
38 | exit (0); |