From 76e4aaf429f3b33ef78f4a8dabc95dc3129fe16f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 12 Nov 2013 14:28:32 +0100 Subject: [PATCH] Import unix passwords for svn access, and fix passwrod/password typo. --- migration/export_users.php | 4 +++- migration/import_users.php | 28 ++++++++++++++++++++++++++++ migration/migration_steps.txt | 2 +- migration/storage.php | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/migration/export_users.php b/migration/export_users.php index d2fe2499a1..23ee5ee2f7 100755 --- a/migration/export_users.php +++ b/migration/export_users.php @@ -24,10 +24,11 @@ require_once $gfwww.'include/squal_pre.php'; require_once 'storage.php'; // (A)ctive, (P)ending, (S)uspended ,(D)eleted -$res = db_query_params ('SELECT user_id,user_pw,user_name,realname,email,add_date,timezone FROM users WHERE status=$1 ORDER BY user_id', array('A')); +$res = db_query_params ('SELECT user_id,user_pw,unix_pw,user_name,realname,email,add_date,timezone FROM users WHERE status=$1 ORDER BY user_id', array('A')); $user_ids = &util_result_column_to_array ($res, "user_id"); $user_pws = &util_result_column_to_array ($res, "user_pw"); +$unix_pws = &util_result_column_to_array ($res, "unix_pw"); $user_names = &util_result_column_to_array ($res, "user_name"); $user_realnames = &util_result_column_to_array ($res, "realname"); $user_emails = &util_result_column_to_array ($res, "email"); @@ -41,6 +42,7 @@ for ($i = 0; $i < count ($user_names); $i++) $muser = new MigrateUser(); $muser->id = $user_ids[$i]; $muser->password = $user_pws[$i]; + $muser->unix_password = $unix_pws[$i]; $muser->name = $user_names[$i]; $muser->realname = trim($user_realnames[$i]); $muser->email = $user_emails[$i]; diff --git a/migration/import_users.php b/migration/import_users.php index b1b6b4abd7..a73630a88e 100755 --- a/migration/import_users.php +++ b/migration/import_users.php @@ -122,12 +122,40 @@ foreach ($musers as $muser) ->setActor($user) ->createNewUser($user, $email_object); + /* profile */ + $profile = $user->loadUserProfile(); + $profile->setTitle(''); + $profile->setBlurb(''); + $user->save(); + /* set password */ $envelope = new PhutilOpaqueEnvelope($muser->password); id(new PhabricatorUserEditor()) ->setActor($user) ->changePassword($user, $envelope, true); + /* set unix password */ + $htaccess_hash = $muser->unix_password; + + if($htaccess_hash) { + $field_list = PhabricatorCustomField::getObjectFields( + $user, + PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS); + + $fields = $field_list->getFields(); + $htaccess_field = idx($fields, 'std:user:htaccess_password_hash'); + $old_value = $htaccess_field->getOldValueForApplicationTransactions(); + $xaction = id(new PhabricatorUserTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) + ->setMetadataValue('customfield:key', $htaccess_field->getFieldKey()) + ->setOldValue($old_value) + ->setNewValue($htaccess_hash); + $editor = id(new PhabricatorUserProfileEditor()) + ->setActor($user) + ->setContentSource($xaction->getContentSource()); + $editor->applyTransactions($user, array($xaction)); + } + /* log imported user */ $importedusers[$username] = $importeduser; $usedemails[strtolower($email)] = $username; diff --git a/migration/migration_steps.txt b/migration/migration_steps.txt index 73384808b4..6d38e6edc2 100644 --- a/migration/migration_steps.txt +++ b/migration/migration_steps.txt @@ -84,7 +84,7 @@ set maniphest.priorities set user.custom-field-definitions { - "htaccess_passowrd_hash":{"name":"htaccess passowrd hash","type":"text","hidden":true} + "htaccess_password_hash":{"name":"htaccess password hash","type":"text","hidden":true} } Disable irrelevant applications diff --git a/migration/storage.php b/migration/storage.php index 63774b5030..c129efadab 100644 --- a/migration/storage.php +++ b/migration/storage.php @@ -52,6 +52,7 @@ class MigrateUser { public $date; public $timezone; public $password; + public $unix_password; } class MigrateImportedUser {