diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2010-09-01 13:45:53 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2010-09-01 13:46:21 -0700 |
commit | 24816be6c14cbc51938d036533ec5ccaa9a056e2 (patch) | |
tree | d806ac747bd2de1b5d730c7c74f22f2ae41474d5 /lib/chdir-long.c | |
parent | 89c0f8b3c26bc3a218969bda3d7116a0528409c8 (diff) | |
download | gnulib-24816be6c14cbc51938d036533ec5ccaa9a056e2.tar.gz |
fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
POSIX 2008 specifies a new 'open' flag O_SEARCH, which can be used
when one needs search access to a directory but not read access.
On systems where it is available, it works in some cases where
O_RDONLY does not, namely on directories that are searchable but
not readable, and which need only to be searchable. If O_SEARCH
is not available, fall back to the traditional method of using
O_RDONLY.
* lib/fcntl.in.h (O_SEARCH): #define to O_RDONLY if not defined.
* lib/chdir-long.c (cdb_advance_fd): Use O_SEARCH, not O_RDONLY,
when opening a directory that needs only to be searchable.
* lib/chdir-safer.c (chdir_no_follow): Likewise.
* lib/fts.c (diropen, fts_open, fd_ring_check): Likewise.
* lib/openat-proc.c (openat_proc_name): Likewise.
* lib/openat.c (openat_needs_fchdir): Likewise.
* lib/save-cwd.c (save_cwd): Likewise.
* lib/savewd.c (savewd_save, savewd_chdir): Likewise.
Diffstat (limited to 'lib/chdir-long.c')
-rw-r--r-- | lib/chdir-long.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chdir-long.c b/lib/chdir-long.c index 28e24070e9..a88e27f34e 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -72,7 +72,7 @@ static int cdb_advance_fd (struct cd_buf *cdb, char const *dir) { int new_fd = openat (cdb->fd, dir, - O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); if (new_fd < 0) return -1; |