[pve-devel] r5606 - pve-access-control/trunk/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Feb 23 14:09:24 CET 2011


Author: dietmar
Date: 2011-02-23 14:09:24 +0100 (Wed, 23 Feb 2011)
New Revision: 5606

Modified:
   pve-access-control/trunk/PVE/API2/ACL.pm
Log:
better output format


Modified: pve-access-control/trunk/PVE/API2/ACL.pm
===================================================================
--- pve-access-control/trunk/PVE/API2/ACL.pm	2011-02-23 12:28:55 UTC (rev 5605)
+++ pve-access-control/trunk/PVE/API2/ACL.pm	2011-02-23 13:09:24 UTC (rev 5606)
@@ -14,7 +14,6 @@
 
 use base qw(PVE::RESTHandler);
 
-# fixme: format, what data exactly??
 __PACKAGE__->register_method ({
     name => 'read_acl', 
     path => '', 
@@ -24,7 +23,20 @@
 	additionalProperties => 0,
 	properties => {},
     },
-    returns => {},
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    additionalProperties => 0,
+	    properties => {
+		path => { type => 'string' },
+		type => { type => 'string' },
+		ugid => { type => 'string' },
+		roleid => { type => 'string' },
+		propagate => { type => 'boolean' },
+	    },
+	},
+    },
     code => sub {
 	my ($param) = @_;
     
@@ -36,7 +48,27 @@
 	    return {};
 	}
 
-	return $usercfg->{acl};
+	my $acl = $usercfg->{acl};
+	foreach my $path (keys %$acl) {
+	    foreach my $type (qw(users groups)) {
+		my $d = $acl->{$path}->{$type};
+		next if !$d;
+		foreach my $id (keys %$d) {
+		    foreach my $role (keys %{$d->{$id}}) {
+			my $propagate = $d->{$id}->{$role};
+			push @$res, {
+			    path => $path,
+			    type => $type eq 'groups' ? 'group' : 'user',
+			    ugid => $id,
+			    roleid => $role,
+			    propagate => $propagate,
+			};
+		    }
+		}
+	    }
+	}
+
+	return $res;
     }});
 
 __PACKAGE__->register_method ({




More information about the pve-devel mailing list