automount: don't pass non-blocking pipe to kernel.

Creating a pipe with O_NONBLOCK causes both the read and the write end to
be marked as non-blocking.
The "write" end is passed to the kernel autofs module, and it does not
expect a non-blocking pipe.  If it gets -EAGAIN when trying to write
(which is unlikely, but not completely impossible), it will close the
write end of the pipe, which leads to unexpected errors.

So change the code to only set O_NONBLOCK on the "read" end of the
pipe.  This is the only end that systemd interacts with, so the only end
it should be configuring.
This commit is contained in:
NeilBrown 2019-02-08 09:44:06 +11:00 committed by Lennart Poettering
parent eb7e351496
commit 1cae151d8e

View file

@ -578,10 +578,13 @@ static void automount_enter_waiting(Automount *a) {
goto fail;
}
if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
if (pipe2(p, O_CLOEXEC) < 0) {
r = -errno;
goto fail;
}
r = fd_nonblock(p[0], true);
if (r < 0)
goto fail;
xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp());
xsprintf(name, "systemd-"PID_FMT, getpid_cached());