You are not logged in.

#1 2015-07-18 21:36:27

hwm
Member
From: Iserlohn, Germany
Registered: 2015-02-10
Posts: 21

[SOLVED] systemd-nspawn cannot run terminal

HI! I am using systemd-nspawn containers for some testing purposes. Basically, I am running an Xfce desktop off a btrfs snapshot of my root file system. Everything has worked fine until systemd 220 or 221. Now the setup still works except when I try to start a terminal within the nspawn'ed Xfce window. This gives me a weird error message. I cannot say for certain when this problem first occured because I rarely need terminal windows in this setup.

After some digging, I can rule out Xfce and all the rest of the test setup as the cause. This is the simplest setup that I found reproduces the problem:

# Xephyr -screen 1024x768 -resizeable -keybd ephyr,,,xkbrules=evdev,xkbmodel=pc101,xkblayout=de :7 &
[... Xephyr messages ...]

# btrfs subvolume snapshot / /.nspawn -r
Create a readonly snapshot of '/' in '//.nspawn'

# systemd-nspawn -M xephyr -D /.nspawn --read-only --tmpfs=/var/log --tmpfs=/var/cache --tmpfs=/home --tmpfs=/root --bind-ro=/tmp/.X11-unix --setenv=DISPLAY=:7 --setenv=LANG=$LANG -u hwm xterm
Spawning container xephyr on /.nspawn.
Press ^] three times within 1s to kill container.
Host and machine ids are equal (8d5a2d70cafc4068b8f2332427b11630): refusing to link journals
xterm: Error 18, errno 13: Keine Berechtigung
Reason: spawn: open() failed on ptsname
Container xephyr exited successfully.

# systemd-nspawn -M xephyr -D /.nspawn --read-only --tmpfs=/var/log --tmpfs=/var/cache --tmpfs=/home --tmpfs=/root --bind-ro=/tmp/.X11-unix --setenv=DISPLAY=:7 --setenv=LANG=$LANG xterm
Spawning container xephyr on /.nspawn.
Press ^] three times within 1s to kill container.
Host and machine ids are equal (8d5a2d70cafc4068b8f2332427b11630): refusing to link journals
[... xterm runs in xephyr window just fine ...]
Container xephyr exited successfully.

That is, running an xterm in a Xephyr window from a systemd-nspawn container works as root, but not as a regular user, with the error message spawn: open() failed on ptsname

Now I am at a loss. Any ideas would be greatly appreciated.

Last edited by hwm (2015-07-19 15:22:17)

Offline

#2 2015-07-19 11:58:12

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [SOLVED] systemd-nspawn cannot run terminal

I have also stumbled upon this, did a bisect and when I went to submit a bug report there was already one[1].

My use case is a bit different from yours, but you should be able to use the same workaround. When I starting the container I call a script to do some setup tasks I need, I have included this among the things I do:

/bin/umount /dev/pts
/bin/mount devpts -t devpts /dev/pts -o newinstance,ptmxmode=0666,mode=620,gid=5,nosuid,noexec

I suppose someone will get around to sort out this bug, but until someone does the workaround should take care of things. There might be a catch however, I'm not using user namespaces and I have no idea if my workaround breaks that use case.

[1] https://github.com/systemd/systemd/issues/337


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2015-07-19 15:21:55

hwm
Member
From: Iserlohn, Germany
Registered: 2015-02-10
Posts: 21

Re: [SOLVED] systemd-nspawn cannot run terminal

Thanks, this works just fine for me, too! I'm mounting all kinds of stuff in my nspawn container anyway, so this was easy to add.

Marking this as solved...

P.S.: systemd 223 fixes this!

Last edited by hwm (2015-07-30 08:46:16)

Offline

Board footer

Powered by FluxBB