Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variable to select storage provider #741

Merged
merged 8 commits into from
Sep 27, 2024
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ You can set the following environment variables:
- `ELECTRON_OZONE_PLATFORM_HINT=auto`: Enables Wayland support
- `SIGNAL_DISABLE_GPU=1`: Disables GPU acceleration
- `SIGNAL_DISABLE_GPU_SANDBOX=1`: Disables GPU sandbox
- `SIGNAL_PASSWORD_STORE`: Selects where the database key is stored. Valid options are:
- `basic` Writes the key in plaintext to config.json. This is the default.
- `gnome_libsecret` for X-Cinnamon, Deepin, GNOME, Pantheon, XFCE, UKUI, unity
- `kwallet` for kde4
- `kwallet5` for kde5
- `kwallet6` for kde6

## Wayland

Expand Down
1 change: 1 addition & 0 deletions org.signal.Signal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ finish-args:
# Environment Variables to control the behavior
- --env=SIGNAL_DISABLE_GPU=0
- --env=SIGNAL_DISABLE_GPU_SANDBOX=0
- --env=SIGNAL_PASSWORD_STORE=basic
# Use same mouse cursors as host
- --env=XCURSOR_PATH=/run/host/user-share/icons:/run/host/share/icons

Expand Down
53 changes: 52 additions & 1 deletion signal-desktop.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,66 @@
#!/bin/bash

report_warning() {
read -r -d '|' MESSAGE <<EOF
Signal is being launched with the <b>plaintext password store</b> by
default due to database corruption bugs when using the encrypted backends.
This will leave your keys <b>unencrypted</b> on disk as it did in all previous versions.

If you wish to experiment with the encrypted backend, set the environment variable
<tt>SIGNAL_PASSWORD_STORE</tt> to <tt>gnome_libsecret</tt>, <tt>kwallet</tt>,
<tt>kwallet5 or <tt>kwallet6</tt> depending on your desktop environment using
Flatseal or the following command:

<tt>flatpak override --env=SIGNAL_PASSWORD_STORE=gnome-libsecret org.signal.Signal</tt>

Note that the encrypted backends are <b>experimental</b> and may cause data loss on some systems.

Press <b>Yes</b> to proceed with <b>plaintext password store</b> or
<b>No</b> to <b>exit</b>. |
EOF
zenity --question --no-wrap --default-cancel --icon-name=dialog-warning --title "Warning" --text "$MESSAGE"

if [ "$?" -eq "1" ]; then
echo "Debug: Abort as user pressed no"
exit 1
else
touch "${XDG_CACHE_HOME}"/warning-shown
fi
}

EXTRA_ARGS=()

declare -i SIGNAL_DISABLE_GPU="${SIGNAL_DISABLE_GPU:-0}"
declare -i SIGNAL_DISABLE_GPU_SANDBOX="${SIGNAL_DISABLE_GPU_SANDBOX:-0}"

# only kept for backward compatibility
if (( ${SIGNAL_USE_WAYLAND:-0} )); then
if ((${SIGNAL_USE_WAYLAND:-0})); then
export ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}"
fi

declare -r SIGNAL_PASSWORD_STORE="${SIGNAL_PASSWORD_STORE:-basic}"

case "${SIGNAL_PASSWORD_STORE}" in
basic | gnome-libsecret | kwallet | kwallet5 | kwallet6)
bbhtt marked this conversation as resolved.
Show resolved Hide resolved
echo "Debug: Using password store: ${SIGNAL_PASSWORD_STORE}"
EXTRA_ARGS=(
"--password-store=${SIGNAL_PASSWORD_STORE}"
)
;;
*)
echo "Error: SIGNAL_PASSWORD_STORE (${SIGNAL_PASSWORD_STORE}) must be one of the following: basic, gnome-libsecret, kwallet, kwallet5, kwallet6"
exit 1
;;
esac

if [[ "${SIGNAL_PASSWORD_STORE}" == "basic" ]]; then
if [[ -f "${XDG_CACHE_HOME}"/warning-shown ]]; then
Copy link
Contributor

@bbhtt bbhtt Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition won't work, this will always be true if you stay on basic. After the first time as the file exists this removes it on the next launch and on the next one even if you are on basic and have seen the warning it will show up again. It becomes a cyclic thing.

Copy link
Contributor

@bbhtt bbhtt Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have to take the rm part out of the first if password store == basic condition.

If someone switches from basic to encrypted and back to basic again the warning should be shown.

rm is piped to true so it doesn't matter if the file previously didn't exist.

rm "${XDG_CACHE_HOME}"/warning-shown || true
else
report_warning
fi
fi

if [[ "${SIGNAL_DISABLE_GPU}" -eq 1 ]]; then
EXTRA_ARGS+=(
"--disable-gpu"
Expand Down