From 4326341df5a2c68e767bf5058e7d93c4188da802 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 30 Jul 2023 16:49:26 +0200 Subject: [PATCH] Fix semantics + the password hash wasnt random + the admin password has to be saved as a setting to be displayed in the postinstall notification --- conf/sql/admin.sql | 2 +- doc/POST_INSTALL.md | 2 +- doc/POST_INSTALL_fr.md | 2 +- scripts/install | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conf/sql/admin.sql b/conf/sql/admin.sql index 127ed0c..16c6ba5 100644 --- a/conf/sql/admin.sql +++ b/conf/sql/admin.sql @@ -1,3 +1,3 @@ -INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__USER_NAME__', '__NAME__', '__USER_EMAIL__', '__PASSWORD__'); +INSERT INTO `wt_user` (`user_id`, `user_name`, `real_name`, `email`, `password`) VALUES (NULL, '__USER_NAME__', '__NAME__', '__USER_EMAIL__', '__ADMIN_PASSWORD__'); INSERT INTO `wt_user_setting` (`user_id`, `setting_name`, `setting_value`) VALUES ('1', 'canadmin', '1'), ('1', 'verified', '1'), ('1', 'verified_by_admin', '1'); diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index bcec90b..caf9443 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,4 +1,4 @@ Your credentials for the admin panel are: - admin username: __ADMIN_USERNAME__ -- admin password: __PASSWORD__ \ No newline at end of file +- admin password: __ADMIN_PASSWORD__ diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md index 5bb106a..ebfaaa9 100644 --- a/doc/POST_INSTALL_fr.md +++ b/doc/POST_INSTALL_fr.md @@ -1,4 +1,4 @@ Vos informations d'identification pour le panneau d'administration sont : - nom d'utilisateur administrateur : __ADMIN_USERNAME__ -- mot de passe administrateur : __PASSWORD__ \ No newline at end of file +- mot de passe administrateur : __ADMIN_PASSWORD__ diff --git a/scripts/install b/scripts/install index fee6910..7caa598 100755 --- a/scripts/install +++ b/scripts/install @@ -13,8 +13,8 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -password=$(ynh_string_random 24) -admin_password=$(openssl passwd -1 -salt xyz $password) +admin_password=$(ynh_string_random 24) +admin_password_hashed=$(mkpasswd -m md5crypt --stdin <<< "$admin_password") admin_username=$YNH_APP_ARG_USERNAME admin_name=$YNH_APP_ARG_NAME admin_email=$YNH_APP_ARG_EMAIL @@ -22,6 +22,7 @@ admin_email=$YNH_APP_ARG_EMAIL ynh_app_setting_set --app=$app --key=admin_username --value=$admin_username ynh_app_setting_set --app=$app --key=admin_name --value=$admin_name ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email +ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -65,7 +66,7 @@ ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/webtrees.sql ynh_replace_string --match_string="__USER_NAME__" --replace_string="$admin_username" --target_file="../conf/sql/admin.sql" ynh_replace_string --match_string="__NAME__" --replace_string="$admin_name" --target_file="../conf/sql/admin.sql" ynh_replace_string --match_string="__USER_EMAIL__" --replace_string="$admin_email" --target_file="../conf/sql/admin.sql" -ynh_replace_string --match_string="__PASSWORD__" --replace_string="$admin_password" --target_file="../conf/sql/admin.sql" +ynh_replace_string --match_string="__ADMIN_PASSWORD_HASHED__" --replace_string="$admin_password_hashed" --target_file="../conf/sql/admin.sql" ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/admin.sql"