Permission denied error from show-motd when updates available
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Release Upgrader |
Fix Released
|
Undecided
|
Unassigned | ||
Ubuntu WSL |
Fix Released
|
High
|
Patrick Wu | ||
ubuntu-release-upgrader (Ubuntu) |
Fix Released
|
Medium
|
Brian Murray | ||
Focal |
Fix Released
|
Undecided
|
Brian Murray | ||
Groovy |
Fix Released
|
Medium
|
Brian Murray |
Bug Description
[Impact]
* This impacts focal (20.04 LTS) users on WSL. On WSL version of Ubuntu 20.04, on the first time of the launch in a day, the MOTD will show. This error will show if apt gets update but packages are not upgrade.
[Test Case]
* Install Ubuntu/Ubuntu 20.04 LTS from Microsoft Store and setup a user.
* `sudo apt update` and remove `~/.motd_shown`, quit and terminate the running distribution by `wsl.exe -t <distro>`.
* Restart the distribution, the MOTD will be shown again, and the error should be gone.
[Regression Potential]
* None for now. The file being called in WSL right now is only being used by WSL confirmed by CPC
[Original Bug Report]
motd on demo of 20.04:
Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.19.84-
....
26 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
/usr/lib/
Related branches
- Balint Reczey: Approve
- Patrick Wu (community): Needs Resubmitting
-
Diff: 17 lines (+6/-0)1 file modifieddebian/91-release-upgrade (+6/-0)
Changed in ubuntuwsl: | |
importance: | Undecided → High |
tags: | added: rls-gg-incoming |
Changed in ubuntuwsl: | |
assignee: | nobody → Patrick Wu (callmepk) |
Changed in update-motd: | |
status: | New → In Progress |
Changed in ubuntuwsl: | |
status: | Confirmed → In Progress |
no longer affects: | update-motd (Ubuntu) |
Changed in ubuntu-release-upgrader (Ubuntu): | |
importance: | Undecided → Medium |
Changed in ubuntuwsl: | |
status: | In Progress → Fix Committed |
Changed in ubuntuwsl: | |
status: | Fix Committed → Fix Released |
description: | updated |
affects: | update-motd → ubuntu-release-upgrader |
Changed in ubuntu-release-upgrader: | |
status: | Invalid → Fix Released |
Changed in ubuntu-release-upgrader (Ubuntu Groovy): | |
assignee: | nobody → Brian Murray (brian-murray) |
status: | Confirmed → In Progress |
Changed in ubuntu-release-upgrader (Ubuntu Focal): | |
assignee: | nobody → Brian Murray (brian-murray) |
status: | New → In Progress |
/etc/update- motd.d/ 91-release- upgrade:
#!/bin/sh
# if the current release is under development there won't be a new one ubuntu- release- upgrader/ release- upgrade- motd ]; then ubuntu- release- upgrader/ release- upgrade- motd
if [ "$(lsb_release -sd | cut -d' ' -f4)" = "(development" ]; then
exit 0
fi
if [ -x /usr/lib/
exec /usr/lib/
fi
calls /usr/lib/ ubuntu- release- upgrader/ release- upgrade- motd:
stamp= /var/lib/ ubuntu- release- upgrader/ release- upgrade- available
lastrun= $(stat -c %Y "$stamp") 2>/dev/null || lastrun=0
expiration= $(expr $lastrun + 86400) lib/ubuntu- release- upgrader/ check-new- release -q > "$stamp" & # <--- Line 31 ubuntu- release- upgrader/ check-new- release -q > "$stamp" &
if [ -f "$stamp" ]; then
# Stamp exists, see if it's expired
now=$(date +%s)
if [ $now -ge $expiration ]; then
# Older than 1 day old, so update in the background
/usr/
elif [ -s "$stamp" ]; then
# Less than 1 day old, and non-empty, so display now
cat "$stamp"
echo
fi
elif [ "$(id -u)" = 0 ]; then
# No cache at all, so update in the background
/usr/lib/
fi
on 20.04 wsl:
$stat -c '%A %a %n' /var/lib/ ubuntu- release- upgrader/ ubuntu- release- upgrader/
drwxr-xr-x 755 /var/lib/
$ ls -la /var/lib/ ubuntu- release- upgrader
drwxr-xr-x 2 root root 4096 Nov 8 13:31 .
same on 16.04 wsl
I don't think /var/lib/ ubuntu- release- upgrader/ release- upgrade- available can be created because /var/lib/ ubuntu- release- upgrader/ belongs to root.
This works fine in containers where users are privileged by default but runs into an issue when WSL starts as an unprivileged user.
Users are not going to invoke motd with sudo normally and this error is confusing to inexperienced users so it should be fixed.
/usr/lib/ ubuntu- release- upgrader/ release- upgrade- motd is in ubuntu- release- upgrader- core: https:/ /git.launchpad. net/ubuntu/ +source/ ubuntu- release- upgrader/ tree/debian/ release- upgrade- motd?h= ubuntu/ focal