[pve-devel] r4836 - pve-access-control/trunk/test

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jun 24 07:07:00 CEST 2010


Author: dietmar
Date: 2010-06-24 05:06:52 +0000 (Thu, 24 Jun 2010)
New Revision: 4836

Added:
   pve-access-control/trunk/test/user.cfg.ex1
Modified:
   pve-access-control/trunk/test/dump-perm.pl
Log:


Modified: pve-access-control/trunk/test/dump-perm.pl
===================================================================
--- pve-access-control/trunk/test/dump-perm.pl	2010-06-23 11:49:30 UTC (rev 4835)
+++ pve-access-control/trunk/test/dump-perm.pl	2010-06-24 05:06:52 UTC (rev 4836)
@@ -2,13 +2,20 @@
 
 use strict;
 use PVE::AccessControl;
+use Getopt::Long;
 use Data::Dumper;
 
+# example: 
+# dump-perm.pl -f myuser.cfg root /
+
+my $opt_file;
+if (!GetOptions ("file=s"   => \$opt_file)) {
+    exit (-1);
+}
+
 my $username = shift;
 my $path = shift;
-
-# example: "dump-perm.pl root /"
-
+ 
 if (!($username && $path)) {
     print "usage: $0 <username> <path>\n";
     exit (-1);
@@ -16,11 +23,20 @@
 
 my $cfg;
 
-$cfg = PVE::AccessControl::load_user_config();
+if ($opt_file) {
 
+    my $fh = IO::File->new ($opt_file, 'r') ||
+	die "can't open file $opt_file - $!\n";
+
+    $cfg = PVE::AccessControl::parse_config ($opt_file, $fh);
+    $fh->close();
+
+} else {
+    $cfg = PVE::AccessControl::load_user_config();
+}
 my $perm = PVE::AccessControl::permission($cfg, $username, $path);
 
 print "permission for user '$username' on '$path':\n";
-print Dumper($perm) . "\n";
+print join(',', keys %$perm) . "\n";
 
 exit (0);

Added: pve-access-control/trunk/test/user.cfg.ex1
===================================================================
--- pve-access-control/trunk/test/user.cfg.ex1	                        (rev 0)
+++ pve-access-control/trunk/test/user.cfg.ex1	2010-06-24 05:06:52 UTC (rev 4836)
@@ -0,0 +1,18 @@
+user:joe:1:
+user:max:1:
+user:alex:1:
+user:carol:1:
+
+group:testgroup1:joe,max:
+group:testgroup2:alex,carol:
+
+role:storage_manager:Datastore.AllocateSpace,Datastore.Browse:
+role:customer:VM.ConfigureCD,VM.PowerOn,VM.PowerOff:
+role:vm_admin:VM.ConfigureCD,VM.Create,Permissions.Modify,VM.Console:
+
+acl:1:/vms:@testgroup1:vm_admin:
+acl:1:/vms/100/:alex:customer:
+acl:1:/storage/nfs1:@testgroup2:storage_manager:
+acl:1:/users:max:Administrator:
+
+



More information about the pve-devel mailing list