3.0.1 - gentoo unpriviliged container - shutdown not working

Whilst reboot and poweroff are working from the cli in the container shutdown does not however

Upon login to the container

cannot set terminal process group (1249): Inappropriate ioctl for device

Upon shutdown

cannot set terminal process group (-1): Inappropriate ioctl for device

Can you run shutdown under strace to see what it may be trying to do with poweroff doesn’t?

Sure, here it is but I would not know what to make of it.

Summary

execve("/sbin/shutdown", [“shutdown”, “now”], 0x7ffce602fe88 /* 21 vars /) = 0
brk(NULL) = 0x563dc5753000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/etc/ld.so.cache”, O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20941, …}) = 0
mmap(NULL, 20941, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc18ec32000
close(3) = 0
openat(AT_FDCWD, “/lib64/libc.so.6”, O_RDONLY|O_CLOEXEC) = 3
read(3, “\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \20\2\0\0\0\0\0”…, 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840896, …}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc18ec30000
mmap(NULL, 3946968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fc18e650000
mprotect(0x7fc18e80b000, 2093056, PROT_NONE) = 0
mmap(0x7fc18ea0a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fc18ea0a000
mmap(0x7fc18ea10000, 14808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fc18ea10000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7fc18ec31500) = 0
mprotect(0x7fc18ea0a000, 16384, PROT_READ) = 0
mprotect(0x563dc4895000, 4096, PROT_READ) = 0
mprotect(0x7fc18ec38000, 4096, PROT_READ) = 0
munmap(0x7fc18ec32000, 20941) = 0
getuid() = 0
geteuid() = 0
setuid(0) = 0
getuid() = 0
brk(NULL) = 0x563dc5753000
brk(0x563dc5774000) = 0x563dc5774000
openat(AT_FDCWD, “/var/run/shutdown.pid”, O_RDONLY) = -1 ENOENT (No such file or directory)
unlink("/var/run/shutdown.pid") = -1 ENOENT (No such file or directory)
umask(022) = 022
openat(AT_FDCWD, “/var/run/shutdown.pid”, O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
getpid() = 11812
fstat(3, {st_mode=S_IFREG|0644, st_size=0, …}) = 0
write(3, “11812\n”, 6) = 6
close(3) = 0
rt_sigaction(SIGQUIT, {sa_handler=SIG_IGN, sa_mask=[QUIT], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_IGN, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[HUP], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTSTP, {sa_handler=SIG_IGN, sa_mask=[TSTP], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTTIN, {sa_handler=SIG_IGN, sa_mask=[TTIN], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTTOU, {sa_handler=SIG_IGN, sa_mask=[TTOU], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc18e686050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x563dc4693990, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fc18e686050}, NULL, 8) = 0
chdir("/") = 0
getuid() = 0
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=447, …}) = 0
read(3, “# /etc/nsswitch.conf:\n# $Header:”…, 4096) = 447
read(3, “”, 4096) = 0
close(3) = 0
openat(AT_FDCWD, “/etc/ld.so.cache”, O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20941, …}) = 0
mmap(NULL, 20941, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc18ec32000
close(3) = 0
openat(AT_FDCWD, “/lib64/tls/x86_64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/tls/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/tls/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/tls/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/tls", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/x86_64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/lib64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib64", {st_mode=S_IFDIR|0755, st_size=3340, …}) = 0
openat(AT_FDCWD, “/usr/lib64/tls/x86_64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls/x86_64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/tls/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/tls/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/tls/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/x86_64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/x86_64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/x86_64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/x86_64", 0x7fff61f0d450) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/lib64/libnss_compat.so.2”, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib64", {st_mode=S_IFDIR|0755, st_size=7528, …}) = 0
munmap(0x7fc18ec32000, 20941) = 0
openat(AT_FDCWD, “/etc/ld.so.cache”, O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20941, …}) = 0
mmap(NULL, 20941, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc18ec32000
close(3) = 0
openat(AT_FDCWD, “/lib64/libnss_files.so.2”, O_RDONLY|O_CLOEXEC) = 3
read(3, “\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360”\0\0\0\0\0\0"…, 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=47320, …}) = 0
mmap(NULL, 2143656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fc18e444000
mprotect(0x7fc18e44f000, 2093056, PROT_NONE) = 0
mmap(0x7fc18e64e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7fc18e64e000
close(3) = 0
mprotect(0x7fc18e64e000, 4096, PROT_READ) = 0
munmap(0x7fc18ec32000, 20941) = 0
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=655, …}) = 0
read(3, “root:x:0:0:root:/root:/bin/bash\n”…, 4096) = 655
close(3) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo …}) = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4), …}) = 0
readlink("/proc/self/fd/0", “/dev/pts/4”, 4095) = 10
stat("/dev/pts/4", 0x7fff61f0de70) = -1 ENOENT (No such file or directory)
stat("/dev/pts", {st_mode=S_IFDIR|0755, st_size=0, …}) = 0
open("/dev/pts", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=0, …}) = 0
getdents(3, /
7 entries /, 32768) = 168
getdents(3, /
0 entries /, 32768) = 0
close(3) = 0
open("/dev", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=460, …}) = 0
getdents(3, /
23 entries /, 32768) = 616
stat("/dev/tty", {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 0), …}) = 0
getdents(3, /
0 entries /, 32768) = 0
close(3) = 0
open("/dev", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=460, …}) = 0
getdents(3, /
23 entries /, 32768) = 616
stat("/dev/.", {st_mode=S_IFDIR|0755, st_size=460, …}) = 0
stat("/dev/…", {st_mode=S_IFDIR|0755, st_size=136, …}) = 0
stat("/dev/shm", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=40, …}) = 0
stat("/dev/mqueue", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=40, …}) = 0
stat("/dev/core", {st_mode=S_IFREG|0400, st_size=140737477881856, …}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, …}) = 0
stat("/dev/tty4", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), …}) = 0
stat("/dev/tty3", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), …}) = 0
stat("/dev/tty2", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), …}) = 0
stat("/dev/tty1", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), …}) = 0
stat("/dev/ptmx", {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 2), …}) = 0
stat("/dev/fd", {st_mode=S_IFDIR|0500, st_size=0, …}) = 0
stat("/dev/console", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), …}) = 0
stat("/dev/zero", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 5), …}) = 0
stat("/dev/urandom", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), …}) = 0
stat("/dev/tty", {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 0), …}) = 0
stat("/dev/random", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 8), …}) = 0
stat("/dev/null", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), …}) = 0
stat("/dev/full", {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 7), …}) = 0
stat("/dev/pts", {st_mode=S_IFDIR|0755, st_size=0, …}) = 0
getdents(3, /
0 entries /, 32768) = 0
close(3) = 0
uname({sysname=“Linux”, nodename=“hpot”, …}) = 0
open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=127, …}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=127, …}) = 0
read(3, “TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0”…, 4096) = 127
lseek(3, -71, SEEK_CUR) = 56
read(3, “TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0”…, 4096) = 71
close(3) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fc18ec317d0) = 11813
getpid() = 11812
socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/dev/log"}, 110) = -1 ENOENT (No such file or directory)
close(3) = 0
unlink("/var/run/shutdown.pid") = 0
unlink("/etc/nologin") = -1 ENOENT (No such file or directory)
sync() = 0
rt_sigaction(SIGALRM, {sa_handler=0x563dc4693980, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fc18e686050}, NULL, 8) = 0
alarm(3) = 0
openat(AT_FDCWD, “/dev/initctl”, O_WRONLY) = 3
write(3, “i\31\t\3\6\0\0\0\0\0\0\0\0\0\0\0INIT_HALT\0\0\0\0\0\0\0”…, 384) = 384
close(3) = 0
alarm(0) = 3
execve("/sbin/init", ["/sbin/init", “S”], 0x7fff61f0e800 /
21 vars */) = 0
brk(NULL) = 0x55805dfa5000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/etc/ld.so.cache”, O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20941, …}) = 0
mmap(NULL, 20941, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fcca189b000
close(3) = 0
openat(AT_FDCWD, “/lib64/libc.so.6”, O_RDONLY|O_CLOEXEC) = 3
read(3, “\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \20\2\0\0\0\0\0”…, 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840896, …}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fcca1899000
mmap(NULL, 3946968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fcca12b9000
mprotect(0x7fcca1474000, 2093056, PROT_NONE) = 0
mmap(0x7fcca1673000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7fcca1673000
mmap(0x7fcca1679000, 14808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fcca1679000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7fcca189a540) = 0
mprotect(0x7fcca1673000, 16384, PROT_READ) = 0
mprotect(0x55805d2d2000, 4096, PROT_READ) = 0
mprotect(0x7fcca18a1000, 4096, PROT_READ) = 0
munmap(0x7fcca189b000, 20941) = 0
umask(022) = 022
geteuid() = 0
getpid() = 11812
chdir("/") = 0
rt_sigaction(SIGALRM, {sa_handler=0x55805d0cc9b0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fcca12ef050}, NULL, 8) = 0
alarm(3) = 0
openat(AT_FDCWD, “/dev/initctl”, O_WRONLY) = 3
write(3, “i\31\t\3\1\0\0\0S\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0”…, 384) = 384
close(3) = 0
alarm(0) = 3
exit_group(0) = ?
+++ exited with 0 +++

Ok, so all that did is open /dev/initctl and send it a message to shutdown the system, then it exited successfully.

This unfortunately means that the difference in handling shutdown and poweroff is inside the init system. I’m not familiar with Gentoo (and I suspect openrc) so can’t really comment on the expected difference between the two or how to track down what init script it may get stuck on.

openrc it is indeed.

Thanks for having had a look at it anyway. Not that important since reboot and poweroff work and lxc-stop

Probably the issue

cannot set terminal process group (-1): Inappropriate ioctl for device
exit_group(0) = ?

Maybe even a consequence of 3.0.1 - apparmor denied mount lxc-container-default-cgns

updated the lxc host kernel to 4.17.4 and shutdown from withing the container now works, confirmed by the instant loss of the vpn connection as the container is hosting a vpn server.

But then it does not to the extent that in lxc it is still running, shown by lxc-info even after a grace period of several minutes granted. lxc-stop then takes ages (in the range of 2 minutes) to tearn down the gentoo container.