From dac51d1f597fba5ef3e5991b0d38298a2686390c Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 2 Dec 2023 18:13:37 +0000 Subject: [PATCH 1/5] gui-fatal: dynamically fall back on kdialog after trying zenity In practice kdialog wasn't used, because the package was built without USE_KDIALOG being defined. Fixes QubesOS/qubes-issues#8738 --- qubes-rpc/gui-fatal.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/qubes-rpc/gui-fatal.c b/qubes-rpc/gui-fatal.c index 02238dd2..c3de7f1f 100644 --- a/qubes-rpc/gui-fatal.c +++ b/qubes-rpc/gui-fatal.c @@ -37,16 +37,13 @@ static void produce_message(const char *type, const char *fmt, va_list args) case 0: if (geteuid() == 0) { if (setuid(getuid()) != 0) { - perror("setuid failed, not calling kdialog/zenity"); + perror("setuid failed, not calling zenity/kdialog"); exit(1); } } fix_display(); -#ifdef USE_KDIALOG - execlp("/usr/bin/kdialog", "kdialog", "--sorry", dialog_msg, NULL); -#else execlp("/usr/bin/zenity", "zenity", "--error", "--text", dialog_msg, NULL); -#endif + execlp("/usr/bin/kdialog", "kdialog", "--sorry", dialog_msg, NULL); exit(1); default:; } From 32426f7ec182bf97a7dd43f93780a4e13136796f Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 2 Dec 2023 18:13:38 +0000 Subject: [PATCH 2/5] qvm-copy-to-vm.gnome: always pass PROGRESS_TYPE=gui to qfile-agent A while ago qfile-agent was changed to show graphical error messages (in addition to stderr messages) only if PROGRESS_TYPE=gui is set. Set it even if a progress bar window is not being shown, e.g. if the total estimated size is 0. Fixes QubesOS/qubes-issues#8738 --- qubes-rpc/qvm-copy-to-vm.gnome | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index 1a5725b6..d515c9ca 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -22,7 +22,7 @@ set -e -o pipefail copy() { - /usr/lib/qubes/qrexec-client-vm @default \ + PROGRESS_TYPE=gui /usr/lib/qubes/qrexec-client-vm @default \ qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" } @@ -79,11 +79,11 @@ else fi if [[ $SIZE == 0 ]]; then - PROGRESS_TYPE=none copy "$@" + copy "$@" >/dev/null elif [[ $0 == *.kde ]] && type kdialog qdbus >/dev/null; then - PROGRESS_TYPE=gui copy "$@" | progress_kdialog + copy "$@" | progress_kdialog elif type zenity >/dev/null; then - PROGRESS_TYPE=gui copy "$@" | progress_zenity + copy "$@" | progress_zenity else - PROGRESS_TYPE=none copy "$@" + copy "$@" >/dev/null fi From 6c31dafb32bd4917f306adda1b40c197a0fa6ccb Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 2 Dec 2023 18:13:39 +0000 Subject: [PATCH 3/5] qvm-copy-to-vm.gnome: update qdbus syntax The new syntax has existed for more than six years: https://invent.kde.org/utilities/kdialog/-/commit/d72ab46df8879024cda620beec9da71a674873dc#5d61d07d60f0444023012a7c0902c123179f8bdd --- qubes-rpc/qvm-copy-to-vm.gnome | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index d515c9ca..ce69d2d9 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -34,10 +34,10 @@ progress_kdialog() { # shellcheck disable=SC2207 ref=( $(kdialog --progressbar "$DESCRIPTION") ) trap 'qdbus "${ref[@]}" close' EXIT # for this subshell - qdbus "${ref[@]}" Set "" maximum "$SIZE" + qdbus "${ref[@]}" maximum "$SIZE" fi - qdbus "${ref[@]}" Set "" value "$pos" + qdbus "${ref[@]}" value "$pos" done) >/dev/null # hide qdbus's empty output lines } From 5043a45b745aaf3acf8ee79a33bd0fab2e84b876 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 2 Dec 2023 18:13:40 +0000 Subject: [PATCH 4/5] qvm-copy-to-vm.gnome: qdbus can have a -qt5/6 suffix (Fedora) --- qubes-rpc/qvm-copy-to-vm.gnome | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index ce69d2d9..a4dd7bbf 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -21,6 +21,17 @@ set -e -o pipefail +set_qdbus() { + for cmd in qdbus qdbus-qt{6,5}; do + type "$cmd" >&2 || continue + qdbus=$cmd + return 0 + done + + unset qdbus + return 1 +} + copy() { PROGRESS_TYPE=gui /usr/lib/qubes/qrexec-client-vm @default \ qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" @@ -33,11 +44,11 @@ progress_kdialog() { if [[ $pos == 0 ]]; then # shellcheck disable=SC2207 ref=( $(kdialog --progressbar "$DESCRIPTION") ) - trap 'qdbus "${ref[@]}" close' EXIT # for this subshell - qdbus "${ref[@]}" maximum "$SIZE" + trap '"$qdbus" "${ref[@]}" close' EXIT # for this subshell + "$qdbus" "${ref[@]}" maximum "$SIZE" fi - qdbus "${ref[@]}" value "$pos" + "$qdbus" "${ref[@]}" value "$pos" done) >/dev/null # hide qdbus's empty output lines } @@ -80,7 +91,7 @@ fi if [[ $SIZE == 0 ]]; then copy "$@" >/dev/null -elif [[ $0 == *.kde ]] && type kdialog qdbus >/dev/null; then +elif [[ $0 == *.kde ]] && type kdialog >/dev/null && set_qdbus; then copy "$@" | progress_kdialog elif type zenity >/dev/null; then copy "$@" | progress_zenity From 0ad16b277bf26a051f970caf421c5155c44390bb Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Sat, 2 Dec 2023 18:13:42 +0000 Subject: [PATCH 5/5] qvm-copy-to-vm.gnome: fix progress_kdialog() for large transfers The estimated total size in bytes can be too large to use as kdialog's maximum. Use the default 100 instead and calculate a percentage for the current position, like in progress_zenity(). Fixes QubesOS/qubes-issues#8723 --- qubes-rpc/qvm-copy-to-vm.gnome | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index a4dd7bbf..cc7f6926 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -45,10 +45,9 @@ progress_kdialog() { # shellcheck disable=SC2207 ref=( $(kdialog --progressbar "$DESCRIPTION") ) trap '"$qdbus" "${ref[@]}" close' EXIT # for this subshell - "$qdbus" "${ref[@]}" maximum "$SIZE" fi - "$qdbus" "${ref[@]}" value "$pos" + "$qdbus" "${ref[@]}" value $((100 * pos / SIZE)) done) >/dev/null # hide qdbus's empty output lines }