]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: turn off O_NONBLOCK in exec: transport
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Jan 2024 17:49:12 +0000 (18:49 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Jan 2024 22:24:39 +0000 (23:24 +0100)
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.

src/shared/varlink.c

index 2b40c7f3bd1fa17fe5bdff20f93078fa8539a9f1..e24da3f89345ffe13a625a306320bff82dd2fec0 100644 (file)
@@ -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,