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

2022-01-25 Thread Adam Dinwoodie
On Tue, Jan 25, 2022 at 06:04:37PM +0100, Michael Biebl wrote:
> 
> Control: tags -1 + moreinfo unreproducible
> 
> Am 25.01.22 um 13:13 schrieb Adam Dinwoodie:
> 
> > 
> >  Failed to connect to bus: No such file or directory
> > 
> 
> Thanks for the reproducer.
> I can't reproduce the issue with the instructions you provided (with v250
> from sid).
> 
> Your problem seems to be related to a missing dbus (user) bus in your ssh
> session and the failing --wait is just a symptom.
> 
> Can you run busctl --user, systemctl --user status dbus.socket dbus.service
> ?
> 
> Is dbus-user-session installed? Is libpam-systemd enabled?

That was it: I'm running a fairly minimal headless system, and didn't
have dbus-user-session installed.  After installing that package, my
reproduction script behaves as expected.

Mea culpa.  Thank you for the help!



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

2022-01-25 Thread Michael Biebl


Control: tags -1 + moreinfo unreproducible

Am 25.01.22 um 13:13 schrieb Adam Dinwoodie:



 Failed to connect to bus: No such file or directory



Thanks for the reproducer.
I can't reproduce the issue with the instructions you provided (with 
v250 from sid).


Your problem seems to be related to a missing dbus (user) bus in your 
ssh session and the failing --wait is just a symptom.


Can you run busctl --user, systemctl --user status dbus.socket 
dbus.service ?


Is dbus-user-session installed? Is libpam-systemd enabled?


OpenPGP_signature
Description: OpenPGP digital signature


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

2022-01-25 Thread Adam Dinwoodie
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  libaudit11:3.0-2
ii  libblkid12.36.1-8
ii  libc62.33-3
ii  libcap2  1:2.44-1
ii  libcrypt11:4.4.18-4
ii  libcryptsetup12  2:2.4.3-1
ii  libfdisk12.36.1-8
ii  libgcrypt20  1.9.4-5
ii  libgnutls30  3.7.2-5
ii  libgpg-error01.38-2
ii  libip4tc21.8.7-1
ii  libkmod2 28-1
ii  liblz4-1 1.9.3-2
ii  liblzma5 5.2.5-2
ii  libmount12.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  mount2.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-11.6.0-2
pn  libtss2-esys-3.0.2-0  
pn  libtss2-mu0   
pn  libtss2-rc0   
pn  policykit-1   
pn  systemd-container 

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

-- no debconf information
set -eu
useradd test
mkdir -p ~test/.config/systemd/user
cat <<'EOF' >~test/.config/systemd/user/sleep@.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@localhost 'systemctl --user start sleep@5.service'
ssh test@localhost 'systemctl --user status sleep@5.service'
ssh test@localhost 'systemctl --user start --wait sleep@6.service' || echo 
"Error: rc=$?"
ssh test@localhost 'systemctl --user status sleep@6.service'