]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
client: Fix symlink open with O_PATH and O_NOFOLLOW
authorAnoop C S <anoopcs@cryptolab.net>
Thu, 29 Aug 2024 06:23:44 +0000 (11:53 +0530)
committerAnoop C S <anoopcs@cryptolab.net>
Tue, 15 Oct 2024 10:51:15 +0000 (16:21 +0530)
commit8443821073b23946a32009106c45581db0d51e8f
treea9cdc5461bc4c50ca593925ae4815fb93db26c1c
parent8723f17294120bb9731efb024e708f45ac196c83
client: Fix symlink open with O_PATH and O_NOFOLLOW

man open(2)[1] says the following for O_PATH:

. . .
If  pathname is a symbolic link and the O_NOFOLLOW flag is also
specified, then the call returns a file descriptor referring to the
symbolic link.  This file descriptor can be used as the dirfd argument
in calls to fchownat(2), fstatat(2), linkat(2), and readlinkat(2) with
an empty pathname to have the calls operate on the symbolic link.
. . .

symlink check within may_open() failed to consider the O_PATH flag
resulting in a ELOOP error to the client. In order to return a valid
file descriptor we introduce a check for the presence of O_PATH in
the client provided flags.

Fixes: https://tracker.ceph.com/issues/67833
[1] https://www.man7.org/linux/man-pages/man2/open.2.html

Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
src/client/Client.cc
src/test/libcephfs/test.cc