about summary refs log tree commit diff
path: root/hurd/hurdlookup.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-18 19:43:04 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-18 19:43:04 +0100
commit72103e73c9a76784b9e8b27a7d5b802178d6755b (patch)
tree1a250b52aba642cab342d056a09c08f1032f409c /hurd/hurdlookup.c
parent489999cc9cb1fab40c308b2e5ede3207e0f7a5be (diff)
downloadglibc-72103e73c9a76784b9e8b27a7d5b802178d6755b.tar.gz
glibc-72103e73c9a76784b9e8b27a7d5b802178d6755b.tar.xz
glibc-72103e73c9a76784b9e8b27a7d5b802178d6755b.zip
hurd: Fix O_DIRECTORY | O_NOFOLLOW
Appending / to the path to be looked up would make us always follow a final
symlink, even with O_NOTRANS (since the final resolution is after the
'/').  In the O_DIRECTORY | O_NOFOLLOW case, we thus have to really open
the node and stat it, which we already do anyway, and check for
directory type.

	* hurd/hurdlookup.c (__hurd_file_name_lookup): Do not append '/' to
	path when flags contains O_NOFOLLOW.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Return ENOTDIR
	if flags contains O_DIRECTORY and the result is a directory.
Diffstat (limited to 'hurd/hurdlookup.c')
-rw-r--r--hurd/hurdlookup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c
index 1861d5879d..a642c49002 100644
--- a/hurd/hurdlookup.c
+++ b/hurd/hurdlookup.c
@@ -72,7 +72,7 @@ __hurd_file_name_lookup (error_t (*use_init_port)
   if (flags & O_NOFOLLOW)	/* See lookup-retry.c about O_NOFOLLOW.  */
     flags |= O_NOTRANS;
 
-  if (flags & O_DIRECTORY)
+  if (flags & O_DIRECTORY && (flags & O_NOFOLLOW) == 0)
     {
       /* The caller wants to require that the file we look up is a directory.
 	 We can do this without an extra RPC by appending a trailing slash