Public bug reported:

Binary package hint: libpam-modules

** Problem:
pam_motd module creates the file /var/run/motd.new but doesn't rename it into 
/var/run/motd.
The /etc/motd symlink points to /var/run/motd and at each user login are shown 
old informations.

** Repeatable:
Yes, always

** How to repeat:
You need to force "run-parts /etc/update-motd.d" to exit with errors.
To complete this task just add in the update-motd.d chain a script that exits 
with error or a symlink to a script that doesn't exist.


** Explanation:
I discover this issue while upgrading from lucid to maverik (server edition).
For some reason, the package update-notifier-common was removed and I was full 
of broken symlinks in the update-motd.d chain.
At each ssh login I was presented with stale informations.

Looking into the pam_motd.c code I found the problem.
The module performs a system("run-parts /etc/update-motd.d > 
/var/run/motd.new") call, that returns a non-zero value if run-parts exits with 
errors.
If the system() call returns a non-zero value, the following rename() call is 
not executed.
The file /var/run/motd.new is *always* created and written to disk with the 
output of the working scripts.
We are in the situation where the /var/run/motd.new is updated but never 
renamed into /var/run/motd, if some scripts have bugs or exit with errors.

I have attached a patch that should solve this problem.
The rename() call is not blocked by the system() call and moreover if run-parts 
exits with a non-zero value, pam_syslog is used to log the error and help 
sysadmins to find rapidly the problem.
Within the patch, the rename() call is always executed, even if run-parts fails 
totally and /var/run/motd.new is not created.
In this case, the rename() call doesn't perform the renaming and returns a 
non-zero value (but we are not interested in it).

Thanks,
Yusef

** Affects: pam (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: motd pam run-parts ssh update-motd.d

-- 
pam_motd doesn't rename /var/run/motd.new if run-parts exits with errors
https://bugs.launchpad.net/bugs/661654
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to