files: ignore errors when calling futimens() on a backup file

Access control lists can permit read and write access to a file
but not permit to manipulate any attributes of the file.  So it
is quite possible for futimens() to fail, just like chown() and
chmod() can fail, but this should be no cause for alarm: as long
as writing the backup file worked, then writing the file itself
will probably work too.
master
Benno Schulenberg 2020-05-28 17:19:45 +02:00
parent 6d00e75dc2
commit 822d764d27
1 changed files with 3 additions and 9 deletions

View File

@ -1704,15 +1704,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
goto cleanup_and_exit;
}
/* And set the backup's timestamps. */
if (futimens(backup_fd, filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
goto cleanup_and_exit;
}
/* Set the backup's timestamps to those of the original file.
* Failure is unimportant: saving the file apparently worked. */
IGNORE_CALL_RESULT(futimens(backup_fd, filetime));
fclose(backup_file);
free(backupname);