conmon: use pipes rather than socketpairs for !terminal

While pipes have their downsides, it turns out that socketpair(2) will
break any program that tries to open /dev/std{out,err} for writing
(because they're symlinked to /proc/1/fd/{1,2} which will cause lots of
fun issues with sockets).

Signed-off-by: Mrunal Patel <mpatel@redhat.com>
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2017-04-04 20:04:03 +10:00
parent c290c0d9c3
commit 14a37fb407
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4

View file

@ -212,10 +212,12 @@ int main(int argc, char *argv[])
* both cases. The runtime_mfd will be closed after we dup over * both cases. The runtime_mfd will be closed after we dup over
* everything. * everything.
* *
* TODO: Maybe this should be done with pipe(2)s? * We use pipes here because open(/dev/std{out,err}) will fail if we
* used anything else (and it wouldn't be a good idea to create a new
* pty pair in the host).
*/ */
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0) if (pipe(fds) < 0)
pexit("Failed to create runtime_mfd socketpair"); pexit("Failed to create runtime_mfd pipes");
mfd = fds[0]; mfd = fds[0];
runtime_mfd = fds[1]; runtime_mfd = fds[1];