From 822d764d27749e831d1b01de3c2327ea2f5745e4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 28 May 2020 17:19:45 +0200 Subject: [PATCH] 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. --- src/files.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/files.c b/src/files.c index 24e846b3..02f94d65 100644 --- a/src/files.c +++ b/src/files.c @@ -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);