[pve-devel] r6299 - in pve-access-control/trunk: . PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jul 14 12:10:49 CEST 2011


Author: dietmar
Date: 2011-07-14 12:10:49 +0200 (Thu, 14 Jul 2011)
New Revision: 6299

Modified:
   pve-access-control/trunk/ChangeLog
   pve-access-control/trunk/PVE/AccessControl.pm
   pve-access-control/trunk/control.in
Log:
remove depend on liburi-perl (code moved
	to pve-common)


Modified: pve-access-control/trunk/ChangeLog
===================================================================
--- pve-access-control/trunk/ChangeLog	2011-07-14 10:09:25 UTC (rev 6298)
+++ pve-access-control/trunk/ChangeLog	2011-07-14 10:10:49 UTC (rev 6299)
@@ -1,3 +1,8 @@
+2011-07-14  Proxmox Support Team  <support at proxmox.com>
+
+	* control.in (Depends): remove depend on liburi-perl (code moved
+	to pve-common)
+
 2011-07-05  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/API2/User.pm (create_user): add -enable parameter

Modified: pve-access-control/trunk/PVE/AccessControl.pm
===================================================================
--- pve-access-control/trunk/PVE/AccessControl.pm	2011-07-14 10:09:25 UTC (rev 6298)
+++ pve-access-control/trunk/PVE/AccessControl.pm	2011-07-14 10:10:49 UTC (rev 6299)
@@ -12,7 +12,6 @@
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::JSONSchema;
 use Encode;
-use URI::Escape;
 
 use Data::Dumper; # fixme: remove
 
@@ -470,20 +469,6 @@
 
 }
 
-sub encode_text {
-    my ($text) = @_;
-
-    # all control and hi-bit characters, and ':'
-    my $unsafe = "^\x20-\x39\x3b-\x7e";
-    return uri_escape(Encode::encode("utf8", $text), $unsafe);
-}
-
-sub decode_text {
-    my ($data) = @_;
-
-    return Encode::decode("utf8", uri_unescape($data));
-}
-
 # we automatically create some predefined roles by splitting privs
 # into 3 groups (per category)
 # root: only root is allowed to do that
@@ -772,10 +757,10 @@
 		enable => $enable,
 		# group => $group,
 	    };
-	    $cfg->{users}->{$user}->{firstname} = decode_text($firstname) if $firstname;
-	    $cfg->{users}->{$user}->{lastname} = decode_text($lastname) if $lastname;
+	    $cfg->{users}->{$user}->{firstname} = PVE::Tools::decode_text($firstname) if $firstname;
+	    $cfg->{users}->{$user}->{lastname} = PVE::Tools::decode_text($lastname) if $lastname;
 	    $cfg->{users}->{$user}->{email} = $email;
-	    $cfg->{users}->{$user}->{comment} = decode_text($comment) if $comment;
+	    $cfg->{users}->{$user}->{comment} = PVE::Tools::decode_text($comment) if $comment;
 	    $cfg->{users}->{$user}->{expire} = $expire;
 
 	    #$cfg->{users}->{$user}->{groups}->{$group} = 1;
@@ -792,7 +777,7 @@
 	    # make sure to add the group (even if there are no members)
 	    $cfg->{groups}->{$group} = { users => {} } if !$cfg->{groups}->{$group};
 
-	    $cfg->{groups}->{$group}->{comment} = decode_text($comment) if $comment;
+	    $cfg->{groups}->{$group}->{comment} = PVE::Tools::decode_text($comment) if $comment;
 
 	    foreach my $user (split_list($userlist)) {
 
@@ -924,7 +909,7 @@
 		if (!$formats->{$k}) {
 		    $data .= "\t$k\n";
 		} elsif ($v =~ m/^$formats->{$k}$/) {
-		    $v = encode_text($v) if $k eq 'comment';
+		    $v = PVE::Tools::encode_text($v) if $k eq 'comment';
 		    $data .= "\t$k $v\n";
 		} else {
 		    die "invalid value '$v' for attribute '$k'\n";
@@ -990,7 +975,7 @@
 				$entry->{$k} = 1;			    
 			} elsif ($formats->{$k} && $v =~ m/^$formats->{$k}$/) {
 			    if (!defined($entry->{$k})) {
-				$v = decode_text($v) if $k eq 'comment';
+				$v = PVE::Tools::decode_text($v) if $k eq 'comment';
 				$entry->{$k} = $v;
 			    } else {
 				warn "ignoring duplicate attribute '$k $v'\n";
@@ -1066,10 +1051,10 @@
 	next if $user eq 'root at pam';
 
 	my $d = $cfg->{users}->{$user};
-	my $firstname = $d->{firstname} ? encode_text($d->{firstname}) : '';
-	my $lastname = $d->{lastname} ? encode_text($d->{lastname}) : '';
+	my $firstname = $d->{firstname} ? PVE::Tools::encode_text($d->{firstname}) : '';
+	my $lastname = $d->{lastname} ? PVE::Tools::encode_text($d->{lastname}) : '';
 	my $email = $d->{email} || '';
-	my $comment = $d->{comment} ? encode_text($d->{comment}) : '';
+	my $comment = $d->{comment} ? PVE::Tools::encode_text($d->{comment}) : '';
 	my $expire = int($d->{expire}) || 0;
 	my $enable = $d->{enable} ? 1 : 0;
 	$data .= "user:$user:$enable:$expire:$firstname:$lastname:$email:$comment:\n";

Modified: pve-access-control/trunk/control.in
===================================================================
--- pve-access-control/trunk/control.in	2011-07-14 10:09:25 UTC (rev 6298)
+++ pve-access-control/trunk/control.in	2011-07-14 10:10:49 UTC (rev 6299)
@@ -3,7 +3,7 @@
 Section: perl
 Priority: optional
 Architecture: @@ARCH@@
-Depends: libc6 (>= 2.3), perl (>= 5.6.0-16), libcrypt-openssl-rsa-perl, libcrypt-openssl-random-perl, libjson-xs-perl, libjson-perl, libterm-readline-gnu-perl,libnet-ldap-perl, libpve-common-perl, pve-cluster, liburi-perl
+Depends: libc6 (>= 2.3), perl (>= 5.6.0-16), libcrypt-openssl-rsa-perl, libcrypt-openssl-random-perl, libjson-xs-perl, libjson-perl, libterm-readline-gnu-perl,libnet-ldap-perl, libpve-common-perl, pve-cluster
 Maintainer: Proxmox Support Team <support at proxmox.com>
 Description: Proxmox VE access control library
  This package contains the role based user management and access



More information about the pve-devel mailing list