fs-util: add new chase_symlinks() flag CHASE_OPEN
authorLennart Poettering <lennart@poettering.net>
Thu, 4 Jan 2018 19:00:28 +0000 (20:00 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 11 Jan 2018 14:12:16 +0000 (15:12 +0100)
commit1ed34d75d4f21d2335c5625261954c848d176ae6
tree3d0b126eba2fd3cbcb5ce957759c8d8ffd3cb197
parentf14f1806e329fe92d01f15c22a384702f0cb4ae0
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.
src/basic/fs-util.c
src/basic/fs-util.h
src/test/test-fs-util.c