Subject: bug#17187: 24.3.50.1 open-dribble-file stores pw

From: Glenn Morris <[email-masked]>
Date: Sat, 05 Apr 2014 19:01:40 -0400

Lightly tested:

*** src/keyboard.c	2014-04-05 18:33:55 +0000
--- src/keyboard.c	2014-04-05 22:59:00 +0000
***************
*** 20,25 ****
--- 20,26 ----
  #include <config.h>
  
  #include "sysstdio.h"
+ #include <sys/stat.h>
  
  #include "lisp.h"
  #include "termchar.h"
***************
*** 10085,10092 ****
      }
    if (!NILP (file))
      {
        file = Fexpand_file_name (file, Qnil);
!       dribble = emacs_fopen (SSDATA (file), "w");
        if (dribble == 0)
  	report_file_error ("Opening dribble", file);
      }
--- 10086,10100 ----
      }
    if (!NILP (file))
      {
+       int fd;
        file = Fexpand_file_name (file, Qnil);
!       if (! NILP (Ffile_exists_p (file)))
!         {
!           if (chmod (SSDATA (file), 0600) < 0)
!             report_file_error ("Doing chmod", file);
!         }
!       fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_TRUNC, 0600);
!       dribble = fd < 0 ? 0 : fdopen (fd, "w");
        if (dribble == 0)
  	report_file_error ("Opening dribble", file);
      }