in do_rcfile(), check for the rcfile's being a directory or device file
and reject it if it is, for consistency with file handling elsewhere; also remove SYSCONFDIR #ifdef, as SYSCONFDIR should always be set git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3369 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
4d72de73b1
Коммит
5fac171c8b
@ -49,6 +49,12 @@ CVS code -
|
|||||||
- Simplify the routine for closing the file just before we
|
- Simplify the routine for closing the file just before we
|
||||||
indicate success on the statusbar. (DLR)
|
indicate success on the statusbar. (DLR)
|
||||||
- rcfile.c:
|
- rcfile.c:
|
||||||
|
do_rcfile()
|
||||||
|
- Check for the rcfile's being a directory or device file and
|
||||||
|
reject it if it is, for consistency with file handling
|
||||||
|
elsewhere. (DLR)
|
||||||
|
- Remove SYSCONFDIR #ifdef, as SYSCONFDIR should always be set.
|
||||||
|
(DLR)
|
||||||
parse_argument()
|
parse_argument()
|
||||||
- Rename variable ptr_bak to ptr_save, for consistency. (DLR)
|
- Rename variable ptr_bak to ptr_save, for consistency. (DLR)
|
||||||
- doc/nano.1, doc/nanorc.5, doc/rnano.1, doc/nano.texi:
|
- doc/nano.1, doc/nanorc.5, doc/rnano.1, doc/nano.texi:
|
||||||
|
25
src/rcfile.c
25
src/rcfile.c
@ -756,15 +756,24 @@ void parse_rcfile(FILE *rcstream)
|
|||||||
* followed by the local rcfile. */
|
* followed by the local rcfile. */
|
||||||
void do_rcfile(void)
|
void do_rcfile(void)
|
||||||
{
|
{
|
||||||
|
struct stat rcinfo;
|
||||||
FILE *rcstream;
|
FILE *rcstream;
|
||||||
|
|
||||||
#ifdef SYSCONFDIR
|
|
||||||
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
|
||||||
|
|
||||||
|
/* Don't open directories, character files, or block files. */
|
||||||
|
if (stat(nanorc, &rcinfo) != -1) {
|
||||||
|
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
|
||||||
|
S_ISBLK(rcinfo.st_mode))
|
||||||
|
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
|
||||||
|
_("\"%s\" is a directory") :
|
||||||
|
_("\"%s\" is a device file"), nanorc);
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to open the system-wide nanorc. */
|
/* Try to open the system-wide nanorc. */
|
||||||
rcstream = fopen(nanorc, "rb");
|
rcstream = fopen(nanorc, "rb");
|
||||||
if (rcstream != NULL)
|
if (rcstream != NULL)
|
||||||
parse_rcfile(rcstream);
|
parse_rcfile(rcstream);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
|
#if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
|
||||||
/* We've already read SYSCONFDIR/nanorc, if it's there. If we're
|
/* We've already read SYSCONFDIR/nanorc, if it's there. If we're
|
||||||
@ -781,8 +790,18 @@ void do_rcfile(void)
|
|||||||
else {
|
else {
|
||||||
nanorc = charealloc(nanorc, strlen(homedir) + 9);
|
nanorc = charealloc(nanorc, strlen(homedir) + 9);
|
||||||
sprintf(nanorc, "%s/.nanorc", homedir);
|
sprintf(nanorc, "%s/.nanorc", homedir);
|
||||||
rcstream = fopen(nanorc, "rb");
|
|
||||||
|
|
||||||
|
/* Don't open directories, character files, or block files. */
|
||||||
|
if (stat(nanorc, &rcinfo) != -1) {
|
||||||
|
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
|
||||||
|
S_ISBLK(rcinfo.st_mode))
|
||||||
|
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
|
||||||
|
_("\"%s\" is a directory") :
|
||||||
|
_("\"%s\" is a device file"), nanorc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to open the current user's nanorc. */
|
||||||
|
rcstream = fopen(nanorc, "rb");
|
||||||
if (rcstream == NULL) {
|
if (rcstream == NULL) {
|
||||||
/* Don't complain about the file's not existing. */
|
/* Don't complain about the file's not existing. */
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user