summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2014-04-10 22:47:32 -0700
committerGlenn Morris <rgm@gnu.org>2014-04-10 22:47:32 -0700
commit34e083e3608c39f4c0cc71354eda8553230b3acc (patch)
tree9ddc09bd917c88a2bcf7b3c4617298349aa93cce
parent20f39add49aee6b55778edd4dc3aa86516928e8d (diff)
downloademacs-34e083e3608c39f4c0cc71354eda8553230b3acc.tar.gz
* src/keyboard.c (Fopen_dribble_file): Make file private.
Fixes: debbugs:17187
-rw-r--r--src/ChangeLog4
-rw-r--r--src/keyboard.c13
2 files changed, 16 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e2c925f03d3..9d59ab1c97c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-11 Glenn Morris <rgm@gnu.org>
+
+ * keyboard.c (Fopen_dribble_file): Make file private. (Bug#17187)
+
2014-04-09 Ken Brown <kbrown@cornell.edu>
* Makefile.in (EMACS_MANIFEST): Revert last change.
diff --git a/src/keyboard.c b/src/keyboard.c
index 3b50140684e..f74ba0ee581 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "sysstdio.h"
+#include <sys/stat.h>
#include "lisp.h"
#include "termchar.h"
@@ -10085,8 +10086,18 @@ This may include sensitive information such as passwords. */)
}
if (!NILP (file))
{
+ int fd;
file = Fexpand_file_name (file, Qnil);
- dribble = emacs_fopen (SSDATA (file), "w");
+ /* This isn't robust, since eg file could be created after we
+ check whether it exists but before emacs_open.
+ Feel free to improve it, but this is not critical. (Bug#17187) */
+ 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);
}