From d460d7f2bddf0ea879ad27abff77a99274b336a9 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Sun, 9 Feb 2020 23:30:01 +0000 Subject: [PATCH] scripts: disable questionnable password complexity rules Enforcing password complexity rules is usually useless, and encourages bad security. However, this is not our main issue. The problem is that when installing Mattermost on Yunohost, if the user chooses a password that doesn't fullfil all these requirements, the installation will fail with a hard- to-spot error message. We don't want this to happen, so we relax the rules a little. Fix #159 --- check_process | 2 +- manifest.json | 4 ++-- scripts/install | 34 ++++++++++++++++++++-------------- scripts/upgrade | 4 ++-- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/check_process b/check_process index b6d972e..29aff32 100644 --- a/check_process +++ b/check_process @@ -3,7 +3,7 @@ domain="ynhtests.local" (DOMAIN) path="/path" (PATH) admin_email="john@gmail.com" - admin_password="MattermostPassword!42" + admin_password="admin!42" admin_locale="fr" team_display_name="Mon équipe" is_public=1 (PUBLIC|public=1|private=0) diff --git a/manifest.json b/manifest.json index 993bd1a..8238ec7 100644 --- a/manifest.json +++ b/manifest.json @@ -64,8 +64,8 @@ "name": "admin_password", "type": "password", "ask": { - "en": "Password for the chat admin. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').", - "fr": "Mot de passe pour l’administrateur du chat. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')." + "en": "Password for the chat admin. At least 8 characters.", + "fr": "Mot de passe pour l’administrateur du chat. Minimum 8 caractères." }, "optional": false }, diff --git a/scripts/install b/scripts/install index 3ac2836..e8b55e6 100644 --- a/scripts/install +++ b/scripts/install @@ -125,28 +125,34 @@ mkdir -p "$logs_path" #================================================= # Configure Service Settings -ynh_replace_string --match "\"SiteURL\": \"\"" --replace "\"SiteURL\": \"https://${domain}${path_url}\"" --target $final_path/config/config.json -ynh_replace_string --match "\"ListenAddress\": \".*\"" --replace "\"ListenAddress\": \"127.0.0.1:${port}\"" --target $final_path/config/config.json +ynh_replace_string --match_string "\"SiteURL\": \"\"" --replace_string "\"SiteURL\": \"https://${domain}${path_url}\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"ListenAddress\": \".*\"" --replace_string "\"ListenAddress\": \"127.0.0.1:${port}\"" --target_file $final_path/config/config.json # Configure the database connection db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" -ynh_replace_string --match "\"DataSource\": \".*\"" --replace "\"DataSource\": \"${db_connection_url}\"" --target $final_path/config/config.json +ynh_replace_string --match_string "\"DataSource\": \".*\"" --replace_string "\"DataSource\": \"${db_connection_url}\"" --target_file $final_path/config/config.json # Configure uploaded files directory -ynh_replace_string --match "\"Directory\": \"./data/\"" --replace "\"Directory\": \"${data_path}/\"" --target $final_path/config/config.json +ynh_replace_string --match_string "\"Directory\": \"./data/\"" --replace_string "\"Directory\": \"${data_path}/\"" --target_file $final_path/config/config.json # Configure SMTP account for sending email notifications -ynh_replace_string --match "\"SendEmailNotifications\": false" --replace "\"SendEmailNotifications\": true" --target $final_path/config/config.json -ynh_replace_string --match "\"FeedbackName\": \"\"" --replace "\"FeedbackName\": \"Mattermost notification\"" --target $final_path/config/config.json -ynh_replace_string --match "\"FeedbackEmail\": \"\"" --replace "\"FeedbackEmail\": \"no-reply@${domain}\"" --target $final_path/config/config.json -ynh_replace_string --match "\"SMTPUsername\": \"\"" --replace "\"SMTPUsername\": \"${mattermost_user}\"" --target $final_path/config/config.json -ynh_replace_string --match "\"SMTPPassword\": \"\"" --replace "\"SMTPPassword\": \"${mattermost_user_password}\"" --target $final_path/config/config.json -ynh_replace_string --match "\"SMTPServer\": \"\"" --replace "\"SMTPServer\": \"localhost\"" --target $final_path/config/config.json -ynh_replace_string --match "\"SMTPPort\": \"\"" --replace "\"SMTPPort\": \"25\"" --target $final_path/config/config.json +ynh_replace_string --match_string "\"SendEmailNotifications\": false" --replace_string "\"SendEmailNotifications\": true" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"FeedbackName\": \"\"" --replace_string "\"FeedbackName\": \"Mattermost notification\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"FeedbackEmail\": \"\"" --replace_string "\"FeedbackEmail\": \"no-reply@${domain}\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"SMTPUsername\": \"\"" --replace_string "\"SMTPUsername\": \"${mattermost_user}\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"SMTPPassword\": \"\"" --replace_string "\"SMTPPassword\": \"${mattermost_user_password}\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"SMTPServer\": \"\"" --replace_string "\"SMTPServer\": \"localhost\"" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"SMTPPort\": \"\"" --replace_string "\"SMTPPort\": \"25\"" --target_file $final_path/config/config.json # Disable Mattermost debug console by default -ynh_replace_string --match "\"EnableConsole\": true" --replace "\"EnableConsole\": false" --target $final_path/config/config.json +ynh_replace_string --match_string "\"EnableConsole\": true" --replace_string "\"EnableConsole\": false" --target_file $final_path/config/config.json # Configure log file location -ynh_replace_string --match "\"FileLocation\": \"\"" --replace "\"FileLocation\": \"$logs_path\"" --target $final_path/config/config.json +ynh_replace_string --match_string "\"FileLocation\": \"\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file $final_path/config/config.json +# Disable questionable password complexity rules +ynh_replace_string --match_string "\"MinimumLength\": 10" --replace_string "\"MinimumLength\": 8" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"Lowercase\": true" --replace_string "\"Lowercase\": false" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"Number\": true" --replace_string "\"Number\": false" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"Uppercase\": true" --replace_string "\"Uppercase\": false" --target_file $final_path/config/config.json +ynh_replace_string --match_string "\"Symbol\": true" --replace_string "\"Symbol\": false" --target_file $final_path/config/config.json # Configure analytics according to user choice if [ $analytics -eq 0 ]; then - ynh_replace_string --match "\"EnableDiagnostics\": true" --replace "\"EnableDiagnostics\": false" --target $final_path/config/config.json + ynh_replace_string --match_string "\"EnableDiagnostics\": true" --replace_string "\"EnableDiagnostics\": false" --target_file $final_path/config/config.json fi ynh_app_setting_set "$app" analytics "$analytics" diff --git a/scripts/upgrade b/scripts/upgrade index a448220..df4af82 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -146,12 +146,12 @@ yunohost service add "$app" --log "$logs_path/mattermost.log" # Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash) # https://docs.mattermost.com/administration/changelog.html#release-v3-8-3 -ynh_replace_string --match "\"FileLocation\": \"/var/log/mattermost.log\"" --replace "\"FileLocation\": \"/var/log\"" --target "$config_file" +ynh_replace_string --match_string "\"FileLocation\": \"/var/log/mattermost.log\"" --replace_string "\"FileLocation\": \"/var/log\"" --target_file "$config_file" # Move log files to a directory (rather than directly in /var/log) # See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61 mkdir -p "$logs_path" -ynh_replace_string --match "\"FileLocation\": \"/var/log\"" --replace "\"FileLocation\": \"$logs_path\"" --target "$config_file" +ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$config_file" if [ -f "/var/log/${app}.log" ]; then mv "/var/log/${app}.log" "$logs_path/" fi