From dfbc413d670cfdbaed349f54d8fa9f6a29f86fa9 Mon Sep 17 00:00:00 2001 From: Danathar Date: Sun, 15 Nov 2026 16:09:38 -0500 Subject: [PATCH 1/2] fix(uwelcome): greet only a terminal so login doesn't stall the portals GDM starts the desktop session through a login shell, which sources /etc/profile.d/uwelcome.sh. uwelcome then asks for the portal before graphical-session.target is up, so xdg-desktop-portal.service fails its dependency and D-Bus holds every portal request for its 120 s activation timeout: file pickers, screenshots and settings portals are dead for about two minutes after login (common#1688, VM serial log of run 43653470297). Only run the greeting when stdout is a terminal. Tests that exercise the greeting guards now run the profile under script(1) for a pty, and a new test pins that a non-terminal login shell does not call uwelcome. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WcWm7tJ5iop2b4GMkKSPAv Signed-off-by: Danathar --- system_files/shared/etc/profile.d/uwelcome.sh | 6 ++++- tests/test_uwelcome_profile.bats | 26 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/system_files/shared/etc/profile.d/uwelcome.sh b/system_files/shared/etc/profile.d/uwelcome.sh index cf1b43702..3143cd036 100644 --- a/system_files/shared/etc/profile.d/uwelcome.sh +++ b/system_files/shared/etc/profile.d/uwelcome.sh @@ -5,11 +5,15 @@ if [ -e ~/.config/no-show-user-motd ]; then mv ~/.config/no-show-user-motd ~/.config/uwelcome/disabled 2>/dev/null fi +# Only greet a terminal: GDM starts the desktop session through a login shell, +# and uwelcome run there (no tty) asks for the portal before +# graphical-session.target is up, so xdg-desktop-portal fails its dependency +# and every portal call then waits out D-Bus's 120 s activation timeout. # Skip for root: root shells (sudo su -, sudo -i) have no desktop session, # and the portal lookup uwelcome makes can stall the prompt when the portal # cannot start. Guard against double greetings when a shell chains into # another (bash login shell starting fish): the first one wins. -if [ "$(id -u)" != "0" ] && [ -z "${UWELCOME_SHOWN-}" ]; then +if [ -t 1 ] && [ "$(id -u)" != "0" ] && [ -z "${UWELCOME_SHOWN-}" ]; then UWELCOME_SHOWN=1 export UWELCOME_SHOWN uwelcome diff --git a/tests/test_uwelcome_profile.bats b/tests/test_uwelcome_profile.bats index b348d0335..51cb668d5 100644 --- a/tests/test_uwelcome_profile.bats +++ b/tests/test_uwelcome_profile.bats @@ -49,6 +49,12 @@ not_called() { [ ! -f "${WORKDIR}/calls" ] } +# The greeting only runs on a terminal, so tests that exercise the greeting +# guards run the profile under script(1), which gives it a pty. +run_tty() { + run script -qec "$1" /dev/null +} + @test "legacy no-show-user-motd marker migrates to uwelcome/disabled" { stub_id 1000 touch "${HOME}/.config/no-show-user-motd" @@ -86,7 +92,7 @@ not_called() { stub_id 1000 unset UWELCOME_SHOWN - run bash "$UWELCOME_PROFILE" + run_tty "bash '$UWELCOME_PROFILE'" [ "$status" -eq 0 ] called @@ -96,7 +102,7 @@ not_called() { @test "uwelcome is skipped for root" { stub_id 0 - run bash "$UWELCOME_PROFILE" + run_tty "bash '$UWELCOME_PROFILE'" [ "$status" -eq 0 ] not_called @@ -106,7 +112,7 @@ not_called() { stub_id 1000 export UWELCOME_SHOWN=1 - run bash "$UWELCOME_PROFILE" + run_tty "bash '$UWELCOME_PROFILE'" [ "$status" -eq 0 ] not_called @@ -117,7 +123,7 @@ not_called() { unset UWELCOME_SHOWN # Source the profile, then start a child shell that sources it again. - run bash -c '. "$1"; bash "$1"' _ "$UWELCOME_PROFILE" + run_tty "bash -c '. \"$UWELCOME_PROFILE\"; bash \"$UWELCOME_PROFILE\"'" [ "$status" -eq 0 ] [ "$(wc -l < "${WORKDIR}/calls")" -eq 1 ] @@ -138,8 +144,18 @@ not_called() { stub_id 1000 export UWELCOME_SHOWN="" - run bash "$UWELCOME_PROFILE" + run_tty "bash '$UWELCOME_PROFILE'" [ "$status" -eq 0 ] called } + +@test "uwelcome is skipped without a terminal (GDM's login shell)" { + stub_id 1000 + unset UWELCOME_SHOWN + + run bash "$UWELCOME_PROFILE" < /dev/null > /dev/null + + [ "$status" -eq 0 ] + not_called +} From d7fa364441e86dbaec4c636f6eeb6912f9357d90 Mon Sep 17 00:00:00 2001 From: castrojo <1264109+castrojo@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:38:13 -0500 Subject: [PATCH 2/2] test(motd): run uwelcome.sh tests under pty for tty guard - Run uwelcome.sh tests under script -qec so tests run with a pty - Answers reviewer findings on PR #1690 Refs #1688 Assisted-by: github-copilot/gemini-3.8-flash via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/test_motd_integration.bats | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_motd_integration.bats b/tests/test_motd_integration.bats index d3d0fee64..5e355e751 100644 --- a/tests/test_motd_integration.bats +++ b/tests/test_motd_integration.bats @@ -48,14 +48,14 @@ teardown() { # --------------------------------------------------------------------------- @test "uwelcome.sh: invokes uwelcome" { - run bash "${UWELCOME_PROFILE}" + run script -qec "bash '${UWELCOME_PROFILE}'" /dev/null [ "${status}" -eq 0 ] [ -f "${WORKDIR}/uwelcome.log" ] } @test "uwelcome.sh: migrates legacy opt-out and still runs uwelcome" { touch "${HOME}/.config/no-show-user-motd" - run bash "${UWELCOME_PROFILE}" + run script -qec "bash '${UWELCOME_PROFILE}'" /dev/null [ "${status}" -eq 0 ] # Legacy marker is consumed, not left behind to retry every login [ ! -e "${HOME}/.config/no-show-user-motd" ] @@ -75,7 +75,7 @@ teardown() { } @test "uwelcome.sh: is a no-op migration when no legacy marker exists" { - run bash "${UWELCOME_PROFILE}" + run script -qec "bash '${UWELCOME_PROFILE}'" /dev/null [ "${status}" -eq 0 ] [ ! -e "${HOME}/.config/uwelcome/disabled" ] [ -f "${WORKDIR}/uwelcome.log" ] @@ -106,7 +106,7 @@ teardown() { @test "uwelcome.sh: skips invocation if UWELCOME_SHOWN is set" { export UWELCOME_SHOWN=1 - run bash "${UWELCOME_PROFILE}" + run script -qec "bash '${UWELCOME_PROFILE}'" /dev/null [ "${status}" -eq 0 ] [ ! -f "${WORKDIR}/uwelcome.log" ] }