]> git.proxmox.com Git - pve-access-control.git/blob - test/dump-perm.pl
followup: s/CUSTOM_TFA_TYPES/USER_CONTROLLED_TFA_TYPES/
[pve-access-control.git] / test / dump-perm.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use PVE::AccessControl;
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 if ($opt_file) {
27
28 my $fh = IO::File->new ($opt_file, 'r') ||
29 die "can't open file $opt_file - $!\n";
30
31 $cfg = PVE::AccessControl::parse_config ($opt_file, $fh);
32 $fh->close();
33
34 } else {
35 $cfg = PVE::AccessControl::load_user_config();
36 }
37 my $perm = PVE::AccessControl::permission($cfg, $username, $path);
38
39 print "permission for user '$username' on '$path':\n";
40 print join(',', keys %$perm) . "\n";
41
42 exit (0);