[pve-devel] [PATCH container 2/3] use better regex for detecting pre crypt()'d passwords

Dominik Csapak d.csapak at proxmox.com
Thu Jun 21 14:14:27 CEST 2018


this means we also have to adapt some tests

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm               | 2 +-
 src/test/run_setup_tests.pl             | 2 +-
 src/test/test-debian-009/etc/shadow.exp | 2 +-
 src/test/test-debian-014/etc/shadow.exp | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 5c69959..ab872a5 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -354,7 +354,7 @@ sub set_user_password {
     my $shadow = "/etc/shadow";
     
     if (defined($opt_password)) {
-	if ($opt_password !~ m/^\$/) {
+	if ($opt_password !~ m/^\$(?:1|2[axy]?|5|6)\$[a-zA-Z0-9.\/]{1,16}\$[a-zA-Z0-9.\/]+$/) {
 	    my $time = substr (Digest::SHA::sha1_base64 (time), 0, 8);
 	    $opt_password = crypt(encode("utf8", $opt_password), "\$1\$$time\$");
 	};
diff --git a/src/test/run_setup_tests.pl b/src/test/run_setup_tests.pl
index bae94e8..678ff0f 100755
--- a/src/test/run_setup_tests.pl
+++ b/src/test/run_setup_tests.pl
@@ -50,7 +50,7 @@ sub run_test {
 	# run tests twice, to make sure scripts are idempotent
 	
 	srand(0);
-	$lxc_setup->post_create_hook('$TEST$ABCDEF','ssh-rsa ABCDEFG ABC at DEF');
+	$lxc_setup->post_create_hook('$5$SALT$PASS','ssh-rsa ABCDEFG ABC at DEF');
 
 	my @testfiles = qw(/etc/hostname
 	                   /etc/hosts
diff --git a/src/test/test-debian-009/etc/shadow.exp b/src/test/test-debian-009/etc/shadow.exp
index 34768b5..03c43ac 100644
--- a/src/test/test-debian-009/etc/shadow.exp
+++ b/src/test/test-debian-009/etc/shadow.exp
@@ -1,4 +1,4 @@
-root:$TEST$ABCDEF:@DAYS@:0:99999:7:::
+root:$5$SALT$PASS:@DAYS@:0:99999:7:::
 daemon:*:15908:0:99999:7:::
 bin:*:15908:0:99999:7:::
 sys:*:15908:0:99999:7:::
diff --git a/src/test/test-debian-014/etc/shadow.exp b/src/test/test-debian-014/etc/shadow.exp
index 34768b5..03c43ac 100644
--- a/src/test/test-debian-014/etc/shadow.exp
+++ b/src/test/test-debian-014/etc/shadow.exp
@@ -1,4 +1,4 @@
-root:$TEST$ABCDEF:@DAYS@:0:99999:7:::
+root:$5$SALT$PASS:@DAYS@:0:99999:7:::
 daemon:*:15908:0:99999:7:::
 bin:*:15908:0:99999:7:::
 sys:*:15908:0:99999:7:::
-- 
2.11.0





More information about the pve-devel mailing list