machined: improve error message when "machinectl login" is used on a container without dbus inside · Issue #685 · systemd/systemd

Filing it here as this does not look to have been fixed. The same bug is also filed on Debian at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=792882

Package: systemd
Version: 222-2
Severity: important
File: /bin/machinectl
Tags: patch

I am evaluating moving from LXC to systemd-nspawn. During the course, I've run into the following problem, which is known upstream, and claimed to be fixed.

My hope was that the fix was part of the 222 release, but I guess that is not the case.

The fix: f227310

The problem:

chutzpah:~# machinectl list
MACHINE CLASS SERVICE
deb-template container nspawn

1 machines listed.

chutzpah:~# machinectl login deb-template
Failed to get machine PTY: Input/output error

chutzpah:#
chutzpah:
# machinectl list
MACHINE CLASS SERVICE
deb-template container nspawn

1 machines listed.

chutzpah:~# machinectl list-images
NAME TYPE RO USAGE CREATED MODIFIED
ceph directory no n/a n/a n/a
deb-template directory no n/a n/a n/a
jenkins directory no n/a n/a n/a
trusty-template directory no n/a n/a n/a
ubuntu directory no n/a n/a n/a

5 images listed.

chutzpah:# man systemd-nspawn
chutzpah:
# machinectl login deb-template
Failed to get machine PTY: Input/output error

-- Package-specific info:

-- System Information:
Debian Release: stretch/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (100, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.1.2+ (SMP w/4 CPU cores)
Locale: LANG=en_IN, LC_CTYPE=en_IN (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages systemd depends on:
ii adduser 3.113+nmu3
ii libacl1 2.2.52-2
ii libapparmor1 2.9.2-3
ii libaudit1 1:2.4.2-1
ii libblkid1 2.26.2-6
ii libc6 2.19-18
ii libcap2 1:2.24-9
ii libcap2-bin 1:2.24-9
ii libcryptsetup4 2:1.6.6-5
ii libgcrypt20 1.6.3-2
ii libkmod2 20-1
ii liblzma5 5.1.1alpha+20120614-2.1
ii libmount1 2.26.2-6
ii libpam0g 1.1.8-3.1
ii libseccomp2 2.2.1-2
ii libselinux1 2.3-2+b1
ii libsystemd0 222-2
ii mount 2.26.2-6
ii sysv-rc 2.88dsf-59.2
ii udev 221-1+deb9u2
ii util-linux 2.26.2-6

Versions of packages systemd recommends:
ii dbus 1.8.18-1
ii libpam-systemd 222-2

Versions of packages systemd suggests:
pn systemd-ui

-- Configuration Files:
/etc/systemd/logind.conf changed:
[Login]
HandleLidSwitch=ignore
LidSwitchIgnoreInhibited=yes

-- no debconf information