in do_writeout(), for consistency, when saving a file with no name,
don't allow overwriting an existing file when in restricted mode git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3937 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
4967eb8fc0
commit
8965af5874
|
@ -1,6 +1,11 @@
|
||||||
CVS code -
|
CVS code -
|
||||||
- General:
|
- General:
|
||||||
- Miscellaneous comment fixes. (DLR)
|
- Miscellaneous comment fixes. (DLR)
|
||||||
|
- files.c:
|
||||||
|
do_writeout()
|
||||||
|
- For consistency, when saving a file with no name, don't
|
||||||
|
allow overwriting an existing file when in restricted
|
||||||
|
mode. (DLR)
|
||||||
|
|
||||||
GNU nano 2.0.0 - 2006.11.06
|
GNU nano 2.0.0 - 2006.11.06
|
||||||
- General:
|
- General:
|
||||||
|
|
12
src/files.c
12
src/files.c
|
@ -1874,10 +1874,22 @@ int do_writeout(bool exiting)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(answer, &st) != -1) {
|
if (stat(answer, &st) != -1) {
|
||||||
|
/* If we're using restricted mode, we aren't allowed
|
||||||
|
* to save a new file under the name of an existing
|
||||||
|
* file. In this case, show a "File exists"
|
||||||
|
* error. */
|
||||||
|
if (!ISSET(RESTRICTED)) {
|
||||||
i = do_yesno_prompt(FALSE,
|
i = do_yesno_prompt(FALSE,
|
||||||
_("File exists, OVERWRITE ? "));
|
_("File exists, OVERWRITE ? "));
|
||||||
if (i == 0 || i == -1)
|
if (i == 0 || i == -1)
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
errno = EEXIST;
|
||||||
|
statusbar(_("Error writing %s: %s"), answer,
|
||||||
|
strerror(errno));
|
||||||
|
retval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* If we're using restricted mode, we aren't allowed to
|
/* If we're using restricted mode, we aren't allowed to
|
||||||
* change the name of a file once it has one, because
|
* change the name of a file once it has one, because
|
||||||
* that would allow reading from or writing to files not
|
* that would allow reading from or writing to files not
|
||||||
|
|
Loading…
Reference in New Issue