open /dev/null for reading AND writing when executing rsync.
authorSebastian Stark <stark@kamp.kyb.local>
Wed, 22 Oct 2008 12:59:11 +0000 (14:59 +0200)
committerSebastian Stark <stark@kamp.kyb.local>
Wed, 22 Oct 2008 13:19:45 +0000 (15:19 +0200)
This is needed for child processes to be able to write to fd 2 without failing.

For example, rsync will not be able to write an error message because of "Bad
file descriptor" which in turn leads to rsync exiting with meaningless exit
code 13 ("Errors with program diagnostics"), masking the actual error and exit
code.

The fact that rsync uses exit code 13 in that case makes this bug particularly
painful since 13 is interpreted by dss as a temporary rsync error that can be
"fixed" by simply restarting rsync. This can lead to an infinite loop,
obviously.

exec.c

diff --git a/exec.c b/exec.c
index b1f60faab79f2929584525ab5728860487a2d46a..d9f5b1b6f6838b4800b4310300e07b89a535d225 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -48,7 +48,7 @@ int dss_exec(pid_t *pid, const char *file, char *const *const args, int *fds)
                goto err_out;
        if (!fds[0] || !fds[1] || !fds[2]) {
                ret = -E_NULL_OPEN;
-               null = open("/dev/null", O_RDONLY);
+               null = open("/dev/null", O_RDWR);
                if (null < 0)
                        goto err_out;
        }