[Pkg-shadow-commits] r2630 - debian/trunk/tests/common

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Fri Apr 10 22:58:06 UTC 2009


Author: nekral-guest
Date: 2009-04-10 22:58:06 +0000 (Fri, 10 Apr 2009)
New Revision: 2630

Modified:
   debian/trunk/tests/common/compare_file.pl
Log:
Added support for SHA256 and SHA512 tests.


Modified: debian/trunk/tests/common/compare_file.pl
===================================================================
--- debian/trunk/tests/common/compare_file.pl	2009-04-10 22:47:47 UTC (rev 2629)
+++ debian/trunk/tests/common/compare_file.pl	2009-04-10 22:58:06 UTC (rev 2630)
@@ -48,7 +48,56 @@
 	}
 }
 
+$tmp = $template;
+while ($tmp =~ m/^(.*?)([^\n]*):\@PASS_SHA256 (.*)\@:(.*)$/s) {
+	my $user = $2;
+	my $pass = $3;
+	$tmp = $4;
+	if ($file =~ m/^$user:/m) {
+		$file =~ s/^$user:([^:]*):(.*)$/$user:\@PASS_SHA256 $pass\@:$2/m;
+		my $cryptpass = $1;
+		# Check the password
+		my $salt = $cryptpass;
+		$salt =~ s/^\$5\$//;
+		my $rounds = "";
+		if ($salt =~ s/rounds=([0-9]*)\$//) {
+			$rounds = "-R $1";
+		}
 
+		$salt =~ s/\$.*$//;
+		my $checkpass = qx!echo '$pass' | /usr/bin/mkpasswd -m sha-256 --salt '$salt' $rounds --stdin!;
+		chomp $checkpass;
+
+		die "Wrong password: '$cryptpass'. Expected password: '$checkpass'\n"
+			if ($checkpass ne $cryptpass);
+	} else {
+		die "No user '$user' in ".$ARGV[1].".\n";
+	}
+}
+
+$tmp = $template;
+while ($tmp =~ m/^(.*?)([^\n]*):\@PASS_SHA512 (.*)\@:(.*)$/s) {
+	my $user = $2;
+	my $pass = $3;
+	$tmp = $4;
+	if ($file =~ m/^$user:/m) {
+		$file =~ s/^$user:([^:]*):(.*)$/$user:\@PASS_SHA512 $pass\@:$2/m;
+		my $cryptpass = $1;
+		# Check the password
+		my $salt = $cryptpass;
+		$salt =~ s/^\$6\$//;
+		$salt =~ s/\$.*$//;
+		my $checkpass = qx!echo '$pass' | /usr/bin/mkpasswd -m sha-512 --salt '$salt' --stdin!;
+		chomp $checkpass;
+
+		die "Wrong password: '$cryptpass'. Expected password: '$checkpass'\n"
+			if ($checkpass ne $cryptpass);
+	} else {
+		die "No user '$user' in ".$ARGV[1].".\n";
+	}
+}
+
+
 exit 0 if ($file =~ m/^\Q$template\E$/s);
 
 print "Files differ.\n";




More information about the Pkg-shadow-commits mailing list