[systemd-devel] systemd-nspawn: starting multiple shells

Nikolaus Rath Nikolaus at rath.org
Fri Jun 29 20:24:10 UTC 2018


On Jun 25 2018, Lennart Poettering <lennart at poettering.net> wrote:
> On Sa, 23.06.18 21:57, Nikolaus Rath (Nikolaus at rath.org) wrote:
>
>> On Jun 23 2018, Nikolaus Rath <Nikolaus at rath.org> wrote:
>> > On Jun 23 2018, aleivag <aleivag at gmail.com> wrote:
>> >> short answer, yes, `machinectl login` is only suppported for systemd-init ,
>> >> and `machinectl shell` `systemd-run` will try to talk to the container via
>> >> dbus, so i dont think you are force to have systemd runing inside the
>> >> container (i may be wrong) but you do need to have dbus (and its easy to
>> >> just have systemd).  if you dont need it, you can always use nsenter to
>> >> access a namespace on your machine
>> >
>> > Still not working:
>> [..]
>> > $ sudo machinectl shell root at iofabric
>> > [sudo] password for nikratio: 
>> > Failed to get shell PTY: Cannot set property
>> > StandardInputFileDescriptor, or unknown property.
>> 
>> So this seems to be caused by systemd in the container being too old,
>> and is therefore not available here.
>> 
>> The 'nsenter' approach seems to work so far, but I don't see a generally
>> applicable way to figure out the right PID. Is there a trick for
>> that?
>
> machinectl show --value $MACHINE -p Leader

Still not quite working, now there seems to be a problem with
/proc/self/fd in the new shell:

$ sudo systemd-nspawn -M $MACHINE \
     --private-users=1379532800:65536 --private-network \
     --as-pid2

# Other terminal

$ pid=$(machinectl show --value $MACHINE -p Leader 2> /dev/null)
$ sudo nsenter -t ${pid} --mount --uts --ipc --net --pid --cgroup --user
[root at iofabric /]# echo $UID
0
[root at iofabric /]# echo 1 > /dev/stderr 
-bash: /dev/stderr: Permission denied
[root at iofabric /]# ll /dev/stderr
lrwxrwxrwx 1 root root 15 Jun 29 21:13 /dev/stderr -> /proc/self/fd/2
[root at iofabric /]# ll /proc/self/fd/2
lrwx------ 1 root root 64 Jun 29 21:22 /proc/self/fd/2 -> /dev/pts/0
[root at iofabric /]# ll /dev/pts/
total 0
crw-rw-rw- 1 root root 5, 2 Jun 29 21:13 ptmx
[root at iofabric /]# 


What's happening here?


Best,
-Nikolaus

-- 
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the systemd-devel mailing list