diff options
author | Eric Blake <ebb9@byu.net> | 2009-09-19 07:12:15 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-09-19 08:18:06 -0600 |
commit | 996f76cd71a98365044457d94b0d87454bcd4deb (patch) | |
tree | e3be327949e601c9a9b153f58272d38c09c7496a /lib/chdir-long.c | |
parent | 112523aea20cc9254b36e0644ca2029b634bfae6 (diff) | |
download | gnulib-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/chdir-long.c')
-rw-r--r-- | lib/chdir-long.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/chdir-long.c b/lib/chdir-long.c index ba47d59973..afe018d168 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -20,19 +20,23 @@ #include "chdir-long.h" +#include <assert.h> +#include <errno.h> +#include <fcntl.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> -#include <errno.h> #include <stdio.h> -#include <assert.h> - -#include "fcntl--.h" #ifndef PATH_MAX # error "compile this file only if your system defines PATH_MAX" #endif +/* The results of openat() in this file are not leaked to any + single-threaded code that could use stdio. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use openat_safer. */ + struct cd_buf { int fd; |