Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launching runc through Python blocks shell input if "terminal" is set to true #1965

Open
marmeladema opened this issue Jan 17, 2019 · 0 comments

Comments

@marmeladema
Copy link

marmeladema commented Jan 17, 2019

Hello everyone and thank you for the great work 👍

I tried to start a very simple container through a Python script, and it happens that after runc exits, the shell input is "blocked" or "hidden":

  • With bash (version 5.0), you can type things, but it will not appear on the screen and you have to type "reset" + enter to reset the terminal and then be able to see what you are typing again
  • With sh, it just blocks the terminal in __GI___libc_read (fd=0, buf=0x55c6697d1ac0, nbytes=8192) call and you have to kill it

To setup the container, i just created a /tmp/roots directory, mount binded my / into it and used this configuration file generated from runc spec after having removed the mounts part:

{
	"ociVersion": "1.0.1-dev",
	"process": {
		"terminal": true,
		"user": {
			"uid": 0,
			"gid": 0
		},
		"args": [
			"sleep",
			"2"
		],
		"env": [
			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
			"TERM=xterm"
		],
		"cwd": "/",
		"capabilities": {
			"bounding": [
				"CAP_AUDIT_WRITE",
				"CAP_KILL",
				"CAP_NET_BIND_SERVICE"
			],
			"effective": [
				"CAP_AUDIT_WRITE",
				"CAP_KILL",
				"CAP_NET_BIND_SERVICE"
			],
			"inheritable": [
				"CAP_AUDIT_WRITE",
				"CAP_KILL",
				"CAP_NET_BIND_SERVICE"
			],
			"permitted": [
				"CAP_AUDIT_WRITE",
				"CAP_KILL",
				"CAP_NET_BIND_SERVICE"
			],
			"ambient": [
				"CAP_AUDIT_WRITE",
				"CAP_KILL",
				"CAP_NET_BIND_SERVICE"
			]
		},
		"rlimits": [
			{
				"type": "RLIMIT_NOFILE",
				"hard": 1024,
				"soft": 1024
			}
		],
		"noNewPrivileges": true
	},
	"root": {
		"path": "rootfs",
		"readonly": true
	},
	"hostname": "runc",
	"linux": {
		"resources": {
			"devices": [
				{
					"allow": false,
					"access": "rwm"
				}
			]
		},
		"namespaces": [
			{
				"type": "pid"
			},
			{
				"type": "network"
			},
			{
				"type": "ipc"
			},
			{
				"type": "uts"
			},
			{
				"type": "mount"
			}
		],
		"maskedPaths": [
			"/proc/kcore",
			"/proc/latency_stats",
			"/proc/timer_list",
			"/proc/timer_stats",
			"/proc/sched_debug",
			"/sys/firmware",
			"/proc/scsi"
		],
		"readonlyPaths": [
			"/proc/asound",
			"/proc/bus",
			"/proc/fs",
			"/proc/irq",
			"/proc/sys",
			"/proc/sysrq-trigger"
		]
	}
}

The Python script is very simple:

import subprocess
import atexit
import time

ARGS = ['runc', 'run', 'myrunc']
print(ARGS)
PROCESS = subprocess.Popen(ARGS)
print('Started subprocess with pid {}'.format(PROCESS.pid))
time.sleep(2)
atexit.register(PROCESS.terminate)

Looking at other issues, i found that it might be related to #1721 because if i set terminal to false, it works fine.

I am using runc 1.0-rc6 on kernel 4.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant