Messages in this thread | | | Date | Mon, 26 Jan 2015 10:53:10 +0100 | Subject | atomic unlink filename only if everything but basename is no symlink? | From | "Axel Kittenberger" <> |
| |
Is there a Linux system call that allows one to call unlink() to execute properly only if no part of the path is a symlink? Except the basename of course since that would be simply removing the symlink itself?
The issue is with some tools like Lsyncd this can lead to removes outside of what is expected if one part of the path happened to become a symlink to some place where it shouldn't operate.
I could test if a "realpath -s PATH" is equals to "realpath PATH" but the basename, but even if I coded that, there would still be a racecondition by something else replacing one physical directory by a symlink just between the test and the call to unlink, so it unlinks something it didn't want to.
Like there is now lchown should there be a lunlink() systemcall or an option to unlink()? Or a global process flag like "do not follow *any* symlinks for me please (including my subprocesses)"?
| |