Add tool to convert old plain passwords to MD5
authorChip Black <bytex64@bytex64.net>
Tue, 19 Jul 2011 01:58:47 +0000 (20:58 -0500)
committerChip Black <bytex64@bytex64.net>
Tue, 19 Jul 2011 01:58:47 +0000 (20:58 -0500)
tools/convert_to_md5_passwords.pl [new file with mode: 0644]

diff --git a/tools/convert_to_md5_passwords.pl b/tools/convert_to_md5_passwords.pl
new file mode 100644 (file)
index 0000000..a129715
--- /dev/null
@@ -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;
+}