diff options
Diffstat (limited to 'sm/server.c')
-rw-r--r-- | sm/server.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/sm/server.c b/sm/server.c index 934d3764d..3e012f1e6 100644 --- a/sm/server.c +++ b/sm/server.c @@ -43,7 +43,7 @@ static FILE *statusfp; /* Data used to assuciate an Assuan context with local server data */ struct server_local_s { assuan_context_t assuan_ctx; - int message_fd; + estream_t message_fp; int list_internal; int list_external; int list_to_output; /* Write keylistings to the output fd. */ @@ -130,12 +130,12 @@ data_line_cookie_close (void *cookie) static void -close_message_fd (ctrl_t ctrl) +close_message_fp (ctrl_t ctrl) { - if (ctrl->server_local->message_fd != -1) + if (ctrl->server_local->message_fp) { - close (ctrl->server_local->message_fd); - ctrl->server_local->message_fd = -1; + es_fclose (ctrl->server_local->message_fp); + ctrl->server_local->message_fp = NULL; } } @@ -320,7 +320,7 @@ reset_notify (assuan_context_t ctx, char *line) gpgsm_release_certlist (ctrl->server_local->signerlist); ctrl->server_local->recplist = NULL; ctrl->server_local->signerlist = NULL; - close_message_fd (ctrl); + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); return 0; @@ -489,8 +489,8 @@ cmd_encrypt (assuan_context_t ctx, char *line) gpgsm_release_certlist (ctrl->server_local->recplist); ctrl->server_local->recplist = NULL; - /* Close and reset the fd */ - close_message_fd (ctrl); + /* Close and reset the fp and the fds */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); return rc; @@ -533,7 +533,7 @@ cmd_decrypt (assuan_context_t ctx, char *line) es_fclose (out_fp); /* Close and reset the fds. */ - close_message_fd (ctrl); + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -574,11 +574,11 @@ cmd_verify (assuan_context_t ctx, char *line) rc = start_audit_session (ctrl); if (!rc) rc = gpgsm_verify (assuan_get_pointer (ctx), fd, - ctrl->server_local->message_fd, out_fp); + ctrl->server_local->message_fp, out_fp); es_fclose (out_fp); - /* Close and reset the fd. */ - close_message_fd (ctrl); + /* Close and reset the fp and the fd. */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -621,8 +621,8 @@ cmd_sign (assuan_context_t ctx, char *line) inp_fd, detached, out_fp); es_fclose (out_fp); - /* close and reset the fd */ - close_message_fd (ctrl); + /* close and reset the fp and the fds */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -657,8 +657,8 @@ cmd_import (assuan_context_t ctx, char *line) rc = gpgsm_import (assuan_get_pointer (ctx), fd, reimport); - /* close and reset the fd */ - close_message_fd (ctrl); + /* close and reset the fp and the fds */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -783,8 +783,8 @@ cmd_export (assuan_context_t ctx, char *line) } free_strlist (list); - /* Close and reset the fds. */ - close_message_fd (ctrl); + /* Close and reset the fp and the fds. */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); return 0; @@ -832,8 +832,8 @@ cmd_delkeys (assuan_context_t ctx, char *line) rc = gpgsm_delete (ctrl, list); free_strlist (list); - /* close and reset the fd */ - close_message_fd (ctrl); + /* close and reset the fp and the fds */ + close_message_fp (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); @@ -867,19 +867,18 @@ static gpg_error_t cmd_message (assuan_context_t ctx, char *line) { int rc; - gnupg_fd_t sysfd; - int fd; + gnupg_fd_t fd; + estream_t fp; ctrl_t ctrl = assuan_get_pointer (ctx); - rc = assuan_command_parse_fd (ctx, line, &sysfd); + rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) return rc; - - fd = translate_sys2libc_fd (sysfd, 0); - if (fd == -1) + fp = open_stream_nc (fd, "rb"); + if (!fp) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - ctrl->server_local->message_fd = fd; + ctrl->server_local->message_fp = fp; return 0; } @@ -1425,7 +1424,7 @@ gpgsm_server (certlist_t default_recplist) assuan_set_pointer (ctx, &ctrl); ctrl.server_local = xcalloc (1, sizeof *ctrl.server_local); ctrl.server_local->assuan_ctx = ctx; - ctrl.server_local->message_fd = -1; + ctrl.server_local->message_fp = NULL; ctrl.server_local->list_internal = 1; ctrl.server_local->list_external = 0; ctrl.server_local->default_recplist = default_recplist; |