summaryrefslogtreecommitdiff
path: root/lib/openat-die.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-19 07:12:15 -0600
committerEric Blake <ebb9@byu.net>2009-09-19 08:18:06 -0600
commit996f76cd71a98365044457d94b0d87454bcd4deb (patch)
treee3be327949e601c9a9b153f58272d38c09c7496a /lib/openat-die.c
parent112523aea20cc9254b36e0644ca2029b634bfae6 (diff)
downloadgnulib-996f76cd71a98365044457d94b0d87454bcd4deb.tar.gz
openat: allow return of fd 0
Partially reverts patch fc33350 from 2009-09-02. * modules/chdir-long (Depends-on): Relax openat-safer to openat. * modules/save-cwd (Depends-on): Replace fcntl-safer with unistd-safer. * lib/chdir-long.c (includes): Replace "fcntl--.h" with <fcntl.h>; this module does not leak fds. * lib/openat.c (includes): Do not use "fcntl_safer"; plain openat must be allowed to return 0, leaving openat_safer to add the safety. (openat_permissive): Avoid writing to just-opened fd 2 if restoring the current directory fails. * lib/openat-die.c (openat_restore_fail): Add comment. * lib/save-cwd.c (includes): Make "fcntl--.h" conditional. (save_cwd): Guarantee safe fd, but without use of open_safer. * tests/test-openat.c: New test. * modules/openat-tests (Files, Makefile.am): Distribute and build new file. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/openat-die.c')
-rw-r--r--lib/openat-die.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/openat-die.c b/lib/openat-die.c
index 677f3e02cb..a507eac10e 100644
--- a/lib/openat-die.c
+++ b/lib/openat-die.c
@@ -40,6 +40,11 @@ openat_save_fail (int errnum)
abort ();
}
+
+/* Exit with an error about failure to restore the working directory
+ during an openat emulation. The caller must ensure that fd 2 is
+ not a just-opened fd, even when openat_safer is not in use. */
+
void
openat_restore_fail (int errnum)
{