fix(motd): guard against double display on GNOME OS / freedesktop-sdk base#283
fix(motd): guard against double display on GNOME OS / freedesktop-sdk base#283castrojo wants to merge 1 commit intoprojectbluefin:mainfrom
Conversation
… base On freedesktop-sdk based images (like dakota), /etc/bashrc unconditionally sources /etc/profile.d/*.sh — unlike Fedora's /etc/bashrc which guards with 'shopt -q login_shell'. This means a Ghostty login shell fires ublue-motd.sh twice: /etc/profile -> profile.d -> MOTD projectbluefin#1 ~/.profile -> ~/.bashrc -> /etc/bashrc -> profile.d -> MOTD projectbluefin#2 Add UBLUE_MOTD_SHOWN guard, identical to the existing BLING_SOURCED pattern in bling.sh, to make the script idempotent. Fixes: projectbluefin/dakota#200 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: Claude Sonnet 4.6 via GitHub Copilot
There was a problem hiding this comment.
Code Review
This pull request introduces a guard against double-sourcing in the ublue-motd.sh script to prevent the message of the day from being displayed multiple times during shell initialization. A review comment correctly identifies that exporting the guard variable could lead to the MOTD being suppressed in subshells or nested login sessions, and suggests using a local shell variable instead.
| # profile.d on GNOME OS / freedesktop-sdk based images (unlike Fedora which | ||
| # guards /etc/bashrc with shopt -q login_shell). Same pattern as BLING_SOURCED. | ||
| [ "${UBLUE_MOTD_SHOWN:-0}" -eq 1 ] && return 0 | ||
| export UBLUE_MOTD_SHOWN=1 |
There was a problem hiding this comment.
The use of export for the UBLUE_MOTD_SHOWN variable will cause the MOTD to be suppressed in all subshells (including nested login shells) because the variable is inherited by child processes. Furthermore, if the desktop environment sources profile.d during session startup, this variable could be exported to the entire graphical session, preventing the MOTD from appearing in any terminal. Since the issue involves double-sourcing within the same shell process initialization, a local shell variable is sufficient and avoids these side effects. This also aligns with the BLING_SOURCED pattern mentioned in the PR description, which does not use export.
| export UBLUE_MOTD_SHOWN=1 | |
| UBLUE_MOTD_SHOWN=1 |
Problem
On GNOME OS / freedesktop-sdk based images (e.g. dakota), the MOTD fires twice in every interactive login shell session (e.g. Ghostty).
Root cause: freedesktop-sdk's
/etc/bashrcunconditionally sources/etc/profile.d/*.sh, while Fedora's/etc/bashrchas ashopt -q login_shellguard that prevents this. This creates a double-source chain:/etc/profile→ profile.d → ublue-motd.sh (MOTD Add common system files from bluefin #1)~/.profile→~/.bashrc→/etc/bashrc→ profile.d → ublue-motd.sh (MOTD Add container build workflow #2)Production Bluefin (Fedora-based) is unaffected because Fedora's bashrc has the guard. Only freedesktop-sdk based images are affected.
Fix
Add an
UBLUE_MOTD_SHOWN=1guard at the top ofublue-motd.sh— identical pattern toBLING_SOURCED=1already used inbling.shin this repo.Testing
Validated on physical hardware (NUC running dakota):
Upstream issue: projectbluefin/dakota #200
Note: The proper root-cause fix is to patch freedesktop-sdk's
/etc/bashrcto add theshopt -q login_shellguard (via dakota's patch_queue). This guard is a defensive fix that also protects against any other future double-source scenarios.