2010-05-23 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Don't even try to chown() the backup file unless we're root, since it's probably going to fail if we're editing a file we don't own. Fixes Savannah bug 29514: [nano 2.2.2] backup should ignore chown errors. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4507 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
0dcfa1d7f7
commit
86be3af75f
|
@ -1,3 +1,9 @@
|
||||||
|
2010-05-23 Chris Allegretta <chrisa@asty.org>
|
||||||
|
* files.c (write_file): Don't even try to chown() the backup
|
||||||
|
file unless we're root, since it's probably going to fail if
|
||||||
|
we're editing a file we don't own. Fixes Savannah bug
|
||||||
|
29514: [nano 2.2.2] backup should ignore chown errors.
|
||||||
|
|
||||||
GNU nano 2.2.4 - 2010.04.15
|
GNU nano 2.2.4 - 2010.04.15
|
||||||
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
||||||
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
|
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
|
||||||
|
|
15
src/files.c
15
src/files.c
|
@ -1612,9 +1612,18 @@ 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 ||
|
/* We shouldn't worry about chown()ing something if we're not
|
||||||
fchown(backup_fd, openfile->current_stat->st_uid,
|
root, since it's likely to fail! */
|
||||||
openfile->current_stat->st_gid) == -1 ) {
|
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
||||||
|
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1 ) {
|
||||||
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
|
strerror(errno));
|
||||||
|
free(backupname);
|
||||||
|
fclose(backup_file);
|
||||||
|
goto cleanup_and_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1) {
|
||||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(backupname);
|
free(backupname);
|
||||||
|
|
Loading…
Reference in New Issue