summaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-08-22 22:36:33 +0200
committerWerner Koch <wk@gnupg.org>2007-08-22 22:36:33 +0200
commit84efbe69c7452fc4fce5f84b5adc4f770aa7613a (patch)
treef20057c44d67c70925afcee9f0fd9f0ab53e744b /agent
parentUpdated estream. (diff)
downloadgnupg2-84efbe69c7452fc4fce5f84b5adc4f770aa7613a.tar.xz
gnupg2-84efbe69c7452fc4fce5f84b5adc4f770aa7613a.zip
Fixed creation of private keys under W32.
Minor code cleanups.
Diffstat (limited to 'agent')
-rw-r--r--agent/ChangeLog3
-rw-r--r--agent/findkey.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 78b4871bb..4c7df8b6d 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,5 +1,8 @@
2007-08-22 Werner Koch <wk@g10code.com>
+ * findkey.c (O_BINARY): Make sure it is defined.
+ (agent_write_private_key): Use O_BINARY
+
* protect-tool.c (import_p12_file): Add hack to allow importing of
gnupg 2.0.4 generated files.
diff --git a/agent/findkey.c b/agent/findkey.c
index 35254c433..d8dc52696 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -32,6 +32,10 @@
#include "agent.h"
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
/* Helper to pass data to the check callback of the unprotect function. */
struct try_unprotect_arg_s {
const unsigned char *protected_key;
@@ -70,8 +74,8 @@ agent_write_private_key (const unsigned char *grip,
POSIX (GNU provides the "x" opentype for fopen, however, this is
not portable). Thus, we use the more flexible open function and
then use fdopen to obtain a stream. */
- fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY)
- : (O_CREAT | O_EXCL | O_WRONLY),
+ fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY | O_BINARY)
+ : (O_CREAT | O_EXCL | O_WRONLY | O_BINARY),
S_IRUSR | S_IWUSR
#ifndef HAVE_W32_SYSTEM
| S_IRGRP