mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-09-11 11:50:52 +03:00
On deficient platforms where we must check for directories ourselves when opening files, check before opening as well as after. This prevents a hang when trying to open a special file like a fifo in a context where a directory is required. Although there is still a race so we could still hang in a perverse situation, it’s the best we can do and it is better than hanging in the more-common case. * lib/open.c (lstatif): New static function. (open) [REPLACE_FCHDIR]: Also inspect O_CREAT. * lib/open.c (open), lib/openat.c (rpl_openat): When checking for directories, also do this before opening. Also, respect O_NOFOLLOW when checking for directories. * lib/openat.c: Remove a few more unnecessary differences from open.c. * modules/open (Depends-on): Depend on lstat. * modules/openat (Depends-on): Add fstatat. * modules/open-tests, modules/openat-tests: (configure.ac) Check for alarm decl. * tests/test-open.c, tests/test-openat.c: Include sys/stat.h, for mkfifo. [HAVE_DECL_ALARM]: Include signal.h, for alarm. * tests/test-open.h (test_open): Fail if test takes too long because we tried to open a fifo. Test opening /dev/null, /dev/tty and a fifo, with a trailing "/" and with O_DIRECTORY.
19 lines
220 B
Plaintext
19 lines
220 B
Plaintext
Files:
|
|
tests/test-open.h
|
|
tests/test-open.c
|
|
tests/signature.h
|
|
tests/macros.h
|
|
|
|
Depends-on:
|
|
bool
|
|
fcntl
|
|
mkfifo
|
|
symlink
|
|
|
|
configure.ac:
|
|
AC_CHECK_DECLS_ONCE([alarm])
|
|
|
|
Makefile.am:
|
|
TESTS += test-open
|
|
check_PROGRAMS += test-open
|