chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:08 +0000 (07:50 +0200)
commit941f374947c8db8311bbde1bba478749d455be43
treee3da7023270163af0924169d33d1c42ca8c19f21
parente2c4475028606343176752bd0974df2c5ed6a520
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