commit:4cb5e55ccf51bafceafa493fb0596fd00d5e551d
author:Chip Black
committer:Chip Black
date:Mon Jul 18 20:58:47 2011 -0500
parents:63b6a13e9540c373890ff54f4b765be82af5e440
Add tool to convert old plain passwords to MD5
diff --git a/tools/convert_to_md5_passwords.pl b/tools/convert_to_md5_passwords.pl
line changes: +23/-0
index 0000000..a129715
--- /dev/null
+++ b/tools/convert_to_md5_passwords.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+# Yes, we were storing passwords in plain text.
+use Digest::MD5 qw/md5/;
+use strict;
+
+my $datadir = shift;
+
+opendir DATA, $datadir;
+while (my $user = readdir(DATA)) {
+	next if $user =~ /^\./;
+	print "Processing $user\n";
+	open P, "$datadir/$user/password";
+	my $password = <P>;
+	close P;
+	chomp $password;
+
+	my $md5password = md5($user . $password);
+
+	rename "$datadir/$user/password", "$datadir/$user/password.old";
+	open P, ">$datadir/$user/password";
+	print P $md5password;
+	close P;
+}