From: Michael Orlitzky Date: Fri, 23 Feb 2018 21:11:08 +0000 (-0500) Subject: Replace most path usage with file descriptors. X-Git-Tag: v0.1.0~32 X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=8a38e0e6e0d8a4247933dd11812062c3590451dd;hp=8a38e0e6e0d8a4247933dd11812062c3590451dd;p=apply-default-acl.git Replace most path usage with file descriptors. Before this commit, we were passing around paths everywhere to specify the targets of operations. This is not optimal from a security standpoint: the best we can do to avoid following hard links is to check whether or not a given file has more than one name. There is a race condition inherent in that approach -- between when you stat the file and when you use it, the number of names may change -- but using paths makes that window larger than it has to be. There's no guarantee that a path used at the bottom of apply_default_acl() will refer to the same file that we called stat() on at the top of the function. To work around that, most of the path handling functions have been replaced with versions that use file descriptors. Now we are able to stat() our file descriptor immediately after opening it, and the descriptor itself will always refer to the same file. There's still the smallest of windows for an exploit, but this makes it much safer to call apply_default_acl() when there may be hard links present. ---