[pve-devel] r4977 - in pve-manager/pve2: bin lib/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Aug 12 13:28:11 CEST 2010


Author: dietmar
Date: 2010-08-12 11:28:11 +0000 (Thu, 12 Aug 2010)
New Revision: 4977

Removed:
   pve-manager/pve2/lib/PVE/API2/User.pm
Modified:
   pve-manager/pve2/bin/pvesh
   pve-manager/pve2/lib/PVE/API2/Makefile.am
Log:
	* lib/PVE/API2/User.pm: moved to pve-access-control


Modified: pve-manager/pve2/bin/pvesh
===================================================================
--- pve-manager/pve2/bin/pvesh	2010-08-12 11:18:43 UTC (rev 4976)
+++ pve-manager/pve2/bin/pvesh	2010-08-12 11:28:11 UTC (rev 4977)
@@ -98,7 +98,9 @@
     my $old = $attribs->{redisplay_function};
     $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
     my $input = $term->readline('password: ');
+    my $conf = $term->readline('Retype new password: ');
     $attribs->{redisplay_function} = $old;
+    die "Passwords do not match.\n" if ($input ne $conf);
     return $input;
 };
 
@@ -116,6 +118,7 @@
 
     # print "CREATE $dir " . Dumper($opts) . "\n";
 
+    print "TEST " . Dumper($handler, $info, $dir, $opts);
     my $res = call_handler($handler, $info, $dir, $opts);
 
     print_result($info, $res);

Modified: pve-manager/pve2/lib/PVE/API2/Makefile.am
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Makefile.am	2010-08-12 11:18:43 UTC (rev 4976)
+++ pve-manager/pve2/lib/PVE/API2/Makefile.am	2010-08-12 11:28:11 UTC (rev 4977)
@@ -4,7 +4,6 @@
 
 pvelib_DATA = 			\
 	AccessControl.pm	\
-	User.pm			\
 	Storage.pm		\
 	Cluster.pm		\
 	VM.pm

Deleted: pve-manager/pve2/lib/PVE/API2/User.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/User.pm	2010-08-12 11:18:43 UTC (rev 4976)
+++ pve-manager/pve2/lib/PVE/API2/User.pm	2010-08-12 11:28:11 UTC (rev 4977)
@@ -1,155 +0,0 @@
-package PVE::API2::User;
-
-use strict;
-use warnings;
-use PVE::AccessControl;
-use PVE::Config;
-
-use PVE::SafeSyslog;
-use Apache2::Const qw(:http);
-use Data::Dumper; # fixme: remove
-
-use PVE::RESTHandler;
-
-use base qw(PVE::RESTHandler);
-
-__PACKAGE__->register_method ({
-    name => 'index', 
-    path => '', 
-    method => 'GET',
-    description => "User index.",
-    parameters => {
-	additionalProperties => 0,
-	properties => {},
-    },
-    returns => {
-	type => 'array',
-	items => {
-	    type => "object",
-	    properties => {
-		id => { type => 'string' },
-	    },
-	},
-	links => [ { rel => 'child', href => "{id}" } ],
-    },
-    code => sub {
-	my ($conn, $resp, $param) = @_;
-    
-	my $res = [];
-
-	my $usercfg = PVE::Config::read_file("usercfg");
- 
-	foreach my $user (keys %{$usercfg->{users}}) {
-	    next if $user eq 'root';
-
-	    push @$res, { id => $user };
-	}
-
-	return $res;
-    }});
-
-__PACKAGE__->register_method ({
-    name => 'create_user', 
-    protected => 1,
-    path => '{userid}', 
-    method => 'POST',
-    description => "Create new user.",
-    parameters => {
-   	additionalProperties => 0,
-	properties => {
-	    userid => { type => 'string' },
-	    password => { type => 'string', optional => 1 },
-	    groups => { type => 'string', optional => 1 },
-	},
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($conn, $resp, $param) = @_;
-
-	$param->{create} = 1;
-	PVE::AccessControl::modify_user($param->{userid}, $param);
-
-	# fixme: maybe it is better to return the user data ?
-
-	return undef;
-    }});
-
-__PACKAGE__->register_method ({
-    name => 'get_user', 
-    path => '{userid}', 
-    method => 'GET',
-    description => "Get user configuration.",
-    parameters => {
-   	additionalProperties => 0,
-	properties => {
-	    userid => { type => 'string' },
-	},
-    },
-    returns => {},
-    code => sub {
-	my ($conn, $resp, $param) = @_;
-
-	my $usercfg = PVE::Config::read_file("usercfg");
- 
-	my $data = $usercfg->{users}->{$param->{userid}};
-	die "no such user\n" if !$data;
-
-	return $data;
-    }});
-
-__PACKAGE__->register_method ({
-    name => 'update_user', 
-    protected => 1,
-    path => '{userid}', 
-    method => 'PUT',
-    description => "Update user configuration.",
-    parameters => {
-   	additionalProperties => 0,
-	properties => {
-	    userid => { type => 'string' },
-	    password => { type => 'string', optional => 1 },
-	    groups => { type => 'string', optional => 1 },
-	    append => { 
-		type => 'boolean', 
-		optional => 1,
-		requires => 'groups',
-	    },
-	    lock => { type => 'boolean', optional => 1 },
-	    unlock => { type => 'boolean', optional => 1 },
-	    name => { type => 'string', optional => 1 },
-	    comment => { type => 'string', optional => 1 },
-	},
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($conn, $resp, $param) = @_;
-
-	PVE::AccessControl::modify_user($param->{userid}, $param);
-
-	# fixme: maybe it is better to return the user data ?
-
-	return undef;
-    }});
-
-__PACKAGE__->register_method ({
-    name => 'delete_user', 
-    protected => 1,
-    path => '{userid}', 
-    method => 'DELETE',
-    description => "Delete user.",
-    parameters => {
-   	additionalProperties => 0,
-	properties => {
-	    userid => { type => 'string' },
-	}
-    },
-    returns => { type => 'null' },
-    code => sub {
-	my ($conn, $resp, $param) = @_;
-
-	PVE::AccessControl::delete_user($param->{userid});  
-	
-	return undef;
-    }});
-
-1;



More information about the pve-devel mailing list