snapd 2.59 behaves different regarding sysemctl

Bug #2003955 reported by Michael Vogt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
New
Undecided
Unassigned

Bug Description

The CERT team reported the following issue. The "systemctl" binary for devmode snaps reports different statues when running on pre-2.59 snapd and post 2.59 snapd. The culprit is probably https://github.com/snapcore/snapd/pull/11367

They report the following https://pastebin.canonical.com/p/4kMPxDXyPH/

So under 2.59 systemctl seems to think it's running inside a chroot when run from a snap shell.

The slightly annoying part is that I cannot reproduce this with my regular 22.10 machine.

For me even with snapd/edge (2.59) it does not error:
"""
$ snap version
snap 2.58.1+git422.g0766efa
snapd 2.58.1+git422.g0766efa
series 16
ubuntu 22.10
kernel 5.19.0-29-generic
$ sudo snap install checkbox22
...
$ sudo snap install --classic checkbox
...
$ sudo checkbox.shell
[sudo] password for egon:
checkbox runtime shell, type 'exit' to quit the session
# systemctl is-active checkbox-ng.service
inactive
# echo $?
3
"""

Revision history for this message
Michael Vogt (mvo) wrote :

Fwiw, systemd defines:
"""
int running_in_chroot(void) {
        int r;

        if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0)
                return 0;

        r = files_same("/proc/1/root", "/", 0);
        if (r < 0)
                return r;

        return r == 0;
}
"""
and with https://github.com/snapcore/snapd/pull/11367 setting up a scratch dir for "/" this seems to be the culprit.

description: updated
Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote :

Hi Michael, which is the status of this one? is that already fixed?

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.