motd symlink from initscripts gets moved on base-files upgrade

Bug #214853 reported by Adam Conrad
2
Affects Status Importance Assigned to Milestone
base-files (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: base-files

On the machines we've upgraded in the Canonical DC, we have the following curious situation:

adconrad@mcmurdo:~$ ls -l /etc/motd*
-rw-r--r-- 1 root root 417 2008-04-09 23:22 /etc/motd
lrwxrwxrwx 1 root root 13 2008-04-03 19:37 /etc/motd.old -> /var/run/motd
-rw-r--r-- 1 root root 266 2008-04-03 19:37 /etc/motd.tail

This seems to be the result of the following code in base-files's postinst:

  if [ -f /etc/motd ]; then
    oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
    newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
    if [ "$oldmd" != "$newmd" ]; then
      if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
        awk 'NR <= 2' /etc/motd > /etc/motd.new
        awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
        mv /etc/motd /etc/motd.old
        mv /etc/motd.new /etc/motd
      fi
    fi
  fi

If the test was changed from "if [ -f /etc/motd ]; then" to "if [ -f /etc/motd ] && [ ! -L /etc/motd ]; then", this postinst would stop mangling symlinks and should coexist well with the New World Order. (For bonus points, adding a bit of transitional code to fix the broken situation wouldn't hurt... if motd.old is a link and motd isn't, and ugrading from << version_with_fix, assume you broke it..)

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :

This patch looks correct to me, but it fails to fix the previous upgrade breakage. Work in progress.

Revision history for this message
Steve Langasek (vorlon) wrote :

whereas this patch actually works.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package base-files - 4.0.1ubuntu4

---------------
base-files (4.0.1ubuntu4) hardy; urgency=low

  * Update the motd upgrade handling to know about /etc/motd.tail, which
    is where the static contents of the motd are stored now with
    initscripts 2.86.ds1-7 and above; and handle fixing the broken
    upgrades introduced in 4.0.1ubuntu3. LP: #214853

 -- Steve Langasek <email address hidden> Thu, 10 Apr 2008 00:02:43 +0000

Changed in base-files:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.