From 1b5d9171f214d64ae39039d22b669c2e4569486e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 14 Jul 2021 10:38:02 +0200 Subject: [PATCH] tweaks: try chmodding a dump file only when it was actually written --- src/nano.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nano.c b/src/nano.c index 501d4f87..3dd9f917 100644 --- a/src/nano.c +++ b/src/nano.c @@ -327,17 +327,16 @@ void emergency_save(const char *filename) fprintf(stderr, _("\nToo many .save files\n")); else if (write_file(targetname, NULL, TRUE, OVERWRITE, FALSE)) { fprintf(stderr, _("\nBuffer written to %s\n"), targetname); - } - #ifndef NANO_TINY - /* Try to chmod/chown the saved file to the values of the original file, - * but ignore any failure as we are in a hurry to get out. */ - if (openfile->statinfo) { - IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode)); - IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid, - openfile->statinfo->st_gid)); - } + /* Try to chmod/chown the saved file to the values of the original file, + * but ignore any failure as we are in a hurry to get out. */ + if (openfile->statinfo) { + IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode)); + IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid, + openfile->statinfo->st_gid)); + } #endif + } free(targetname); free(plainname);