From 2c0c522c1380c797f597c2ca482e360fba8a5f8c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 23 Nov 2015 12:51:31 -0500 Subject: [PATCH] LP#1468422 Admin seed data sets new-style passwd Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- Open-ILS/src/support-scripts/eg_db_config.in | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/support-scripts/eg_db_config.in b/Open-ILS/src/support-scripts/eg_db_config.in index a30b09eac8..2d0bd3b050 100755 --- a/Open-ILS/src/support-scripts/eg_db_config.in +++ b/Open-ILS/src/support-scripts/eg_db_config.in @@ -226,10 +226,27 @@ sub set_admin_account { print STDERR "Error was " . $dbh->errstr . "\n"; return; } - my $stmt = $dbh->prepare("UPDATE actor.usr SET usrname = ?, passwd = ? WHERE id = 1"); - $stmt->execute(($admin_user, $admin_pw)); + my $stmt = $dbh->prepare("UPDATE actor.usr SET usrname = ? WHERE id = 1"); + $stmt->execute(($admin_user)); if ($dbh->err) { - print STDERR "Failed to set admin account. "; + print STDERR "Failed to set admin username. "; + print STDERR "Error was " . $dbh->errstr . "\n"; + return; + } + + # Legacy actor.usr.passwd-style passwords must go through + # in intermediate round of hashing before final crypt'ing. + # The hashing step requires access to the password salt. + # Create a new salt, perform MD5 hashing, set the new password. + $stmt = $dbh->prepare("SELECT actor.create_salt('main') AS new_salt"); + $stmt->execute; + my $new_salt = $stmt->selectrow_hashref->{new_salt}; + + $stmt = $dbh->prepare( + "SELECT actor.set_passwd(1, 'main', MD5(? || MD5(?)), ?)"); + $stmt->execute(($new_salt, $admin_pw, $new_salt)); + if ($dbh->err) { + print STDERR "Failed to set admin password. "; print STDERR "Error was " . $dbh->errstr . "\n"; return; } -- 2.43.2