1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/transmission_ynh.git synced 2024-09-04 01:46:12 +02:00

Transmission edits its settings file to save the hashed password, let's save it.

This commit is contained in:
Félix Piédallu 2023-12-06 10:44:01 +01:00 committed by Salamandar
parent 49d6dcebad
commit 806bfaf4b4
2 changed files with 27 additions and 1 deletions

View file

@ -10,6 +10,26 @@ SETTINGS_FILE="/etc/transmission-daemon/settings.json"
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
_wait_and_save_rcp_password_hash() {
# Transmission first reads the plaintext password in the config, then
# computes a cryptographic hash and rewrites the config file.
for ((i=0;i<10;i++)); do
pass=$(jq -r '.["rpc-password"]' "$SETTINGS_FILE")
if [[ "$pass" == "{"* ]]; then
# Save the hashed password
ynh_app_setting_set --app="$app" --key="rpcpassword" --value="$pass"
# Save the edited settings file
ynh_store_file_checksum --file="$SETTINGS_FILE"
return
fi
sleep 1
done
echo "Timeout! Transmission did not save a cryptographic hash of the password in 10 seconds!"
return 1
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
rpcpassword=$(ynh_string_random) rpcpassword=$(ynh_string_random)
ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -107,6 +106,13 @@ ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd"
#=================================================
# RETRIEVE HASHED PASSWORD
#=================================================
ynh_script_progression --message="Saving the encrypted password..."
_wait_and_save_rcp_password_hash
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================