]> granicus.if.org Git - mutt/commitdiff
As you all know, running "mutt -F foo.rc" will have mutt read foo.rc
authorMike Schiraldi <1074468571@schiraldi.org>
Sun, 1 Feb 2004 18:00:16 +0000 (18:00 +0000)
committerMike Schiraldi <1074468571@schiraldi.org>
Sun, 1 Feb 2004 18:00:16 +0000 (18:00 +0000)
as its config file. However, there is a bug -- if you specify a
directory (like accidentally typing "mutt -F /etc/mutt") mutt will
silently ignore the flag and leave you wondering why it isn't
working.

Emil Sit posted a patch for this in March of 2002, but it seems to
have slipped through the cracks. Here's the patch again; please
consider it for inclusion.

init.c

diff --git a/init.c b/init.c
index db636b4a9631b993ad6e8af4fbb43b51906965de..80ef6ee71c5b3ba90858628c65b3b482e0712ec6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1368,6 +1368,18 @@ static int source_rc (const char *rcfile, BUFFER *err)
   char *linebuf = NULL;
   size_t buflen;
   pid_t pid;
+  struct stat s;
+
+  if (stat (rcfile, &s) < 0)
+  {
+    snprintf (err->data, err->dsize, _("%s: stat: %s"), rcfile, strerror (errno));
+    return (-1);
+  }
+  if (!S_ISREG (s.st_mode))
+  {
+    snprintf (err->data, err->dsize, _("%s: not a regular file"), rcfile);
+    return (-1);
+  }
 
   if ((f = mutt_open_read (rcfile, &pid)) == NULL)
   {