Commit 123110c5 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

2009-11-19 Chris Allegretta <chrisa@asty.org>

        * nano.c (die_save_file) Try nd match the permissions of the file we were
          editing but only make a minimal effort to do so. Fixes Savannah bug 27273     
          reported by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent cbba7755
Showing with 19 additions and 5 deletions
+19 -5
2009-11-19 Chris Allegretta <chrisa@asty.org>
* nano.c (die_save_file) Try nd match the permissions of the file we were
editing but only make a minimal effort to do so. Fixes Savannah bug 27273
reported by Mike Frysinger.
2009-11-18 Adrian Bunk <bunk via Savannah> 2009-11-18 Adrian Bunk <bunk via Savannah>
* nano.c (main) - Allow --fill and --nowrap to override nanorc entries and each other * nano.c (main): Allow --fill and --nowrap to override nanorc entries and each other
on the command line. on the command line.
2009-11-15 Chris Allegretta <chrisa@asty.org> 2009-11-15 Chris Allegretta <chrisa@asty.org>
......
...@@ -638,7 +638,7 @@ void die(const char *msg, ...) ...@@ -638,7 +638,7 @@ void die(const char *msg, ...)
if (filepart != NULL) if (filepart != NULL)
unpartition_filestruct(&filepart); unpartition_filestruct(&filepart);
die_save_file(openfile->filename); die_save_file(openfile->filename, openfile->current_stat);
} }
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
...@@ -651,7 +651,7 @@ void die(const char *msg, ...) ...@@ -651,7 +651,7 @@ void die(const char *msg, ...)
/* Save the current file buffer if it's been modified. */ /* Save the current file buffer if it's been modified. */
if (openfile->modified) if (openfile->modified)
die_save_file(openfile->filename); die_save_file(openfile->filename, openfile->current_stat);
} }
} }
#endif #endif
...@@ -662,7 +662,7 @@ void die(const char *msg, ...) ...@@ -662,7 +662,7 @@ void die(const char *msg, ...)
/* Save the current file under the name spacified in die_filename, which /* Save the current file under the name spacified in die_filename, which
* is modified to be unique if necessary. */ * is modified to be unique if necessary. */
void die_save_file(const char *die_filename) void die_save_file(const char *die_filename, struct stat *die_stat)
{ {
char *retval; char *retval;
bool failed = TRUE; bool failed = TRUE;
...@@ -691,6 +691,15 @@ void die_save_file(const char *die_filename) ...@@ -691,6 +691,15 @@ void die_save_file(const char *die_filename)
fprintf(stderr, _("\nBuffer not written: %s\n"), fprintf(stderr, _("\nBuffer not written: %s\n"),
_("Too many backup files?")); _("Too many backup files?"));
/* Try and chmod/chown the save file to the values of the original file, but
dont worry if it fails because we're supposed to be bailing as fast
as possible. */
if (die_stat) {
int shush;
shush = chmod(retval, die_stat->st_mode);
shush = chown(retval, die_stat->st_uid, die_stat->st_gid);
}
free(retval); free(retval);
} }
......
...@@ -428,7 +428,7 @@ void free_openfilestruct(openfilestruct *src); ...@@ -428,7 +428,7 @@ void free_openfilestruct(openfilestruct *src);
void print_view_warning(void); void print_view_warning(void);
void finish(void); void finish(void);
void die(const char *msg, ...); void die(const char *msg, ...);
void die_save_file(const char *die_filename); void die_save_file(const char *die_filename, struct stat *die_stat);
void window_init(void); void window_init(void);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
void disable_mouse_support(void); void disable_mouse_support(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment