[Bug 1888572] Re: motd-news: use wget instead of curl
Andreas Hasenack
1888572 at bugs.launchpad.net
Tue Aug 25 18:02:37 UTC 2020
Bionic verification
Test (a)
Current base-files, ubuntu-server and curl installed:
ii base-files 10.1ubuntu2.9 amd64 Debian base system miscellaneous files
ii curl 7.58.0-2ubuntu3.10 amd64 command line tool for transferring data with URL syntax
ii ubuntu-server 1.417.4 amd64 The Ubuntu Server system
motd-news runs:
$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
Without curl, it exits immediately:
ubuntu at bionic-motd-news-wget:~$ dpkg -l curl | grep curl
un curl <none> <none> (no description available)
ubuntu at bionic-motd-news-wget:~$ sudo /etc/update-motd.d/50-motd-news --force
ubuntu at bionic-motd-news-wget:~$ echo $?
0
ubuntu at bionic-motd-news-wget:~$
Installing base-files and motd-news-config from bionic-proposed:
ubuntu at bionic-motd-news-wget:~$ apt-cache policy base-files motd-news-config
base-files:
Installed: 10.1ubuntu2.10
Candidate: 10.1ubuntu2.10
Version table:
*** 10.1ubuntu2.10 500
500 http://br.archive.ubuntu.com/ubuntu bionic-proposed/main amd64 Packages
100 /var/lib/dpkg/status
(...)
motd-news-config:
Installed: 10.1ubuntu2.10
Candidate: 10.1ubuntu2.10
Version table:
*** 10.1ubuntu2.10 500
500 http://br.archive.ubuntu.com/ubuntu bionic-proposed/main amd64 Packages
Still no curl:
$ dpkg -l curl | grep curl
un curl <none> <none> (no description available)
motd-news works again:
ubuntu at bionic-motd-news-wget:~$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
ubuntu at bionic-motd-news-wget:~$ echo $?
0
Test (b)
Verify motd-news per cloud remains working.
b1) aws
ubuntu at bionic-motd-news-wget:~$ cloud-id
aws
ubuntu at bionic-motd-news-wget:~$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
ubuntu at bionic-motd-news-wget:~$ sudo sh -x /etc/update-motd.d/50-motd-news --force 2>&1 | grep -wE 'wget .*cloud_id/[a-z]+'
+ wget --timeout 60 -U wget/1.19.4-1ubuntu2.2 Ubuntu/18.04.5/LTS GNU/Linux/5.4.0-42-generic/x86_64 Intel(R)/Core(TM)/i7-7600U/CPU/@/2.80GHz cloud_id/aws -O- --content-on-error https://motd.ubuntu.com
b2) gce
ubuntu at bionic-motd-news-wget:~$ cloud-id
gce
ubuntu at bionic-motd-news-wget:~$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
ubuntu at bionic-motd-news-wget:~$ sudo sh -x /etc/update-motd.d/50-motd-news --force 2>&1 | grep -wE 'wget .*cloud_id/[a-z]+'
+ wget --timeout 60 -U wget/1.19.4-1ubuntu2.2 Ubuntu/18.04.5/LTS GNU/Linux/5.4.0-42-generic/x86_64 Intel(R)/Core(TM)/i7-7600U/CPU/@/2.80GHz cloud_id/gce -O- --content-on-error https://motd.ubuntu.com
b3) azure
ubuntu at bionic-motd-news-wget:~$ cloud-id
azure
ubuntu at bionic-motd-news-wget:~$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
ubuntu at bionic-motd-news-wget:~$ sudo sh -x /etc/update-motd.d/50-motd-news --force 2>&1 | grep -wE 'wget .*cloud_id/[a-z]+'
+ wget --timeout 60 -U wget/1.19.4-1ubuntu2.2 Ubuntu/18.04.5/LTS GNU/Linux/5.4.0-42-generic/x86_64 Intel(R)/Core(TM)/i7-7600U/CPU/@/2.80GHz cloud_id/azure -O- --content-on-error https://motd.ubuntu.com
Bionic verification succeeded.
** Tags removed: verification-needed-bionic verification-needed-focal
** Tags added: verification-done-bionic verification-done-focal
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to base-files in Ubuntu.
https://bugs.launchpad.net/bugs/1888572
Title:
motd-news: use wget instead of curl
Status in base-files package in Ubuntu:
Fix Released
Status in base-files source package in Xenial:
Fix Committed
Status in base-files source package in Bionic:
Fix Committed
Status in base-files source package in Focal:
Fix Committed
Bug description:
[Impact]
The motd-news script is using curl, but since that is an optional package, there is no guarantee that it will be installed. The script correctly checks for its presence before trying to use it, though, so it won't fail. As we don't want to add such a dependency to the base-files package, we should switch to wget, which is standard.
[Test Case]
wget has a different behavior than curl in some areas, one of which is crucial for the motd-per-cloud feature. While curl will only complain about a 404 from the server if given a specific parameter (-f), wget does that by default, and needs special handling.
a) With curl, base-files and ubuntu-server installed, first verify motd-news works:
$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
Now remove curl, and retry. It should exit immediately with no output:
$ sudo /etc/update-motd.d/50-motd-news --force
Install the updated base-files package and the new motd-news-config
package from proposed:
$ sudo apt install base-files motd-news-config
Note curl is still not available:
$ curl
Command 'curl' not found, but can be installed with:
sudo apt install curl
Re-run the motd-news script, this time it should produce output again:
$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
b) Verify motd-news per cloud remains working.
If you have /usr/bin/cloud-id, copy it to a backup:
sudo cp /usr/bin/cloud-id{,.orig}
Create a new one, per supported cloud. For aws, for example:
echo -e '#!/bin/sh\necho aws' | sudo tee /usr/bin/cloud-id
Confirm by running it:
$ cloud-id
aws
And confirm motd-news keeps working (it might return different content):
$ sudo /etc/update-motd.d/50-motd-news --force
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
Repeat for the gce and azure clouds, by changing the cloud-id script
accordingly.
To confirm the right cloud_id is being used, use sh -x and grep for
its output:
$ sudo sh -x /etc/update-motd.d/50-motd-news --force 2>&1 | grep -wE 'wget .*cloud_id/[a-z]+'
+ wget --timeout 60 -U wget/1.20.3-1ubuntu1 Ubuntu/20.04.1/LTS GNU/Linux/5.4.0-42-generic/x86_64 Intel(R)/Core(TM)/i7-7600U/CPU/@/2.80GHz cloud_id/azure -O- --content-on-error https://motd.ubuntu.com
This also verifies again it's using wget instead of curl.
[Regression Potential]
Possible regressions will likely be tied to a difference in behavior between curl and wget. In fact, one was caught[1] in the development release and the fix is included here, with a test.
[Other Info]
N/A
1. https://bugs.launchpad.net/bugs/1889117
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/base-files/+bug/1888572/+subscriptions
More information about the foundations-bugs
mailing list