Bug#1004339: /usr/bin/systemctl: `systemctl start --user --wait` fails with "Failed to connect to bus: No such file or directory"

Adam Dinwoodie debian-reportbug at post.dinwoodie.org
Tue Jan 25 12:13:39 GMT 2022


Package: systemd
Version: 250.3-1
Severity: normal
File: /usr/bin/systemctl

Dear Maintainer,

According to the systemctl.1 man page, it should be possible to specify
`--wait` to systemctl commands that will start units, to have the
systemctl command block until the units terminate again.  This seems to
work as expected for system units, but not for user units.

The attached short script provides a simple test case: given appropriate
ssh configuration, when run with `sudo bash test.sh` it will create a
new user called "test" with a simple example service template unit, then
log in through using ssh to start that unit twice, once without
`--wait`, and once with.  Expected behaviour is for this script to
start both unit instances, with the second one sleeping before the
script finishes.  Actual behaviour is that the first unit starts as
expected, but the second unit is never started, and the attempt gives a
return code of 1 and the following error printed to the terminal:

    Failed to connect to bus: No such file or directory

As I say, the `--wait` function works as expected for system units; it's
only with user units that it seems to fail.

Kind regards,

Adam

-- Package-specific info:

-- System Information:
Debian Release: 11.2
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-10-cloud-amd64 (SMP w/2 CPU threads)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd depends on:
ii  adduser          3.118
ii  libacl1          2.2.53-10
ii  libapparmor1     2.13.6-10
ii  libaudit1        1:3.0-2
ii  libblkid1        2.36.1-8
ii  libc6            2.33-3
ii  libcap2          1:2.44-1
ii  libcrypt1        1:4.4.18-4
ii  libcryptsetup12  2:2.4.3-1
ii  libfdisk1        2.36.1-8
ii  libgcrypt20      1.9.4-5
ii  libgnutls30      3.7.2-5
ii  libgpg-error0    1.38-2
ii  libip4tc2        1.8.7-1
ii  libkmod2         28-1
ii  liblz4-1         1.9.3-2
ii  liblzma5         5.2.5-2
ii  libmount1        2.36.1-8
ii  libpam0g         1.4.0-9+deb11u1
ii  libseccomp2      2.5.1-1+deb11u1
ii  libselinux1      3.1-3
ii  libsystemd0      250.3-1
ii  libzstd1         1.4.8+dfsg-2.1
ii  mount            2.36.1-8
ii  util-linux       2.36.1-8

Versions of packages systemd recommends:
ii  dbus [default-dbus-system-bus]   1.12.20-2
ii  systemd-timesyncd [time-daemon]  250.3-1

Versions of packages systemd suggests:
ii  libfido2-1            1.6.0-2
pn  libtss2-esys-3.0.2-0  <none>
pn  libtss2-mu0           <none>
pn  libtss2-rc0           <none>
pn  policykit-1           <none>
pn  systemd-container     <none>

Versions of packages systemd is related to:
pn  dracut           <none>
ii  initramfs-tools  0.140
pn  libnss-systemd   <none>
ii  libpam-systemd   250.3-1
ii  udev             247.3-6

-- no debconf information
-------------- next part --------------
set -eu
useradd test
mkdir -p ~test/.config/systemd/user
cat <<'EOF' >~test/.config/systemd/user/sleep at .service
[Service]
ExecStart=sleep %I
EOF
mkdir -p ~test/.ssh
cp ~/.ssh/id_rsa.pub ~test/.ssh/authorized_keys
chown -R test:test ~test
ssh test at localhost 'systemctl --user start sleep at 5.service'
ssh test at localhost 'systemctl --user status sleep at 5.service'
ssh test at localhost 'systemctl --user start --wait sleep at 6.service' || echo "Error: rc=$?"
ssh test at localhost 'systemctl --user status sleep at 6.service'


More information about the Pkg-systemd-maintainers mailing list