Apply Ubuntu phasing in the agent's sandbox
apt skips phasing in chroots, which it detects by running `ischroot -t`. ischroot compares / with /proc/1/root; the agent's DynamicUser can't read /proc/1/root, so ischroot answers "chroot" (-t = assume yes when unsure) and apt offered every phased update. On a real 26.04 host, 4 updates apt deferred as root were reported as installable, with 0 phased. Pass -o Dir::Bin::ischroot=/bin/false so apt applies phasing from /etc/machine-id exactly as it does for root. Agent 0.3.1, server 0.3.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a8c51ec84
commit
73b4a164e4
3 files changed
+20
-3
No files matched your search
@@ -6,7 +6,7 @@
|
||||
# rules can change without redeploying agents.
|
||||
set -euo pipefail
|
||||
|
||||
AGENT_VERSION=0.3.0
|
||||
AGENT_VERSION=0.3.1
|
||||
|
||||
# Prefix for every file the agent reads. Only the test suite sets this.
|
||||
ROOT=${KERNELWATCH_ROOT:-}
|
||||
@@ -154,8 +154,14 @@ read_needrestart() {
|
||||
# Simulated dist-upgrade. Reads only: no locks, no cache files written.
|
||||
# dist-upgrade (not upgrade) so new-ABI kernel packages pulled in by the
|
||||
# meta-package show up. C locale because we parse apt's messages.
|
||||
#
|
||||
# apt skips phasing in chroots, detected with `ischroot -t`, which compares /
|
||||
# with /proc/1/root. Unprivileged we can't read /proc/1/root, so ischroot
|
||||
# answers "chroot" and apt would offer every phased update. We're not in one:
|
||||
# say so, and apt applies phasing from /etc/machine-id like it does for root.
|
||||
apt_simulation() {
|
||||
LC_ALL=C apt-get -s -q \
|
||||
-o Dir::Bin::ischroot=/bin/false \
|
||||
-o Debug::NoLocking=true \
|
||||
-o Dir::Cache::pkgcache= \
|
||||
-o Dir::Cache::srcpkgcache= \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""kernelwatch: fleet kernel and reboot status dashboard."""
|
||||
|
||||
__version__ = "0.3.1"
|
||||
__version__ = "0.3.2"
|
||||
|
||||
# Version of agent/kernelwatch-agent shipped alongside this server; older agents
|
||||
# are noted on the dashboard. tests/test_status.py checks the two stay in sync.
|
||||
AGENT_VERSION = "0.3.0"
|
||||
AGENT_VERSION = "0.3.1"
|
||||
@@ -198,6 +198,17 @@ X
|
||||
["libnss-systemd", "libpam-systemd", "libsystemd-shared", "libsystemd0", "libudev1",
|
||||
"systemd", "systemd-resolved", "udev"]))
|
||||
|
||||
def test_apt_told_it_is_not_in_a_chroot(self):
|
||||
# Otherwise unprivileged apt thinks it's in a chroot and ignores phasing
|
||||
# (seen on a real 26.04 host: 4 phased updates counted as installable).
|
||||
stub(self.bin, "apt-get", 'case "$*" in *Dir::Bin::ischroot=/bin/false*) ;; *) exit 1;; esac\n'
|
||||
'echo "The following upgrades have been deferred due to phasing:"\n'
|
||||
'echo " snapd open-vm-tools"\n'
|
||||
'echo "0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded."\n')
|
||||
r = self.report()
|
||||
self.assertEqual(r["phased_packages"], ["open-vm-tools", "snapd"])
|
||||
self.assertEqual(r["upgradable_count"], 0)
|
||||
|
||||
def test_apt_runs_in_c_locale(self):
|
||||
stub(self.bin, "apt-get", 'echo "Inst locale-$LC_ALL [1] (2 x [amd64])"\n')
|
||||
self.assertEqual(self.report()["upgradable_count"], 1)
|
||||
|
||||
Reference in new issue
Block a user