<div dir="ltr"><div>If the master process registers the child before the child<br></div><div>has initialized, when the child tries to setup /dev/console</div><div>it gets "operation not permitted".</div><div>---</div>
<div> src/nspawn/nspawn.c | 14 +++++++++++---</div><div> 1 file changed, 11 insertions(+), 3 deletions(-)</div><div><br></div><div>diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c</div><div>index 92b6728..a83d1f3 100644</div>
<div>--- a/src/nspawn/nspawn.c</div><div>+++ b/src/nspawn/nspawn.c</div><div>@@ -1776,7 +1776,7 @@ finish:</div><div> </div><div> int main(int argc, char *argv[]) {</div><div> </div><div>- _cleanup_close_ int master = -1, kdbus_fd = -1, sync_fd = -1;</div>
<div>+ _cleanup_close_ int master = -1, kdbus_fd = -1, sync_fd = -1, sync_fd2 = -1;</div><div> _cleanup_close_pipe_ int kmsg_socket_pair[2] = { -1, -1 };</div><div> _cleanup_free_ char *kdbus_domain = NULL;</div>
<div> _cleanup_fdset_free_ FDSet *fds = NULL;</div><div>@@ -1925,9 +1925,11 @@ int main(int argc, char *argv[]) {</div><div> </div><div> for (;;) {</div><div> siginfo_t status;</div><div>+ eventfd_t x;</div>
<div> </div><div> sync_fd = eventfd(0, EFD_CLOEXEC);</div><div>- if (sync_fd < 0) {</div><div>+ sync_fd2 = eventfd(0, EFD_CLOEXEC);</div><div>+ if (sync_fd < 0 || sync_fd2 < 0) {</div>
<div> log_error("Failed to create event fd: %m");</div><div> goto finish;</div><div> }</div><div>@@ -1964,7 +1966,6 @@ int main(int argc, char *argv[]) {</div>
<div> NULL</div><div> };</div><div> char **env_use;</div><div>- eventfd_t x;</div><div> </div><div> envp[n_env] = strv_find_prefix(environ, "TERM=");</div>
<div> if (envp[n_env])</div><div>@@ -2201,6 +2202,9 @@ int main(int argc, char *argv[]) {</div><div> goto child_fail;</div><div> }</div>
<div> }</div><div>+ eventfd_write(sync_fd2, 1);</div><div>+ close_nointr_nofail(sync_fd2);</div><div>+ sync_fd2 = -1;</div><div>
</div><div> eventfd_read(sync_fd, &x);</div><div> close_nointr_nofail(sync_fd);</div><div>@@ -2256,6 +2260,10 @@ int main(int argc, char *argv[]) {</div><div> _exit(EXIT_FAILURE);</div>
<div> }</div><div> </div><div>+ eventfd_read(sync_fd2, &x);</div><div>+ close_nointr_nofail(sync_fd2);</div><div>+ sync_fd2 = -1;</div><div>+</div><div> fdset_free(fds);</div>
<div> fds = NULL;</div><div> </div><div>-- </div><div>1.9.0</div><div><br></div></div>