[pve-devel] r5006 - pve-access-control/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Aug 16 12:29:55 CEST 2010


Author: dietmar
Date: 2010-08-16 10:29:55 +0000 (Mon, 16 Aug 2010)
New Revision: 5006

Modified:
   pve-access-control/trunk/ACL.pm
   pve-access-control/trunk/AccessControl.pm
   pve-access-control/trunk/ChangeLog
   pve-access-control/trunk/Group.pm
   pve-access-control/trunk/Role.pm
   pve-access-control/trunk/User.pm
Log:
  	* AccessControl.pm (lock_user_config): add call to die, remove
	@param - we do not need that here
	(lock_shadow_config): add call to die, remove @param



Modified: pve-access-control/trunk/ACL.pm
===================================================================
--- pve-access-control/trunk/ACL.pm	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/ACL.pm	2010-08-16 10:29:55 UTC (rev 5006)
@@ -99,12 +99,8 @@
 		}
 
 		write_file("usercfg", $cfg);
-	    });
+	    }, "ACL update failed");
 
-	my $err = $@;
-
-	die "ACL update failed: $err" if $err;
-
 	return undef;
     }});
 

Modified: pve-access-control/trunk/AccessControl.pm
===================================================================
--- pve-access-control/trunk/AccessControl.pm	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/AccessControl.pm	2010-08-16 10:29:55 UTC (rev 5006)
@@ -51,19 +51,27 @@
 }
 
 sub lock_user_config {
-    my ($code, @param) = @_;
+    my ($code, $errmsg) = @_;
 
     my $parent = ( caller(1) )[3];
 
-    lock_file($userconfiglock, undef, $parent, $code, @param);
+    lock_file($userconfiglock, undef, $parent, $code);
+    my $err = $@;
+    if ($err) {
+	$errmsg ? die "$errmsg: $err" : die $err;
+    }
 }
 
 sub lock_shadow_config {
-    my ($code, @param) = @_;
+    my ($code, $errmsg) = @_;
 
     my $parent = ( caller(1) )[3];
 
-    lock_file($shadowconfiglock, undef, $parent, $code, @param);
+    lock_file($shadowconfiglock, undef, $parent, $code);
+    my $err = $@;
+    if ($err) {
+	$errmsg ? die "$errmsg: $err" : die $err;
+    }
 }
 
 sub read_pubkey {
@@ -347,7 +355,6 @@
 	    if $shadow_cfg->{users}->{$username};
 	write_file($shadowconfigpath, $shadow_cfg);
     });
-    die $@ if $@;
 }
 
 sub store_shadow_password {
@@ -358,7 +365,6 @@
 	$shadow_cfg->{users}->{$username}->{shadow} = encrypt_pw($password);
 	write_file($shadowconfigpath, $shadow_cfg);
     });
-    die $@ if $@;
 }
 
 sub encrypt_pw {

Modified: pve-access-control/trunk/ChangeLog
===================================================================
--- pve-access-control/trunk/ChangeLog	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/ChangeLog	2010-08-16 10:29:55 UTC (rev 5006)
@@ -1,5 +1,9 @@
 2010-08-16  Proxmox Support Team  <support at proxmox.com>
 
+	* AccessControl.pm (lock_user_config): add call to die, remove
+	@param - we do not need that here
+	(lock_shadow_config): add call to die, remove @param
+
 	* *.pm: remove $resp parameter everywhere.
 
 	* AccessControl.pm (verify_username): add test for username

Modified: pve-access-control/trunk/Group.pm
===================================================================
--- pve-access-control/trunk/Group.pm	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/Group.pm	2010-08-16 10:29:55 UTC (rev 5006)
@@ -76,12 +76,8 @@
 		$usercfg->{groups}->{$group} = {};
 
 		write_file("usercfg", $usercfg);
-	    });
+	    }, "create group failed");
 
-	my $err = $@;
-
-	die "create group failed: $err" if $err;
-
 	return undef;
     }});
 
@@ -144,11 +140,7 @@
 		PVE::AccessControl::delete_group_acl($group, $usercfg);
 
 		write_file("usercfg", $usercfg);
-	    });
-
-	my $err = $@;
-
-	die "delete group failed: $err" if $err;
+	    }, "delete group failed");
 	
 	return undef;
     }});

Modified: pve-access-control/trunk/Role.pm
===================================================================
--- pve-access-control/trunk/Role.pm	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/Role.pm	2010-08-16 10:29:55 UTC (rev 5006)
@@ -79,12 +79,8 @@
 		PVE::AccessControl::add_role_privs($role, $usercfg, $param->{privs});
 
 		write_file("usercfg", $usercfg);
-	    });
+	    }, "create role failed");
 
-	my $err = $@;
-
-	die "create role failed: $err" if $err;
-
 	return undef;
     }});
 
@@ -125,12 +121,8 @@
 		PVE::AccessControl::add_role_privs($role, $usercfg, $param->{privs});
 
 		write_file("usercfg", $usercfg);
-	    });
+	    }, "update role failed");
 
-	my $err = $@;
-
-	die "update role failed: $err" if $err;
-
 	return undef;
     }});
 
@@ -193,11 +185,7 @@
 		# fixme: delete role from acl?
 
 		write_file("usercfg", $usercfg);
-	    });
-
-	my $err = $@;
-
-	die "delete role failed: $err" if $err;
+	    }, "delete role failed");
 	
 	return undef;
     }});

Modified: pve-access-control/trunk/User.pm
===================================================================
--- pve-access-control/trunk/User.pm	2010-08-16 10:13:16 UTC (rev 5005)
+++ pve-access-control/trunk/User.pm	2010-08-16 10:29:55 UTC (rev 5006)
@@ -122,12 +122,8 @@
 		}
 
 		write_file("usercfg", $usercfg);
-	    });
+	    }, "create user failed");
 
-	my $err = $@;
-
-	die "create user failed: $err" if $err;
-
 	return undef;
     }});
 
@@ -185,12 +181,12 @@
     code => sub {
 	my ($conn, $param) = @_;
 	
-	die "conflicting parameters unlock/lock\n" 
-	    if $param->{unlock} && $param->{lock};
-
 	PVE::AccessControl::lock_user_config(
 	    sub {
-			
+
+		die "conflicting parameters unlock/lock\n" 
+		    if $param->{unlock} && $param->{lock};
+
 		my ($username, undef, $domain) = 
 		    PVE::AccessControl::verify_username($param->{userid});
 	
@@ -229,12 +225,8 @@
 		PVE::AccessControl::comment_user($username, $usercfg) if $param->{comment};
 
 		write_file("usercfg", $usercfg);
-	    });
-
-	my $err = $@;
+	    }, "update user failed");
 	
-	die "update user failed: $err" if $err;
-
 	return undef;
     }});
 
@@ -272,11 +264,7 @@
 		PVE::AccessControl::delete_user_acl($username, $usercfg);
 
 		write_file("usercfg", $usercfg);
-	    });
-
-	my $err = $@;
-
-	die "delete user failed: $err" if $err;
+	    }, "delete user failed");
 	
 	return undef;
     }});




More information about the pve-devel mailing list