nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 822d764d27749e831d1b01de3c2327ea2f5745e4
parent 6d00e75dc26a24c77d63831c837a60f8497027c2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 28 May 2020 17:19:45 +0200

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.

Diffstat:
Msrc/files.c | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git 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);