fs-util: add new chase_symlinks() flag CHASE_OPEN 49/219149/3
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 20 Nov 2019 13:52:46 +0000 (14:52 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 5 Dec 2019 11:02:14 +0000 (11:02 +0000)
commitf425d76aa0223534e8dc0f934ee3707b97cc9b31
tree587a1721ca2780168b39085ebac12440a3171abb
parent1d71394847e4dddf154135ef55222cc28419a91e
fs-util: add new chase_symlinks() flag CHASE_OPEN

The new flag returns the O_PATH fd of the final component, which may be
converted into a proper fd by open()ing it again through the
/proc/self/fd/xyz path.

Together with O_SAFE this provides us with a somewhat safe way to open()
files in directories potentially owned by unprivileged code, where we
want to refuse operation if any symlink tricks are played pointing to
privileged files.

(cherry picked from commit 1ed34d75d4f21d2335c5625261954c848d176ae6)

Change-Id: I5e5ce0affec97e4d19483b4f534db99f4f950f89
Related: #1663143
Makefile.am
src/basic/fs-util.c
src/basic/fs-util.h
src/test/test-fs-util.c