From d5eaa4855a90057c268bf4d717f366ccf3197dba Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 16 Oct 2026 09:56:48 +0200 Subject: fix(user): userctl survives leading dashes and reports failed reads busctl and kwriteconfig6 parse a value starting with '-' as an option, so a location like '-x' failed; '--' before the value ends option parsing (checked against both binaries). get ran without pipefail, so a failing busctl gave empty fields and exit 0, which the page would show as a blank form. It now reads all fields first and, on failure, prints one error= line and exits 1. keys listed revoked, expired or invalid primaries, keys that cannot sign, and could label a key with a revoked uid. It now skips those. Unsetting the signing key uses --unset-all, since git exits 5 on a multi-valued key with --unset. Co-Authored-By: Claude Sonnet 5.5 --- desktop/modules/user/userctl | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'desktop/modules/user/userctl') diff --git a/desktop/modules/user/userctl b/desktop/modules/user/userctl index 07d3a63..d9720d8 100755 --- a/desktop/modules/user/userctl +++ b/desktop/modules/user/userctl @@ -49,12 +49,16 @@ run() { } # --json, because plain get-property prints non-ASCII as octal escapes. +# Fails with the first line of stderr as its output, so get can report it. prop() { - busctl --system --json=short get-property "$ACC" "$OBJ" "$IFACE" "$1" | jq -r .data + local out + out="$(busctl --system --json=short get-property "$ACC" "$OBJ" "$IFACE" "$1" 2>&1)" \ + || { head -n1 <<< "${out:-failed}"; return 1; } + jq -r .data <<< "$out" } -acc() { run busctl --system call "$ACC" "$OBJ" "$IFACE" "$1" s "$2"; } -kde() { run kwriteconfig6 --file emaildefaults --group PROFILE_Default --key "$1" "$2"; } +acc() { run busctl --system call -- "$ACC" "$OBJ" "$IFACE" "$1" s "$2"; } +kde() { run kwriteconfig6 --file emaildefaults --group PROFILE_Default --key "$1" -- "$2"; } # The surname as an initial, for commits: "Jane Doèr" -> "Jane D.". gitname() { @@ -69,20 +73,22 @@ gitname() { case "$1" in get) - printf 'name=%s\n' "$(prop RealName)" - printf 'email=%s\n' "$(prop Email)" - printf 'avatar=%s\n' "$(prop IconFile)" - printf 'language=%s\n' "$(prop Language)" - printf 'location=%s\n' "$(prop Location)" + out= + # Read everything first: one error line and exit 1, never blank fields. + for p in RealName:name Email:email IconFile:avatar Language:language Location:location; do + val="$(prop "${p%%:*}")" || { printf 'error=%s\n' "$val"; exit 1; } + out+="${p#*:}=$val"$'\n' + done + printf '%s' "$out" printf 'signingkey=%s\n' "$(git config --global --get user.signingkey)" ;; keys) # The first fpr after a sec is the primary key's; the first uid # after that names it. ssb fingerprints come later and are skipped. gpg --list-secret-keys --with-colons 2>/dev/null | awk -F: ' - $1 == "sec" { want = 1; next } + $1 == "sec" { want = ($2 !~ /^[rei]$/ && $12 ~ /S/) ? 1 : 0; next } $1 == "fpr" && want == 1 { fpr = $10; want = 2; next } - $1 == "uid" && want == 2 { print fpr "\t" $10; want = 0 }' + $1 == "uid" && want == 2 && $2 !~ /^[re]$/ { print fpr "\t" $10; want = 0 }' ;; set) [[ $# -eq 3 ]] || usage @@ -105,7 +111,7 @@ case "$1" in if [[ -n "$v" ]]; then run git config --global user.signingkey "$v" elif git config --global --get user.signingkey >/dev/null; then - run git config --global --unset user.signingkey + run git config --global --unset-all user.signingkey fi ;; *) usage ;; -- cgit v1.2.3