From: Lennart Poettering Date: Mon, 8 Jan 2024 17:49:12 +0000 (+0100) Subject: varlink: turn off O_NONBLOCK in exec: transport X-Git-Tag: v256-rc1~1232^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07dca3c4b013bf9de440436142986408b4a3537d;p=thirdparty%2Fsystemd.git varlink: turn off O_NONBLOCK in exec: transport If we invoke our own varlink implementation we'll turn on O_NONBLOCK right-away again, hence there is little point in turning it off, however, I generally think we probably should always path this fd as blocking, since that is the default after all, and invoked processes might want to use it like that. Or to see this differently: I think the varlink fd passed for activation in many ways is similar to and as fundamental as stdin/stderr/stdout, hence should probably be synchronous by default. --- diff --git a/src/shared/varlink.c b/src/shared/varlink.c index 2b40c7f3bd1..e24da3f8934 100644 --- a/src/shared/varlink.c +++ b/src/shared/varlink.c @@ -450,6 +450,10 @@ int varlink_connect_exec(Varlink **ret, const char *_command, char **_argv) { if (socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, pair) < 0) return log_debug_errno(errno, "Failed to allocate AF_UNIX socket pair: %m"); + r = fd_nonblock(pair[1], false); + if (r < 0) + return log_debug_errno(r, "Failed to disable O_NONBLOCK for varlink socket: %m"); + r = safe_fork_full( "(sd-vlexec)", /* stdio_fds= */ NULL,