2011-02-06 Chris Allegretta <chrisa@asty.org>
* files.c (write_file) - Fix problems with writing the backup file (albeit interactively) with new function prompt_failed_backupwrite(), allows more secure handling of problems with failing to write the backup file compared to 'allow_insecure_backup'. * winio.c (edit_redraw): Removed unused variable git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4526 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
d5b1c7c5bf
commit
3d411188f6
|
@ -1,3 +1,9 @@
|
||||||
|
2011-02-06 Chris Allegretta <chrisa@asty.org>
|
||||||
|
* files.c (write_file) - Fix problems with writing the backup file (albeit interactively)
|
||||||
|
with new function prompt_failed_backupwrite(), allows more secure handling of problems
|
||||||
|
with failing to write the backup file compared to 'allow_insecure_backup'.
|
||||||
|
* winio.c (edit_redraw): Removed unused variable
|
||||||
|
|
||||||
2010-11-15 Chris Allegretta <chrisa@asty.org>
|
2010-11-15 Chris Allegretta <chrisa@asty.org>
|
||||||
* Add a section to the FAQ about using nanorc on Win32 systems.
|
* Add a section to the FAQ about using nanorc on Win32 systems.
|
||||||
|
|
||||||
|
|
30
src/files.c
30
src/files.c
|
@ -1366,6 +1366,23 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
/* Although this sucks, it sucks less than having a single 'my system is messed up
|
||||||
|
* and I'm blanket allowing insecure file writing operations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int prompt_failed_backupwrite(const char *filename)
|
||||||
|
{
|
||||||
|
static int i;
|
||||||
|
static char *prevfile = NULL; /* What was the laast file we were paased so we don't keep asking this?
|
||||||
|
though maybe we should.... */
|
||||||
|
if (prevfile == NULL || strcmp(filename, prevfile)) {
|
||||||
|
i = do_yesno_prompt(FALSE,
|
||||||
|
_("Failed to write backup file, continue saving? (Say N if unsure) "));
|
||||||
|
prevfile = mallocstrcpy(prevfile, filename);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
void init_backup_dir(void)
|
void init_backup_dir(void)
|
||||||
{
|
{
|
||||||
char *full_backup_dir;
|
char *full_backup_dir;
|
||||||
|
@ -1600,6 +1617,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
file with O_CREAT and O_EXCL. If it succeeds, we
|
file with O_CREAT and O_EXCL. If it succeeds, we
|
||||||
have a file descriptor to a new backup file. */
|
have a file descriptor to a new backup file. */
|
||||||
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
|
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
|
||||||
|
if (prompt_failed_backupwrite(backupname))
|
||||||
|
goto skip_backup;
|
||||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(backupname);
|
free(backupname);
|
||||||
|
@ -1628,7 +1647,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
root, since it's likely to fail! */
|
root, since it's likely to fail! */
|
||||||
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
||||||
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
|
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
|
||||||
&& !ISSET(INSECURE_BACKUP)) {
|
&& !ISSET(INSECURE_BACKUP)) {
|
||||||
|
if (prompt_failed_backupwrite(backupname))
|
||||||
|
goto skip_backup;
|
||||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(backupname);
|
free(backupname);
|
||||||
|
@ -1636,7 +1657,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 && !ISSET(INSECURE_BACKUP)) {
|
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1
|
||||||
|
&& !ISSET(INSECURE_BACKUP)) {
|
||||||
|
if (prompt_failed_backupwrite(backupname))
|
||||||
|
goto skip_backup;
|
||||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(backupname);
|
free(backupname);
|
||||||
|
@ -1664,6 +1688,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
|
|
||||||
/* And set its metadata. */
|
/* And set its metadata. */
|
||||||
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
|
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
|
||||||
|
if (prompt_failed_backupwrite(backupname))
|
||||||
|
goto skip_backup;
|
||||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
/* If we can't write to the backup, DONT go on, since
|
/* If we can't write to the backup, DONT go on, since
|
||||||
|
|
|
@ -3125,7 +3125,6 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||||
old_current->lineno, openfile->edittop->lineno);
|
old_current->lineno, openfile->edittop->lineno);
|
||||||
#endif
|
#endif
|
||||||
filestruct *old_edittop = openfile->edittop;
|
filestruct *old_edittop = openfile->edittop;
|
||||||
ssize_t nlines;
|
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* If the mark is on, update all the lines between old_current
|
/* If the mark is on, update all the lines between old_current
|
||||||
|
|
Loading…
Reference in New Issue