aboutsummaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu27@gmail.com>2010-06-02 10:24:59 -0700
committerAndreas Schwab <schwab@redhat.com>2010-12-01 15:35:07 +0100
commit5268b1935686d102df4767e08a0135f7b4add353 (patch)
tree9587c6bd2bcf428680c5f89dd3e2b416e5ece511 /hurd
parent230f03954fc437897ca3f1926462d8b43b80c375 (diff)
downloadglibc-5268b1935686d102df4767e08a0135f7b4add353.zip
glibc-5268b1935686d102df4767e08a0135f7b4add353.tar.gz
glibc-5268b1935686d102df4767e08a0135f7b4add353.tar.bz2
Hurd: Fix linkat symlink handling.
(cherry picked from commit 2a50c07836d2750baf70442f8f760bf6cd43b3af)
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurd/fd.h5
-rw-r--r--hurd/lookup-at.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h
index d1aa867..2473476 100644
--- a/hurd/hurd/fd.h
+++ b/hurd/hurd/fd.h
@@ -254,8 +254,9 @@ extern int _hurd_select (int nfds, struct pollfd *pollfds,
const sigset_t *sigmask);
/* Variant of file_name_lookup used in *at function implementations.
- AT_FLAGS should contain only AT_SYMLINK_NOFOLLOW; other bits
- cause EINVAL. */
+ AT_FLAGS may only contain AT_SYMLINK_FOLLOW or AT_SYMLINK_NOFOLLOW,
+ which will remove and add O_NOLINK from FLAGS respectively.
+ Other bits cause EINVAL. */
extern file_t __file_name_lookup_at (int fd, int at_flags,
const char *file_name,
int flags, mode_t mode);
diff --git a/hurd/lookup-at.c b/hurd/lookup-at.c
index 7f55527..728a970 100644
--- a/hurd/lookup-at.c
+++ b/hurd/lookup-at.c
@@ -30,8 +30,14 @@ __file_name_lookup_at (int fd, int at_flags,
error_t err;
file_t result;
+ if ((at_flags & AT_SYMLINK_FOLLOW) && (at_flags & AT_SYMLINK_NOFOLLOW))
+ return (__hurd_fail (EINVAL), MACH_PORT_NULL);
+
flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
at_flags &= ~AT_SYMLINK_NOFOLLOW;
+ if (at_flags & AT_SYMLINK_FOLLOW)
+ flags &= ~O_NOLINK;
+ at_flags &= ~AT_SYMLINK_FOLLOW;
if (at_flags != 0)
return (__hurd_fail (EINVAL), MACH_PORT_NULL);