summaryrefslogtreecommitdiffstats
path: root/assuan
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2001-12-14 20:35:56 +0100
committerWerner Koch <wk@gnupg.org>2001-12-14 20:35:56 +0100
commit8cd7e2ab8d81aa432c236aee64c9f6cb02bc0c20 (patch)
tree62d92dfc604ae6b663b1e7a4c524906521d97864 /assuan
parent* gpgsm.c (main): New option --debug-wait n, so that it is (diff)
downloadgnupg2-8cd7e2ab8d81aa432c236aee64c9f6cb02bc0c20.tar.xz
gnupg2-8cd7e2ab8d81aa432c236aee64c9f6cb02bc0c20.zip
* assuan-listen.c (assuan_close_input_fd): New.
(assuan_close_output_fd): New. * assuan-handler.c (std_handler_reset): Always close them after a reset command. (std_handler_bye): Likewise.
Diffstat (limited to 'assuan')
-rw-r--r--assuan/ChangeLog8
-rw-r--r--assuan/assuan-handler.c4
-rw-r--r--assuan/assuan-listen.c26
-rw-r--r--assuan/assuan.h2
4 files changed, 40 insertions, 0 deletions
diff --git a/assuan/ChangeLog b/assuan/ChangeLog
index 5ccba926d..f85e22042 100644
--- a/assuan/ChangeLog
+++ b/assuan/ChangeLog
@@ -1,3 +1,11 @@
+2001-12-14 Werner Koch <wk@gnupg.org>
+
+ * assuan-listen.c (assuan_close_input_fd): New.
+ (assuan_close_output_fd): New.
+ * assuan-handler.c (std_handler_reset): Always close them after a
+ reset command.
+ (std_handler_bye): Likewise.
+
2001-12-14 Marcus Brinkmann <marcus@g10code.de>
* assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use
diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c
index 8ec8b2301..a82bd5379 100644
--- a/assuan/assuan-handler.c
+++ b/assuan/assuan-handler.c
@@ -54,6 +54,8 @@ std_handler_bye (ASSUAN_CONTEXT ctx, char *line)
{
if (ctx->bye_notify_fnc)
ctx->bye_notify_fnc (ctx);
+ assuan_close_input_fd (ctx);
+ assuan_close_output_fd (ctx);
return -1; /* pretty simple :-) */
}
@@ -68,6 +70,8 @@ std_handler_reset (ASSUAN_CONTEXT ctx, char *line)
{
if (ctx->reset_notify_fnc)
ctx->reset_notify_fnc (ctx);
+ assuan_close_input_fd (ctx);
+ assuan_close_output_fd (ctx);
return 0;
}
diff --git a/assuan/assuan-listen.c b/assuan/assuan-listen.c
index 822ef32cd..57fe4b669 100644
--- a/assuan/assuan-listen.c
+++ b/assuan/assuan-listen.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include "assuan-defs.h"
@@ -106,3 +107,28 @@ assuan_get_output_fd (ASSUAN_CONTEXT ctx)
}
+/* Close the fd descriptor set by the command INPUT FD=n. We handle
+ this fd inside assuan so that we can do some initial checks */
+AssuanError
+assuan_close_input_fd (ASSUAN_CONTEXT ctx)
+{
+ if (!ctx || ctx->input_fd == -1)
+ return ASSUAN_Invalid_Value;
+ close (ctx->input_fd);
+ ctx->input_fd = -1;
+ return 0;
+}
+
+/* Close the fd descriptor set by the command OUTPUT FD=n. We handle
+ this fd inside assuan so that we can do some initial checks */
+AssuanError
+assuan_close_output_fd (ASSUAN_CONTEXT ctx)
+{
+ if (!ctx || ctx->output_fd == -1)
+ return ASSUAN_Invalid_Value;
+
+ close (ctx->output_fd);
+ ctx->output_fd = -1;
+ return 0;
+}
+
diff --git a/assuan/assuan.h b/assuan/assuan.h
index 485ad2225..a4f887f6f 100644
--- a/assuan/assuan.h
+++ b/assuan/assuan.h
@@ -136,6 +136,8 @@ AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line);
AssuanError assuan_accept (ASSUAN_CONTEXT ctx);
int assuan_get_input_fd (ASSUAN_CONTEXT ctx);
int assuan_get_output_fd (ASSUAN_CONTEXT ctx);
+AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx);
+AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx);
/*-- assuan-pipe-server.c --*/