From 011503a5b3a6e345da00b39b34dbd9c261de0362 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 21 Dec 2017 20:44:05 +0100 Subject: [PATCH] Remove password from log --- scripts/_common.sh | 17 +++++++++++++++++ scripts/install | 10 +++++++--- scripts/restore | 4 +++- scripts/upgrade | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 883fe5e..522fde5 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -343,6 +343,23 @@ ynh_exec_fully_quiet () { eval $@ > /dev/null 2>&1 } +# Remove any logs for all the following commands. +# +# usage: ynh_print_OFF +# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging. +ynh_print_OFF () { + set +x +} + +# Restore the logging after ynh_print_OFF +# +# usage: ynh_print_ON +ynh_print_ON () { + set -x + # Print an echo only for the log, to be able to know that ynh_print_ON has been called. + echo ynh_print_ON > /dev/null +} + #================================================= # Install or update the main directory yunohost.multimedia diff --git a/scripts/install b/scripts/install index 91cfbc4..e8b05d5 100644 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,7 @@ ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est dét domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN -password=$YNH_APP_ARG_PASSWORD +ynh_print_OFF; password=$YNH_APP_ARG_PASSWORD; ynh_print_ON language=$YNH_APP_ARG_LANGUAGE is_public=$YNH_APP_ARG_IS_PUBLIC export=$YNH_APP_ARG_EXPORT @@ -41,10 +41,12 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS #================================================= +ynh_print_OFF if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ] then ynh_die "The password must be between 8 and 30 characters." fi +ynh_print_ON if [ "$path_url" != "/" ] && [ $mypads -eq 1 ] then @@ -70,7 +72,7 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app password $password +ynh_print_OFF; ynh_app_setting_set $app password $password; ynh_print_ON ynh_app_setting_set $app language $language ynh_app_setting_set $app export $export ynh_app_setting_set $app mypads $mypads @@ -167,7 +169,7 @@ ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" ynh_replace_string "__DB_USER__" "$db_name" "$final_path/credentials.json" ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" -ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json" +ynh_print_OFF; ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON if [ "$export" = "abiword" ] then abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword @@ -297,6 +299,7 @@ else Informations2="" fi +ynh_print_OFF message="$Informations1 Or, you can find a config file for etherpad at this path /var/www/etherpad_mypads/settings.json. @@ -307,3 +310,4 @@ $Informations2 If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh" ynh_send_readme_to_admin "$message" "$admin" +ynh_print_ON diff --git a/scripts/restore b/scripts/restore index f4ae657..0144967 100644 --- a/scripts/restore +++ b/scripts/restore @@ -40,7 +40,7 @@ db_name=$(ynh_app_setting_get $app db_name) export=$(ynh_app_setting_get $app export) mypads=$(ynh_app_setting_get $app mypads) admin=$(ynh_app_setting_get $app admin) -password=$(ynh_app_setting_get $app password) +ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -164,6 +164,7 @@ else Informations2="" fi +ynh_print_OFF message="$Informations1 Or, you can find a config file for etherpad at this path /var/www/etherpad_mypads/settings.json. @@ -174,3 +175,4 @@ $Informations2 If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh" ynh_send_readme_to_admin "$message" "$admin" +ynh_print_ON diff --git a/scripts/upgrade b/scripts/upgrade index 347ab6e..bc1b244 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -155,10 +155,10 @@ cp ../conf/credentials.json "$final_path/credentials.json" ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json" db_pwd=$(ynh_app_setting_get $app mysqlpwd) -password=$(ynh_app_setting_get $app password) +ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" -ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json" +ynh_print_OFF; ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON if [ "$export" = "abiword" ] then abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword