if (unlinkat(dfd, filename, unlink_flags) < 0) {
r = -errno;
/* Try to restore the original access mode if this didn't work */
- (void) fchmod(dfd, old_mode);
+ (void) fchmod(dfd, old_mode & 07777);
return r;
}
- if (FLAGS_SET(remove_flags, REMOVE_CHMOD_RESTORE) && fchmod(dfd, old_mode) < 0)
+ if (FLAGS_SET(remove_flags, REMOVE_CHMOD_RESTORE) && fchmod(dfd, old_mode & 07777) < 0)
return -errno;
/* If this worked, we won't reset the old mode by default, since we'll need it for other entries too,
if (fstatat(dfd, filename, ret, fstatat_flags) < 0) {
r = -errno;
- (void) fchmod(dfd, old_mode);
+ (void) fchmod(dfd, old_mode & 07777);
return r;
}
- if (FLAGS_SET(remove_flags, REMOVE_CHMOD_RESTORE) && fchmod(dfd, old_mode) < 0)
+ if (FLAGS_SET(remove_flags, REMOVE_CHMOD_RESTORE) && fchmod(dfd, old_mode & 07777) < 0)
return -errno;
return 0;