From fa670c6fdd42ecbb4c02c0d16b13a9c0e80f09da Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Tue, 30 Mar 2021 00:07:37 -0400 Subject: [PATCH] Don't compile Nitter as root --- scripts/install | 10 ++++++---- scripts/restore | 1 + scripts/upgrade | 10 ++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 65f69dd..3d2b871 100755 --- a/scripts/install +++ b/scripts/install @@ -124,6 +124,7 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app +usermod -d $final_path $app 2>&1 #================================================= # SPECIFIC SETUP @@ -132,10 +133,11 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Compiling Nitter..." --weight=30 pushd "$final_path" || ynh_die - export PATH="$final_path/.nim/bin:$PATH" - nimble build -d:release -y - nimble scss -y - mkdir -p ./tmp + chown -R $app:$app $final_path + sudo -u $app "PATH=/opt/yunohost/$app/.nim/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/.nim/bin/nimble build -d:release -y + sudo -u $app "PATH=/opt/yunohost/$app/.nim/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/.nim/bin/nimble scss -y + mkdir -p $final_path/tmp + chown -R root:root $final_path popd || ynh_die #================================================= diff --git a/scripts/restore b/scripts/restore index 6aef7e0..44093ff 100755 --- a/scripts/restore +++ b/scripts/restore @@ -63,6 +63,7 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei # Create the dedicated user (if not existing) ynh_system_user_create --username=$app +usermod -d $final_path $app 2>&1 #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index 3a15ad0..3040aa5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -98,6 +98,7 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app +usermod -d $final_path $app 2>&1 #================================================= # SPECIFIC UPGRADE @@ -106,10 +107,11 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Compiling Nitter..." --weight=30 pushd "$final_path" || ynh_die - export PATH="$final_path/.nim/bin:$PATH" - nimble build -d:release -y - nimble scss -y - mkdir -p ./tmp + chown -R $app:$app $final_path + sudo -u $app "PATH=/opt/yunohost/$app/.nim/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/.nim/bin/nimble build -d:release -y + sudo -u $app "PATH=/opt/yunohost/$app/.nim/bin:$(sudo -u $app sh -c 'echo $PATH')" $final_path/.nim/bin/nimble scss -y + mkdir -p $final_path/tmp + chown -R root:root $final_path popd || ynh_die #=================================================