]> git.proxmox.com Git - pve-access-control.git/blame - test/dump-perm.pl
flush output file handle and send kill to whole process group
[pve-access-control.git] / test / dump-perm.pl
CommitLineData
2c3a6c0a
DM
1#!/usr/bin/perl -w
2
3use strict;
4use PVE::AccessControl;
5use Getopt::Long;
6use Data::Dumper;
7
8# example:
9# dump-perm.pl -f myuser.cfg root /
10
11my $opt_file;
12if (!GetOptions ("file=s" => \$opt_file)) {
13 exit (-1);
14}
15
16my $username = shift;
17my $path = shift;
18
19if (!($username && $path)) {
20 print "usage: $0 <username> <path>\n";
21 exit (-1);
22}
23
24my $cfg;
25
26if ($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}
37my $perm = PVE::AccessControl::permission($cfg, $username, $path);
38
39print "permission for user '$username' on '$path':\n";
40print join(',', keys %$perm) . "\n";
41
42exit (0);