* race condition here, but the window is as small as possible
* between when we open the file descriptor (look above) and when we
* fstat it.
* race condition here, but the window is as small as possible
* between when we open the file descriptor (look above) and when we
* fstat it.
- struct stat s;
- if (fstat(fd, &s) == -1) {
- perror("apply_default_acl (fstat)");
- goto cleanup;
+ if (sp == NULL) {
+ struct stat s;
+ if (fstat(fd, &s) == -1) {
+ perror("apply_default_acl (fstat)");
+ goto cleanup;
+ }
+
+ sp = &s;
bool apply_default_acl_recursive(const char *target, bool no_exec_mask) {
if (!is_path_directory(target)) {
bool apply_default_acl_recursive(const char *target, bool no_exec_mask) {
if (!is_path_directory(target)) {