groovy debootstrap leaves /e/d/motd-news.wasremoved around
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
base-files (Ubuntu) |
Fix Released
|
High
|
Andreas Hasenack | ||
Xenial |
Confirmed
|
Undecided
|
Unassigned | ||
Bionic |
Confirmed
|
Undecided
|
Unassigned | ||
Focal |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
[Impact]
A fresh install of base-files, like done when using debootstrap, using the base-files from the -updates repository (in the case of ubuntu stable releases), will leave an empty /etc/default/
Another case where /etc/default/
The consequence of having /etc/default/
This was the case of the groovy debootstrap which resulted in this bug being filed. While debootstrap won't mix multiple repositories (like release with updates), and thus this isn't easily a problem in released versions of ubuntu, the groovy case was the one that was doing a fresh install of base-files with the buggy touch /etc/default/
These are the scenarios I was able to come up with in which a stable release could be affected by this bug:
a) debootstrap with release and updates pocket enabled
There are no config options that I'm aware of that would tell debootstrap to use multiple pockets when creating a chroot, but let's say it was done by hacking the script or something else. It would then be the same case as groovy until this fix: subsequent installations of ubuntu-server or motd-news-config would default to having motd-news disabled
b) A system that has just base-files from the previous SRU installed, and no ubuntu-server and no motd-news-config. If base-files were updated again and without the fix presented here (let's say, another SRU instead of this one), it would create /etc/default/
c) Any other case where the postinst script of base-files is run again without the fix presented here, and when there is no /etc/default/
To avoid creating /etc/default/
- motd-news-config postinst: always remove the .wasremoved file in configure if found, regardless if /etc/default/
- base-files postinst: guard the creation of .wasremoved with:
- Only during an upgrade
- Only if ubuntu-server is installed (via a dpkg -l check)
[Test Case]
* On the system under test, remove motd-news-config and ubuntu-server if they are installed, and keep base-files from the update pocket. Something like this:
sudo apt update && sudo apt dist-upgrade -y
sudo apt purge motd-news-config ubuntu-server
apt-cache policy base-files <-- to verify it's from updates
* In this scenario, you should have no /etc/default/motd* files:
$ ll /etc/default/motd*
ls: cannot access '/etc/default/
* reinstall base-files:
sudo apt install --reinstall base-files
* Before this SRU, this would create /etc/default/
$ ll /etc/default/motd*
-rw-r--r-- 1 root root 0 Sep 16 20:24 /etc/default/
With the package from proposed for this SRU installed, no such file is created:
$ ll /etc/default/motd*
ls: cannot access '/etc/default/
[Regression Potential]
This SRU is further changing maintainer scripts, to address an issue in the previous maintainer script. Should there be new regressions or new issues, it might get harder and harder to fix them.
I did wonder about the `dpkg -l` call in base-files' postinst. I worried about locks, or pre-dependencies, but dpkg was already being used in this script, although not with -l (list), just a version comparison. But at least it's already installed.
My other worry was with the dpkg -l output and which flags I should check to determine if ubuntu-server was installed. "^ii" doesn't work, because ubuntu-server might be being upgraded in the same apt transaction, but ^i seemed good enough. Furthermore, I changed the check for a package name that doesn't exist, to see if dpkg -l would complain and fail the whole script (which runs with set -e), but it was ok and just behaved as if the package wasn't installed, which is what we need.
[Other Info]
The previous SRU at https:/
Manually, I used debootstrap with --make-tarball, replace the base-files deb, and --unpack-tarball, to simulate debootstrap with an updated base-files, to confirm this change here would fix the debootstrap problem, and it worked. But I deemed it too complicated to describe as a testcase for this SRU. If you, dear SRU reviewer, would prefer this test to be added, please let me know.
If a user of a stable release already has an unintended /etc/default/
[Original Description]
When debootstrapping groovy, we see an empty /etc/default/
- groovy: base-files 11ubuntu12
-rw-r--r-- 1 root root 0 set 11 10:20 /etc/default/
If motd-news-config is later installed, maybe via ubuntu-server, then the presence of this file will disable motd-news by default, which is unintended as it's meant to be enabled on a server.
Related branches
- Bryce Harrington (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 64 lines (+25/-7)3 files modifieddebian/changelog (+14/-0)
debian/motd-news-config.postinst (+1/-1)
debian/postinst.in (+10/-6)
- Bryce Harrington (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 64 lines (+25/-7)3 files modifieddebian/changelog (+14/-0)
debian/motd-news-config.postinst (+1/-1)
debian/postinst.in (+10/-6)
- Bryce Harrington (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 64 lines (+25/-7)3 files modifieddebian/changelog (+14/-0)
debian/motd-news-config.postinst (+1/-1)
debian/postinst.in (+10/-6)
- Canonical Server: Pending requested
- Christian Ehrhardt : Pending requested
-
Diff: 64 lines (+25/-7)3 files modifieddebian/changelog (+14/-0)
debian/motd-news-config.postinst (+1/-1)
debian/postinst.in (+10/-6)
description: | updated |
Changed in base-files (Ubuntu Focal): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
status: | New → In Progress |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in base-files (Ubuntu Xenial): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in base-files (Ubuntu Bionic): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in base-files (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in base-files (Ubuntu Bionic): | |
status: | New → In Progress |
description: | updated |
description: | updated |
I think this postinst bit never considered the fresh install case:
# special case of having /etc/default/ motd-news removed by hand config= "/etc/default/ motd-news" news_config} .dpkg-remove ]; then news_config} .dpkg-backup ]; then news_config} .wasremoved
# signal the motd-news-config package that this happened, so that
# it does not put back the file with default contents which would
# re-enable motd-news
motd_news_
if [ ! -e ${motd_news_config} ]; then
if [ ! -e ${motd_
if [ ! -e ${motd_
touch ${motd_
fi
fi
fi
Having it only act on upgrades might be the easier fix. I'll test.