diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-23 01:06:39 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-11-23 01:06:39 +0100 |
commit | 8ee41e99502f3983fcfb75d9a88cd3dbcc4de78d (patch) | |
tree | c15971eb8abff4edd3ef85e29e5dfcb00d3fb6be | |
parent | 2bc1a49404e22e50e91c61e7cb07144871448c20 (diff) |
hurd: Fix O_DIRECTORY | O_NOFOLLOW
Appending / to the path to be looked up makes 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.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r-- | .topdeps | 2 | ||||
-rw-r--r-- | .topmsg | 12 | ||||
-rw-r--r-- | hurd/hurdlookup.c | 2 | ||||
-rw-r--r-- | hurd/lookup-retry.c | 2 |
4 files changed, 10 insertions, 8 deletions
@@ -1 +1 @@ -baseline +t/NOFOLLOW @@ -1,10 +1,10 @@ From: Samuel Thibault <samuel.thibault@ens-lyon.org> -Subject: [PATCH] hurd: Fix O_NOFOLLOW +Subject: [PATCH] hurd: Fix O_DIRECTORY | O_NOFOLLOW -The error code documented by POSIX for opening a symlink with O_NOFOLLOW -is ELOOP. - -Also, if the translator does not expose symlink as a symlink translator but -as a S_IFLNK file, O_NOFOLLOW needs to return ELOOP too. +Appending / to the path to be looked up makes 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. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c index dbff009539..bd720c27ec 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)) { /* 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 diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c index b7a6a2b2a5..d37295972b 100644 --- a/hurd/lookup-retry.c +++ b/hurd/lookup-retry.c @@ -147,6 +147,8 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) err = __io_stat (*result, &st); if (!err) { + if (flags & O_DIRECTORY && !S_ISDIR(st.st_mode)) + err = ENOTDIR; if (S_ISLNK(st.st_mode)) err = ELOOP; else if (st.st_mode & (S_IPTRANS|S_IATRANS)) |