chiark / gitweb /
fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()
authorLennart Poettering <lennart@poettering.net>
Tue, 29 Nov 2016 17:02:45 +0000 (18:02 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
commit62383061a34dc8233b3e26c49271d5cb43fcb0f6
tree9db67aa74dc1f41cf7fa93aa06eb5ddad3222952
parent8036e4d0b9ef0990597196155fe6fc6329a6a881
fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()

This new flag controls whether to consider a problem if the referenced path
doesn't actually exist. If specified it's OK if the final file doesn't exist.

Note that this permits one or more final components of the path not to exist,
but these must not contain "../" for safety reasons (or, to be extra safe,
neither "./" and a couple of others, i.e. what path_is_safe() permits).

This new flag is useful when resolving paths before issuing an mkdir() or
open(O_CREAT) on a path, as it permits that the file or directory is created
later.

The return code of chase_symlinks() is changed to return 1 if the file exists,
and 0 if it doesn't. The latter is only returned in case CHASE_NON_EXISTING is
set.
src/basic/fs-util.c
src/basic/fs-util.h