Public bug reported: ## Environment
Source package: `pam` Binary package: `libpam-modules` (amd64) ```text $ lsb_release -rd Description: Ubuntu 24.04.5 LTS Release: 24.04 $ apt-cache policy libpam-modules libpam-modules: Installed: 1.5.3-5ubuntu5.7 Candidate: 1.5.3-5ubuntu5.7 ``` ## Steps to reproduce 1. Open a fresh interactive SSH connection to an affected Ubuntu system with `UsePAM yes` and `pam_motd.so` enabled in `/etc/pam.d/sshd`. I used `ssh -o ControlPath=none user@host` to avoid reusing an existing connection. 2. Confirm that the Ubuntu MOTD is displayed before the shell prompt. 3. In the login Bash shell, inspect the environment it received at startup: ```sh tr '\0' '\n' < /proc/$$/environ | grep '^MOTD_SHOWN=' ``` ## Expected result The command prints `MOTD_SHOWN=pam`. The `pam_motd(8)` manual documents that the module sets this variable after displaying the MOTD. ## Actual result The MOTD was displayed, but the command produced no output. I also verified this directly in a separate PAM session: `pam_motd.so noupdate` displayed a supplied test message, `pam_open_session()` succeeded, and `pam_getenv(pamh, "MOTD_SHOWN")` on the same handle immediately returned `NULL`. ## Cause In `pam_sm_open_session()`, `try_to_display()` returns `PAM_SUCCESS` after displaying the MOTD. Ubuntu’s `debian/patches/pam_motd-legal- notice` then overwrites that result with `retval = display_legal(pamh)`. The normal return value of `display_legal()` is `PAM_IGNORE`, so the later `retval == PAM_SUCCESS` check cannot reach `pam_putenv(pamh, "MOTD_SHOWN=pam")`. The intended behavior was previously tracked in [LP #1855092](https://bugs.launchpad.net/ubuntu/+source/pam/+bug/1855092). The same assignment is present in the Ubuntu 1.7.0-8ubuntu1 source package. I have verified the runtime symptom on Noble only. ## User-visible impact Ubuntu’s `/etc/profile.d/update-motd.sh` checks `MOTD_SHOWN` to determine whether PAM has already displayed the message. On the affected WSL installation, a root login shell can consequently run `update-motd` again and write `/run/motd`. I observed a subsequent SSH login display two announcements: the current system information from November 27, followed by a stale copy from November 25. ## Suggested fix Preserve the result of `try_to_display()` across the legal-notice check and propagate genuine errors from either operation. After a successful display, the module should set `MOTD_SHOWN=pam` and retain its normal `PAM_IGNORE` return behavior. ** Affects: pam (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2178205 Title: pam_motd displays the MOTD but leaves MOTD_SHOWN unset on Ubuntu 24.04 To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/pam/+bug/2178205/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
