stdin is supposed to be readable, stdout and stderr writable. Otherwise,
we get this:
index de6dd716..ca4812cd 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -90,7 +90,7 @@ __libc_check_standard_fds (void)
is really paranoid but some people actually are. If /dev/null
should happen to be a symlink to somewhere else and not the
device commonly known as "/dev/null" we bail out. */
- check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW);
- check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW);
- check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW);
+ check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW);
+ check_one_fd (STDOUT_FILENO, O_WRONLY | O_NOFOLLOW);
+ check_one_fd (STDERR_FILENO, O_WRONLY | O_NOFOLLOW);
}
--
2.40.0
Im a little bit lost on what it was supposed to do in this old form.. as the open flags are all wrong..
Changelog says:
(__libc_check_standard_fds): Reverse modes so that common operations on
the descriptors fail.
So this was intended at some point in the past decades to make it fail.. I see it is used only for SUID statically linked binaries. is this really needed now? playing silly games with this fds will always result in silly prices.