From 3436d6f8c530bedcaa4120c9e7c47305efd5d3b8 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 21 Dec 2017 20:45:00 +0100 Subject: [PATCH] Remove password from log --- scripts/_common.sh | 17 +++++++++++++++++ scripts/install | 11 +++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 883fe5e..522fde5 100644 --- 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 6b1b0e3..486f072 100755 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ ynh_abort_if_errors ssh_user=$YNH_APP_ARG_SSH_USER # Default value null -password=${YNH_APP_ARG_PASSWORD:-} +ynh_print_OFF; password=${YNH_APP_ARG_PASSWORD:-}; ynh_print_ON pub_key=${YNH_APP_ARG_PUB_KEY:-} size=$YNH_APP_ARG_SIZE @@ -32,7 +32,8 @@ app=$YNH_APP_INSTANCE_NAME # DISCLAIMER #================================================= -if IS_PACKAGE_CHECK; then +PACKAGE_CHECK_EXEC=${PACKAGE_CHECK_EXEC:-0} +if [ "$PACKAGE_CHECK_EXEC" != "0" ]; then ynh_print_warn "This app can't be tested by package check. Please see the readme for more information. https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh" fi @@ -50,10 +51,12 @@ ynh_system_user_exists $ssh_user && ynh_die "This user already exist" final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" +ynh_print_OFF if test -z "$password" && test -z "$pub_key" then ynh_die "You can't left empty both password and public key. Please fill at least one of them." fi +ynh_print_ON #================================================= # STORE SETTINGS FROM MANIFEST @@ -110,11 +113,13 @@ quotas_activate "$quotas_mount_point" #================================================= add_password="" +ynh_print_OFF if [ -n "$password" ] then auth_opt="--password" auth_value="$password" fi +ynh_print_ON add_sshkey="" if [ -n "$pub_key" ] @@ -124,7 +129,9 @@ then auth_value="$pub_key" fi +ynh_print_OFF $final_path/chroot_manager.sh adduser --name $ssh_user $auth_opt "$auth_value" --directory "$user_dir" --quota $size +ynh_print_ON #================================================= # ADD A LINK TO CHROOT_MANAGER