From cvs at cvs.gnupg.org Mon Nov 2 18:06:15 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 02 Nov 2009 18:06:15 +0100 Subject: [svn] gpgme - r1411 - trunk/src Message-ID: Author: marcus Date: 2009-11-02 18:06:14 +0100 (Mon, 02 Nov 2009) New Revision: 1411 Modified: trunk/src/ChangeLog trunk/src/opassuan.c Log: 2009-11-02 Marcus Brinkmann * opassuan.c (gpgme_op_assuan_transact): Fix return value. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-10-30 14:21:08 UTC (rev 1410) +++ trunk/src/ChangeLog 2009-11-02 17:06:14 UTC (rev 1411) @@ -1,3 +1,7 @@ +2009-11-02 Marcus Brinkmann + + * opassuan.c (gpgme_op_assuan_transact): Fix return value. + 2009-10-30 Marcus Brinkmann * Makefile.am (noinst_PROGRAMS): New target gpgme-tool. Modified: trunk/src/opassuan.c =================================================================== --- trunk/src/opassuan.c 2009-10-30 14:21:08 UTC (rev 1410) +++ trunk/src/opassuan.c 2009-11-02 17:06:14 UTC (rev 1411) @@ -197,9 +197,9 @@ /* Users of the old-style session based interfaces need to look at the result structure. */ - gpgme_op_assuan_transact_ext (ctx, command, data_cb, data_cb_value, - inq_cb, inq_cb_value, - status_cb, status_cb_value, NULL); + err = gpgme_op_assuan_transact_ext (ctx, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, + status_cb, status_cb_value, NULL); - return err; + return TRACE_ERR (err); } From cvs at cvs.gnupg.org Mon Nov 2 18:18:48 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 02 Nov 2009 18:18:48 +0100 Subject: [svn] gpgme - r1412 - trunk/src Message-ID: Author: marcus Date: 2009-11-02 18:18:48 +0100 (Mon, 02 Nov 2009) New Revision: 1412 Modified: trunk/src/ChangeLog trunk/src/debug.c trunk/src/debug.h trunk/src/decrypt.c trunk/src/gpgme-tool.c trunk/src/opassuan.c Log: 2009-11-02 Marcus Brinkmann * debug.h (_gpgme_debug_buffer): Make TAG argument const const. * debug.c (_gpgme_debug_buffer): Likewise. * gpgme-tool.c (input_notify, output_notify): Adjust type to new assuan interface. * decrypt.c (gpgme_op_decrypt_result): Remove unused variable. * opassuan.c (gpgme_op_assuan_transact): Fix return value. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/ChangeLog 2009-11-02 17:18:48 UTC (rev 1412) @@ -1,5 +1,10 @@ 2009-11-02 Marcus Brinkmann + * debug.h (_gpgme_debug_buffer): Make TAG argument const const. + * debug.c (_gpgme_debug_buffer): Likewise. + * gpgme-tool.c (input_notify, output_notify): Adjust type to new + assuan interface. + * decrypt.c (gpgme_op_decrypt_result): Remove unused variable. * opassuan.c (gpgme_op_assuan_transact): Fix return value. 2009-10-30 Marcus Brinkmann Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/debug.c 2009-11-02 17:18:48 UTC (rev 1412) @@ -266,7 +266,8 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, const char *const func, const char *const tagname, - void *tag, const char *const buffer, size_t len) + const void *const tag, const char *const buffer, + size_t len) { int idx = 0; int j; Modified: trunk/src/debug.h =================================================================== --- trunk/src/debug.h 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/debug.h 2009-11-02 17:18:48 UTC (rev 1412) @@ -73,7 +73,8 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, const char *const func, const char *const tagname, - void *tag, const char *const buffer, size_t len); + const void *const tag, const char *const buffer, + size_t len); /* Trace support. */ Modified: trunk/src/decrypt.c =================================================================== --- trunk/src/decrypt.c 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/decrypt.c 2009-11-02 17:18:48 UTC (rev 1412) @@ -88,7 +88,6 @@ if (_gpgme_debug_trace ()) { gpgme_recipient_t rcp; - int signatures = 0; if (opd->result.unsupported_algorithm) { Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/gpgme-tool.c 2009-11-02 17:18:48 UTC (rev 1412) @@ -1203,19 +1203,21 @@ } -static void -input_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +input_notify (assuan_context_t ctx, char *line) { struct server *server = assuan_get_pointer (ctx); server->input_enc = server_data_encoding (line); + return 0; } -static void -output_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +output_notify (assuan_context_t ctx, char *line) { struct server *server = assuan_get_pointer (ctx); server->output_enc = server_data_encoding (line); + return 0; } Modified: trunk/src/opassuan.c =================================================================== --- trunk/src/opassuan.c 2009-11-02 17:06:14 UTC (rev 1411) +++ trunk/src/opassuan.c 2009-11-02 17:18:48 UTC (rev 1412) @@ -200,6 +200,5 @@ err = gpgme_op_assuan_transact_ext (ctx, command, data_cb, data_cb_value, inq_cb, inq_cb_value, status_cb, status_cb_value, NULL); - - return TRACE_ERR (err); + return err; } From cvs at cvs.gnupg.org Mon Nov 2 18:33:53 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 02 Nov 2009 18:33:53 +0100 Subject: [svn] assuan - r313 - in trunk: . src Message-ID: Author: marcus Date: 2009-11-02 18:33:53 +0100 (Mon, 02 Nov 2009) New Revision: 313 Modified: trunk/NEWS trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan.h Log: 2009-11-02 Marcus Brinkmann * assuan.h (assuan_handler_t): New type. (assuan_register_bye_notify, assuan_register_reset_notify) (assuan_register_cancel_notify, assuan_register_input_notify) (assuan_register_output_notify, assuan_register_command): Use it. * assuan-handler.c (std_handler_cancel, std_handler_bye): Pass LINE argument to user handler. (std_handler_reset): Likewise, and also abort RESET if error is returned from user handler. (std_handler_input, std_handler_output): Check return value from user handler before assigning FD. * assuan-defs.h (struct cmdtbl_s): Change type of member HANDLER to assuan_handler_t. (struct assuan_context_s): Change type of members RESET_NOTIFY_FNC, CANCEL_NOTIFY_FNC, BYE_NOTIFY_FNC, INPUT_NOTIFY_FNC and OUTPUT_NOTIFY_FNC to assuan_handler_t. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-10-30 14:13:22 UTC (rev 312) +++ trunk/src/ChangeLog 2009-11-02 17:33:53 UTC (rev 313) @@ -1,3 +1,21 @@ +2009-11-02 Marcus Brinkmann + + * assuan.h (assuan_handler_t): New type. + (assuan_register_bye_notify, assuan_register_reset_notify) + (assuan_register_cancel_notify, assuan_register_input_notify) + (assuan_register_output_notify, assuan_register_command): Use it. + * assuan-handler.c (std_handler_cancel, std_handler_bye): Pass + LINE argument to user handler. + (std_handler_reset): Likewise, and also abort RESET if error is + returned from user handler. + (std_handler_input, std_handler_output): Check return value from + user handler before assigning FD. + * assuan-defs.h (struct cmdtbl_s): Change type of member HANDLER + to assuan_handler_t. + (struct assuan_context_s): Change type of members + RESET_NOTIFY_FNC, CANCEL_NOTIFY_FNC, BYE_NOTIFY_FNC, + INPUT_NOTIFY_FNC and OUTPUT_NOTIFY_FNC to assuan_handler_t. + 2009-10-30 Marcus Brinkmann * system.c (_assuan_spawn): Check fd_child_list before dumping it. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-10-30 14:13:22 UTC (rev 312) +++ trunk/NEWS 2009-11-02 17:33:53 UTC (rev 313) @@ -67,6 +67,12 @@ ASSUAN_SYSTEM_PTH NEW assuan_sock_init NEW assuan_sock_deinit NEW +assuan_handler_t NEW +assuan_register_bye_notify CHANGED: Handler gets line and returns err now. +assuan_register_reset_notify CHANGED: Handler gets line and returns err now. +assuan_register_cancel_notify CHANGED: Handler gets line and returns err now. +assuan_register_input_notify CHANGED: Handler returns error now. +assuan_register_output_notify CHANGED: Handler returns error now. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-10-30 14:13:22 UTC (rev 312) +++ trunk/src/assuan-defs.h 2009-11-02 17:33:53 UTC (rev 313) @@ -52,7 +52,7 @@ struct cmdtbl_s { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; }; @@ -206,12 +206,12 @@ handler. */ const char *current_cmd_name; - void (*bye_notify_fnc)(assuan_context_t); - void (*reset_notify_fnc)(assuan_context_t); - void (*cancel_notify_fnc)(assuan_context_t); + assuan_handler_t bye_notify_fnc; + assuan_handler_t reset_notify_fnc; + assuan_handler_t cancel_notify_fnc; gpg_error_t (*option_handler_fnc)(assuan_context_t,const char*, const char*); - void (*input_notify_fnc)(assuan_context_t, const char *); - void (*output_notify_fnc)(assuan_context_t, const char *); + assuan_handler_t input_notify_fnc; + assuan_handler_t output_notify_fnc; /* This function is called right after a command has been processed. It may be used to command related cleanup. */ Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-10-30 14:13:22 UTC (rev 312) +++ trunk/src/assuan-handler.c 2009-11-02 17:33:53 UTC (rev 313) @@ -58,7 +58,8 @@ std_handler_cancel (assuan_context_t ctx, char *line) { if (ctx->cancel_notify_fnc) - ctx->cancel_notify_fnc (ctx); + /* Return value ignored. */ + ctx->cancel_notify_fnc (ctx, line); return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, NULL)); } @@ -119,7 +120,8 @@ std_handler_bye (assuan_context_t ctx, char *line) { if (ctx->bye_notify_fnc) - ctx->bye_notify_fnc (ctx); + /* Return value ignored. */ + ctx->bye_notify_fnc (ctx, line); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); /* pretty simple :-) */ @@ -135,12 +137,17 @@ static gpg_error_t std_handler_reset (assuan_context_t ctx, char *line) { + gpg_error_t err = 0; + if (ctx->reset_notify_fnc) - ctx->reset_notify_fnc (ctx); - assuan_close_input_fd (ctx); - assuan_close_output_fd (ctx); - _assuan_uds_close_fds (ctx); - return PROCESS_DONE (ctx, 0); + err = ctx->reset_notify_fnc (ctx, line); + if (! err) + { + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); + _assuan_uds_close_fds (ctx); + } + return PROCESS_DONE (ctx, err); } static gpg_error_t @@ -213,10 +220,11 @@ rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) return PROCESS_DONE (ctx, rc); - ctx->input_fd = fd; if (ctx->input_notify_fnc) - ctx->input_notify_fnc (ctx, line); - return PROCESS_DONE (ctx, 0); + rc = ctx->input_notify_fnc (ctx, line); + if (! rc) + ctx->input_fd = fd; + return PROCESS_DONE (ctx, rc); } @@ -230,10 +238,11 @@ rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) return PROCESS_DONE (ctx, rc); - ctx->output_fd = fd; if (ctx->output_notify_fnc) - ctx->output_notify_fnc (ctx, line); - return PROCESS_DONE (ctx, 0); + rc = ctx->output_notify_fnc (ctx, line); + if (!rc) + ctx->output_fd = fd; + return PROCESS_DONE (ctx, rc); } @@ -274,9 +283,8 @@ * Return value: 0 on success or an error code **/ gpg_error_t -assuan_register_command (assuan_context_t ctx, - const char *cmd_name, - gpg_error_t (*handler)(assuan_context_t, char *)) +assuan_register_command (assuan_context_t ctx, const char *cmd_name, + assuan_handler_t handler) { int i; const char *s; @@ -349,8 +357,7 @@ } gpg_error_t -assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) +assuan_register_bye_notify (assuan_context_t ctx, assuan_handler_t fnc) { if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); @@ -359,8 +366,7 @@ } gpg_error_t -assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) +assuan_register_reset_notify (assuan_context_t ctx, assuan_handler_t fnc) { if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); @@ -369,8 +375,7 @@ } gpg_error_t -assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)) +assuan_register_cancel_notify (assuan_context_t ctx, assuan_handler_t fnc) { if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); @@ -390,8 +395,7 @@ } gpg_error_t -assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)) +assuan_register_input_notify (assuan_context_t ctx, assuan_handler_t fnc) { if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); @@ -400,8 +404,7 @@ } gpg_error_t -assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)) +assuan_register_output_notify (assuan_context_t ctx, assuan_handler_t fnc) { if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-10-30 14:13:22 UTC (rev 312) +++ trunk/src/assuan.h 2009-11-02 17:33:53 UTC (rev 313) @@ -300,22 +300,24 @@ void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); +typedef gpg_error_t (*assuan_handler_t) (assuan_context_t, char *); + /*-- assuan-handler.c --*/ gpg_error_t assuan_register_command (assuan_context_t ctx, const char *cmd_string, - gpg_error_t (*handler)(assuan_context_t, char *)); + assuan_handler_t handler); gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx, void (*fnc)(assuan_context_t, gpg_error_t)); gpg_error_t assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); + assuan_handler_t handler); gpg_error_t assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); + assuan_handler_t handler); gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); + assuan_handler_t handler); gpg_error_t assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); + assuan_handler_t handler); gpg_error_t assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); + assuan_handler_t handler); gpg_error_t assuan_register_option_handler (assuan_context_t ctx, gpg_error_t (*fnc)(assuan_context_t, From cvs at cvs.gnupg.org Mon Nov 2 18:34:41 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 02 Nov 2009 18:34:41 +0100 Subject: [svn] dirmngr - r328 - trunk/src Message-ID: Author: marcus Date: 2009-11-02 18:34:41 +0100 (Mon, 02 Nov 2009) New Revision: 328 Modified: trunk/src/ChangeLog trunk/src/server.c Log: 2009-11-02 Marcus Brinkmann * server.c (reset_notify): Take LINE argument, return gpg_error_t. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-10-16 18:27:13 UTC (rev 327) +++ trunk/src/ChangeLog 2009-11-02 17:34:41 UTC (rev 328) @@ -1,3 +1,7 @@ +2009-11-02 Marcus Brinkmann + + * server.c (reset_notify): Take LINE argument, return gpg_error_t. + 2009-10-16 Marcus Brinkmann * Makefile.am: (dirmngr_LDADD): Link to $(LIBASSUAN_LIBS) instead Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2009-10-16 18:27:13 UTC (rev 327) +++ trunk/src/server.c 2009-11-02 17:34:41 UTC (rev 328) @@ -1314,13 +1314,14 @@ } -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); ldapserver_list_free (ctrl->server_local->ldapservers); ctrl->server_local->ldapservers = NULL; + return 0; } From cvs at cvs.gnupg.org Mon Nov 2 18:47:12 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 02 Nov 2009 18:47:12 +0100 Subject: [svn] GnuPG - r5188 - in trunk: agent common g10 g13 scd sm Message-ID: Author: marcus Date: 2009-11-02 18:47:11 +0100 (Mon, 02 Nov 2009) New Revision: 5188 Modified: trunk/agent/ChangeLog trunk/agent/command.c trunk/common/ChangeLog trunk/common/get-passphrase.c trunk/g10/ChangeLog trunk/g10/server.c trunk/g13/ChangeLog trunk/g13/server.c trunk/scd/ChangeLog trunk/scd/command.c trunk/sm/ChangeLog trunk/sm/call-agent.c trunk/sm/server.c Log: agent/ 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. (register_commands): Use assuan_handler_t type. common/ 2009-11-02 Marcus Brinkmann * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return type to gpg_error_t. g10/ 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to new assuan interface. (register_commands): Use assuan_handler_t. scd/ 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. (register_commands): Use assuan_handler_t type. sm/ 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to new assuan interface. (register_commands): Use assuan_handler_t. * call-agent.c (membuf_data_cb, default_inq_cb) (inq_ciphertext_cb, scd_serialno_status_cb) (scd_keypairinfo_status_cb, istrusted_status_cb) (learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/agent/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,8 @@ +2009-11-02 Marcus Brinkmann + + * command.c (reset_notify): Take LINE arg and return error. + (register_commands): Use assuan_handler_t type. + 2009-10-16 Marcus Brinkmann * gpg_agent_CFLAGS, gpg_agent_LDADD: Use libassuan instead of Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/common/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,8 @@ +2009-11-02 Marcus Brinkmann + + * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return + type to gpg_error_t. + 2009-10-28 Werner Koch * status.h (STATUS_MOUNTPOINT): New. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/g10/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,9 @@ +2009-11-02 Marcus Brinkmann + + * server.c (reset_notify, input_notify, output_notify): Update to + new assuan interface. + (register_commands): Use assuan_handler_t. + 2009-10-19 Werner Koch * options.h (glo_ctrl): Add field LASTERR. Modified: trunk/g13/ChangeLog =================================================================== --- trunk/g13/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/g13/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,2 @@ - Under initial development - no need for a ChangeLog. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/scd/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,8 @@ +2009-11-02 Marcus Brinkmann + + * command.c (reset_notify): Take LINE arg and return error. + (register_commands): Use assuan_handler_t type. + 2009-10-25 Werner Koch * scdaemon.c (scd_deinit_default_ctrl): Release IN_DATA. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/sm/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) @@ -1,3 +1,13 @@ +2009-11-02 Marcus Brinkmann + + * server.c (reset_notify, input_notify, output_notify): Update to + new assuan interface. + (register_commands): Use assuan_handler_t. + * call-agent.c (membuf_data_cb, default_inq_cb) + (inq_ciphertext_cb, scd_serialno_status_cb) + (scd_keypairinfo_status_cb, istrusted_status_cb) + (learn_status_cb, learn_cb, keyinfo_status_cb): Return gpg_error_t. + 2009-10-16 Werner Koch * gpgsm.c (default_include_certs): Change to -2. Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/agent/command.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -146,17 +146,20 @@ } -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void) line; + memset (ctrl->keygrip, 0, 20); ctrl->have_keygrip = 0; ctrl->digest.valuelen = 0; xfree (ctrl->server_local->keydesc); ctrl->server_local->keydesc = NULL; + return 0; } @@ -1823,7 +1826,7 @@ { static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; } table[] = { { "GETEVENTCOUNTER",cmd_geteventcounter }, { "ISTRUSTED", cmd_istrusted }, Modified: trunk/common/get-passphrase.c =================================================================== --- trunk/common/get-passphrase.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/common/get-passphrase.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -103,7 +103,7 @@ /* This is the default inquiry callback. It merely handles the Pinentry notification. */ -static int +static gpg_error_t default_inq_cb (void *opaque, const char *line) { (void)opaque; @@ -120,7 +120,7 @@ } -static int +static gpg_error_t membuf_data_cb (void *opaque, const void *buffer, size_t length) { membuf_t *data = opaque; Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/g10/server.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -144,23 +144,26 @@ /* Called by libassuan for RESET commands. */ -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void)line; + release_pk_list (ctrl->server_local->recplist); ctrl->server_local->recplist = NULL; close_message_fd (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); + return 0; } /* Called by libassuan for INPUT commands. */ -static void -input_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +input_notify (assuan_context_t ctx, char *line) { /* ctrl_t ctrl = assuan_get_pointer (ctx); */ @@ -176,12 +179,13 @@ { /* FIXME (autodetect encoding) */ } + return 0; } /* Called by libassuan for OUTPUT commands. */ -static void -output_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +output_notify (assuan_context_t ctx, char *line) { /* ctrl_t ctrl = assuan_get_pointer (ctx); */ @@ -193,6 +197,7 @@ { /* FIXME */ } + return 0; } @@ -605,7 +610,7 @@ static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; } table[] = { { "RECIPIENT", cmd_recipient }, { "SIGNER", cmd_signer }, Modified: trunk/g13/server.c =================================================================== --- trunk/g13/server.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/g13/server.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -184,11 +184,13 @@ /* The handler for an Assuan RESET command. */ -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void)line; + xfree (ctrl->server_local->containername); ctrl->server_local->containername = NULL; @@ -196,6 +198,7 @@ assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); + return 0; } @@ -539,7 +542,7 @@ { static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; } table[] = { { "OPEN", cmd_open }, { "MOUNT", cmd_mount }, @@ -655,7 +658,7 @@ log_info ("Assuan accept problem: %s\n", gpg_strerror (err)); leave: - reset_notify (ctx); /* Release all items hold by SERVER_LOCAL. */ + reset_notify (ctx, NULL); /* Release all items hold by SERVER_LOCAL. */ if (ctrl->server_local) { xfree (ctrl->server_local); Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/scd/command.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -338,12 +338,15 @@ } -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void) line; + do_reset (ctrl, 1); + return 0; } @@ -1843,7 +1846,7 @@ { static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; } table[] = { { "SERIALNO", cmd_serialno }, { "LEARN", cmd_learn }, Modified: trunk/sm/call-agent.c =================================================================== --- trunk/sm/call-agent.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/sm/call-agent.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -111,7 +111,7 @@ -static int +static gpg_error_t membuf_data_cb (void *opaque, const void *buffer, size_t length) { membuf_t *data = opaque; @@ -124,7 +124,7 @@ /* This is the default inquiry callback. It mainly handles the Pinentry notifications. */ -static int +static gpg_error_t default_inq_cb (void *opaque, const char *line) { gpg_error_t err; @@ -301,7 +301,7 @@ /* Handle a CIPHERTEXT inquiry. Note, we only send the data, assuan_transact talkes care of flushing and writing the end */ -static int +static gpg_error_t inq_ciphertext_cb (void *opaque, const char *line) { struct cipher_parm_s *parm = opaque; @@ -423,7 +423,7 @@ /* Handle a KEYPARMS inquiry. Note, we only send the data, assuan_transact takes care of flushing and writing the end */ -static int +static gpg_error_t inq_genkey_parms (void *opaque, const char *line) { struct genkey_parm_s *parm = opaque; @@ -561,7 +561,7 @@ /* Callback for the gpgsm_agent_serialno fucntion. */ -static int +static gpg_error_t scd_serialno_status_cb (void *opaque, const char *line) { char **r_serialno = opaque; @@ -613,7 +613,7 @@ /* Callback for the gpgsm_agent_serialno fucntion. */ -static int +static gpg_error_t scd_keypairinfo_status_cb (void *opaque, const char *line) { strlist_t *listaddr = opaque; @@ -681,7 +681,7 @@ -static int +static gpg_error_t istrusted_status_cb (void *opaque, const char *line) { struct rootca_flags_s *flags = opaque; @@ -812,7 +812,7 @@ } -static int +static gpg_error_t learn_status_cb (void *opaque, const char *line) { struct learn_parm_s *parm = opaque; @@ -831,7 +831,7 @@ return 0; } -static int +static gpg_error_t learn_cb (void *opaque, const void *buffer, size_t length) { struct learn_parm_s *parm = opaque; @@ -1002,7 +1002,7 @@ -static int +static gpg_error_t keyinfo_status_cb (void *opaque, const char *line) { char **serialno = opaque; Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2009-10-28 12:02:15 UTC (rev 5187) +++ trunk/sm/server.c 2009-11-02 17:47:11 UTC (rev 5188) @@ -308,11 +308,13 @@ } -static void -reset_notify (assuan_context_t ctx) +static gpg_error_t +reset_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); + (void) line; + gpgsm_release_certlist (ctrl->server_local->recplist); gpgsm_release_certlist (ctrl->server_local->signerlist); ctrl->server_local->recplist = NULL; @@ -320,11 +322,12 @@ close_message_fd (ctrl); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); + return 0; } -static void -input_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +input_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -339,10 +342,11 @@ ; else ctrl->autodetect_encoding = 1; + return 0; } -static void -output_notify (assuan_context_t ctx, const char *line) +static gpg_error_t +output_notify (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -352,6 +356,7 @@ ctrl->create_pem = 1; else if (strstr (line, "--base64")) ctrl->create_base64 = 1; /* just the raw output */ + return 0; } @@ -1100,7 +1105,7 @@ { static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; } table[] = { { "RECIPIENT", cmd_recipient }, { "SIGNER", cmd_signer }, From cvs at cvs.gnupg.org Tue Nov 3 13:01:24 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 13:01:24 +0100 Subject: [svn] GpgOL - r315 - in trunk: . forms po src Message-ID: Author: wk Date: 2009-11-03 13:01:24 +0100 (Tue, 03 Nov 2009) New Revision: 315 Added: trunk/forms/gpgol-cs_en.cfg trunk/forms/gpgol-ms_en.cfg trunk/forms/gpgol_en.cfg trunk/src/mailitem.cpp trunk/src/mailitem.h Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/forms/Makefile.am trunk/po/de.po trunk/po/sv.po trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/cmdbarcontrols.h trunk/src/common.h trunk/src/display.cpp trunk/src/display.h trunk/src/ext-commands.cpp trunk/src/inspectors.cpp trunk/src/inspectors.h trunk/src/item-events.cpp trunk/src/main.c trunk/src/message-events.cpp trunk/src/message.cpp trunk/src/message.h trunk/src/myexchext.h trunk/src/olflange.cpp trunk/src/oomhelp.cpp trunk/src/oomhelp.h trunk/src/revert.cpp Log: The new icon code is ready. However the whiole module needs a lot more testing because I rewrote a lot of code. [The diff below has been truncated] Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/ChangeLog 2009-11-03 12:01:24 UTC (rev 315) @@ -1,3 +1,7 @@ +2009-11-02 Werner Koch + + * forms/Makefile.am (cfg_english): New. + 2009-10-30 Werner Koch * forms/Makefile.am (icons): Udpate all icons. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/ChangeLog 2009-11-03 12:01:24 UTC (rev 315) @@ -1,3 +1,27 @@ +2009-11-03 Werner Koch + + * inspectors.cpp (deregister_inspector): Delete the buttons. + (set_one_button): New. + (set_inspector_composer_flags): Also set toolbar buttons. + * oomhelp.cpp (del_oom_button): New. + +2009-11-02 Werner Koch + + * mailitem.cpp, mailitem.h: New. + + * inspectors.cpp (get_message_from_button): New. + (get_inspector_from_instid): New. + (proc_inspector_button_click): Implement missing commands. + + * message.cpp (message_display_handler): Change to take an + LPMESSAGE argument. + * display.cpp (update_display): Replace the eecb arg by an + inspector object. + * message-events.cpp (OnReadComplete): Adjust for changes. + + * oomhelp.cpp (get_oom_iunknown): New. + * revert.cpp (gpgol_folder_revert): Change to work without an eecb. + 2009-10-30 Werner Koch * oomhelp.cpp (get_oom_control_bytag): Fix silly bug. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/NEWS 2009-11-03 12:01:24 UTC (rev 315) @@ -1,7 +1,7 @@ Noteworthy changes for version 1.1.0 =================================================== - * Replaced some ECF code by direct OOM code. This was required to + * Replaced most ECE code by direct OOM code. This was required to support better icons; i.e. icons not limited to a 16 color palette. * New icons. Modified: trunk/TODO =================================================================== --- trunk/TODO 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/TODO 2009-11-03 12:01:24 UTC (rev 315) @@ -15,5 +15,3 @@ presented file names and decrypt them only on OpenSzFile. Need to find some documentation first. -* We need to use the micalg as returned by the UI-server. - Modified: trunk/forms/Makefile.am =================================================================== --- trunk/forms/Makefile.am 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/forms/Makefile.am 2009-11-03 12:01:24 UTC (rev 315) @@ -13,9 +13,11 @@ icons = encr-l.ico encr-s.ico sign-l.ico sign-s.ico -cfg_german = gpgol_de.cfg gpgol-ms_de.cfg gpgol-cs_de.cfg +cfg_german = gpgol_de.cfg gpgol-ms_de.cfg gpgol-cs_de.cfg +cfg_english = gpgol_en.cfg gpgol-ms_en.cfg gpgol-cs_en.cfg -dist_pkgdata_DATA = $(icons) $(cfg_german) +dist_pkgdata_DATA = $(icons) $(cfg_german) $(cfg_english) + Added: trunk/forms/gpgol-cs_en.cfg =================================================================== --- trunk/forms/gpgol-cs_en.cfg (rev 0) +++ trunk/forms/gpgol-cs_en.cfg 2009-11-03 12:01:24 UTC (rev 315) @@ -0,0 +1,35 @@ +[Description] +MessageClass=IPM.Note.GpgOL.ClearSigned +DesignerRuntimeGuid={0006F020-0000-0000-C000-000000000046} +CLSID={00061033-0000-0000-C000-000000000046} +DisplayName=Form for class IPM.Note.GpgOL.MultipartSigned +Category=Standard +Subcategory=Formular +Comment= +LargeIcon=sign-l.ico +SmallIcon=sign-s.ico +VersionMajor=1 +VersionMinor=0 +Locale=eng +Hidden=1 +Owner=Public Domain + +[Properties] + +[Verbs] +Verb1=1 + +[Verb.1] +DisplayName=&Open +Code=0 +Flags=0 +Attribs=2 + +[Extensions] +Extensions1=1 + +[Extension.1] +Type=30 +NmidPropset={00020D0C-0000-0000-C000-000000000046} +NmidInteger=1 +Value=1011111111111111 Added: trunk/forms/gpgol-ms_en.cfg =================================================================== --- trunk/forms/gpgol-ms_en.cfg (rev 0) +++ trunk/forms/gpgol-ms_en.cfg 2009-11-03 12:01:24 UTC (rev 315) @@ -0,0 +1,35 @@ +[Description] +MessageClass=IPM.Note.GpgOL.MultipartSigned +DesignerRuntimeGuid={0006F020-0000-0000-C000-000000000046} +CLSID={00061033-0000-0000-C000-000000000046} +DisplayName=Form for class IPM.Note.GpgOL.MultipartSigned +Category=Standard +Subcategory=Formular +Comment= +LargeIcon=sign-l.ico +SmallIcon=sign-s.ico +VersionMajor=1 +VersionMinor=0 +Locale=eng +Hidden=1 +Owner=Public Domain + +[Properties] + +[Verbs] +Verb1=1 + +[Verb.1] +DisplayName=&Open +Code=0 +Flags=0 +Attribs=2 + +[Extensions] +Extensions1=1 + +[Extension.1] +Type=30 +NmidPropset={00020D0C-0000-0000-C000-000000000046} +NmidInteger=1 +Value=1011111111111111 Added: trunk/forms/gpgol_en.cfg =================================================================== --- trunk/forms/gpgol_en.cfg (rev 0) +++ trunk/forms/gpgol_en.cfg 2009-11-03 12:01:24 UTC (rev 315) @@ -0,0 +1,36 @@ +[Description] +MessageClass=IPM.Note.GpgOL +DesignerRuntimeGuid={0006F020-0000-0000-C000-000000000046} +CLSID={00061033-0000-0000-C000-000000000046} +DisplayName=Form for class IPM.Note.GpgOL +Category=Standard +Subcategory=Formular +Comment= +LargeIcon=encr-l.ico +SmallIcon=encr-s.ico +VersionMajor=1 +VersionMinor=0 +Locale=eng +Hidden=1 +Owner=Public Domain + +[Properties] + +[Verbs] +Verb1=1 + +[Verb.1] +DisplayName=&Open +Code=0 +Flags=0 +Attribs=2 + +[Extensions] +Extensions1=1 + +[Extension.1] +Type=30 +NmidPropset={00020D0C-0000-0000-C000-000000000046} +NmidInteger=1 +Value=1011111111111111 + Modified: trunk/po/de.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/Makefile.am 2009-11-03 12:01:24 UTC (rev 315) @@ -71,6 +71,7 @@ oomhelp.cpp oomhelp.h eventsink.h \ explorers.cpp explorers.h \ inspectors.cpp inspectors.h \ + mailitem.cpp mailitem.h \ cmdbarcontrols.cpp cmdbarcontrols.h \ w32-gettext.c w32-gettext.h Modified: trunk/src/cmdbarcontrols.h =================================================================== --- trunk/src/cmdbarcontrols.h 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/cmdbarcontrols.h 2009-11-03 12:01:24 UTC (rev 315) @@ -31,7 +31,10 @@ struct IOOMCommandBarButton; typedef IOOMCommandBarButton *LPOOMCOMMANDBARBUTTON; +struct GpgolCommandBarButtonEvents; +typedef GpgolCommandBarButtonEvents *LPGPGOLCOMMANDBARBUTTONEVENTS; + EXTERN_C const IID IID_IOOMCommandBarButtonEvents; #undef INTERFACE #define INTERFACE IOOMCommandBarButtonEvents @@ -57,6 +60,7 @@ LPDISPATCH install_GpgolCommandBarButtonEvents_sink (LPDISPATCH button); +void detach_GpgolCommandBarButtonEvents_sink (LPDISPATCH sink); Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/common.h 2009-11-03 12:01:24 UTC (rev 315) @@ -169,6 +169,7 @@ #define DBG_COMMANDS (1<<6) #define DBG_MIME_PARSER (1<<7) #define DBG_MIME_DATA (1<<8) +#define DBG_OOM (1<<9) /* Macros to used in conditionals to enable debug output. */ #define debug_commands (opt.enable_debug & DBG_COMMANDS) Modified: trunk/src/display.cpp =================================================================== --- trunk/src/display.cpp 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/display.cpp 2009-11-03 12:01:24 UTC (rev 315) @@ -215,7 +215,7 @@ /* Update the display with TEXT using the message MSG. Return 0 on success. */ int -update_display (HWND hwnd, void *exchange_cb, int is_sensitive, +update_display (HWND hwnd, LPDISPATCH inspector, int is_sensitive, bool is_html, const char *text) { HWND window; @@ -245,28 +245,27 @@ SetWindowTextA (window, text); return 0; } - else if (exchange_cb && !opt.compat.no_oom_write) + else if (inspector && !opt.compat.no_oom_write) { - LPDISPATCH obj; int rc; + LPDISPATCH item; log_debug ("%s:%s: updating display using OOM\n", SRCNAME, __func__); - obj = get_eecb_object ((LPEXCHEXTCALLBACK)exchange_cb); - if (!obj) + item = get_oom_object (inspector, "get_CurrentItem"); + if (item) { - log_error ("%s:%s: Object not found via EECB\n", SRCNAME, __func__); - return -1; + if (is_html) + { + /* Bug in OL 2002 and 2003 - as a workaround set the body + first to empty. */ + put_oom_string (item, "Body", ""); + } + rc = put_oom_string (item, is_html? "HTMLBody":"Body", text); + item->Release (); } - - if (is_html) - { - /* Bug in OL 2002 and 2003 - as a workaround set the body - first to empty. */ - put_oom_string (obj, "Body", ""); - } - rc = put_oom_string (obj, is_html? "HTMLBody":"Body", text); - obj->Release (); + else + rc = -1; return rc; } else Modified: trunk/src/display.h =================================================================== --- trunk/src/display.h 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/display.h 2009-11-03 12:01:24 UTC (rev 315) @@ -25,7 +25,7 @@ char *add_html_line_endings (const char *body); int is_inspector_display (HWND hwnd); -int update_display (HWND hwnd, void *exchange_cb, int is_sensitive, +int update_display (HWND hwnd, LPDISPATCH inspector, int is_sensitive, bool is_html, const char *text); int set_message_body (LPMESSAGE message, const char *string, bool is_html); Modified: trunk/src/ext-commands.cpp =================================================================== --- trunk/src/ext-commands.cpp 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/ext-commands.cpp 2009-11-03 12:01:24 UTC (rev 315) @@ -37,7 +37,6 @@ #include "olflange.h" #include "message.h" #include "engine.h" -#include "revert.h" #include "ext-commands.h" #include "explorers.h" #include "inspectors.h" @@ -283,8 +282,7 @@ if (force_encrypt) encrypt = true; - /* FIXME: ove that to the inspector activation. */ - //set_crypto_flags (eecb, sign, encrypt); + set_crypto_flags (eecb, sign, encrypt); } xfree (draft_info); } Modified: trunk/src/inspectors.cpp =================================================================== --- trunk/src/inspectors.cpp 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/inspectors.cpp 2009-11-03 12:01:24 UTC (rev 315) @@ -27,11 +27,14 @@ #include "common.h" #include "oomhelp.h" #include "myexchext.h" -#include "inspectors.h" +#include "mapihelp.h" +#include "message.h" #include "dialogs.h" /* IDB_xxx */ #include "cmdbarcontrols.h" - #include "eventsink.h" +#include "inspectors.h" +#include "mailitem.h" +#include "revert.h" /* Event sink for an Inspectors collection object. */ @@ -72,7 +75,6 @@ STDMETHOD_ (void, Close) (THIS_); STDMETHOD_ (void, Deactivate) (THIS_); bool m_first_activate_seen; - unsigned long m_serialno; EVENT_SINK_CTOR(GpgolInspectorEvents) { m_first_activate_seen = false; @@ -109,7 +111,6 @@ struct button_list_s { struct button_list_s *next; - unsigned long serialno; /* of the inspector. */ LPDISPATCH sink; LPDISPATCH button; int instid; @@ -126,16 +127,13 @@ /* We are pretty lame and keep all inspectors in a linked list. */ struct inspector_info_s *next; + /* The event sink object. This is used by the event methods to + locate the inspector object. */ + LPGPGOLINSPECTOREVENTS eventsink; + /* The inspector object. */ LPOOMINSPECTOR inspector; - /* Our serial number for the inspector. */ - unsigned long serialno; - - /* The event sink object. This is used by the event methods to - locate the inspector object. */ - LPOOMINSPECTOREVENTS eventsink; - /* A list of all the buttons. */ button_list_t buttons; @@ -147,9 +145,8 @@ static HANDLE all_inspectors_lock; -static void add_inspector_controls (LPOOMINSPECTOR inspector, - unsigned long serialno); -static void update_crypto_info (LPDISPATCH button); +static void add_inspector_controls (LPOOMINSPECTOR inspector); +static void update_crypto_info (LPDISPATCH inspector); @@ -197,30 +194,13 @@ } -/* Return a new serial number for an inspector. These serial numbers - are used to make the button tags unique. */ -static unsigned long -create_inspector_serial (void) -{ - static long serial; - long n; - - /* Avoid returning 0 because we use that value as Nil. */ - while (!(n = InterlockedIncrement (&serial))) - ; - return (unsigned long)n; -} - - /* Add SINK and BUTTON to the list at LISTADDR. The list takes ownership of SINK and BUTTON, thus the caller may not use OBJ or - OBJ2 after this call. If TAG must be given without the - serialnumber suffix. SERIALNO is the serialno of the correspnding - inspector. */ + OBJ2 after this call. TAG must be given without the '#' marked + suffix. */ static void move_to_button_list (button_list_t *listaddr, - LPDISPATCH sink, LPDISPATCH button, - const char *tag, unsigned long serialno) + LPDISPATCH sink, LPDISPATCH button, const char *tag) { button_list_t item; int instid; @@ -237,28 +217,29 @@ item->sink = sink; item->button = button; item->instid = instid; - item->serialno = serialno; strcpy (item->tag, tag); item->next = *listaddr; *listaddr = item; } -/* Register the inspector object INSPECTOR along with its event SINK. */ +/* Register the inspector object INSPECTOR with its event SINK. */ static void -register_inspector (LPOOMINSPECTOR inspector, LPGPGOLINSPECTOREVENTS sink) +register_inspector (LPGPGOLINSPECTOREVENTS sink, LPOOMINSPECTOR inspector) { inspector_info_t item; + log_debug ("%s:%s: Called (sink=%p, inspector=%p)", + SRCNAME, __func__, sink, inspector); item = (inspector_info_t)xcalloc (1, sizeof *item); lock_all_inspectors (); - inspector->AddRef (); - item->inspector = inspector; - item->serialno = sink->m_serialno = create_inspector_serial (); sink->AddRef (); item->eventsink = sink; + inspector->AddRef (); + item->inspector = inspector; + item->next = all_inspectors; all_inspectors = item; @@ -268,11 +249,13 @@ /* Deregister the inspector with the event SINK. */ static void -deregister_inspector (LPOOMINSPECTOREVENTS sink) +deregister_inspector (LPGPGOLINSPECTOREVENTS sink) { inspector_info_t r, rprev; button_list_t ol, ol2; + log_debug ("%s:%s: Called (sink=%p)", SRCNAME, __func__, sink); + if (!sink) return; @@ -293,21 +276,28 @@ log_error ("%s:%s: inspector not registered", SRCNAME, __func__); return; } - r->eventsink->Release (); - r->eventsink = NULL; - if (r->inspector) - r->inspector->Release (); + detach_GpgolInspectorEvents_sink (r->eventsink); + for (ol = r->buttons; ol; ol = ol2) { ol2 = ol->next; if (ol->sink) - ol->sink->Release (); + { + detach_GpgolCommandBarButtonEvents_sink (ol->sink); + ol->sink->Release (); + } if (ol->button) - ol->button->Release (); + { + del_oom_button (ol->button); + ol->button->Release (); + } xfree (ol); } + r->inspector->Release (); + r->eventsink->Release (); + xfree (r); } @@ -333,39 +323,40 @@ } -/* Return the serialno of INSPECTOR or 0 if not found. */ -static unsigned long -get_serialno (LPDISPATCH inspector) +/* Return the button with TAG and assigned to INSPECTOR. TAG must be + given without the suffix. Returns NULL if not found. */ +static LPDISPATCH +get_button (LPDISPATCH inspector, const char *tag) { - unsigned int result = 0; + LPDISPATCH result = NULL; inspector_info_t iinfo; + button_list_t ol; - /* FIXME: This might not bet reliable. We merely compare the - pointer and not something like an Instance Id. We should check - whether this is sufficient or whether to track the inspectors - with different hack. For example we could add an invisible menu - entry and scan for that entry to get the serial number serial - number of it. A better option would be to add a custom property - to the inspector, but that seems not supported - we could of - course add it to a button then. */ lock_all_inspectors (); for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next) if (iinfo->inspector == inspector) { - result = iinfo->serialno; + for (ol = iinfo->buttons; ol; ol = ol->next) + if (ol->tag && !strcmp (ol->tag, tag)) + { + result = ol->button; + if (result) + result->AddRef (); + break; + } break; } - + unlock_all_inspectors (); return result; } -/* Return the button with TAG and assigned to the isnpector with - SERIALNO. Return NULL if not found. */ +/* Search through all objects and find the inspector which has a + button with the instance id INSTID. Returns NULL if not found. */ static LPDISPATCH -get_button (unsigned long serialno, const char *tag) +get_inspector_from_instid (int instid) { LPDISPATCH result = NULL; inspector_info_t iinfo; @@ -374,18 +365,14 @@ lock_all_inspectors (); for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next) - if (iinfo->serialno == serialno) - { - for (ol = iinfo->buttons; ol; ol = ol->next) - if (ol->tag && !strcmp (ol->tag, tag)) - { - result = ol->button; - if (result) - result->AddRef (); - break; - } - break; - } + for (ol = iinfo->buttons; ol; ol = ol->next) + if (ol->instid == instid) + { + result = iinfo->inspector; + if (result) + result->AddRef (); + break; + } unlock_all_inspectors (); return result; @@ -393,9 +380,8 @@ /* Search through all objects and find the inspector which has a - button with the instanceId INSTID. The find the button with TAG in - that inspector and return it. Caller must release the returned - button. Returns NULL if not found. */ + button with the instanceId INSTID. Theb find the button with TAG + in that inspector and return it. Returns NULL if not found. */ static LPDISPATCH get_button_by_instid_and_tag (int instid, const char *tag) { @@ -428,8 +414,6 @@ } - - /* The method called by outlook for each new inspector. Note that Outlook sometimes reuses Inspectro objects thus this event is not an indication for a newly opened Inspector. */ @@ -437,16 +421,19 @@ GpgolInspectorsEvents::NewInspector (LPOOMINSPECTOR inspector) { LPDISPATCH obj; - log_debug ("%s:%s: Called", SRCNAME, __func__); + log_debug ("%s:%s: Called (this=%p, inspector=%p)", + SRCNAME, __func__, this, inspector); + /* It has been said that INSPECTOR here a "weak" reference. This may mean that the object has not been fully initialized. So better take some care here and also take an additional reference. */ + inspector->AddRef (); obj = install_GpgolInspectorEvents_sink ((LPDISPATCH)inspector); if (obj) { - register_inspector (inspector, (LPGPGOLINSPECTOREVENTS)obj); + register_inspector ((LPGPGOLINSPECTOREVENTS)obj, inspector); obj->Release (); } inspector->Release (); @@ -458,10 +445,12 @@ STDMETHODIMP_(void) GpgolInspectorEvents::Close (void) { - log_debug ("%s:%s: Called", SRCNAME, __func__); - /* Deregister the inspector and free outself. */ + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this ); + + /* Deregister the inspector. */ deregister_inspector (this); - this->Release (); + /* We don't release ourself because we already dropped the initial + reference after doing a register_inspector. */ } @@ -469,11 +458,11 @@ STDMETHODIMP_(void) GpgolInspectorEvents::Activate (void) { - LPDISPATCH obj, button; LPOOMINSPECTOR inspector; + // LPDISPATCH obj, obj2; - log_debug ("%s:%s: Called", SRCNAME, __func__); - + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); + /* Note: It is easier to use the registered inspector object than to find the inspector object in the ALL_INSPECTORS list. The ALL_INSPECTORS list primarly useful to keep track of additional @@ -484,6 +473,7 @@ return; } inspector = (LPOOMINSPECTOR)m_object; + inspector->AddRef (); /* If this is the first activate for the inspector, we add the controls. We do it only now to be sure that everything has been @@ -492,23 +482,19 @@ if (!m_first_activate_seen) { m_first_activate_seen = true; - add_inspector_controls (inspector, m_serialno); + add_inspector_controls (inspector); + // obj = get_oom_object (inspector, "get_CurrentItem"); + // if (obj) + // { + // obj2 = install_GpgolItemEvents_sink (obj); + // if (obj2) + // obj2->Release (); + // obj->Release (); + // } } - /* Update the crypt info. */ - obj = get_oom_object (inspector, "CommandBars"); - if (!obj) - log_error ("%s:%s: CommandBars not found", SRCNAME, __func__); - else - { - button = get_button (m_serialno, "GpgOL_Inspector_Crypto_Info"); - obj->Release (); - if (button) - { - update_crypto_info (button); - button->Release (); - } - } + update_crypto_info (inspector); + inspector->Release (); } @@ -516,7 +502,7 @@ STDMETHODIMP_(void) GpgolInspectorEvents::Deactivate (void) { - log_debug ("%s:%s: Called", SRCNAME, __func__); + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); } @@ -551,16 +537,8 @@ { LPDISPATCH button; int rc = 0; - unsigned long serialno; - serialno = get_serialno (inspector); - if (!serialno) - { - log_error ("%s:%s: S/n not found", SRCNAME, __func__); - return -1; - } - - button = get_button (serialno, "GpgOL_Inspector_Sign"); + button = get_button (inspector, "GpgOL_Inspector_Sign"); if (!button) { log_error ("%s:%s: Sign button not found", SRCNAME, __func__); @@ -572,7 +550,7 @@ button->Release (); } - button = get_button (serialno, "GpgOL_Inspector_Encrypt"); + button = get_button (inspector, "GpgOL_Inspector_Encrypt"); if (!button) { log_error ("%s:%s: Encrypt button not found", SRCNAME, __func__); @@ -591,59 +569,59 @@ } -/* Set the flags for the inspector; i.e. whether to sign or encrypt a - message. Returns 0 on success. */ -int -set_inspector_composer_flags (LPDISPATCH inspector, bool sign, bool encrypt) +static int +set_one_button (LPDISPATCH inspector, const char *tag, bool down) { LPDISPATCH button; int rc = 0; - unsigned long serialno; - serialno = get_serialno (inspector); - if (!serialno) - { - log_error ("%s:%s: S/n not found", SRCNAME, __func__); - return -1; - } - - button = get_button (serialno, "GpgOL_Inspector_Sign"); + button = get_button (inspector, tag); if (!button) { - log_error ("%s:%s: Sign button not found", SRCNAME, __func__); + log_error ("%s:%s: `%s' not found", SRCNAME, __func__, tag); rc = -1; } else { - if (put_oom_int (button, "State", sign? msoButtonDown : msoButtonUp)) + if (put_oom_int (button, "State", down? msoButtonDown : msoButtonUp)) rc = -1; button->Release (); } + return rc; +} - button = get_button (serialno, "GpgOL_Inspector_Encrypt"); - if (!button) - { - log_error ("%s:%s: Encrypt button not found", SRCNAME, __func__); - rc = -1; - } - else - { - if (put_oom_int (button, "State", encrypt? msoButtonDown : msoButtonUp)) - rc = -1; - button->Release (); - } - + + +/* Set the flags for the inspector; i.e. whether to sign or encrypt a + message. Returns 0 on success. */ +int +set_inspector_composer_flags (LPDISPATCH inspector, bool sign, bool encrypt) +{ + int rc = 0; + + if (set_one_button (inspector, "GpgOL_Inspector_Sign", sign)) + rc = -1; + if (set_one_button (inspector, "GpgOL_Inspector_Sign at t", sign)) + rc = -1; + if (set_one_button (inspector, "GpgOL_Inspector_Encrypt", encrypt)) + rc = -1; + if (set_one_button (inspector, "GpgOL_Inspector_Encrypt at t", encrypt)) + rc = -1; + return rc; } /* Helper to make the tag unique. */ static const char * -add_tag (LPDISPATCH control, unsigned long serialno, const char *value) +add_tag (LPDISPATCH control, const char *value) { + int instid; + char buf[256]; - snprintf (buf, sizeof buf, "%s#%lu", value, serialno); + instid = get_oom_int (control, "InstanceId"); + snprintf (buf, sizeof buf, "%s#%d", value, instid); put_oom_string (control, "Tag", buf); return value; } @@ -651,7 +629,7 @@ /* Add all the controls. */ static void -add_inspector_controls (LPOOMINSPECTOR inspector, unsigned long serialno) +add_inspector_controls (LPOOMINSPECTOR inspector) { static LPDISPATCH obj, controls, button; @@ -660,7 +638,6 @@ const char *tag; int in_composer; - log_debug ("%s:%s: Enter", SRCNAME, __func__); /* Check whether we are in composer or read mode. */ @@ -678,7 +655,7 @@ button = opt.disable_gpgol? NULL : add_oom_button (controls); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Encrypt"); + tag = add_tag (button, "GpgOL_Inspector_Encrypt"); put_oom_bool (button, "BeginGroup", true); put_oom_int (button, "Style", msoButtonIconAndCaption ); put_oom_string (button, "Caption", @@ -686,19 +663,19 @@ put_oom_icon (button, IDB_ENCRYPT, 16); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = opt.disable_gpgol? NULL : add_oom_button (controls); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Sign"); + tag = add_tag (button, "GpgOL_Inspector_Sign"); put_oom_int (button, "Style", msoButtonIconAndCaption ); put_oom_string (button, "Caption", _("&sign message with GnuPG")); put_oom_icon (button, IDB_SIGN, 16); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } controls->Release (); @@ -716,49 +693,49 @@ button = in_composer? NULL : add_oom_button (controls); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Verify"); + tag = add_tag (button, "GpgOL_Inspector_Verify"); put_oom_int (button, "Style", msoButtonIconAndCaption ); put_oom_string (button, "Caption", _("GpgOL Decrypt/Verify")); put_oom_icon (button, IDB_DECRYPT_VERIFY, 16); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = opt.enable_debug? add_oom_button (controls) : NULL; if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Debug-0"); + tag = add_tag (button, "GpgOL_Inspector_Debug-0"); put_oom_int (button, "Style", msoButtonCaption ); put_oom_string (button, "Caption", "GpgOL Debug-0 (display crypto info)"); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = opt.enable_debug? add_oom_button (controls) : NULL; if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Debug-1"); + tag = add_tag (button, "GpgOL_Inspector_Debug-1"); put_oom_int (button, "Style", msoButtonCaption ); put_oom_string (button, "Caption", - "GpgOL Debug-1 (open_inspector)"); + "GpgOL Debug-1 (not used)"); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = opt.enable_debug? add_oom_button (controls) : NULL; if (button) { - tag = add_tag (button, serialno,"GpgOL_Inspector_Debug-2"); + tag = add_tag (button, "GpgOL_Inspector_Debug-2"); put_oom_int (button, "Style", msoButtonCaption ); put_oom_string (button, "Caption", "GpgOL Debug-2 (change message class)"); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } controls->Release (); @@ -777,38 +754,38 @@ ? NULL : add_oom_button (controls)); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Encrypt at t"); + tag = add_tag (button, "GpgOL_Inspector_Encrypt at t"); put_oom_int (button, "Style", msoButtonIcon ); put_oom_string (button, "Caption", _("Encrypt message with GnuPG")); put_oom_icon (button, IDB_ENCRYPT, 16); put_oom_int (button, "State", msoButtonMixed ); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = (opt.disable_gpgol || !in_composer ? NULL : add_oom_button (controls)); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Sign at t"); + tag = add_tag (button, "GpgOL_Inspector_Sign at t"); put_oom_int (button, "Style", msoButtonIcon); put_oom_string (button, "Caption", _("Sign message with GnuPG")); put_oom_icon (button, IDB_SIGN, 16); put_oom_int (button, "State", msoButtonDown); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } button = in_composer? NULL : add_oom_button (controls); if (button) { - tag = add_tag (button, serialno, "GpgOL_Inspector_Crypto_Info"); + tag = add_tag (button, "GpgOL_Inspector_Crypto_Info"); put_oom_int (button, "Style", msoButtonIcon); obj = install_GpgolCommandBarButtonEvents_sink (button); - move_to_button_list (&buttonlist, obj, button, tag, serialno); + move_to_button_list (&buttonlist, obj, button, tag); } controls->Release (); @@ -844,91 +821,141 @@ /* Update the crypto info icon. */ static void -update_crypto_info (LPDISPATCH button) +update_crypto_info (LPDISPATCH inspector) { - LPDISPATCH inspector; - char *msgcls = NULL;; - const char *s; - int in_composer = 0; - int is_encrypted = 0; - int is_signed = 0; - const char *tooltip; - int iconrc; + HRESULT hr; + LPDISPATCH button; + const char *tooltip = ""; + int iconrc = -1; - /* FIXME: We should store the information retrieved by old - versions via mapi_get_message_type and mapi_test_sig_status - in UserProperties and use them instead of a direct lookup of - the messageClass. */ - - inspector = get_oom_object (button, "get_Parent.get_Parent.get_CurrentItem"); - if (inspector) + button = get_button (inspector, "GpgOL_Inspector_Crypto_Info"); + if (!button) { - msgcls = get_oom_string (inspector, "MessageClass"); - in_composer = is_inspector_in_composer_mode (inspector); - inspector->Release (); + log_error ("%s:%s: Crypto Info button not found", SRCNAME, __func__); + return; } - if (msgcls) + + if (!is_inspector_in_composer_mode (inspector)) { - log_debug ("%s:%s: message class is `%s'", SRCNAME, __func__, msgcls); - if (!strncmp (msgcls, "IPM.Note.GpgOL", 14) - && (!msgcls[14] || msgcls[14] == '.')) + LPDISPATCH obj; + LPUNKNOWN unknown; + LPMESSAGE message = NULL; + + obj = get_oom_object (inspector, "get_CurrentItem"); + if (obj) { - s = msgcls + 14; - if (!*s) - ; - else if (!strcmp (s, ".MultipartSigned")) - is_signed = 1; - else if (!strcmp (s, ".MultipartEncrypted")) - is_encrypted = 1; - else if (!strcmp (s, ".OpaqueSigned")) - is_signed = 1; - else if (!strcmp (s, ".OpaqueEncrypted")) - is_encrypted = 1; - else if (!strcmp (s, ".ClearSigned")) - is_signed = 1; - else if (!strcmp (s, ".PGPMessage")) - is_encrypted = 1; + unknown = get_oom_iunknown (obj, "MAPIOBJECT"); + if (!unknown) + log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__); + else + { + hr = unknown->QueryInterface (IID_IMessage, (void**)&message); + if (hr != S_OK || !message) + { + message = NULL; + log_error ("%s:%s: error getting IMESSAGE: hr=%#lx", + SRCNAME, __func__, hr); + } + unknown->Release (); + } + obj->Release (); } - - /*FIXME: check something like mail_test_sig_status to see - whether it is an encrypted and signed message. */ - - if (in_composer) + if (message) { - tooltip = ""; - iconrc = -1; + int is_encrypted = 0; + int is_signed = 0; + + switch (mapi_get_message_type (message)) + { + case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED: + case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED: + case MSGTYPE_GPGOL_PGP_MESSAGE: + is_encrypted = 1; + if ( mapi_test_sig_status (message) ) + is_signed = 1; + break; + case MSGTYPE_GPGOL: + case MSGTYPE_SMIME: + case MSGTYPE_UNKNOWN: + break; + default: + is_signed = 1; + break; + } + + if (is_signed && is_encrypted) + { + tooltip = _("This is a signed and encrypted message.\n" + "Click for more information. "); + iconrc = IDB_DECRYPT_VERIFY; + } + else if (is_signed) + { + tooltip = _("This is a signed message.\n" + "Click for more information. "); + iconrc = IDB_VERIFY; + } + else if (is_encrypted) + { + tooltip = _("This is an encrypted message.\n" + "Click for more information. "); + iconrc = IDB_DECRYPT; + } + + message->Release (); } - else if (is_signed && is_encrypted) + } + + put_oom_string (button, "TooltipText", tooltip); + if (iconrc != -1) + put_oom_icon (button, iconrc, 16); + put_oom_bool (button, "Visible", (iconrc != -1)); + button->Release (); +} + + +/* Return the MAPI message object of then inspector from a button's + instance id. */ +static LPMESSAGE +get_message_from_button (unsigned long instid, LPDISPATCH *r_inspector) +{ + HRESULT hr; + LPDISPATCH inspector, obj; + LPUNKNOWN unknown; + LPMESSAGE message = NULL; + + if (r_inspector) + *r_inspector = NULL; + inspector = get_inspector_from_instid (instid); + if (inspector) + { + obj = get_oom_object (inspector, "get_CurrentItem"); + if (!obj) + log_error ("%s:%s: error getting CurrentItem", SRCNAME, __func__); + else { - tooltip = _("This is a signed and encrypted message.\n" - "Click for more information. "); - iconrc = IDB_DECRYPT_VERIFY; + unknown = get_oom_iunknown (obj, "MAPIOBJECT"); + if (!unknown) + log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__); + else + { + hr = unknown->QueryInterface (IID_IMessage, (void**)&message); + if (hr != S_OK || !message) + { + message = NULL; + log_error ("%s:%s: error getting IMESSAGE: hr=%#lx", + SRCNAME, __func__, hr); + } + unknown->Release (); + } + obj->Release (); } - else if (is_signed) - { - tooltip = _("This is a signed message.\n" - "Click for more information. "); - iconrc = IDB_VERIFY; - } - else if (is_encrypted) - { - tooltip = _("This is an encrypted message.\n" - "Click for more information. "); - iconrc = IDB_DECRYPT; - } + if (r_inspector) + *r_inspector = inspector; else - { - tooltip = ""; - iconrc = -1; - } - - put_oom_string (button, "TooltipText", tooltip); - if (iconrc != -1) - put_oom_icon (button, iconrc, 16); - put_oom_bool (button, "Visible", (iconrc != -1)); - - xfree (msgcls); + inspector->Release (); } + return message; } @@ -949,7 +976,7 @@ mem2str (tag2, tag, sizeof tag2 - 2); p = strchr (tag2, '#'); if (p) - *p = 0; /* Strip the serialno suffix. */ + *p = 0; /* Strip the instance id suffix. */ if (*tag2 && tag2[1] && !strcmp (tag2+strlen(tag2)-2, "@t")) tag2[strlen(tag2)-2] = 0; /* Remove the "@t". */ else @@ -973,6 +1000,9 @@ void proc_inspector_button_click (LPDISPATCH button, const char *tag, int instid) { + LPMESSAGE message; + HWND hwnd = NULL; /* Fixme */ + if (!tagcmp (tag, "GpgOL_Inspector_Encrypt")) { toggle_button (button, tag, instid); @@ -981,85 +1011,65 @@ { toggle_button (button, tag, instid); } - else if (!tagcmp (tag, "GpgOL_Inspector_Verify")) + else if (!tagcmp (tag, "GpgOL_Inspector_Verify") + || !tagcmp (tag, "GpgOL_Inspector_Crypto_Info")) { - /* FIXME: We need to invoke decrypt/verify again. */ - } - else if (!tagcmp (tag, "GpgOL_Inspector_Crypto_Info")) - { - /* FIXME: We should invoke the decrypt/verify again. */ - update_crypto_info (button); -#if 0 /* This is the code we used to use. */ - log_debug ("%s:%s: command CryptoState called\n", SRCNAME, __func__); - hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); - if (SUCCEEDED (hr)) + LPDISPATCH inspector; + + message = get_message_from_button (instid, &inspector); + if (message) { if (message_incoming_handler (message, hwnd, true)) - message_display_handler (eecb, hwnd); - } - else - log_debug_w32 (hr, "%s:%s: command CryptoState failed", - SRCNAME, __func__); - ul_release (message, __func__, __LINE__); - ul_release (mdb, __func__, __LINE__); -#endif + message_display_handler (message, inspector, hwnd); + message->Release (); + } + if (inspector) + { + update_crypto_info (inspector); + inspector->Release (); + } } else if (!tagcmp (tag, "GpgOL_Inspector_Debug-0")) { - /* Show crypto info. */ log_debug ("%s:%s: command Debug0 (showInfo) called\n", SRCNAME, __func__); - // hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); - // if (SUCCEEDED (hr)) - // { - // message_show_info (message, hwnd); - // } - // ul_release (message, __func__, __LINE__); - // ul_release (mdb, __func__, __LINE__); + message = get_message_from_button (instid, NULL); + if (message) + { + message_show_info (message, hwnd); + message->Release (); + } } else if (!tagcmp (tag, "GpgOL_Inspector_Debug-1")) { - /* Open inspector. */ - log_debug ("%s:%s: command Debug1 (open inspector) called\n", + log_debug ("%s:%s: command Debug1 (not used) called\n", SRCNAME, __func__); - // hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); - // if (SUCCEEDED (hr)) - // { - // open_inspector (eecb, message); - // } - // ul_release (message, __func__, __LINE__); - // ul_release (mdb, __func__, __LINE__); } else if (!tagcmp (tag, "GpgOL_Inspector_Debug-2")) { - /* Change message class. */ log_debug ("%s:%s: command Debug2 (change message class) called", SRCNAME, __func__); - // hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); - // if (SUCCEEDED (hr)) - // { - // /* We sync here. */ - // mapi_change_message_class (message, 1); - // } - // ul_release (message, __func__, __LINE__); - // ul_release (mdb, __func__, __LINE__); + message = get_message_from_button (instid, NULL); + if (message) + { + /* We sync here. */ + mapi_change_message_class (message, 1); + message->Release (); + } } else if (!tagcmp (tag, "GpgOL_Inspector_Debug-3")) { log_debug ("%s:%s: command Debug3 (revert_message_class) called", SRCNAME, __func__); - // hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); - // if (SUCCEEDED (hr)) - // { - // int rc = gpgol_message_revert (message, 1, - // KEEP_OPEN_READWRITE|FORCE_SAVE); - // log_debug ("%s:%s: gpgol_message_revert returns %d\n", - // SRCNAME, __func__, rc); - // } - // ul_release (message, __func__, __LINE__); - // ul_release (mdb, __func__, __LINE__); + message = get_message_from_button (instid, NULL); + if (message) + { + int rc = gpgol_message_revert (message, 1, + KEEP_OPEN_READWRITE|FORCE_SAVE); + log_debug ("%s:%s: gpgol_message_revert returns %d\n", + SRCNAME, __func__, rc); + message->Release (); + } } - - } Modified: trunk/src/inspectors.h =================================================================== --- trunk/src/inspectors.h 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/inspectors.h 2009-11-03 12:01:24 UTC (rev 315) @@ -118,9 +118,11 @@ }; +/* Create a new sink and attach it to OBJECT. */ LPDISPATCH install_GpgolInspectorsEvents_sink (LPDISPATCH object); LPDISPATCH install_GpgolInspectorEvents_sink (LPDISPATCH object); +void detach_GpgolInspectorEvents_sink (LPDISPATCH sink); void proc_inspector_button_click (LPDISPATCH button, Modified: trunk/src/item-events.cpp =================================================================== --- trunk/src/item-events.cpp 2009-10-30 21:44:43 UTC (rev 314) +++ trunk/src/item-events.cpp 2009-11-03 12:01:24 UTC (rev 315) @@ -135,18 +135,33 @@ STDMETHODIMP GpgolItemEvents::OnOpenComplete (LPEXCHEXTCALLBACK eecb, ULONG flags) { + HRESULT hr; + log_debug ("%s:%s: received, flags=%#lx", SRCNAME, __func__, flags); /* If the message has been processed by us (i.e. in OnOpen), we now use our own display code. */ if (!flags && m_processed) { + LPMDB mdb = NULL; + LPMESSAGE message = NULL; HWND hwnd = NULL; if (FAILED (eecb->GetWindow (&hwnd))) hwnd = NULL; - if (message_display_handler (eecb, hwnd)) - m_wasencrypted = true; + hr = eecb->GetObject (&mdb, (LPMAPIPROP *)&message); + if (hr != S_OK || !message) + log_error ("%s:%s: error getting message: hr=%#lx", + SRCNAME, __func__, hr); + else + { + if (message_display_handler (message, hwnd)) + m_wasencrypted = true; + } + if (message) + message->Release (); + if (mdb) + mdb->Release (); } return S_FALSE; Added: trunk/src/mailitem.cpp =================================================================== --- trunk/src/mailitem.cpp (rev 0) +++ trunk/src/mailitem.cpp 2009-11-03 12:01:24 UTC (rev 315) @@ -0,0 +1,133 @@ +/* mailitem.cpp - Code to handle the Outlook MailItem + * Copyright (C) 2009 g10 Code GmbH + * + * This file is part of GpgOL. + * + * GpgOL is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * GpgOL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "common.h" +#include "oomhelp.h" +#include "eventsink.h" +#include "mailitem.h" + + +/* Subclass of ItemEvents so that we can hook into the events. */ +BEGIN_EVENT_SINK(GpgolItemEvents, IOOMItemEvents) + STDMETHOD(Read)(THIS_ ); + STDMETHOD(Write)(THIS_ PBOOL cancel); + STDMETHOD(Open)(THIS_ PBOOL cancel); + STDMETHOD(Close)(THIS_ PBOOL cancel); +EVENT_SINK_DEFAULT_CTOR(GpgolItemEvents) +EVENT_SINK_DEFAULT_DTOR(GpgolItemEvents) +EVENT_SINK_INVOKE(GpgolItemEvents) +{ + HRESULT hr; + (void)lcid; (void)riid; (void)result; (void)exepinfo; (void)argerr; + + switch (dispid) + { + case 0xf001: + if (!(flags & DISPATCH_METHOD)) + goto badflags; + if (parms->cArgs != 0) + hr = DISP_E_BADPARAMCOUNT; + else + { + Read (); + hr = S_OK; + } + break; + + case 0xf004: + if (!(flags & DISPATCH_METHOD)) + goto badflags; + if (!parms) + hr = DISP_E_PARAMNOTOPTIONAL; + else if (parms->cArgs != 1) + hr = DISP_E_BADPARAMCOUNT; + else if (parms->rgvarg[0].vt != (VT_BOOL|VT_BYREF)) + hr = DISP_E_BADVARTYPE; + else + { + BOOL cancel_default = !!*parms->rgvarg[0].pboolVal; + switch (dispid) + { + case 0xf002: Write (&cancel_default); break; + case 0xf003: Open (&cancel_default); break; + case 0xf004: Close (&cancel_default); break; + } + *parms->rgvarg[0].pboolVal = (cancel_default + ? VARIANT_TRUE:VARIANT_FALSE); + hr = S_OK; + } + break; + + badflags: + default: + hr = DISP_E_MEMBERNOTFOUND; + } + return hr; +} +END_EVENT_SINK(GpgolItemEvents, IID_IOOMItemEvents) + + +/* This is the event sink for a read event. */ +STDMETHODIMP +GpgolItemEvents::Read (void) From cvs at cvs.gnupg.org Tue Nov 3 13:41:34 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 13:41:34 +0100 Subject: [svn] GpgOL - r316 - trunk/src Message-ID: Author: wk Date: 2009-11-03 13:41:34 +0100 (Tue, 03 Nov 2009) New Revision: 316 Modified: trunk/src/ChangeLog trunk/src/inspectors.cpp Log: Simplified. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-03 12:01:24 UTC (rev 315) +++ trunk/src/ChangeLog 2009-11-03 12:41:34 UTC (rev 316) @@ -3,6 +3,9 @@ * inspectors.cpp (deregister_inspector): Delete the buttons. (set_one_button): New. (set_inspector_composer_flags): Also set toolbar buttons. + (toggle_button): Use set_one_button. + (get_button_by_instid_and_tag): Remove. + * oomhelp.cpp (del_oom_button): New. 2009-11-02 Werner Koch Modified: trunk/src/inspectors.cpp =================================================================== --- trunk/src/inspectors.cpp 2009-11-03 12:01:24 UTC (rev 315) +++ trunk/src/inspectors.cpp 2009-11-03 12:41:34 UTC (rev 316) @@ -379,41 +379,6 @@ } -/* Search through all objects and find the inspector which has a - button with the instanceId INSTID. Theb find the button with TAG - in that inspector and return it. Returns NULL if not found. */ -static LPDISPATCH -get_button_by_instid_and_tag (int instid, const char *tag) -{ - LPDISPATCH result = NULL; - inspector_info_t iinfo; - button_list_t ol; - - // log_debug ("%s:%s: inst=%d tag=(%s)",SRCNAME, __func__, instid, tag); - - lock_all_inspectors (); - - for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next) - for (ol = iinfo->buttons; ol; ol = ol->next) - if (ol->instid == instid) - { - /* Found the inspector. Now look for the tag. */ - for (ol = iinfo->buttons; ol; ol = ol->next) - if (ol->tag && !strcmp (ol->tag, tag)) - { - result = ol->button; - if (result) - result->AddRef (); - break; - } - break; - } - - unlock_all_inspectors (); - return result; -} - - /* The method called by outlook for each new inspector. Note that Outlook sometimes reuses Inspectro objects thus this event is not an indication for a newly opened Inspector. */ @@ -591,7 +556,6 @@ } - /* Set the flags for the inspector; i.e. whether to sign or encrypt a message. Returns 0 on success. */ int @@ -661,6 +625,8 @@ put_oom_string (button, "Caption", _("&encrypt message with GnuPG")); put_oom_icon (button, IDB_ENCRYPT, 16); + put_oom_int (button, "State", + opt.encrypt_default? msoButtonDown: msoButtonUp); obj = install_GpgolCommandBarButtonEvents_sink (button); move_to_button_list (&buttonlist, obj, button, tag); @@ -673,6 +639,8 @@ put_oom_int (button, "Style", msoButtonIconAndCaption ); put_oom_string (button, "Caption", _("&sign message with GnuPG")); put_oom_icon (button, IDB_SIGN, 16); + put_oom_int (button, "State", + opt.sign_default? msoButtonDown: msoButtonUp); obj = install_GpgolCommandBarButtonEvents_sink (button); move_to_button_list (&buttonlist, obj, button, tag); @@ -759,6 +727,8 @@ put_oom_string (button, "Caption", _("Encrypt message with GnuPG")); put_oom_icon (button, IDB_ENCRYPT, 16); put_oom_int (button, "State", msoButtonMixed ); + put_oom_int (button, "State", + opt.encrypt_default? msoButtonDown: msoButtonUp); obj = install_GpgolCommandBarButtonEvents_sink (button); move_to_button_list (&buttonlist, obj, button, tag); @@ -773,6 +743,8 @@ put_oom_string (button, "Caption", _("Sign message with GnuPG")); put_oom_icon (button, IDB_SIGN, 16); put_oom_int (button, "State", msoButtonDown); + put_oom_int (button, "State", + opt.sign_default? msoButtonDown: msoButtonUp); obj = install_GpgolCommandBarButtonEvents_sink (button); move_to_button_list (&buttonlist, obj, button, tag); @@ -960,14 +932,22 @@ /* Toggle a button and return the new state. */ -static int +static void toggle_button (LPDISPATCH button, const char *tag, int instid) { - int state = get_oom_int (button, "State"); + int state; char tag2[256]; char *p; - LPDISPATCH button2; + LPDISPATCH inspector; + + inspector = get_inspector_from_instid (instid); + if (!inspector) + { + log_debug ("%s:%s: inspector not found", SRCNAME, __func__); + return; + } + state = get_oom_int (button, "State"); log_debug ("%s:%s: button `%s' state is %d", SRCNAME, __func__, tag, state); state = (state == msoButtonUp)? msoButtonDown : msoButtonUp; put_oom_int (button, "State", state); @@ -981,16 +961,10 @@ tag2[strlen(tag2)-2] = 0; /* Remove the "@t". */ else strcat (tag2, "@t"); /* Append a "@t". */ - - button2 = get_button_by_instid_and_tag (instid, tag2); - if (!button2) - log_debug ("%s:%s: button `%s' not found", SRCNAME, __func__, tag2); - else - { - put_oom_int (button2, "State", state); - button2->Release (); - } - return state; + + log_debug ("%s:%s: setting `%s' state to %d", SRCNAME, __func__, tag2, state); + set_one_button (inspector, tag2, state); + inspector->Release (); } From cvs at cvs.gnupg.org Tue Nov 3 18:23:07 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 18:23:07 +0100 Subject: [svn] GpgOL - r317 - trunk/src Message-ID: Author: wk Date: 2009-11-03 18:23:07 +0100 (Tue, 03 Nov 2009) New Revision: 317 Added: trunk/src/encrypt-16m.bmp Log: Add file Property changes on: trunk/src/encrypt-16m.bmp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From cvs at cvs.gnupg.org Tue Nov 3 20:15:35 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 03 Nov 2009 20:15:35 +0100 Subject: [svn] gpgme - r1413 - trunk/src Message-ID: Author: marcus Date: 2009-11-03 20:15:35 +0100 (Tue, 03 Nov 2009) New Revision: 1413 Added: trunk/src/vfs-create.c trunk/src/vfs-mount.c Removed: trunk/src/g13.c Modified: trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/gpgme-tool.c trunk/src/gpgme.def trunk/src/gpgme.h.in trunk/src/libgpgme.vers Log: 2009-11-03 Marcus Brinkmann * Makefile.am (main_sources): Change g13.c to vfs-mount.c. Add vfs-create.c * vfs-create.c: New file. * g13.c: Renamed to ... * vfs-mount.c: ... this new file. * gpgme.h.in (gpgme_op_vfs_create): New prototype. * gpgme.def, libgpgme.vers: Add gpgme_op_vfs_create. * gpgme-tool.c (gt_vfs_create, cmd_vfs_create): New functions. (register_commands): Add VFS_CREATE and CREAET. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/ChangeLog 2009-11-03 19:15:35 UTC (rev 1413) @@ -1,3 +1,15 @@ +2009-11-03 Marcus Brinkmann + + * Makefile.am (main_sources): Change g13.c to vfs-mount.c. Add + vfs-create.c + * vfs-create.c: New file. + * g13.c: Renamed to ... + * vfs-mount.c: ... this new file. + * gpgme.h.in (gpgme_op_vfs_create): New prototype. + * gpgme.def, libgpgme.vers: Add gpgme_op_vfs_create. + * gpgme-tool.c (gt_vfs_create, cmd_vfs_create): New functions. + (register_commands): Add VFS_CREATE and CREAET. + 2009-11-02 Marcus Brinkmann * debug.h (_gpgme_debug_buffer): Make TAG argument const const. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/Makefile.am 2009-11-03 19:15:35 UTC (rev 1413) @@ -111,7 +111,7 @@ opassuan.c \ engine.h engine-backend.h engine.c engine-gpg.c status-table.h \ $(gpgsm_components) $(assuan_components) $(gpgconf_components) \ - $(g13_components) g13.c \ + $(g13_components) vfs-mount.c vfs-create.c \ gpgconf.c \ sema.h priv-io.h $(system_components) dirinfo.c \ debug.c debug.h gpgme.c version.c error.c Deleted: trunk/src/g13.c Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/gpgme-tool.c 2009-11-03 19:15:35 UTC (rev 1413) @@ -483,6 +483,7 @@ STATUS_TEXTMODE, STATUS_INCLUDE_CERTS, STATUS_KEYLIST_MODE, + STATUS_RECIPIENT, STATUS_ENCRYPT_RESULT } status_t; @@ -495,6 +496,7 @@ "TEXTMODE", "INCLUDE_CERTS", "KEYLIST_MODE", + "RECIPIENT", "ENCRYPT_RESULT" }; @@ -574,15 +576,96 @@ gpg_error_t -gt_recipients_add (gpgme_tool_t gt, const char *fpr) +gt_get_key (gpgme_tool_t gt, const char *pattern, gpgme_key_t *r_key) { + gpgme_ctx_t ctx; + gpgme_ctx_t listctx; + gpgme_error_t err; + gpgme_key_t key; + + if (!gt || !r_key || !pattern) + return gpg_error (GPG_ERR_INV_VALUE); + + ctx = gt->ctx; + + err = gpgme_new (&listctx); + if (err) + return err; + + { + gpgme_protocol_t proto; + gpgme_engine_info_t info; + + /* Clone the relevant state. */ + proto = gpgme_get_protocol (ctx); + /* The g13 protocol does not allow keylisting, we need to choose + something else. */ + if (proto == GPGME_PROTOCOL_G13) + proto = GPGME_PROTOCOL_OpenPGP; + + gpgme_set_protocol (listctx, proto); + gpgme_set_keylist_mode (listctx, gpgme_get_keylist_mode (ctx)); + info = gpgme_ctx_get_engine_info (ctx); + while (info && info->protocol != proto) + info = info->next; + if (info) + gpgme_ctx_set_engine_info (listctx, proto, + info->file_name, info->home_dir); + } + + err = gpgme_op_keylist_start (listctx, pattern, 0); + if (!err) + err = gpgme_op_keylist_next (listctx, r_key); + if (!err) + { + try_next_key: + err = gpgme_op_keylist_next (listctx, &key); + if (gpgme_err_code (err) == GPG_ERR_EOF) + err = 0; + else + { + if (!err + && *r_key && (*r_key)->subkeys && (*r_key)->subkeys->fpr + && key && key->subkeys && key->subkeys->fpr + && !strcmp ((*r_key)->subkeys->fpr, key->subkeys->fpr)) + { + /* The fingerprint is identical. We assume that this is + the same key and don't mark it as an ambiguous. This + problem may occur with corrupted keyrings and has + been noticed often with gpgsm. In fact gpgsm uses a + similar hack to sort out such duplicates but it can't + do that while listing keys. */ + gpgme_key_unref (key); + goto try_next_key; + } + if (!err) + { + gpgme_key_unref (key); + err = gpg_error (GPG_ERR_AMBIGUOUS_NAME); + } + gpgme_key_unref (*r_key); + } + } + gpgme_release (listctx); + + if (! err) + gt_write_status (gt, STATUS_RECIPIENT, + ((*r_key)->subkeys && (*r_key)->subkeys->fpr) ? + (*r_key)->subkeys->fpr : "invalid", NULL); + return err; +} + + +gpg_error_t +gt_recipients_add (gpgme_tool_t gt, const char *pattern) +{ gpg_error_t err; gpgme_key_t key; if (gt->recipients_nr >= MAX_RECIPIENTS) return gpg_error_from_errno (ENOMEM); - err = gpgme_get_key (gt->ctx, fpr, &key, 0); + err = gt_get_key (gt, pattern, &key); if (err) return err; @@ -962,6 +1045,18 @@ } +gpg_error_t +gt_vfs_create (gpgme_tool_t gt, const char *container_file, int flags) +{ + gpg_error_t err; + gpg_error_t op_err; + err = gpgme_op_vfs_create (gt->ctx, gt->recipients, container_file, + flags, &op_err); + gt_recipients_clear (gt); + return err || op_err; +} + + // TODO #define GT_RESULT_ENCRYPT 0x1 #define GT_RESULT_DECRYPT 0x2 @@ -1743,6 +1838,27 @@ static gpg_error_t +cmd_vfs_create (assuan_context_t ctx, char *line) +{ + struct server *server = assuan_get_pointer (ctx); + gpg_error_t err; + char *end; + + end = strchr (line, ' '); + if (end) + { + *(end++) = '\0'; + while (*end == ' ') + end++; + } + + err = gt_vfs_create (server->gt, line, 0); + + return err; +} + + +static gpg_error_t cmd_result (assuan_context_t ctx, char *line) { struct server *server = assuan_get_pointer (ctx); @@ -1835,6 +1951,8 @@ // TODO: ASSUAN { "VFS_MOUNT", cmd_vfs_mount }, { "MOUNT", cmd_vfs_mount }, + { "VFS_CREATE", cmd_vfs_create }, + { "CREATE", cmd_vfs_create }, // TODO: GPGCONF { "RESULT", cmd_result }, { "STRERROR", cmd_strerror }, Modified: trunk/src/gpgme.def =================================================================== --- trunk/src/gpgme.def 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/gpgme.def 2009-11-03 19:15:35 UTC (rev 1413) @@ -190,6 +190,7 @@ gpgme_wait_ext @145 gpgme_op_vfs_mount_result @146 gpgme_op_vfs_mount @147 + gpgme_op_vfs_create @148 ; END Modified: trunk/src/gpgme.h.in =================================================================== --- trunk/src/gpgme.h.in 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/gpgme.h.in 2009-11-03 19:15:35 UTC (rev 1413) @@ -1808,9 +1808,13 @@ or destroyed. Transmission errors are returned directly, operational errors are returned in OP_ERR. */ gpgme_error_t gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file, - const char *mount_dir, int flags, + const char *mount_dir, unsigned int flags, gpgme_error_t *op_err); +gpgme_error_t gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *container_file, + unsigned int flags, gpgme_error_t *op_err); + /* Interface to gpgconf(1). */ Modified: trunk/src/libgpgme.vers =================================================================== --- trunk/src/libgpgme.vers 2009-11-02 17:18:48 UTC (rev 1412) +++ trunk/src/libgpgme.vers 2009-11-03 19:15:35 UTC (rev 1413) @@ -71,6 +71,8 @@ gpgme_op_vfs_mount_result; gpgme_op_vfs_mount; + gpgme_op_vfs_create; + }; Added: trunk/src/vfs-create.c =================================================================== --- trunk/src/vfs-create.c (rev 0) +++ trunk/src/vfs-create.c 2009-11-03 19:15:35 UTC (rev 1413) @@ -0,0 +1,193 @@ +/* vfs-create.c - vfs create support in GPGME + Copyright (C) 2009 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +#include "gpgme.h" +#include "debug.h" +#include "context.h" +#include "ops.h" +#include "util.h" + +static gpgme_error_t +vfs_start (gpgme_ctx_t ctx, int synchronous, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value) +{ + gpgme_error_t err; + + if (!command || !*command) + return gpg_error (GPG_ERR_INV_VALUE); + + /* The flag value 256 is used to suppress an engine reset. This is + required to keep the connection running. */ + err = _gpgme_op_reset (ctx, ((synchronous & 255) | 256)); + if (err) + return err; + + return _gpgme_engine_op_assuan_transact (ctx->engine, command, + data_cb, data_cb_value, + inq_cb, inq_cb_value, + status_cb, status_cb_value); +} + + + +/* XXXX. This is the asynchronous variant. */ +static gpgme_error_t +gpgme_op_vfs_transact_start (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value) +{ + return vfs_start (ctx, 0, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, status_cb, status_cb_value); +} + + +/* XXXX. This is the synchronous variant. */ +static gpgme_error_t +gpgme_op_vfs_transact (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value, + gpgme_error_t *op_err) +{ + gpgme_error_t err; + + err = vfs_start (ctx, 1, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, status_cb, status_cb_value); + if (!err) + err = _gpgme_wait_one_ext (ctx, op_err); + return err; +} + + +/* The actual exported interface follows. */ + +/* The container is automatically uncreateed when the context is reset + or destroyed. This is a synchronous convenience interface, which + automatically returns an operation error if there is no + transmission error. */ +static gpgme_error_t +_gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *container_file, unsigned int flags, + gpgme_error_t *op_err) +{ + gpg_error_t err; + char *cmd; + char *container_file_esc = NULL; + int i; + + /* We want to encourage people to check error values, so not getting + them is discouraged here. Also makes our code easier. */ + if (! op_err) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_encode_percent_string (container_file, &container_file_esc, 0); + if (err) + return err; + + i = 0; + while (!err && recp[i]) + { + if (!recp[i]->subkeys || !recp[i]->subkeys->fpr) + { + free (container_file_esc); + return gpg_error (GPG_ERR_UNUSABLE_PUBKEY); + } + + if (asprintf (&cmd, "RECIPIENT %s", recp[i]->subkeys->fpr) < 0) + { + err = gpg_error_from_syserror (); + free (container_file_esc); + return err; + } + + err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL, + NULL, NULL, op_err); + free (cmd); + if (err || *op_err) + { + free (container_file_esc); + return err; + } + recp++; + } + + if (asprintf (&cmd, "CREATE -- %s", container_file_esc) < 0) + { + err = gpg_error_from_syserror (); + free (container_file_esc); + return err; + } + free (container_file_esc); + + err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL, + NULL, NULL, op_err); + free (cmd); + + return err; +} + + +gpgme_error_t +gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *container_file, unsigned int flags, + gpgme_error_t *op_err) +{ + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_vfs_create", ctx, + "container_file=%s, flags=0x%x, op_err=%p", + container_file, flags, op_err); + + if (_gpgme_debug_trace () && recp) + { + int i = 0; + + while (recp[i]) + { + TRACE_LOG3 ("recipient[%i] = %p (%s)", i, recp[i], + (recp[i]->subkeys && recp[i]->subkeys->fpr) ? + recp[i]->subkeys->fpr : "invalid"); + i++; + } + } + + return TRACE_ERR (_gpgme_op_vfs_create (ctx, recp, container_file, + flags, op_err)); +} + Copied: trunk/src/vfs-mount.c (from rev 1412, trunk/src/g13.c) =================================================================== --- trunk/src/vfs-mount.c (rev 0) +++ trunk/src/vfs-mount.c 2009-11-03 19:15:35 UTC (rev 1413) @@ -0,0 +1,210 @@ +/* vfs-mount.c - vfs mount support in GPGME + Copyright (C) 2009 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +#include "gpgme.h" +#include "debug.h" +#include "context.h" +#include "ops.h" +#include "util.h" + +typedef struct +{ + struct _gpgme_op_vfs_mount_result result; +} *op_data_t; + + + +gpgme_vfs_mount_result_t +gpgme_op_vfs_mount_result (gpgme_ctx_t ctx) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_VFS_MOUNT, &hook, -1, NULL); + opd = hook; + /* Check in case this function is used without having run a command + before. */ + if (err || !opd) + return NULL; + + return &opd->result; +} + + +static gpgme_error_t +vfs_start (gpgme_ctx_t ctx, int synchronous, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + if (!command || !*command) + return gpg_error (GPG_ERR_INV_VALUE); + + /* The flag value 256 is used to suppress an engine reset. This is + required to keep the connection running. */ + err = _gpgme_op_reset (ctx, ((synchronous & 255) | 256)); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_VFS_MOUNT, &hook, sizeof (*opd), + NULL); + opd = hook; + if (err) + return err; + + return _gpgme_engine_op_assuan_transact (ctx->engine, command, + data_cb, data_cb_value, + inq_cb, inq_cb_value, + status_cb, status_cb_value); +} + + + +/* XXXX. This is the asynchronous variant. */ +static gpgme_error_t +gpgme_op_vfs_transact_start (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value) +{ + return vfs_start (ctx, 0, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, status_cb, status_cb_value); +} + + +/* XXXX. This is the synchronous variant. */ +static gpgme_error_t +gpgme_op_vfs_transact (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value, + gpgme_error_t *op_err) +{ + gpgme_error_t err; + + err = vfs_start (ctx, 1, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, status_cb, status_cb_value); + if (!err) + err = _gpgme_wait_one_ext (ctx, op_err); + return err; +} + + +/* The actual exported interface follows. */ + +/* The container is automatically unmounted when the context is reset + or destroyed. This is a synchronous convenience interface, which + automatically returns an operation error if there is no + transmission error. */ +static gpgme_error_t +_gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file, + const char *mount_dir, int flags, gpgme_error_t *op_err) +{ + gpg_error_t err; + char *cmd; + char *container_file_esc = NULL; + + /* We want to encourage people to check error values, so not getting + them is discouraged here. Also makes our code easier. */ + if (! op_err) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_encode_percent_string (container_file, &container_file_esc, 0); + if (err) + return err; + + if (asprintf (&cmd, "OPEN -- %s", container_file_esc) < 0) + { + err = gpg_error_from_syserror (); + free (container_file_esc); + return err; + } + free (container_file_esc); + + err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL, + NULL, NULL, op_err); + free (cmd); + if (err || *op_err) + return err; + + if (mount_dir) + { + char *mount_dir_esc = NULL; + + err = _gpgme_encode_percent_string (mount_dir, &mount_dir_esc, 0); + if (err) + return err; + + if (asprintf (&cmd, "MOUNT -- %s", mount_dir_esc) < 0) + { + err = gpg_error_from_syserror (); + free (mount_dir_esc); + return err; + } + free (mount_dir_esc); + } + else + { + if (asprintf (&cmd, "MOUNT") < 0) + return gpg_error_from_syserror (); + } + + err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL, + NULL, NULL, op_err); + free (cmd); + + return err; +} + +gpgme_error_t +gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file, + const char *mount_dir, unsigned int flags, + gpgme_error_t *op_err) +{ + TRACE_BEG4 (DEBUG_CTX, "gpgme_op_vfs_mount", ctx, + "container=%s, mount_dir=%s, flags=0x%x, op_err=%p", + container_file, mount_dir, flags, op_err); + return TRACE_ERR (_gpgme_op_vfs_mount (ctx, container_file, mount_dir, + flags, op_err)); +} + From cvs at cvs.gnupg.org Tue Nov 3 20:29:20 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 20:29:20 +0100 Subject: [svn] GpgOL - r318 - trunk/src Message-ID: Author: wk Date: 2009-11-03 20:29:20 +0100 (Tue, 03 Nov 2009) New Revision: 318 Added: trunk/src/eventsink.h Log: More missing files.. :-( From cvs at cvs.gnupg.org Tue Nov 3 20:54:07 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 20:54:07 +0100 Subject: [svn] gpg-error - r225 - trunk Message-ID: Author: wk Date: 2009-11-03 20:54:06 +0100 (Tue, 03 Nov 2009) New Revision: 225 Modified: trunk/ChangeLog Log: Resolved changelog conflict Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-10-26 16:45:05 UTC (rev 224) +++ trunk/ChangeLog 2009-11-03 19:54:06 UTC (rev 225) @@ -2,6 +2,10 @@ * src/gpg-error.h.in (GPG_ERR_SOURCE_DIM): Reduce to 128. +2009-09-29 Werner Koch + + * src/err-codes.h.in (GPG_ERR_NO_ENGINE): New. + 2009-09-21 Werner Koch * src/err-sources.h.in (GPG_ERR_SOURCE_G13): New. From cvs at cvs.gnupg.org Tue Nov 3 21:27:35 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 03 Nov 2009 21:27:35 +0100 Subject: [svn] gpgme - r1414 - in trunk: doc src tests Message-ID: Author: wk Date: 2009-11-03 21:27:35 +0100 (Tue, 03 Nov 2009) New Revision: 1414 Modified: trunk/doc/gpgme.texi trunk/src/ChangeLog trunk/src/gpgme.h.in trunk/src/verify.c trunk/tests/ChangeLog trunk/tests/run-sign.c trunk/tests/run-support.h Log: Prepare for a new protocol. Comment clarification. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/src/ChangeLog 2009-11-03 20:27:35 UTC (rev 1414) @@ -1,3 +1,7 @@ +2009-11-03 Werner Koch + + * gpgme.h.in (GPGME_PROTOCOL_UISERVER): New. + 2009-11-03 Marcus Brinkmann * Makefile.am (main_sources): Change g13.c to vfs-mount.c. Add Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/tests/ChangeLog 2009-11-03 20:27:35 UTC (rev 1414) @@ -1,3 +1,9 @@ +2009-11-03 Werner Koch + + * run-support.h (fail_if_err): Include program name. + + * run-sign.c (main): Add option --uiserver. + 2009-10-26 Marcus Brinkmann * opassuan/t-command.c: Update to new interface. Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/doc/gpgme.texi 2009-11-03 20:27:35 UTC (rev 1414) @@ -766,6 +766,15 @@ @item GPGME_PROTOCOL_CMS This specifies the Cryptographic Message Syntax. + at item GPGME_PROTOCOL_ASSUAN +Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. + + at item GPGME_PROTOCOL_G13 +Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. + + at item GPGME_PROTOCOL_UISERVER +Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. + @item GPGME_PROTOCOL_UNKNOWN Reserved for future extension. You may use this to indicate that the used protocol is not known to the application. Currently, Modified: trunk/src/gpgme.h.in =================================================================== --- trunk/src/gpgme.h.in 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/src/gpgme.h.in 2009-11-03 20:27:35 UTC (rev 1414) @@ -325,6 +325,7 @@ GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */ GPGME_PROTOCOL_ASSUAN = 3, /* Low-level access to an Assuan server. */ GPGME_PROTOCOL_G13 = 4, + GPGME_PROTOCOL_UISERVER= 5, GPGME_PROTOCOL_UNKNOWN = 255 } gpgme_protocol_t; Modified: trunk/src/verify.c =================================================================== --- trunk/src/verify.c 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/src/verify.c 2009-11-03 20:27:35 UTC (rev 1414) @@ -201,7 +201,7 @@ sum |= GPGME_SIGSUM_BAD_POLICY; /* Set the valid flag when the signature is unquestionable - valid. */ + valid. (The test is identical to if(sum == GPGME_SIGSUM_GREEN)). */ if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN)) sum |= GPGME_SIGSUM_VALID; Modified: trunk/tests/run-sign.c =================================================================== --- trunk/tests/run-sign.c 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/tests/run-sign.c 2009-11-03 20:27:35 UTC (rev 1414) @@ -69,6 +69,7 @@ " --verbose run in verbose mode\n" " --openpgp use the OpenPGP protocol (default)\n" " --cms use the CMS protocol\n" + " --uiserver use the UI server\n" " --key NAME use key NAME for signing\n" , stderr); exit (ex); @@ -115,6 +116,11 @@ protocol = GPGME_PROTOCOL_CMS; argc--; argv++; } + else if (!strcmp (*argv, "--uiserver")) + { + protocol = GPGME_PROTOCOL_UISERVER; + argc--; argv++; + } else if (!strcmp (*argv, "--key")) { argc--; argv++; @@ -131,6 +137,12 @@ if (argc != 1) show_usage (1); + if (key_string && protocol == GPGME_PROTOCOL_UISERVER) + { + fprintf (stderr, PGM ": ignoring --key in UI-server mode\n"); + key_string = NULL; + } + init_gpgme (protocol); err = gpgme_new (&ctx); @@ -141,12 +153,10 @@ if (key_string) { gpgme_key_t akey; - + err = gpgme_get_key (ctx, key_string, &akey, 1); if (err) { - fprintf (stderr, PGM ": error getting key `%s': %s\n", - key_string, gpg_strerror (err)); exit (1); } err = gpgme_signers_add (ctx, akey); Modified: trunk/tests/run-support.h =================================================================== --- trunk/tests/run-support.h 2009-11-03 19:15:35 UTC (rev 1413) +++ trunk/tests/run-support.h 2009-11-03 20:27:35 UTC (rev 1414) @@ -38,7 +38,7 @@ { \ if (err) \ { \ - fprintf (stderr, "%s:%d: %s: %s\n", \ + fprintf (stderr, PGM": file %s line %d: <%s> %s\n", \ __FILE__, __LINE__, gpgme_strsource (err), \ gpgme_strerror (err)); \ exit (1); \ From cvs at cvs.gnupg.org Wed Nov 4 11:00:25 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 11:00:25 +0100 Subject: [svn] assuan - r314 - in trunk: . src tests Message-ID: Author: wk Date: 2009-11-04 11:00:24 +0100 (Wed, 04 Nov 2009) New Revision: 314 Modified: trunk/ChangeLog trunk/NEWS trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan.h trunk/tests/fdpassing.c Log: Extended HELP command. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/ChangeLog 2009-11-04 10:00:24 UTC (rev 314) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * tests/fdpassing.c (register_commands): Add NULL arg to + assuan_register_command. + 2009-10-16 Marcus Brinkmann * autogen.sh: Remove --with-pth-prefix from configure invocation. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/src/ChangeLog 2009-11-04 10:00:24 UTC (rev 314) @@ -1,3 +1,11 @@ +2009-11-04 Werner Koch + + * Makefile.am (common_sources): Add debug.h. + + * assuan-defs.h (cmdtbl_s): Add field HELPSTR. + * assuan-handler.c (assuan_register_command): Add arg HELP_STRING. + (std_handler_help): Print the help. + 2009-11-02 Marcus Brinkmann * assuan.h (assuan_handler_t): New type. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/NEWS 2009-11-04 10:00:24 UTC (rev 314) @@ -14,7 +14,8 @@ of NULL, you have to provide a non-NULL ARGV argument and check that against "server" or "client" to determine which end you got after fork(). If you use the assuan sock interface, you must call - assuan_sock_init after setting global context defaults. + assuan_sock_init after setting global context defaults. Add a NULL + as the last arg to assuan_register_command. * Pth support has changed. This now follows the same style as libgcrypt by setting system hook callbacks. @@ -68,11 +69,12 @@ assuan_sock_init NEW assuan_sock_deinit NEW assuan_handler_t NEW +assuan_register_command CHANGED: Add arg HELP_STRING. assuan_register_bye_notify CHANGED: Handler gets line and returns err now. assuan_register_reset_notify CHANGED: Handler gets line and returns err now. assuan_register_cancel_notify CHANGED: Handler gets line and returns err now. assuan_register_input_notify CHANGED: Handler returns error now. -assuan_register_output_notify CHANGED: Handler returns error now. +assuan_register_output_notify CHANGED: Handler returns error now. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/src/Makefile.am 2009-11-04 10:00:24 UTC (rev 314) @@ -39,7 +39,7 @@ assuan.c \ context.c \ system.c \ - debug.c \ + debug.c debug.h \ conversion.c \ assuan-error.c \ assuan-buffer.c \ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/src/assuan-defs.h 2009-11-04 10:00:24 UTC (rev 314) @@ -53,6 +53,7 @@ { const char *name; assuan_handler_t handler; + const char *helpstr; }; Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/src/assuan-handler.c 2009-11-04 10:00:24 UTC (rev 314) @@ -155,13 +155,56 @@ { unsigned int i; char buf[ASSUAN_LINELENGTH]; + const char *helpstr; + size_t n; - for (i = 0; i < ctx->cmdtbl_used; i++) + n = strcspn (line, " \t\n"); + if (!n) { - snprintf (buf, sizeof (buf), "# %s", ctx->cmdtbl[i].name); - buf[ASSUAN_LINELENGTH - 1] = '\0'; - assuan_write_line (ctx, buf); + /* Print all commands. If a help string is available and that + starts with the command name, print the first line of the + help string. */ + for (i = 0; i < ctx->cmdtbl_used; i++) + { + n = strlen (ctx->cmdtbl[i].name); + helpstr = ctx->cmdtbl[i].helpstr; + if (helpstr + && !strncmp (ctx->cmdtbl[i].name, helpstr, n) + && (!helpstr[n] || helpstr[n] == '\n' || helpstr[n] == ' ') + && (n = strcspn (helpstr, "\n")) ) + snprintf (buf, sizeof (buf), "# %.*s", (int)n, helpstr); + else + snprintf (buf, sizeof (buf), "# %s", ctx->cmdtbl[i].name); + buf[ASSUAN_LINELENGTH - 1] = '\0'; + assuan_write_line (ctx, buf); + } } + else + { + /* Print the help for the given command. */ + int c = line[n]; + line[n] = 0; + for (i=0; ctx->cmdtbl[i].name; i++) + if (!my_strcasecmp (line, ctx->cmdtbl[i].name)) + break; + line[n] = c; + if (!ctx->cmdtbl[i].name) + return PROCESS_DONE (ctx, set_error (ctx,GPG_ERR_UNKNOWN_COMMAND,NULL)); + helpstr = ctx->cmdtbl[i].helpstr; + if (!helpstr) + return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_NOT_FOUND, NULL)); + do + { + n = strcspn (helpstr, "\n"); + snprintf (buf, sizeof (buf), "# %.*s", (int)n, helpstr); + helpstr += n; + if (*helpstr == '\n') + helpstr++; + buf[ASSUAN_LINELENGTH - 1] = '\0'; + assuan_write_line (ctx, buf); + } + while (*helpstr); + } return PROCESS_DONE (ctx, 0); } @@ -275,6 +318,7 @@ * @cmd_name: A string with the command name * @handler: The handler function to be called or NULL to use a default * handler. + * HELPSTRING * * Register a handler to be used for a given command. Note that * several default handlers are already regsitered with a new context. @@ -284,7 +328,7 @@ **/ gpg_error_t assuan_register_command (assuan_context_t ctx, const char *cmd_name, - assuan_handler_t handler) + assuan_handler_t handler, const char *help_string) { int i; const char *s; @@ -332,6 +376,7 @@ ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name; ctx->cmdtbl[ctx->cmdtbl_used].handler = handler; + ctx->cmdtbl[ctx->cmdtbl_used].helpstr = help_string; ctx->cmdtbl_used++; return 0; } @@ -424,7 +469,7 @@ { if (std_cmd_table[i].always) { - rc = assuan_register_command (ctx, std_cmd_table[i].name, NULL); + rc = assuan_register_command (ctx, std_cmd_table[i].name, NULL, NULL); if (rc) return rc; } Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/src/assuan.h 2009-11-04 10:00:24 UTC (rev 314) @@ -305,9 +305,11 @@ /*-- assuan-handler.c --*/ gpg_error_t assuan_register_command (assuan_context_t ctx, const char *cmd_string, - assuan_handler_t handler); + assuan_handler_t handler, + const char *help_string); gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, gpg_error_t)); + void (*fnc)(assuan_context_t, + gpg_error_t)); gpg_error_t assuan_register_bye_notify (assuan_context_t ctx, assuan_handler_t handler); gpg_error_t assuan_register_reset_notify (assuan_context_t ctx, @@ -321,7 +323,8 @@ gpg_error_t assuan_register_option_handler (assuan_context_t ctx, gpg_error_t (*fnc)(assuan_context_t, - const char*, const char*)); + const char*, + const char*)); gpg_error_t assuan_process (assuan_context_t ctx); gpg_error_t assuan_process_next (assuan_context_t ctx); Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2009-11-02 17:33:53 UTC (rev 313) +++ trunk/tests/fdpassing.c 2009-11-04 10:00:24 UTC (rev 314) @@ -88,7 +88,7 @@ for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 11:06:39 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 11:06:39 +0100 Subject: [svn] GnuPG - r5189 - in trunk: agent g10 g13 scd sm Message-ID: Author: wk Date: 2009-11-04 11:06:38 +0100 (Wed, 04 Nov 2009) New Revision: 5189 Modified: trunk/agent/ChangeLog trunk/agent/command.c trunk/g10/ChangeLog trunk/g10/server.c trunk/g13/ChangeLog trunk/g13/server.c trunk/scd/ChangeLog trunk/scd/command.c trunk/sm/ChangeLog trunk/sm/server.c Log: Adjust for assuan_register_command change. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/agent/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * command.c (register_commands): Add NULL arg to + assuan_register_command. + 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/g10/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * server.c (register_commands): Add NULL arg to + assuan_register_command. + 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to Modified: trunk/g13/ChangeLog =================================================================== --- trunk/g13/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/g13/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) @@ -1,2 +1,4 @@ +2009-11-04 Werner Koch + Under initial development - no need for a ChangeLog. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/scd/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * command.c (register_commands): Add NULL arg to + assuan_register_command. + 2009-11-02 Marcus Brinkmann * command.c (reset_notify): Take LINE arg and return error. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/sm/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * server.c (register_commands): Add NULL arg to + assuan_register_command. + 2009-11-02 Marcus Brinkmann * server.c (reset_notify, input_notify, output_notify): Update to Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/agent/command.c 2009-11-04 10:06:38 UTC (rev 5189) @@ -1865,7 +1865,7 @@ for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; } Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/g10/server.c 2009-11-04 10:06:38 UTC (rev 5189) @@ -634,7 +634,7 @@ for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; } Modified: trunk/g13/server.c =================================================================== --- trunk/g13/server.c 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/g13/server.c 2009-11-04 10:06:38 UTC (rev 5189) @@ -212,6 +212,15 @@ further commands. The filename is reset with the RESET command, another OPEN or the CREATE command. */ +static const char hlp_open[] = + "OPEN [] \n" + "\n" + "Open the container FILENAME. FILENAME must be percent-plus\n" + "escaped. A quick check to see whether this is a suitable G13\n" + "container file is done. However no cryptographic check or any\n" + "other check is done. This command is used to define the target for\n" + "further commands. The filename is reset with the RESET command,\n" + "another OPEN or the CREATE command."; static gpg_error_t cmd_open (assuan_context_t ctx, char *line) { @@ -543,8 +552,9 @@ static struct { const char *name; assuan_handler_t handler; + const char * const help; } table[] = { - { "OPEN", cmd_open }, + { "OPEN", cmd_open, hlp_open }, { "MOUNT", cmd_mount }, { "UMOUNT", cmd_umount }, { "RECIPIENT", cmd_recipient }, @@ -560,7 +570,8 @@ for (i=0; table[i].name; i++) { - err = assuan_register_command (ctx, table[i].name, table[i].handler); + err = assuan_register_command (ctx, table[i].name, table[i].handler, + table[i].help); if (err) return err; } Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/scd/command.c 2009-11-04 10:06:38 UTC (rev 5189) @@ -1879,7 +1879,7 @@ for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; } Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2009-11-02 17:47:11 UTC (rev 5188) +++ trunk/sm/server.c 2009-11-04 10:06:38 UTC (rev 5189) @@ -1132,7 +1132,7 @@ for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 11:32:21 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 11:32:21 +0100 Subject: [svn] dirmngr - r329 - trunk/src Message-ID: Author: wk Date: 2009-11-04 11:32:21 +0100 (Wed, 04 Nov 2009) New Revision: 329 Modified: trunk/src/ChangeLog trunk/src/server.c Log: Provide help for all server commands. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-02 17:34:41 UTC (rev 328) +++ trunk/src/ChangeLog 2009-11-04 10:32:21 UTC (rev 329) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * server.c (register_commands): Add help arg to + assuan_register_command. Change all command comments to strings. + 2009-11-02 Marcus Brinkmann * server.c (reset_notify): Take LINE argument, return gpg_error_t. Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2009-11-02 17:34:41 UTC (rev 328) +++ trunk/src/server.c 2009-11-04 10:32:21 UTC (rev 329) @@ -1,6 +1,6 @@ /* dirmngr.c - LDAP access * Copyright (C) 2002 Klar?lvdalens Datakonsult AB - * Copyright (C) 2003, 2004, 2005, 2007, 2008 g10 Code GmbH + * Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 g10 Code GmbH * * This file is part of DirMngr. * @@ -437,7 +437,11 @@ return 0; } - +static const char hlp_ldapserver[] = + "LDAPSERVER \n" + "\n" + "Add a new LDAP server to the list of configured LDAP servers.\n" + "DATA is in the same format as expected in the configure file."; static gpg_error_t cmd_ldapserver (assuan_context_t ctx, char *line) { @@ -462,30 +466,29 @@ } -/* ISVALID [--only-ocsp] [--force-default-responder] - | - - This command checks whether the certificate identified by the - certificate_id is valid. This is done by consulting CRLs or - whatever has been configured. Note, that the returned error codes - are from gpg-error.h. The command may callback using the inquire - function. See the manual for details. - - The CERTIFICATE_ID is a hex encoded string consisting of two parts, - delimited by a single dot. The first part is the SHA-1 hash of the - issuer name and the second part the serial number. - - Alternatively the certificate's fingerprint may be given in which - case an OCSP request is done before consulting the CRL. - - If the option --only-ocsp is given, no fallback to a CRL check will - be used. - - If the option --force-default-responder is given, only the default - OCSP responder will be used and any other methods of obtaining an - OCSP responder URL won't be used. - */ - +static const char hlp_isvalid[] = + "ISVALID [--only-ocsp] [--force-default-responder]" + " |\n" + "\n" + "This command checks whether the certificate identified by the\n" + "certificate_id is valid. This is done by consulting CRLs or\n" + "whatever has been configured. Note, that the returned error codes\n" + "are from gpg-error.h. The command may callback using the inquire\n" + "function. See the manual for details.\n" + "\n" + "The CERTIFICATE_ID is a hex encoded string consisting of two parts,\n" + "delimited by a single dot. The first part is the SHA-1 hash of the\n" + "issuer name and the second part the serial number.\n" + "\n" + "Alternatively the certificate's fingerprint may be given in which\n" + "case an OCSP request is done before consulting the CRL.\n" + "\n" + "If the option --only-ocsp is given, no fallback to a CRL check will\n" + "be used.\n" + "\n" + "If the option --force-default-responder is given, only the default\n" + "OCSP responder will be used and any other methods of obtaining an\n" + "OCSP responder URL won't be used."; static gpg_error_t cmd_isvalid (assuan_context_t ctx, char *line) { @@ -615,26 +618,26 @@ -/* CHECKCRL [] - - Check whether the certificate with FINGERPRINT (SHA-1 hash of the - entire X.509 certificate blob) is valid or not by consulting the - CRL responsible for this certificate. If the fingerprint has not - been given or the certificate is not known, the function - inquires the certificate using an - - INQUIRE TARGETCERT - - and the caller is expected to return the certificate for the - request (which should match FINGERPRINT) as a binary blob. - Processing then takes place without further interaction; in - particular dirmngr tries to locate other required certificate by - its own mechanism which includes a local certificate store as well - as a list of trusted root certificates. - - The return value is the usual gpg-error code or 0 for ducesss; - i.e. the certificate validity has been confirmed by a valid CRL. -*/ +static const char hlp_checkcrl[] = + "CHECKCRL []\n" + "\n" + "Check whether the certificate with FINGERPRINT (SHA-1 hash of the\n" + "entire X.509 certificate blob) is valid or not by consulting the\n" + "CRL responsible for this certificate. If the fingerprint has not\n" + "been given or the certificate is not known, the function \n" + "inquires the certificate using an\n" + "\n" + " INQUIRE TARGETCERT\n" + "\n" + "and the caller is expected to return the certificate for the\n" + "request (which should match FINGERPRINT) as a binary blob.\n" + "Processing then takes place without further interaction; in\n" + "particular dirmngr tries to locate other required certificate by\n" + "its own mechanism which includes a local certificate store as well\n" + "as a list of trusted root certificates.\n" + "\n" + "The return value is the usual gpg-error code or 0 for ducesss;\n" + "i.e. the certificate validity has been confirmed by a valid CRL."; static gpg_error_t cmd_checkcrl (assuan_context_t ctx, char *line) { @@ -692,33 +695,33 @@ } -/* CHECKOCSP [--force-default-responder] [] - - Check whether the certificate with FINGERPRINT (SHA-1 hash of the - entire X.509 certificate blob) is valid or not by asking an OCSP - responder responsible for this certificate. The optional - fingerprint may be used for a quick check in case an OCSP check has - been done for this certificate recently (we always cache OCSP - responses for a couple of minutes). If the fingerprint has not been - given or there is no cached result, the function inquires the - certificate using an - - INQUIRE TARGETCERT - - and the caller is expected to return the certificate for the - request (which should match FINGERPRINT) as a binary blob. - Processing then takes place without further interaction; in - particular dirmngr tries to locate other required certificates by - its own mechanism which includes a local certificate store as well - as a list of trusted root certifciates. - - If the option --force-default-responder is given, only the default - OCSP responder will be used and any other methods of obtaining an - OCSP responder URL won't be used. - - The return value is the usual gpg-error code or 0 for ducesss; - i.e. the certificate validity has been confirmed by a valid CRL. -*/ +static const char hlp_checkocsp[] = + "CHECKOCSP [--force-default-responder] []\n" + "\n" + "Check whether the certificate with FINGERPRINT (SHA-1 hash of the\n" + "entire X.509 certificate blob) is valid or not by asking an OCSP\n" + "responder responsible for this certificate. The optional\n" + "fingerprint may be used for a quick check in case an OCSP check has\n" + "been done for this certificate recently (we always cache OCSP\n" + "responses for a couple of minutes). If the fingerprint has not been\n" + "given or there is no cached result, the function inquires the\n" + "certificate using an\n" + "\n" + " INQUIRE TARGETCERT\n" + "\n" + "and the caller is expected to return the certificate for the\n" + "request (which should match FINGERPRINT) as a binary blob.\n" + "Processing then takes place without further interaction; in\n" + "particular dirmngr tries to locate other required certificates by\n" + "its own mechanism which includes a local certificate store as well\n" + "as a list of trusted root certifciates.\n" + "\n" + "If the option --force-default-responder is given, only the default\n" + "OCSP responder will be used and any other methods of obtaining an\n" + "OCSP responder URL won't be used.\n" + "\n" + "The return value is the usual gpg-error code or 0 for ducesss;\n" + "i.e. the certificate validity has been confirmed by a valid CRL."; static gpg_error_t cmd_checkocsp (assuan_context_t ctx, char *line) { @@ -1024,27 +1027,25 @@ } -/* LOOKUP [--url] [--single] [--cache-only] - - Lookup certificates matching PATTERN. With --url the pattern is - expected to be one URL. - - If --url is not given: To allow for multiple - patterns (which are ORed) quoting is required: Spaces are to be - translated into "+" or into "%20"; obviously this requires that the - usual escape quoting rules are applied. - - If --url is given no special escaping is required because URLs are - already escaped this way. - - if --single is given the first and only the first match will be - returned. If --cache-only is _not_ given, no local query will be - done. - - if --cache-only is given no external lookup is done so that only - certificates from the cache may get returned. -*/ - +static const char hlp_lookup[] = + "LOOKUP [--url] [--single] [--cache-only] \n" + "\n" + "Lookup certificates matching PATTERN. With --url the pattern is\n" + "expected to be one URL.\n" + "\n" + "If --url is not given: To allow for multiple patterns (which are ORed)\n" + "quoting is required: Spaces are translated to \"+\" or \"%20\";\n" + "obviously this requires that the usual escape quoting rules are applied.\n" + "\n" + "If --url is given no special escaping is required because URLs are\n" + "already escaped this way.\n" + "\n" + "If --single is given the first and only the first match will be\n" + "returned. If --cache-only is _not_ given, no local query will be\n" + "done.\n" + "\n" + "If --cache-only is given no external lookup is done so that only\n" + "certificates from the cache may get returned."; static gpg_error_t cmd_lookup (assuan_context_t ctx, char *line) { @@ -1072,18 +1073,18 @@ } -/* LOADCRL [--url] - - Load the CRL in the file with name FILENAME into our cache. Note - that FILENAME should be given with an absolute path because - Dirmngrs cwd is not known. With --url the CRL is directly loaded - from the given URL. - - This command is usually used by gpgsm using the invocation "gpgsm - --call-dirmngr loadcrl ". A direct invocation of Dirmngr - is not useful because gpgsm might need to callback gpgsm to ask for - the CA's certificate. */ - +static const char hlp_loadcrl[] = + "LOADCRL [--url] \n" + "\n" + "Load the CRL in the file with name FILENAME into our cache. Note\n" + "that FILENAME should be given with an absolute path because\n" + "Dirmngrs cwd is not known. With --url the CRL is directly loaded\n" + "from the given URL.\n" + "\n" + "This command is usually used by gpgsm using the invocation \"gpgsm\n" + "--call-dirmngr loadcrl \". A direct invocation of Dirmngr\n" + "is not useful because gpgsm might need to callback gpgsm to ask for\n" + "the CA's certificate."; static gpg_error_t cmd_loadcrl (assuan_context_t ctx, char *line) { @@ -1131,14 +1132,13 @@ } -/* LISTCRLS - - List the content of all CRLs in a readable format. This command is - usually used by gpgsm using the invocation "gpgsm --call-dirmngr - listcrls". It may also be used directly using "dirmngr - --list-crls". -*/ - +static const char hlp_listcrls[] = + "LISTCRLS\n" + "\n" + "List the content of all CRLs in a readable format. This command is\n" + "usually used by gpgsm using the invocation \"gpgsm --call-dirmngr\n" + "listcrls\". It may also be used directly using \"dirmngr\n" + "--list-crls\"."; static gpg_error_t cmd_listcrls (assuan_context_t ctx, char *line) { @@ -1157,19 +1157,19 @@ } -/* CACHECERT - - Put a certificate into the internal cache. This command might be - useful if a client knows in advance certificates required for a - test and wnats to make sure they get added to the internal cache. - It is also helpful for debugging. To get the actual certificate, - this command immediately inquires it using - - INQUIRE TARGETCERT - - and the caller is expected to return the certificate for the - request as a binary blob. -*/ +static const char hlp_cachecert[] = + "CACHECERT\n" + "\n" + "Put a certificate into the internal cache. This command might be\n" + "useful if a client knows in advance certificates required for a\n" + "test and wnats to make sure they get added to the internal cache.\n" + "It is also helpful for debugging. To get the actual certificate,\n" + "this command immediately inquires it using\n" + "\n" + " INQUIRE TARGETCERT\n" + "\n" + "and the caller is expected to return the certificate for the\n" + "request as a binary blob."; static gpg_error_t cmd_cachecert (assuan_context_t ctx, char *line) { @@ -1211,18 +1211,18 @@ } -/* VALIDATE - - Validate a certificate using the certificate validation function - used internally by dirmngr. This command is only useful for - debugging. To get the actual certificate, this command immediately - inquires it using - - INQUIRE TARGETCERT - - and the caller is expected to return the certificate for the - request as a binary blob. -*/ +static const char hlp_validate[] = + "VALIDATE\n" + "\n" + "Validate a certificate using the certificate validation function\n" + "used internally by dirmngr. This command is only useful for\n" + "debugging. To get the actual certificate, this command immediately\n" + "inquires it using\n" + "\n" + " INQUIRE TARGETCERT\n" + "\n" + "and the caller is expected to return the certificate for the\n" + "request as a binary blob."; static gpg_error_t cmd_validate (assuan_context_t ctx, char *line) { @@ -1287,17 +1287,18 @@ { static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; + const char * const help; } table[] = { - { "LDAPSERVER", cmd_ldapserver }, - { "ISVALID", cmd_isvalid }, - { "CHECKCRL", cmd_checkcrl }, - { "CHECKOCSP", cmd_checkocsp }, - { "LOOKUP", cmd_lookup }, - { "LOADCRL", cmd_loadcrl }, - { "LISTCRLS", cmd_listcrls }, - { "CACHECERT", cmd_cachecert }, - { "VALIDATE", cmd_validate }, + { "LDAPSERVER", cmd_ldapserver, hlp_ldapserver }, + { "ISVALID", cmd_isvalid, hlp_isvalid }, + { "CHECKCRL", cmd_checkcrl, hlp_checkcrl }, + { "CHECKOCSP", cmd_checkocsp, hlp_checkocsp }, + { "LOOKUP", cmd_lookup, hlp_lookup }, + { "LOADCRL", cmd_loadcrl, hlp_loadcrl }, + { "LISTCRLS", cmd_listcrls, hlp_listcrls }, + { "CACHECERT", cmd_cachecert, hlp_cachecert }, + { "VALIDATE", cmd_validate, hlp_validate }, { "INPUT", NULL }, { "OUTPUT", NULL }, { NULL, NULL } @@ -1306,7 +1307,8 @@ for (i=j=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, + table[i].help); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 11:43:42 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 11:43:42 +0100 Subject: [svn] gpgme - r1415 - trunk/src Message-ID: Author: wk Date: 2009-11-04 11:43:42 +0100 (Wed, 04 Nov 2009) New Revision: 1415 Modified: trunk/src/ChangeLog trunk/src/gpgme-tool.c Log: Adjust for changed assuan_register_command. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-03 20:27:35 UTC (rev 1414) +++ trunk/src/ChangeLog 2009-11-04 10:43:42 UTC (rev 1415) @@ -1,3 +1,7 @@ +2009-11-04 Werner Koch + + * gpgme-tool.c (register_commands): Add HELP feature. + 2009-11-03 Werner Koch * gpgme.h.in (GPGME_PROTOCOL_UISERVER): New. Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-03 20:27:35 UTC (rev 1414) +++ trunk/src/gpgme-tool.c 2009-11-04 10:43:42 UTC (rev 1415) @@ -1174,7 +1174,10 @@ return 0; } - +static const char hlp_version[] = + "VERSION []\n" + "\n" + "Call the function gpgme_check_version."; static gpg_error_t cmd_version (assuan_context_t ctx, char *line) { @@ -1199,6 +1202,10 @@ } +static const char hlp_protocol[] = + "PROTOCOL []\n" + "\n" + "With NAME, set the protocol. Without return the current protocol."; static gpg_error_t cmd_protocol (assuan_context_t ctx, char *line) { @@ -1911,13 +1918,14 @@ gpg_error_t err; static struct { const char *name; - gpg_error_t (*handler)(assuan_context_t, char *line); + assuan_handler_t handler; + const char * const help; } table[] = { // RESET, BYE are implicit. - { "VERSION", cmd_version }, + { "VERSION", cmd_version, hlp_version }, // TODO: Set engine info. { "ENGINE", cmd_engine }, - { "PROTOCOL", cmd_protocol }, + { "PROTOCOL", cmd_protocol, hlp_protocol }, { "ARMOR", cmd_armor }, { "TEXTMODE", cmd_textmode }, { "INCLUDE_CERTS", cmd_include_certs }, @@ -1964,7 +1972,8 @@ for (idx = 0; table[idx].name; idx++) { - err = assuan_register_command (ctx, table[idx].name, table[idx].handler); + err = assuan_register_command (ctx, table[idx].name, table[idx].handler, + table[idx].help); if (err) return err; } From cvs at cvs.gnupg.org Wed Nov 4 11:59:11 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 11:59:11 +0100 Subject: [svn] GnuPG - r5190 - trunk/tools Message-ID: Author: wk Date: 2009-11-04 11:59:11 +0100 (Wed, 04 Nov 2009) New Revision: 5190 Modified: trunk/tools/ChangeLog trunk/tools/gpg-connect-agent.c Log: Add hack for the HELP command. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2009-11-04 10:06:38 UTC (rev 5189) +++ trunk/tools/ChangeLog 2009-11-04 10:59:11 UTC (rev 5190) @@ -1,3 +1,8 @@ +2009-11-04 Werner Koch + + * gpg-connect-agent.c (read_and_print_response): Add arg WITHHASH. + (main): Pass true for WITHHASH for the HELP command. + 2009-09-23 Marcus Brinkmann * gpg-connect-agent.c (getinfo_pid_cb, read_and_print_response) Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2009-11-04 10:06:38 UTC (rev 5189) +++ trunk/tools/gpg-connect-agent.c 2009-11-04 10:59:11 UTC (rev 5190) @@ -159,7 +159,8 @@ /*-- local prototypes --*/ static char *substitute_line_copy (const char *buffer); -static int read_and_print_response (assuan_context_t ctx, int *r_goterr); +static int read_and_print_response (assuan_context_t ctx, int withhash, + int *r_goterr); static assuan_context_t start_agent (void); @@ -1232,7 +1233,7 @@ exit (1); } - rc = assuan_pipe_connect_ext (ctx, *argv, argv, + rc = assuan_pipe_connect_ext (ctx, *argv, (const char **)argv, no_close, NULL, NULL, opt.connect_flags); if (rc) @@ -1274,7 +1275,7 @@ assuan did not run the initial handshaking). */ if (assuan_pending_line (ctx)) { - rc = read_and_print_response (ctx, &cmderr); + rc = read_and_print_response (ctx, 0, &cmderr); if (rc) log_info (_("receiving line failed: %s\n"), gpg_strerror (rc) ); } @@ -1762,7 +1763,9 @@ if (*line == '#' || !*line) continue; /* Don't expect a response for a comment line. */ - rc = read_and_print_response (ctx, &cmderr); + rc = read_and_print_response (ctx, (!ascii_strncasecmp (line, "HELP", 4) + && (spacep (line+4) || !line[4])), + &cmderr); if (rc) log_info (_("receiving line failed: %s\n"), gpg_strerror (rc) ); if ((rc || cmderr) && script_fp) @@ -1891,10 +1894,11 @@ /* Read all response lines from server and print them. Returns 0 on - success or an assuan error code. Set R_GOTERR to true if the - command did not returned OK. */ + success or an assuan error code. If WITHHASH istrue, comment lines + are printed. Sets R_GOTERR to true if the command did not returned + OK. */ static int -read_and_print_response (assuan_context_t ctx, int *r_goterr) +read_and_print_response (assuan_context_t ctx, int withhash, int *r_goterr) { char *line; size_t linelen; @@ -1911,7 +1915,7 @@ if (rc) return rc; - if (opt.verbose > 1 && *line == '#') + if ((withhash || opt.verbose > 1) && *line == '#') { fwrite (line, linelen, 1, stdout); putchar ('\n'); From cvs at cvs.gnupg.org Wed Nov 4 12:57:26 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 12:57:26 +0100 Subject: [svn] GnuPG - r5191 - trunk/g13 Message-ID: Author: wk Date: 2009-11-04 12:57:26 +0100 (Wed, 04 Nov 2009) New Revision: 5191 Modified: trunk/g13/server.c Log: Add help strings for all commands. Modified: trunk/g13/server.c =================================================================== --- trunk/g13/server.c 2009-11-04 10:59:11 UTC (rev 5190) +++ trunk/g13/server.c 2009-11-04 11:57:26 UTC (rev 5191) @@ -202,16 +202,6 @@ } - -/* OPEN [options] - - Open the container FILENAME. FILENAME must be percent-plus - escaped. A quick check to see whether this is a suitable G13 - container file is done. However no cryptographic check or any - other check is done. This command is used to define the target for - further commands. The filename is reset with the RESET command, - another OPEN or the CREATE command. - */ static const char hlp_open[] = "OPEN [] \n" "\n" @@ -272,12 +262,12 @@ } -/* MOUNT [options] [] - - Mount the currently open file onto MOUNTPOINT. If MOUNTPOINT is - not given the system picks an unused mountpoint. MOUNTPOINT must - be percent-plus escaped to allow for arbitrary names. - */ +static const char hlp_mount[] = + "MOUNT [options] []\n" + "\n" + "Mount the currently open file onto MOUNTPOINT. If MOUNTPOINT is not\n" + "given the system picks an unused mountpoint. MOUNTPOINT must\n" + "be percent-plus escaped to allow for arbitrary names."; static gpg_error_t cmd_mount (assuan_context_t ctx, char *line) { @@ -323,12 +313,12 @@ } -/* UMOUNT [options] [] - - Unmount the currently open file or the one opened at MOUNTPOINT. - MOUNTPOINT must be percent-plus escaped. On success the mountpoint - is returned via a "MOUNTPOINT" status line. - */ +static const char hlp_umount[] = + "UMOUNT [options] []\n" + "\n" + "Unmount the currently open file or the one opened at MOUNTPOINT.\n" + "MOUNTPOINT must be percent-plus escaped. On success the mountpoint\n" + "is returned via a \"MOUNTPOINT\" status line."; static gpg_error_t cmd_umount (assuan_context_t ctx, char *line) { @@ -368,13 +358,12 @@ } - -/* RECIPIENT - - FIXME - description. - All RECIPIENT commands are cumulative until a RESET or an - successful CREATE command. - */ +static const char hlp_recipient[] = + "RECIPIENT \n" + "\n" + "Add USERID to the list of recipients to be used for the next CREATE\n" + "command. All recipient commands are cumulative until a RESET or an\n" + "successful create command."; static gpg_error_t cmd_recipient (assuan_context_t ctx, char *line) { @@ -390,10 +379,10 @@ } -/* SIGNER - - FIXME - description. - */ +static const char hlp_signer[] = + "SIGNER \n" + "\n" + "Not yet implemented."; static gpg_error_t cmd_signer (assuan_context_t ctx, char *line) { @@ -408,11 +397,11 @@ } -/* CREATE [options] filename - - Create a new container. On success the OPEN command is done - implictly for the new container. - */ +static const char hlp_create[] = + "CREATE [options] \n" + "\n" + "Create a new container. On success the OPEN command is \n" + "implictly done for the new container."; static gpg_error_t cmd_create (assuan_context_t ctx, char *line) { @@ -466,17 +455,16 @@ } -/* GETINFO - - Multipurpose function to return a variety of information. - Supported values for WHAT are: - - version - Return the version of the program. - pid - Return the process id of the server. - cmd_has_option CMD OPT - - Returns OK if the command CMD implements the option OPT. - - */ +static const char hlp_getinfo[] = + "GETINFO \n" + "\n" + "Multipurpose function to return a variety of information.\n" + "Supported values for WHAT are:\n" + "\n" + " version - Return the version of the program.\n" + " pid - Return the process id of the server.\n" + " cmd_has_option CMD OPT\n" + " - Return OK if the command CMD implements the option OPT."; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { @@ -554,15 +542,15 @@ assuan_handler_t handler; const char * const help; } table[] = { - { "OPEN", cmd_open, hlp_open }, - { "MOUNT", cmd_mount }, - { "UMOUNT", cmd_umount }, - { "RECIPIENT", cmd_recipient }, - { "SIGNER", cmd_signer }, - { "CREATE", cmd_create }, + { "OPEN", cmd_open, hlp_open }, + { "MOUNT", cmd_mount, hlp_mount}, + { "UMOUNT", cmd_umount, hlp_umount }, + { "RECIPIENT", cmd_recipient, hlp_recipient }, + { "SIGNER", cmd_signer, hlp_signer }, + { "CREATE", cmd_create, hlp_create }, { "INPUT", NULL }, { "OUTPUT", NULL }, - { "GETINFO", cmd_getinfo }, + { "GETINFO", cmd_getinfo,hlp_getinfo }, { NULL } }; gpg_error_t err; From cvs at cvs.gnupg.org Wed Nov 4 12:58:16 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 12:58:16 +0100 Subject: [svn] GnuPG - r5192 - trunk/agent Message-ID: Author: wk Date: 2009-11-04 12:58:06 +0100 (Wed, 04 Nov 2009) New Revision: 5192 Modified: trunk/agent/ChangeLog trunk/agent/command.c Log: Add help strings for all commands. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-11-04 11:57:26 UTC (rev 5191) +++ trunk/agent/ChangeLog 2009-11-04 11:58:06 UTC (rev 5192) @@ -1,7 +1,8 @@ 2009-11-04 Werner Koch - * command.c (register_commands): Add NULL arg to - assuan_register_command. + * command.c (register_commands): Add help arg to + assuan_register_command. Convert all command comments to help + strings. 2009-11-02 Marcus Brinkmann Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-11-04 11:57:26 UTC (rev 5191) +++ trunk/agent/command.c 2009-11-04 11:58:06 UTC (rev 5192) @@ -264,7 +264,7 @@ parse_keygrip (assuan_context_t ctx, const char *string, unsigned char *buf) { int rc; - size_t n; + size_t n = 0; rc = parse_hexstring (ctx, string, &n); if (rc) @@ -343,19 +343,19 @@ -/* GETEVENTCOUNTER - - Return a a status line named EVENTCOUNTER with the current values - of all event counters. The values are decimal numbers in the range - 0 to UINT_MAX and wrapping around to 0. The actual values should - not be relied upon, they shall only be used to detect a change. - - The currently defined counters are: - - ANY - Incremented with any change of any of the other counters. - KEY - Incremented for added or removed private keys. - CARD - Incremented for changes of the card readers stati. -*/ +static const char hlp_geteventcounter[] = + "GETEVENTCOUNTER\n" + "\n" + "Return a a status line named EVENTCOUNTER with the current values\n" + "of all event counters. The values are decimal numbers in the range\n" + "0 to UINT_MAX and wrapping around to 0. The actual values should\n" + "not be relied upon, they shall only be used to detect a change.\n" + "\n" + "The currently defined counters are:\n" + "\n" + "ANY - Incremented with any change of any of the other counters.\n" + "KEY - Incremented for added or removed private keys.\n" + "CARD - Incremented for changes of the card readers stati."; static gpg_error_t cmd_geteventcounter (assuan_context_t ctx, char *line) { @@ -401,10 +401,11 @@ -/* ISTRUSTED - - Return OK when we have an entry with this fingerprint in our - trustlist */ +static const char hlp_istrusted[] = + "ISTRUSTED \n" + "\n" + "Return OK when we have an entry with this fingerprint in our\n" + "trustlist"; static gpg_error_t cmd_istrusted (assuan_context_t ctx, char *line) { @@ -439,9 +440,11 @@ } } -/* LISTTRUSTED - List all entries from the trustlist */ +static const char hlp_listtrusted[] = + "LISTTRUSTED\n" + "\n" + "List all entries from the trustlist."; static gpg_error_t cmd_listtrusted (assuan_context_t ctx, char *line) { @@ -456,9 +459,10 @@ } -/* MARKTRUSTED - - Store a new key in into the trustlist*/ +static const char hlp_martrusted[] = + "MARKTRUSTED \n" + "\n" + "Store a new key in into the trustlist."; static gpg_error_t cmd_marktrusted (assuan_context_t ctx, char *line) { @@ -500,9 +504,10 @@ -/* HAVEKEY - - Return success when the secret key is available */ +static const char hlp_havekey[] = + "HAVEKEY \n" + "\n" + "Return success when the secret key is available."; static gpg_error_t cmd_havekey (assuan_context_t ctx, char *line) { @@ -520,10 +525,11 @@ } -/* SIGKEY - SETKEY - - Set the key used for a sign or decrypt operation */ +static const char hlp_sigkey[] = + "SIGKEY \n" + "SETKEY \n" + "\n" + "Set the key used for a sign or decrypt operation."; static gpg_error_t cmd_sigkey (assuan_context_t ctx, char *line) { @@ -538,20 +544,20 @@ } -/* SETKEYDESC plus_percent_escaped_string - - Set a description to be used for the next PKSIGN or PKDECRYPT - operation if this operation requires the entry of a passphrase. If - this command is not used a default text will be used. Note, that - this description implictly selects the label used for the entry - box; if the string contains the string PIN (which in general will - not be translated), "PIN" is used, otherwise the translation of - "passphrase" is used. The description string should not contain - blanks unless they are percent or '+' escaped. - - The description is only valid for the next PKSIGN or PKDECRYPT - operation. -*/ +static const char hlp_setkeydesc[] = + "SETKEYDESC plus_percent_escaped_string\n" + "\n" + "Set a description to be used for the next PKSIGN or PKDECRYPT\n" + "operation if this operation requires the entry of a passphrase. If\n" + "this command is not used a default text will be used. Note, that\n" + "this description implictly selects the label used for the entry\n" + "box; if the string contains the string PIN (which in general will\n" + "not be translated), \"PIN\" is used, otherwise the translation of\n" + "\"passphrase\" is used. The description string should not contain\n" + "blanks unless they are percent or '+' escaped.\n" + "\n" + "The description is only valid for the next PKSIGN or PKDECRYPT\n" + "operation."; static gpg_error_t cmd_setkeydesc (assuan_context_t ctx, char *line) { @@ -582,10 +588,11 @@ } -/* SETHASH --hash=| - - The client can use this command to tell the server about the data - (which usually is a hash) to be signed. */ +static const char hlp_sethash[] = + "SETHASH --hash=| \n" + "\n" + "The client can use this command to tell the server about the data\n" + "(which usually is a hash) to be signed."; static gpg_error_t cmd_sethash (assuan_context_t ctx, char *line) { @@ -637,6 +644,7 @@ ctrl->digest.algo = algo; /* Parse the hash value. */ + n = 0; rc = parse_hexstring (ctx, line, &n); if (rc) return rc; @@ -660,10 +668,11 @@ } -/* PKSIGN - - Perform the actual sign operation. Neither input nor output are - sensitive to eavesdropping. */ +static const char hlp_pksign[] = + "PKSIGN [options]\n" + "\n" + "Perform the actual sign operation. Neither input nor output are\n" + "sensitive to eavesdropping."; static gpg_error_t cmd_pksign (assuan_context_t ctx, char *line) { @@ -694,10 +703,12 @@ return rc; } -/* PKDECRYPT - Perform the actual decrypt operation. Input is not - sensitive to eavesdropping */ +static const char hlp_pkdecrypt[] = + "PKDECRYPT \n" + "\n" + "Perform the actual decrypt operation. Input is not\n" + "sensitive to eavesdropping."; static gpg_error_t cmd_pkdecrypt (assuan_context_t ctx, char *line) { @@ -732,20 +743,20 @@ } -/* GENKEY - - Generate a new key, store the secret part and return the public - part. Here is an example transaction: - - C: GENKEY - S: INQUIRE KEYPARAM - C: D (genkey (rsa (nbits 1024))) - C: END - S: D (public-key - S: D (rsa (n 326487324683264) (e 10001))) - S OK key created -*/ - +static const char hlp_genkey[] = + "GENKEY\n" + "\n" + "Generate a new key, store the secret part and return the public\n" + "part. Here is an example transaction:\n" + "\n" + " C: GENKEY\n" + " S: INQUIRE KEYPARAM\n" + " C: D (genkey (rsa (nbits 1024)))\n" + " C: END\n" + " S: D (public-key\n" + " S: D (rsa (n 326487324683264) (e 10001)))\n" + " S: OK key created\n" + "\n"; static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { @@ -778,9 +789,10 @@ -/* READKEY - - Return the public key for the given keygrip. */ +static const char hlp_readkey[] = + "READKEY \n" + "\n" + "Return the public key for the given keygrip."; static gpg_error_t cmd_readkey (assuan_context_t ctx, char *line) { @@ -821,32 +833,32 @@ -/* KEYINFO [--list] - - Return information about the key specified by the KEYGRIP. If the - key is not available GPG_ERR_NOT_FOUND is returned. If the option - --list is given the keygrip is ignored and information about all - available keys are returned. The information is returned as a - status line with this format: - - KEYINFO - - KEYGRIP is the keygrip. - - TYPE is describes the type of the key: - 'D' - Regular key stored on disk, - 'T' - Key is stored on a smartcard (token). - '-' - Unknown type. - - SERIALNO is an ASCII string with the serial number of the - smartcard. If the serial number is not known a single - dash '-' is used instead. - - IDSTR is the IDSTR used to distinguish keys on a smartcard. If it - is not known a dash is used instead. - - More information may be added in the future. -*/ +static const char hlp_keyinfo[] = + "KEYINFO [--list] \n" + "\n" + "Return information about the key specified by the KEYGRIP. If the\n" + "key is not available GPG_ERR_NOT_FOUND is returned. If the option\n" + "--list is given the keygrip is ignored and information about all\n" + "available keys are returned. The information is returned as a\n" + "status line with this format:\n" + "\n" + " KEYINFO \n" + "\n" + "KEYGRIP is the keygrip.\n" + "\n" + "TYPE is describes the type of the key:\n" + " 'D' - Regular key stored on disk,\n" + " 'T' - Key is stored on a smartcard (token).\n" + " '-' - Unknown type.\n" + "\n" + "SERIALNO is an ASCII string with the serial number of the\n" + " smartcard. If the serial number is not known a single\n" + " dash '-' is used instead.\n" + "\n" + "IDSTR is the IDSTR used to distinguish keys on a smartcard. If it\n" + " is not known a dash is used instead.\n" + "\n" + "More information may be added in the future."; static gpg_error_t do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip) { @@ -988,34 +1000,33 @@ } -/* GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]] - [--qualitybar] - [ ] - - This function is usually used to ask for a passphrase to be used - for conventional encryption, but may also be used by programs which - need specal handling of passphrases. This command uses a syntax - which helps clients to use the agent with minimum effort. The - agent either returns with an error or with a OK followed by the hex - encoded passphrase. Note that the length of the strings is - implicitly limited by the maximum length of a command. - - If the option "--data" is used the passphrase is returned by usual - data lines and not on the okay line. - - If the option "--check" is used the passphrase constraints checks as - implemented by gpg-agent are applied. A check is not done if the - passphrase has been found in the cache. - - If the option "--no-ask" is used and the passphrase is not in the - cache the user will not be asked to enter a passphrase but the error - code GPG_ERR_NO_DATA is returned. - - If the option "--qualitybar" is used a visual indication of the - entered passphrase quality is shown. (Unless no minimum passphrase - length has been configured.) -*/ - +static const char hlp_get_passphrase[] = + "GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]]\n" + " [--qualitybar] \n" + " [ ]\n" + "\n" + "This function is usually used to ask for a passphrase to be used\n" + "for conventional encryption, but may also be used by programs which\n" + "need specal handling of passphrases. This command uses a syntax\n" + "which helps clients to use the agent with minimum effort. The\n" + "agent either returns with an error or with a OK followed by the hex\n" + "encoded passphrase. Note that the length of the strings is\n" + "implicitly limited by the maximum length of a command.\n" + "\n" + "If the option \"--data\" is used the passphrase is returned by usual\n" + "data lines and not on the okay line.\n" + "\n" + "If the option \"--check\" is used the passphrase constraints checks as\n" + "implemented by gpg-agent are applied. A check is not done if the\n" + "passphrase has been found in the cache.\n" + "\n" + "If the option \"--no-ask\" is used and the passphrase is not in the\n" + "cache the user will not be asked to enter a passphrase but the error\n" + "code GPG_ERR_NO_DATA is returned. \n" + "\n" + "If the option \"--qualitybar\" is used a visual indication of the\n" + "entered passphrase quality is shown. (Unless no minimum passphrase\n" + "length has been configured.)"; static gpg_error_t cmd_get_passphrase (assuan_context_t ctx, char *line) { @@ -1163,12 +1174,11 @@ } -/* CLEAR_PASSPHRASE - - may be used to invalidate the cache entry for a passphrase. The - function returns with OK even when there is no cached passphrase. -*/ - +static const char hlp_clear_passphrase[] = + "CLEAR_PASSPHRASE \n" + "\n" + "may be used to invalidate the cache entry for a passphrase. The\n" + "function returns with OK even when there is no cached passphrase."; static gpg_error_t cmd_clear_passphrase (assuan_context_t ctx, char *line) { @@ -1190,18 +1200,17 @@ } -/* GET_CONFIRMATION - - This command may be used to ask for a simple confirmation. - DESCRIPTION is displayed along with a Okay and Cancel button. This - command uses a syntax which helps clients to use the agent with - minimum effort. The agent either returns with an error or with a - OK. Note, that the length of DESCRIPTION is implicitly limited by - the maximum length of a command. DESCRIPTION should not contain - any spaces, those must be encoded either percent escaped or simply - as '+'. -*/ - +static const char hlp_get_confirmation[] = + "GET_CONFIRMATION \n" + "\n" + "This command may be used to ask for a simple confirmation.\n" + "DESCRIPTION is displayed along with a Okay and Cancel button. This\n" + "command uses a syntax which helps clients to use the agent with\n" + "minimum effort. The agent either returns with an error or with a\n" + "OK. Note, that the length of DESCRIPTION is implicitly limited by\n" + "the maximum length of a command. DESCRIPTION should not contain\n" + "any spaces, those must be encoded either percent escaped or simply\n" + "as '+'."; static gpg_error_t cmd_get_confirmation (assuan_context_t ctx, char *line) { @@ -1239,10 +1248,11 @@ -/* LEARN [--send] - - Learn something about the currently inserted smartcard. With - --send the new certificates are send back. */ +static const char hlp_learn[] = + "LEARN [--send]\n" + "\n" + "Learn something about the currently inserted smartcard. With\n" + "--send the new certificates are send back."; static gpg_error_t cmd_learn (assuan_context_t ctx, char *line) { @@ -1257,9 +1267,10 @@ -/* PASSWD - - Change the passphrase/PIN for the key identified by keygrip in LINE. */ +static const char hlp_passwd[] = + "PASSWD \n" + "\n" + "Change the passphrase/PIN for the key identified by keygrip in LINE."; static gpg_error_t cmd_passwd (assuan_context_t ctx, char *line) { @@ -1299,13 +1310,15 @@ return rc; } -/* PRESET_PASSPHRASE - - Set the cached passphrase/PIN for the key identified by the keygrip - to passwd for the given time, where -1 means infinite and 0 means - the default (currently only a timeout of -1 is allowed, which means - to never expire it). If passwd is not provided, ask for it via the - pinentry module. */ + +static const char hlp_preset_passphrase[] = + "PRESET_PASSPHRASE \n" + "\n" + "Set the cached passphrase/PIN for the key identified by the keygrip\n" + "to passwd for the given time, where -1 means infinite and 0 means\n" + "the default (currently only a timeout of -1 is allowed, which means\n" + "to never expire it). If passwd is not provided, ask for it via the\n" + "pinentry module."; static gpg_error_t cmd_preset_passphrase (assuan_context_t ctx, char *line) { @@ -1338,6 +1351,7 @@ line++; /* Syntax check the hexstring. */ + len = 0; rc = parse_hexstring (ctx, line, &len); if (rc) return rc; @@ -1364,11 +1378,13 @@ return rc; } + -/* SCD - - This is a general quote command to redirect everything to the - SCDAEMON. */ +static const char hlp_scd[] = + "SCD \n" + " \n" + "This is a general quote command to redirect everything to the\n" + "SCdaemon."; static gpg_error_t cmd_scd (assuan_context_t ctx, char *line) { @@ -1382,11 +1398,11 @@ -/* GETVAL - - Return the value for KEY from the special environment as created by - PUTVAL. - */ +static const char hlp_getval[] = + "GETVAL \n" + "\n" + "Return the value for KEY from the special environment as created by\n" + "PUTVAL."; static gpg_error_t cmd_getval (assuan_context_t ctx, char *line) { @@ -1426,24 +1442,24 @@ } -/* PUTVAL [] - - The gpg-agent maintains a kind of environment which may be used to - store key/value pairs in it, so that they can be retrieved later. - This may be used by helper daemons to daemonize themself on - invocation and register them with gpg-agent. Callers of the - daemon's service may now first try connect to get the information - for that service from gpg-agent through the GETVAL command and then - try to connect to that daemon. Only if that fails they may start - an own instance of the service daemon. - - KEY is an an arbitrary symbol with the same syntax rules as keys - for shell environment variables. PERCENT_ESCAPED_VALUE is the - corresponsing value; they should be similar to the values of - envronment variables but gpg-agent does not enforce any - restrictions. If that value is not given any value under that KEY - is removed from this special environment. -*/ +static const char hlp_putval[] = + "PUTVAL []\n" + "\n" + "The gpg-agent maintains a kind of environment which may be used to\n" + "store key/value pairs in it, so that they can be retrieved later.\n" + "This may be used by helper daemons to daemonize themself on\n" + "invocation and register them with gpg-agent. Callers of the\n" + "daemon's service may now first try connect to get the information\n" + "for that service from gpg-agent through the GETVAL command and then\n" + "try to connect to that daemon. Only if that fails they may start\n" + "an own instance of the service daemon. \n" + "\n" + "KEY is an an arbitrary symbol with the same syntax rules as keys\n" + "for shell environment variables. PERCENT_ESCAPED_VALUE is the\n" + "corresponsing value; they should be similar to the values of\n" + "envronment variables but gpg-agent does not enforce any\n" + "restrictions. If that value is not given any value under that KEY\n" + "is removed from this special environment."; static gpg_error_t cmd_putval (assuan_context_t ctx, char *line) { @@ -1513,12 +1529,13 @@ -/* UPDATESTARTUPTTY - - Set startup TTY and X DISPLAY variables to the values of this - session. This command is useful to pull future pinentries to - another screen. It is only required because there is no way in the - ssh-agent protocol to convey this information. */ +static const char hlp_updatestartuptty[] = + "UPDATESTARTUPTTY\n" + "\n" + "Set startup TTY and X11 DISPLAY variables to the values of this\n" + "session. This command is useful to pull future pinentries to\n" + "another screen. It is only required because there is no way in the\n" + "ssh-agent protocol to convey this information."; static gpg_error_t cmd_updatestartuptty (assuan_context_t ctx, char *line) { @@ -1574,10 +1591,11 @@ #ifdef HAVE_W32_SYSTEM -/* KILLAGENT - - Under Windows we start the agent on the fly. Thus it also make - sense to allow a client to stop the agent. */ +static const char hlp_killagent[] = + "KILLAGENT\n" + "\n" + "Under Windows we start the agent on the fly. Thus it also make\n" + "sense to allow a client to stop the agent."; static gpg_error_t cmd_killagent (assuan_context_t ctx, char *line) { @@ -1589,10 +1607,12 @@ return gpg_error (GPG_ERR_EOF); } -/* RELOADAGENT - As signals are inconvenient under Windows, we provide this command - to allow reloading of the configuration. */ +static const char hlp_reloadagent[] = + "RELOADAGENT\n" + "\n" + "As signals are inconvenient under Windows, we provide this command\n" + "to allow reloading of the configuration."; static gpg_error_t cmd_reloadagent (assuan_context_t ctx, char *line) { @@ -1606,20 +1626,19 @@ -/* GETINFO - - Multipurpose function to return a variety of information. - Supported values for WHAT are: - - version - Return the version of the program. - pid - Return the process id of the server. - socket_name - Return the name of the socket. - ssh_socket_name - Return the name of the ssh socket. - scd_running - Return OK if the SCdaemon is already running. - - gpg_error_t - - Returns OK if the command CMD implements the option OPT. - */ +static const char hlp_getinfo[] = + "GETINFO \n" + "\n" + "Multipurpose function to return a variety of information.\n" + "Supported values for WHAT are:\n" + "\n" + " version - Return the version of the program.\n" + " pid - Return the process id of the server.\n" + " socket_name - Return the name of the socket.\n" + " ssh_socket_name - Return the name of the ssh socket.\n" + " scd_running - Return OK if the SCdaemon is already running.\n" + " cmd_has_option\n" + " - Returns OK if the command CMD implements the option OPT."; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { @@ -1827,45 +1846,47 @@ static struct { const char *name; assuan_handler_t handler; + const char * const help; } table[] = { - { "GETEVENTCOUNTER",cmd_geteventcounter }, - { "ISTRUSTED", cmd_istrusted }, - { "HAVEKEY", cmd_havekey }, - { "KEYINFO", cmd_keyinfo }, - { "SIGKEY", cmd_sigkey }, - { "SETKEY", cmd_sigkey }, - { "SETKEYDESC", cmd_setkeydesc }, - { "SETHASH", cmd_sethash }, - { "PKSIGN", cmd_pksign }, - { "PKDECRYPT", cmd_pkdecrypt }, - { "GENKEY", cmd_genkey }, - { "READKEY", cmd_readkey }, - { "GET_PASSPHRASE", cmd_get_passphrase }, - { "PRESET_PASSPHRASE", cmd_preset_passphrase }, - { "CLEAR_PASSPHRASE", cmd_clear_passphrase }, - { "GET_CONFIRMATION", cmd_get_confirmation }, - { "LISTTRUSTED", cmd_listtrusted }, - { "MARKTRUSTED", cmd_marktrusted }, - { "LEARN", cmd_learn }, - { "PASSWD", cmd_passwd }, + { "GETEVENTCOUNTER",cmd_geteventcounter, hlp_geteventcounter }, + { "ISTRUSTED", cmd_istrusted, hlp_istrusted }, + { "HAVEKEY", cmd_havekey, hlp_havekey }, + { "KEYINFO", cmd_keyinfo, hlp_keyinfo }, + { "SIGKEY", cmd_sigkey, hlp_sigkey }, + { "SETKEY", cmd_sigkey, hlp_sigkey }, + { "SETKEYDESC", cmd_setkeydesc,hlp_setkeydesc }, + { "SETHASH", cmd_sethash, hlp_sethash }, + { "PKSIGN", cmd_pksign, hlp_pksign }, + { "PKDECRYPT", cmd_pkdecrypt, hlp_pkdecrypt }, + { "GENKEY", cmd_genkey, hlp_genkey }, + { "READKEY", cmd_readkey, hlp_readkey }, + { "GET_PASSPHRASE", cmd_get_passphrase, hlp_get_passphrase }, + { "PRESET_PASSPHRASE", cmd_preset_passphrase, hlp_preset_passphrase }, + { "CLEAR_PASSPHRASE", cmd_clear_passphrase, hlp_clear_passphrase }, + { "GET_CONFIRMATION", cmd_get_confirmation, hlp_get_confirmation }, + { "LISTTRUSTED", cmd_listtrusted, hlp_listtrusted }, + { "MARKTRUSTED", cmd_marktrusted, hlp_martrusted }, + { "LEARN", cmd_learn, hlp_learn }, + { "PASSWD", cmd_passwd, hlp_passwd }, { "INPUT", NULL }, { "OUTPUT", NULL }, - { "SCD", cmd_scd }, - { "GETVAL", cmd_getval }, - { "PUTVAL", cmd_putval }, - { "UPDATESTARTUPTTY", cmd_updatestartuptty }, + { "SCD", cmd_scd, hlp_scd }, + { "GETVAL", cmd_getval, hlp_getval }, + { "PUTVAL", cmd_putval, hlp_putval }, + { "UPDATESTARTUPTTY", cmd_updatestartuptty, hlp_updatestartuptty }, #ifdef HAVE_W32_SYSTEM - { "KILLAGENT", cmd_killagent }, - { "RELOADAGENT", cmd_reloadagent }, + { "KILLAGENT", cmd_killagent, hlp_killagent }, + { "RELOADAGENT", cmd_reloadagent,hlp_reloadagent }, #endif - { "GETINFO", cmd_getinfo }, + { "GETINFO", cmd_getinfo, hlp_getinfo }, { NULL } }; int i, rc; for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, + table[i].help); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 13:22:09 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 13:22:09 +0100 Subject: [svn] GnuPG - r5193 - trunk/scd Message-ID: Author: wk Date: 2009-11-04 13:22:09 +0100 (Wed, 04 Nov 2009) New Revision: 5193 Modified: trunk/scd/ChangeLog trunk/scd/command.c Log: Add help strings for all commands. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-11-04 11:58:06 UTC (rev 5192) +++ trunk/scd/ChangeLog 2009-11-04 12:22:09 UTC (rev 5193) @@ -1,7 +1,7 @@ 2009-11-04 Werner Koch - * command.c (register_commands): Add NULL arg to - assuan_register_command. + * command.c (register_commands): Add help arg to + assuan_register_command. Add help strings to all commands. 2009-11-02 Marcus Brinkmann Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-11-04 11:58:06 UTC (rev 5192) +++ trunk/scd/command.c 2009-11-04 12:22:09 UTC (rev 5193) @@ -466,25 +466,25 @@ } -/* SERIALNO [APPTYPE] - - Return the serial number of the card using a status reponse. This - function should be used to check for the presence of a card. - - If APPTYPE is given, an application of that type is selected and an - error is returned if the application is not supported or available. - The default is to auto-select the application using a hardwired - preference system. Note, that a future extension to this function - may allow to specify a list and order of applications to try. - - This function is special in that it can be used to reset the card. - Most other functions will return an error when a card change has - been detected and the use of this function is therefore required. - - Background: We want to keep the client clear of handling card - changes between operations; i.e. the client can assume that all - operations are done on the same card unless he calls this function. - */ +static const char hlp_serialno[] = + "SERIALNO []\n" + "\n" + "Return the serial number of the card using a status reponse. This\n" + "function should be used to check for the presence of a card.\n" + "\n" + "If APPTYPE is given, an application of that type is selected and an\n" + "error is returned if the application is not supported or available.\n" + "The default is to auto-select the application using a hardwired\n" + "preference system. Note, that a future extension to this function\n" + "may allow to specify a list and order of applications to try.\n" + "\n" + "This function is special in that it can be used to reset the card.\n" + "Most other functions will return an error when a card change has\n" + "been detected and the use of this function is therefore required.\n" + "\n" + "Background: We want to keep the client clear of handling card\n" + "changes between operations; i.e. the client can assume that all\n" + "operations are done on the same card unless he calls this function."; static gpg_error_t cmd_serialno (assuan_context_t ctx, char *line) { @@ -521,77 +521,75 @@ } - - -/* LEARN [--force] [--keypairinfo] - - Learn all useful information of the currently inserted card. When - used without the force options, the command might do an INQUIRE - like this: - - INQUIRE KNOWNCARDP - - The client should just send an "END" if the processing should go on - or a "CANCEL" to force the function to terminate with a Cancel - error message. - - With the option --keypairinfo only KEYPARIINFO lstatus lines are - returned. - - The response of this command is a list of status lines formatted as - this: - - S APPTYPE - - This returns the type of the application, currently the strings: - - P15 = PKCS-15 structure used - DINSIG = DIN SIG - OPENPGP = OpenPGP card - NKS = NetKey card - - are implemented. These strings are aliases for the AID - - S KEYPAIRINFO - - If there is no certificate yet stored on the card a single "X" is - returned as the keygrip. In addition to the keypair info, information - about all certificates stored on the card is also returned: - - S CERTINFO - - Where CERTTYPE is a number indicating the type of certificate: - 0 := Unknown - 100 := Regular X.509 cert - 101 := Trusted X.509 cert - 102 := Useful X.509 cert - 110 := Root CA cert in a special format (e.g. DINSIG) - 111 := Root CA cert as standard X509 cert. - - For certain cards, more information will be returned: - - S KEY-FPR - - For OpenPGP cards this returns the stored fingerprints of the - keys. This can be used check whether a key is available on the - card. NO may be 1, 2 or 3. - - S CA-FPR - - Similar to above, these are the fingerprints of keys assumed to be - ultimately trusted. - - S DISP-NAME - - The name of the card holder as stored on the card; percent - escaping takes place, spaces are encoded as '+' - - S PUBKEY-URL - - The URL to be used for locating the entire public key. - - Note, that this function may even be used on a locked card. -*/ +static const char hlp_learn[] = + "LEARN [--force] [--keypairinfo]\n" + "\n" + "Learn all useful information of the currently inserted card. When\n" + "used without the force options, the command might do an INQUIRE\n" + "like this:\n" + "\n" + " INQUIRE KNOWNCARDP \n" + "\n" + "The client should just send an \"END\" if the processing should go on\n" + "or a \"CANCEL\" to force the function to terminate with a Cancel\n" + "error message.\n" + "\n" + "With the option --keypairinfo only KEYPARIINFO lstatus lines are\n" + "returned.\n" + "\n" + "The response of this command is a list of status lines formatted as\n" + "this:\n" + "\n" + " S APPTYPE \n" + "\n" + "This returns the type of the application, currently the strings:\n" + "\n" + " P15 = PKCS-15 structure used\n" + " DINSIG = DIN SIG\n" + " OPENPGP = OpenPGP card\n" + " NKS = NetKey card\n" + "\n" + "are implemented. These strings are aliases for the AID\n" + "\n" + " S KEYPAIRINFO \n" + "\n" + "If there is no certificate yet stored on the card a single 'X' is\n" + "returned as the keygrip. In addition to the keypair info, information\n" + "about all certificates stored on the card is also returned:\n" + "\n" + " S CERTINFO \n" + "\n" + "Where CERTTYPE is a number indicating the type of certificate:\n" + " 0 := Unknown\n" + " 100 := Regular X.509 cert\n" + " 101 := Trusted X.509 cert\n" + " 102 := Useful X.509 cert\n" + " 110 := Root CA cert in a special format (e.g. DINSIG)\n" + " 111 := Root CA cert as standard X509 cert.\n" + "\n" + "For certain cards, more information will be returned:\n" + "\n" + " S KEY-FPR \n" + "\n" + "For OpenPGP cards this returns the stored fingerprints of the\n" + "keys. This can be used check whether a key is available on the\n" + "card. NO may be 1, 2 or 3.\n" + "\n" + " S CA-FPR \n" + "\n" + "Similar to above, these are the fingerprints of keys assumed to be\n" + "ultimately trusted.\n" + "\n" + " S DISP-NAME \n" + "\n" + "The name of the card holder as stored on the card; percent\n" + "escaping takes place, spaces are encoded as '+'\n" + "\n" + " S PUBKEY-URL \n" + "\n" + "The URL to be used for locating the entire public key.\n" + " \n" + "Note, that this function may even be used on a locked card."; static gpg_error_t cmd_learn (assuan_context_t ctx, char *line) { @@ -660,10 +658,10 @@ -/* READCERT | - - Note, that this function may even be used on a locked card. - */ +static const char hlp_readcert[] = + "READCERT |\n" + "\n" + "Note, that this function may even be used on a locked card."; static gpg_error_t cmd_readcert (assuan_context_t ctx, char *line) { @@ -694,13 +692,13 @@ } -/* READKEY - - Return the public key for the given cert or key ID as an standard - S-Expression. - - Note, that this function may even be used on a locked card. - */ +static const char hlp_readkey[] = + "READKEY \n" + "\n" + "Return the public key for the given cert or key ID as a standard\n" + "S-expression.\n" + "\n" + "Note, that this function may even be used on a locked card."; static gpg_error_t cmd_readkey (assuan_context_t ctx, char *line) { @@ -777,11 +775,10 @@ - -/* SETDATA - - The client should use this command to tell us the data he want to - sign. */ +static const char hlp_setdata[] = + "SETDATA \n" + "\n" + "The client should use this command to tell us the data he want to sign."; static gpg_error_t cmd_setdata (assuan_context_t ctx, char *line) { @@ -876,11 +873,10 @@ } -/* PKSIGN [--hash=[rmd160|sha{1,224,256,384,512}|md5]] - - The --hash option is optional; the default is SHA1. - - */ +static const char hlp_pksign[] = + "PKSIGN [--hash=[rmd160|sha{1,224,256,384,512}|md5]] \n" + "\n" + "The --hash option is optional; the default is SHA1."; static gpg_error_t cmd_pksign (assuan_context_t ctx, char *line) { @@ -948,9 +944,9 @@ return rc; } -/* PKAUTH - */ +static const char hlp_pkauth[] = + "PKAUTH "; static gpg_error_t cmd_pkauth (assuan_context_t ctx, char *line) { @@ -998,9 +994,9 @@ return rc; } -/* PKDECRYPT - */ +static const char hlp_pkdecrypt[] = + "PKDECRYPT "; static gpg_error_t cmd_pkdecrypt (assuan_context_t ctx, char *line) { @@ -1043,18 +1039,18 @@ } -/* GETATTR - - This command is used to retrieve data from a smartcard. The - allowed names depend on the currently selected smartcard - application. NAME must be percent and '+' escaped. The value is - returned through status message, see the LEARN command for details. - - However, the current implementation assumes that Name is not escaped; - this works as long as noone uses arbitrary escaping. - - Note, that this function may even be used on a locked card. -*/ +static const char hlp_getattr[] = + "GETATTR \n" + "\n" + "This command is used to retrieve data from a smartcard. The\n" + "allowed names depend on the currently selected smartcard\n" + "application. NAME must be percent and '+' escaped. The value is\n" + "returned through status message, see the LEARN command for details.\n" + "\n" + "However, the current implementation assumes that Name is not escaped;\n" + "this works as long as noone uses arbitrary escaping. \n" + "\n" + "Note, that this function may even be used on a locked card."; static gpg_error_t cmd_getattr (assuan_context_t ctx, char *line) { @@ -1082,18 +1078,19 @@ } -/* SETATTR - - This command is used to store data on a a smartcard. The allowed - names and values are depend on the currently selected smartcard - application. NAME and VALUE must be percent and '+' escaped. - - However, the current implementation assumes that NAME is not - escaped; this works as long as noone uses arbitrary escaping. - - A PIN will be requested for most NAMEs. See the corresponding - setattr function of the actually used application (app-*.c) for - details. */ +static const char hlp_setattr[] = + "SETATTR \n" + "\n" + "This command is used to store data on a a smartcard. The allowed\n" + "names and values are depend on the currently selected smartcard\n" + "application. NAME and VALUE must be percent and '+' escaped.\n" + "\n" + "However, the current implementation assumes that NAME is not\n" + "escaped; this works as long as noone uses arbitrary escaping.\n" + "\n" + "A PIN will be requested for most NAMEs. See the corresponding\n" + "setattr function of the actually used application (app-*.c) for\n" + "details."; static gpg_error_t cmd_setattr (assuan_context_t ctx, char *orig_line) { @@ -1134,17 +1131,17 @@ } - -/* WRITECERT - - This command is used to store a certifciate on a smartcard. The - allowed certids depend on the currently selected smartcard - application. The actual certifciate is requested using the inquiry - "CERTDATA" and needs to be provided in its raw (e.g. DER) form. - - In almost all cases a a PIN will be requested. See the related - writecert function of the actually used application (app-*.c) for - details. */ +static const char hlp_writecert[] = + "WRITECERT \n" + "\n" + "This command is used to store a certifciate on a smartcard. The\n" + "allowed certids depend on the currently selected smartcard\n" + "application. The actual certifciate is requested using the inquiry\n" + "\"CERTDATA\" and needs to be provided in its raw (e.g. DER) form.\n" + "\n" + "In almost all cases a a PIN will be requested. See the related\n" + "writecert function of the actually used application (app-*.c) for\n" + "details."; static gpg_error_t cmd_writecert (assuan_context_t ctx, char *line) { @@ -1196,20 +1193,20 @@ } - -/* WRITEKEY [--force] - - This command is used to store a secret key on a a smartcard. The - allowed keyids depend on the currently selected smartcard - application. The actual keydata is requested using the inquiry - "KEYDATA" and need to be provided without any protection. With - --force set an existing key under this KEYID will get overwritten. - The keydata is expected to be the usual canonical encoded - S-expression. - - A PIN will be requested for most NAMEs. See the corresponding - writekey function of the actually used application (app-*.c) for - details. */ +static const char hlp_writekey[] = + "WRITEKEY [--force] \n" + "\n" + "This command is used to store a secret key on a a smartcard. The\n" + "allowed keyids depend on the currently selected smartcard\n" + "application. The actual keydata is requested using the inquiry\n" + "\"KEYDATA\" and need to be provided without any protection. With\n" + "--force set an existing key under this KEYID will get overwritten.\n" + "The keydata is expected to be the usual canonical encoded\n" + "S-expression.\n" + "\n" + "A PIN will be requested for most NAMEs. See the corresponding\n" + "writekey function of the actually used application (app-*.c) for\n" + "details."; static gpg_error_t cmd_writekey (assuan_context_t ctx, char *line) { @@ -1263,29 +1260,27 @@ } - -/* GENKEY [--force] [--timestamp=] - - Generate a key on-card identified by NO, which is application - specific. Return values are application specific. For OpenPGP - cards 2 status lines are returned: - - S KEY-FPR - S KEY-CREATED-AT - S KEY-DATA [p|n] - - --force is required to overwrite an already existing key. The - KEY-CREATED-AT is required for further processing because it is - part of the hashed key material for the fingerprint. - - If --timestamp is given an OpenPGP key will be created using this - value. The value needs to be in ISO Format; e.g. - "--timestamp=20030316T120000" and after 1970-01-01 00:00:00. - - The public part of the key can also later be retrieved using the - READKEY command. - - */ +static const char hlp_genkey[] = + "GENKEY [--force] [--timestamp=] \n" + "\n" + "Generate a key on-card identified by NO, which is application\n" + "specific. Return values are application specific. For OpenPGP\n" + "cards 2 status lines are returned:\n" + "\n" + " S KEY-FPR \n" + " S KEY-CREATED-AT \n" + " S KEY-DATA [p|n] \n" + "\n" + "--force is required to overwrite an already existing key. The\n" + "KEY-CREATED-AT is required for further processing because it is\n" + "part of the hashed key material for the fingerprint.\n" + "\n" + "If --timestamp is given an OpenPGP key will be created using this\n" + "value. The value needs to be in ISO Format; e.g.\n" + "\"--timestamp=20030316T120000\" and after 1970-01-01 00:00:00.\n" + "\n" + "The public part of the key can also later be retrieved using the\n" + "READKEY command."; static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { @@ -1339,12 +1334,14 @@ } -/* RANDOM - - Get NBYTES of random from the card and send them back as data. - - Note, that this function may be even be used on a locked card. -*/ +static const char hlp_random[] = + "RANDOM \n" + "\n" + "Get NBYTES of random from the card and send them back as data.\n" + "This usually involves EEPROM write on the card and thus excessive\n" + "use of this command may destroy the card.\n" + "\n" + "Note, that this function may be even be used on a locked card."; static gpg_error_t cmd_random (assuan_context_t ctx, char *line) { @@ -1354,7 +1351,8 @@ unsigned char *buffer; if (!*line) - return set_error (GPG_ERR_ASS_PARAMETER, "number of requested bytes missing"); + return set_error (GPG_ERR_ASS_PARAMETER, + "number of requested bytes missing"); nbytes = strtoul (line, NULL, 0); if ((rc = open_card (ctrl, NULL))) @@ -1380,13 +1378,15 @@ return rc; } + -/* PASSWD [--reset] [--nullpin] - - Change the PIN or, if --reset is given, reset the retry counter of - the card holder verfication vector CHVNO. The option --nullpin is - used for TCOS cards to set the initial PIN. The format of CHVNO - depends on the card application. */ +static const char hlp_passwd[] = + "PASSWD [--reset] [--nullpin] \n" + "\n" + "Change the PIN or, if --reset is given, reset the retry counter of\n" + "the card holder verfication vector CHVNO. The option --nullpin is\n" + "used for TCOS cards to set the initial PIN. The format of CHVNO\n" + "depends on the card application."; static gpg_error_t cmd_passwd (assuan_context_t ctx, char *line) { @@ -1431,39 +1431,38 @@ } -/* CHECKPIN - - Perform a VERIFY operation without doing anything else. This may - be used to initialize a the PIN cache earlier to long lasting - operations. Its use is highly application dependent. - - For OpenPGP: - - Perform a simple verify operation for CHV1 and CHV2, so that - further operations won't ask for CHV2 and it is possible to do a - cheap check on the PIN: If there is something wrong with the PIN - entry system, only the regular CHV will get blocked and not the - dangerous CHV3. IDSTR is the usual card's serial number in hex - notation; an optional fingerprint part will get ignored. There - is however a special mode if the IDSTR is sffixed with the - literal string "[CHV3]": In this case the Admin PIN is checked - if and only if the retry counter is still at 3. - - For Netkey: - - Any of the valid PIN Ids may be used. These are the strings: - - PW1.CH - Global password 1 - PW2.CH - Global password 2 - PW1.CH.SIG - SigG password 1 - PW2.CH.SIG - SigG password 2 - - For a definitive list, see the implementation in app-nks.c. - Note that we call a PW2.* PIN a "PUK" despite that since TCOS - 3.0 they are technically alternative PINs used to mutally - unblock each other. - - */ +static const char hlp_checkpin[] = + "CHECKPIN \n" + "\n" + "Perform a VERIFY operation without doing anything else. This may\n" + "be used to initialize a the PIN cache earlier to long lasting\n" + "operations. Its use is highly application dependent.\n" + "\n" + "For OpenPGP:\n" + "\n" + " Perform a simple verify operation for CHV1 and CHV2, so that\n" + " further operations won't ask for CHV2 and it is possible to do a\n" + " cheap check on the PIN: If there is something wrong with the PIN\n" + " entry system, only the regular CHV will get blocked and not the\n" + " dangerous CHV3. IDSTR is the usual card's serial number in hex\n" + " notation; an optional fingerprint part will get ignored. There\n" + " is however a special mode if the IDSTR is sffixed with the\n" + " literal string \"[CHV3]\": In this case the Admin PIN is checked\n" + " if and only if the retry counter is still at 3.\n" + "\n" + "For Netkey:\n" + "\n" + " Any of the valid PIN Ids may be used. These are the strings:\n" + "\n" + " PW1.CH - Global password 1\n" + " PW2.CH - Global password 2\n" + " PW1.CH.SIG - SigG password 1\n" + " PW2.CH.SIG - SigG password 2\n" + "\n" + " For a definitive list, see the implementation in app-nks.c.\n" + " Note that we call a PW2.* PIN a \"PUK\" despite that since TCOS\n" + " 3.0 they are technically alternative PINs used to mutally\n" + " unblock each other."; static gpg_error_t cmd_checkpin (assuan_context_t ctx, char *line) { @@ -1497,16 +1496,16 @@ } -/* LOCK [--wait] - - Grant exclusive card access to this session. Note that there is - no lock counter used and a second lock from the same session will - be ignored. A single unlock (or RESET) unlocks the session. - Return GPG_ERR_LOCKED if another session has locked the reader. - - If the option --wait is given the command will wait until a - lock has been released. - */ +static const char hlp_lock[] = + "LOCK [--wait]\n" + "\n" + "Grant exclusive card access to this session. Note that there is\n" + "no lock counter used and a second lock from the same session will\n" + "be ignored. A single unlock (or RESET) unlocks the session.\n" + "Return GPG_ERR_LOCKED if another session has locked the reader.\n" + "\n" + "If the option --wait is given the command will wait until a\n" + "lock has been released."; static gpg_error_t cmd_lock (assuan_context_t ctx, char *line) { @@ -1541,10 +1540,10 @@ } -/* UNLOCK - - Release exclusive card access. - */ +static const char hlp_unlock[] = + "UNLOCK\n" + "\n" + "Release exclusive card access."; static gpg_error_t cmd_unlock (assuan_context_t ctx, char *line) { @@ -1569,34 +1568,33 @@ } -/* GETINFO - - Multi purpose command to return certain information. - Supported values of WHAT are: - - version - Return the version of the program. - pid - Return the process id of the server. - - socket_name - Return the name of the socket. - - status - Return the status of the current slot (in the future, may - also return the status of all slots). The status is a list of - one-character flags. The following flags are currently defined: - 'u' Usable card present. This is the normal state during operation. - 'r' Card removed. A reset is necessary. - These flags are exclusive. - - reader_list - Return a list of detected card readers. Does - currently only work with the internal CCID driver. - - deny_admin - Returns OK if admin commands are not allowed or - GPG_ERR_GENERAL if admin commands are allowed. - - app_list - Return a list of supported applications. One - application per line, fields delimited by colons, - first field is the name. -*/ - +static const char hlp_getinfo[] = + "GETINFO \n" + "\n" + "Multi purpose command to return certain information. \n" + "Supported values of WHAT are:\n" + "\n" + "version - Return the version of the program.\n" + "pid - Return the process id of the server.\n" + "\n" + "socket_name - Return the name of the socket.\n" + "\n" + "status - Return the status of the current slot (in the future, may\n" + "also return the status of all slots). The status is a list of\n" + "one-character flags. The following flags are currently defined:\n" + " 'u' Usable card present. This is the normal state during operation.\n" + " 'r' Card removed. A reset is necessary.\n" + "These flags are exclusive.\n" + "\n" + "reader_list - Return a list of detected card readers. Does\n" + " currently only work with the internal CCID driver.\n" + "\n" + "deny_admin - Returns OK if admin commands are not allowed or\n" + " GPG_ERR_GENERAL if admin commands are allowed.\n" + "\n" + "app_list - Return a list of supported applications. One\n" + " application per line, fields delimited by colons,\n" + " first field is the name."; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { @@ -1677,17 +1675,16 @@ } -/* RESTART - - Restart the current connection; this is a kind of warm reset. It - deletes the context used by this connection but does not send a - RESET to the card. Thus the card itself won't get reset. - - This is used by gpg-agent to reuse a primary pipe connection and - may be used by clients to backup from a conflict in the serial - command; i.e. to select another application. -*/ - +static const char hlp_restart[] = + "RESTART\n" + "\n" + "Restart the current connection; this is a kind of warm reset. It\n" + "deletes the context used by this connection but does not send a\n" + "RESET to the card. Thus the card itself won't get reset. \n" + "\n" + "This is used by gpg-agent to reuse a primary pipe connection and\n" + "may be used by clients to backup from a conflict in the serial\n" + "command; i.e. to select another application."; static gpg_error_t cmd_restart (assuan_context_t ctx, char *line) { @@ -1709,11 +1706,11 @@ } -/* DISCONNECT - - Disconnect the card if it is not any longer used by other - connections and the backend supports a disconnect operation. - */ +static const char hlp_disconnect[] = + "DISCONNECT\n" + "\n" + "Disconnect the card if it is not any longer used by other\n" + "connections and the backend supports a disconnect operation."; static gpg_error_t cmd_disconnect (assuan_context_t ctx, char *line) { @@ -1727,25 +1724,25 @@ -/* APDU [--atr] [--more] [--exlen[=N]] [hexstring] - - Send an APDU to the current reader. This command bypasses the high - level functions and sends the data directly to the card. HEXSTRING - is expected to be a proper APDU. If HEXSTRING is not given no - commands are set to the card but the command will implictly check - whether the card is ready for use. - - Using the option "--atr" returns the ATR of the card as a status - message before any data like this: - S CARD-ATR 3BFA1300FF813180450031C173C00100009000B1 - - Using the option --more handles the card status word MORE_DATA - (61xx) and concatenates all reponses to one block. - - Using the option "--exlen" the returned APDU may use extended - length up to N bytes. If N is not given a default value is used - (currently 4096). - */ +static const char hlp_apdu[] = + "APDU [--atr] [--more] [--exlen[=N]] [hexstring]\n" + "\n" + "Send an APDU to the current reader. This command bypasses the high\n" + "level functions and sends the data directly to the card. HEXSTRING\n" + "is expected to be a proper APDU. If HEXSTRING is not given no\n" + "commands are set to the card but the command will implictly check\n" + "whether the card is ready for use. \n" + "\n" + "Using the option \"--atr\" returns the ATR of the card as a status\n" + "message before any data like this:\n" + " S CARD-ATR 3BFA1300FF813180450031C173C00100009000B1\n" + "\n" + "Using the option --more handles the card status word MORE_DATA\n" + "(61xx) and concatenates all reponses to one block.\n" + "\n" + "Using the option \"--exlen\" the returned APDU may use extended\n" + "length up to N bytes. If N is not given a default value is used\n" + "(currently 4096)."; static gpg_error_t cmd_apdu (assuan_context_t ctx, char *line) { @@ -1826,7 +1823,10 @@ } -/* KILLSCD - Commit suicide. */ +static const char hlp_killscd[] = + "KILLSCD\n" + "\n" + "Commit suicide."; static gpg_error_t cmd_killscd (assuan_context_t ctx, char *line) { @@ -1847,39 +1847,41 @@ static struct { const char *name; assuan_handler_t handler; + const char * const help; } table[] = { - { "SERIALNO", cmd_serialno }, - { "LEARN", cmd_learn }, - { "READCERT", cmd_readcert }, - { "READKEY", cmd_readkey }, - { "SETDATA", cmd_setdata }, - { "PKSIGN", cmd_pksign }, - { "PKAUTH", cmd_pkauth }, - { "PKDECRYPT", cmd_pkdecrypt }, + { "SERIALNO", cmd_serialno, hlp_serialno }, + { "LEARN", cmd_learn, hlp_learn }, + { "READCERT", cmd_readcert, hlp_readcert }, + { "READKEY", cmd_readkey, hlp_readkey }, + { "SETDATA", cmd_setdata, hlp_setdata }, + { "PKSIGN", cmd_pksign, hlp_pksign }, + { "PKAUTH", cmd_pkauth, hlp_pkauth }, + { "PKDECRYPT", cmd_pkdecrypt,hlp_pkdecrypt }, { "INPUT", NULL }, { "OUTPUT", NULL }, - { "GETATTR", cmd_getattr }, - { "SETATTR", cmd_setattr }, - { "WRITECERT", cmd_writecert }, - { "WRITEKEY", cmd_writekey }, - { "GENKEY", cmd_genkey }, - { "RANDOM", cmd_random }, - { "PASSWD", cmd_passwd }, - { "CHECKPIN", cmd_checkpin }, - { "LOCK", cmd_lock }, - { "UNLOCK", cmd_unlock }, - { "GETINFO", cmd_getinfo }, - { "RESTART", cmd_restart }, - { "DISCONNECT", cmd_disconnect }, - { "APDU", cmd_apdu }, - { "KILLSCD", cmd_killscd }, + { "GETATTR", cmd_getattr, hlp_getattr }, + { "SETATTR", cmd_setattr, hlp_setattr }, + { "WRITECERT", cmd_writecert,hlp_writecert }, + { "WRITEKEY", cmd_writekey, hlp_writekey }, + { "GENKEY", cmd_genkey, hlp_genkey }, + { "RANDOM", cmd_random, hlp_random }, + { "PASSWD", cmd_passwd, hlp_passwd }, + { "CHECKPIN", cmd_checkpin, hlp_checkpin }, + { "LOCK", cmd_lock, hlp_lock }, + { "UNLOCK", cmd_unlock, hlp_unlock }, + { "GETINFO", cmd_getinfo, hlp_getinfo }, + { "RESTART", cmd_restart, hlp_restart }, + { "DISCONNECT", cmd_disconnect,hlp_disconnect }, + { "APDU", cmd_apdu, hlp_apdu }, + { "KILLSCD", cmd_killscd, hlp_killscd }, { NULL } }; int i, rc; for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, + table[i].help); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 16:31:53 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Nov 2009 16:31:53 +0100 Subject: [svn] GnuPG - r5194 - trunk/sm Message-ID: Author: wk Date: 2009-11-04 16:31:52 +0100 (Wed, 04 Nov 2009) New Revision: 5194 Modified: trunk/sm/ChangeLog trunk/sm/server.c Log: Add help strings for all commands Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-04 12:22:09 UTC (rev 5193) +++ trunk/sm/ChangeLog 2009-11-04 15:31:52 UTC (rev 5194) @@ -1,7 +1,7 @@ 2009-11-04 Werner Koch - * server.c (register_commands): Add NULL arg to - assuan_register_command. + * server.c (register_commands): Add help arg to + assuan_register_command. Provide help strings for all commands. 2009-11-02 Marcus Brinkmann Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2009-11-04 12:22:09 UTC (rev 5193) +++ trunk/sm/server.c 2009-11-04 15:31:52 UTC (rev 5194) @@ -360,18 +360,18 @@ } - -/* RECIPIENT - - Set the recipient for the encryption. should be the - internal representation of the key; the server may accept any other - way of specification [we will support this]. If this is a valid and - trusted recipient the server does respond with OK, otherwise the - return is an ERR with the reason why the recipient can't be used, - the encryption will then not be done for this recipient. If the - policy is not to encrypt at all if not all recipients are valid, the - client has to take care of this. All RECIPIENT commands are - cumulative until a RESET or an successful ENCRYPT command. */ +static const char hlp_recipient[] = + "RECIPIENT \n" + "\n" + "Set the recipient for the encryption. USERID shall be the\n" + "internal representation of the key; the server may accept any other\n" + "way of specification [we will support this]. If this is a valid and\n" + "trusted recipient the server does respond with OK, otherwise the\n" + "return is an ERR with the reason why the recipient can't be used,\n" + "the encryption will then not be done for this recipient. If the\n" + "policy is not to encrypt at all if not all recipients are valid, the\n" + "client has to take care of this. All RECIPIENT commands are\n" + "cumulative until a RESET or an successful ENCRYPT command."; static gpg_error_t cmd_recipient (assuan_context_t ctx, char *line) { @@ -395,19 +395,21 @@ return rc; } -/* SIGNER - Set the signer's keys for the signature creation. should - be the internal representation of the key; the server may accept any - other way of specification [we will support this]. If this is a - valid and usable signing key the server does respond with OK, - otherwise it returns an ERR with the reason why the key can't be - used, the signing will then not be done for this key. If the policy - is not to sign at all if not all signer keys are valid, the client - has to take care of this. All SIGNER commands are cumulative until - a RESET but they are *not* reset by an SIGN command becuase it can - be expected that set of signers are used for more than one sign - operation. */ +static const char hlp_signer[] = + "SIGNER \n" + "\n" + "Set the signer's keys for the signature creation. USERID should\n" + "be the internal representation of the key; the server may accept any\n" + "other way of specification [we will support this]. If this is a\n" + "valid and usable signing key the server does respond with OK,\n" + "otherwise it returns an ERR with the reason why the key can't be\n" + "used, the signing will then not be done for this key. If the policy\n" + "is not to sign at all if not all signer keys are valid, the client\n" + "has to take care of this. All SIGNER commands are cumulative until\n" + "a RESET but they are *not* reset by an SIGN command becuase it can\n" + "be expected that set of signers are used for more than one sign\n" + "operation."; static gpg_error_t cmd_signer (assuan_context_t ctx, char *line) { @@ -429,19 +431,20 @@ } -/* ENCRYPT - - Do the actual encryption process. Takes the plaintext from the INPUT - command, writes to the ciphertext to the file descriptor set with - the OUTPUT command, take the recipients form all the recipients set - so far. If this command fails the clients should try to delete all - output currently done or otherwise mark it as invalid. GPGSM does - ensure that there won't be any security problem with leftover data - on the output in this case. - - This command should in general not fail, as all necessary checks - have been done while setting the recipients. The input and output - pipes are closed. */ +static const char hlp_encrypt[] = + "ENCRYPT \n" + "\n" + "Do the actual encryption process. Takes the plaintext from the INPUT\n" + "command, writes to the ciphertext to the file descriptor set with\n" + "the OUTPUT command, take the recipients form all the recipients set\n" + "so far. If this command fails the clients should try to delete all\n" + "output currently done or otherwise mark it as invalid. GPGSM does\n" + "ensure that there won't be any security problem with leftover data\n" + "on the output in this case.\n" + "\n" + "This command should in general not fail, as all necessary checks\n" + "have been done while setting the recipients. The input and output\n" + "pipes are closed."; static gpg_error_t cmd_encrypt (assuan_context_t ctx, char *line) { @@ -492,13 +495,14 @@ } -/* DECRYPT - - This performs the decrypt operation after doing some check on the - internal state. (e.g. that only needed data has been set). Because - it utilizes the GPG-Agent for the session key decryption, there is - no need to ask the client for a protecting passphrase - GpgAgent - does take care of this by requesting this from the user. */ +static const char hlp_decrypt[] = + "DECRYPT\n" + "\n" + "This performs the decrypt operation after doing some check on the\n" + "internal state. (e.g. that only needed data has been set). Because\n" + "it utilizes the GPG-Agent for the session key decryption, there is\n" + "no need to ask the client for a protecting passphrase - GPG-Agent\n" + "does take care of this by requesting this from the user."; static gpg_error_t cmd_decrypt (assuan_context_t ctx, char *line) { @@ -534,15 +538,15 @@ } -/* VERIFY - - This does a verify operation on the message send to the input-FD. - The result is written out using status lines. If an output FD was - given, the signed text will be written to that. - - If the signature is a detached one, the server will inquire about - the signed material and the client must provide it. - */ +static const char hlp_verify[] = + "VERIFY\n" + "\n" + "This does a verify operation on the message send to the input FD.\n" + "The result is written out using status lines. If an output FD was\n" + "given, the signed text will be written to that.\n" + "\n" + "If the signature is a detached one, the server will inquire about\n" + "the signed material and the client must provide it."; static gpg_error_t cmd_verify (assuan_context_t ctx, char *line) { @@ -580,11 +584,12 @@ } -/* SIGN [--detached] - - Sign the data set with the INPUT command and write it to the sink - set by OUTPUT. With "--detached" specified, a detached signature is - created (surprise). */ +static const char hlp_sign[] = + "SIGN [--detached]\n" + "\n" + "Sign the data set with the INPUT command and write it to the sink\n" + "set by OUTPUT. With \"--detached\", a detached signature is\n" + "created (surprise)."; static gpg_error_t cmd_sign (assuan_context_t ctx, char *line) { @@ -622,17 +627,18 @@ } -/* IMPORT [--re-import] - - Import the certificates read form the input-fd, return status - message for each imported one. The import checks the validity of - the certificate but not of the entire chain. It is possible to - import expired certificates. - - With the option --re-import the input data is expected to a be a LF - separated list of fingerprints. The command will re-import these - certificates, meaning that they are made permanent by removing - their ephemeral flag. */ +static const char hlp_import[] = + "IMPORT [--re-import]\n" + "\n" + "Import the certificates read form the input-fd, return status\n" + "message for each imported one. The import checks the validity of\n" + "the certificate but not of the entire chain. It is possible to\n" + "import expired certificates.\n" + "\n" + "With the option --re-import the input data is expected to a be a LF\n" + "separated list of fingerprints. The command will re-import these\n" + "certificates, meaning that they are made permanent by removing\n" + "their ephemeral flag."; static gpg_error_t cmd_import (assuan_context_t ctx, char *line) { @@ -657,10 +663,14 @@ } -/* EXPORT [--data [--armor|--base64]] [--] pattern - - */ - +static const char hlp_export[] = + "EXPORT [--data [--armor|--base64]] [--] \n" + "\n" + "Export the certificates selected by PATTERN. With --data the output\n" + "is returned using Assuan D lines; the default is to use the sink given\n" + "by the last \"OUTPUT\" command. The options --armor or --base64 encode \n" + "the output using the PEM respective a plain base-64 format; the default\n" + "is a binary format which is only suitable for a single certificate."; static gpg_error_t cmd_export (assuan_context_t ctx, char *line) { @@ -747,6 +757,13 @@ } + +static const char hlp_delkeys[] = + "DELKEYS \n" + "\n" + "Delete the certificates specified by PATTERNS. Each pattern shall be\n" + "a percent-plus escaped certificate specification. Usually a\n" + "fingerprint will be used for this."; static gpg_error_t cmd_delkeys (assuan_context_t ctx, char *line) { @@ -791,10 +808,27 @@ -/* MESSAGE FD= - - Set the file descriptor to read a message which is used with - detached signatures */ +static const char hlp_output[] = + "OUTPUT FD[=]\n" + "\n" + "Set the file descriptor to write the output data to N. If N is not\n" + "given and the operating system supports file descriptor passing, the\n" + "file descriptor currently in flight will be used. See also the\n" + "\"INPUT\" and \"MESSAGE\" commands."; +static const char hlp_input[] = + "INPUT FD[=]\n" + "\n" + "Set the file descriptor to read the input data to N. If N is not\n" + "given and the operating system supports file descriptor passing, the\n" + "file descriptor currently in flight will be used. See also the\n" + "\"MESSAGE\" and \"OUTPUT\" commands."; +static const char hlp_message[] = + "MESSAGE FD[=]\n" + "\n" + "Set the file descriptor to read the message for a detached\n" + "signatures to N. If N is not given and the operating system\n" + "supports file descriptor passing, the file descriptor currently in\n" + "flight will be used. See also the \"INPUT\" and \"OUTPUT\" commands."; static gpg_error_t cmd_message (assuan_context_t ctx, char *line) { @@ -813,11 +847,36 @@ return 0; } -/* LISTKEYS [] - DUMPKEYS [] - LISTSECRETKEYS [] - DUMPSECRETKEYS [] -*/ + + +static const char hlp_listkeys[] = + "LISTKEYS []\n" + "LISTSECRETKEYS []\n" + "DUMPKEYS []\n" + "DUMPSECRETKEYS []\n" + "\n" + "List all certificates or only those specified by PATTERNS. Each\n" + "pattern shall be a percent-plus escaped certificate specification.\n" + "The \"SECRET\" versions of the command filter the output to include\n" + "only certificates where the secret key is available or a corresponding\n" + "smartcard has been registered. The \"DUMP\" versions of the command\n" + "are only useful for debugging. The output format is a percent escaped\n" + "colon delimited listing as described in the manual.\n" + "\n" + "These \"OPTION\" command keys effect the output::\n" + "\n" + " \"list-mode\" set to 0: List only local certificates (default).\n" + " 1: Ditto.\n" + " 2: List only external certificates.\n" + " 3: List local and external certificates.\n" + "\n" + " \"with-validation\" set to true: Validate each certificate.\n" + "\n" + " \"with-ephemeral-key\" set to true: Always include ephemeral\n" + " certificates.\n" + "\n" + " \"list-to-output\" set to true: Write output to the file descriptor\n" + " given by the last \"OUTPUT\" command."; static int do_listkeys (assuan_context_t ctx, char *line, int mode) { @@ -907,12 +966,13 @@ return do_listkeys (ctx, line, 258); } + -/* GENKEY - - Read the parameters in native format from the input fd and write a - certificate request to the output. - */ +static const char hlp_genkey[] = + "GENKEY\n" + "\n" + "Read the parameters in native format from the input fd and write a\n" + "certificate request to the output."; static gpg_error_t cmd_genkey (assuan_context_t ctx, char *line) { @@ -953,16 +1013,14 @@ -/* GETAUDITLOG [--data] [--html] - - !!!WORK in PROGRESS!!! - - If --data is used, the output is send using D-lines and not to the - source given by an OUTPUT command. - - If --html is used the output is formated as an XHTML block. This is - designed to be incorporated into a HTML document. - */ +static const char hlp_getauditlog[] = + "GETAUDITLOG [--data] [--html]\n" + "\n" + "If --data is used, the output is send using D-lines and not to the\n" + "file descriptor given by an OUTPUT command.\n" + "\n" + "If --html is used the output is formated as an XHTML block. This is\n" + "designed to be incorporated into a HTML document."; static gpg_error_t cmd_getauditlog (assuan_context_t ctx, char *line) { @@ -1011,18 +1069,17 @@ } -/* GETINFO - - Multipurpose function to return a variety of information. - Supported values for WHAT are: - - version - Return the version of the program. - pid - Return the process id of the server. - agent-check - Return success if the agent is running. - cmd_has_option CMD OPT - - Returns OK if the command CMD implements the option OPT. - - */ +static const char hlp_getinfo[] = + "GETINFO \n" + "\n" + "Multipurpose function to return a variety of information.\n" + "Supported values for WHAT are:\n" + "\n" + " version - Return the version of the program.\n" + " pid - Return the process id of the server.\n" + " agent-check - Return success if the agent is running.\n" + " cmd_has_option CMD OPT\n" + " - Returns OK if the command CMD implements the option OPT."; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) { @@ -1106,33 +1163,35 @@ static struct { const char *name; assuan_handler_t handler; + const char * const help; } table[] = { - { "RECIPIENT", cmd_recipient }, - { "SIGNER", cmd_signer }, - { "ENCRYPT", cmd_encrypt }, - { "DECRYPT", cmd_decrypt }, - { "VERIFY", cmd_verify }, - { "SIGN", cmd_sign }, - { "IMPORT", cmd_import }, - { "EXPORT", cmd_export }, - { "INPUT", NULL }, - { "OUTPUT", NULL }, - { "MESSAGE", cmd_message }, - { "LISTKEYS", cmd_listkeys }, - { "DUMPKEYS", cmd_dumpkeys }, - { "LISTSECRETKEYS",cmd_listsecretkeys }, - { "DUMPSECRETKEYS",cmd_dumpsecretkeys }, - { "GENKEY", cmd_genkey }, - { "DELKEYS", cmd_delkeys }, - { "GETAUDITLOG", cmd_getauditlog }, - { "GETINFO", cmd_getinfo }, + { "RECIPIENT", cmd_recipient, hlp_recipient }, + { "SIGNER", cmd_signer, hlp_signer }, + { "ENCRYPT", cmd_encrypt, hlp_encrypt }, + { "DECRYPT", cmd_decrypt, hlp_decrypt }, + { "VERIFY", cmd_verify, hlp_verify }, + { "SIGN", cmd_sign, hlp_sign }, + { "IMPORT", cmd_import, hlp_import }, + { "EXPORT", cmd_export, hlp_export }, + { "INPUT", NULL, hlp_input }, + { "OUTPUT", NULL, hlp_output }, + { "MESSAGE", cmd_message, hlp_message }, + { "LISTKEYS", cmd_listkeys, hlp_listkeys }, + { "DUMPKEYS", cmd_dumpkeys, hlp_listkeys }, + { "LISTSECRETKEYS",cmd_listsecretkeys, hlp_listkeys }, + { "DUMPSECRETKEYS",cmd_dumpsecretkeys, hlp_listkeys }, + { "GENKEY", cmd_genkey, hlp_genkey }, + { "DELKEYS", cmd_delkeys, hlp_delkeys }, + { "GETAUDITLOG", cmd_getauditlog, hlp_getauditlog }, + { "GETINFO", cmd_getinfo, hlp_getinfo }, { NULL } }; int i, rc; for (i=0; table[i].name; i++) { - rc = assuan_register_command (ctx, table[i].name, table[i].handler, NULL); + rc = assuan_register_command (ctx, table[i].name, table[i].handler, + table[i].help); if (rc) return rc; } From cvs at cvs.gnupg.org Wed Nov 4 19:13:45 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 04 Nov 2009 19:13:45 +0100 Subject: [svn] gpgme - r1416 - trunk/src Message-ID: Author: marcus Date: 2009-11-04 19:13:44 +0100 (Wed, 04 Nov 2009) New Revision: 1416 Modified: trunk/src/ChangeLog trunk/src/ath-pth.c trunk/src/ath-pthread.c trunk/src/ath.c trunk/src/ath.h trunk/src/debug.c trunk/src/debug.h trunk/src/posix-io.c trunk/src/version.c Log: 2009-11-04 Marcus Brinkmann * ath.h (ath_self): New prototype. Include * ath.c, ath-pth.c, ath-pthread.c (ath_self): New function. * debug.h: Rewrite most macros to beautify debug output. (_gpgme_debug_buffer): Remove tagname and tag argument. (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New prototypes. * debug.c: Include . Don't include assuan.h. (frame_nr, FRAME_NR): New thread-specific variable and macro. (debug_init): Do not initialize assuan. Call _gpgme_debug after initialization instead using printf directly. (_gpgme_debug): Do not call debug_init (we now ensure proper initialization by user). Add timestamp and thread/process ID. (_gpgme_debug_buffer): Do not take tagname and tag argument. (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New functions. * version.c (gpgme_check_version_internal, gpgme_check_version): Fix debug string. Do not initialize assuan. * posix-io.c (get_max_fds): Use 0 not NULL (nicer debug output). Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/ChangeLog 2009-11-04 18:13:44 UTC (rev 1416) @@ -1,3 +1,22 @@ +2009-11-04 Marcus Brinkmann + + * ath.h (ath_self): New prototype. Include + * ath.c, ath-pth.c, ath-pthread.c (ath_self): New function. + * debug.h: Rewrite most macros to beautify debug output. + (_gpgme_debug_buffer): Remove tagname and tag argument. + (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New prototypes. + * debug.c: Include . Don't include assuan.h. + (frame_nr, FRAME_NR): New thread-specific variable and macro. + (debug_init): Do not initialize assuan. Call _gpgme_debug after + initialization instead using printf directly. + (_gpgme_debug): Do not call debug_init (we now ensure proper + initialization by user). Add timestamp and thread/process ID. + (_gpgme_debug_buffer): Do not take tagname and tag argument. + (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New functions. + * version.c (gpgme_check_version_internal, gpgme_check_version): + Fix debug string. Do not initialize assuan. + * posix-io.c (get_max_fds): Use 0 not NULL (nicer debug output). + 2009-11-04 Werner Koch * gpgme-tool.c (register_commands): Add HELP feature. Modified: trunk/src/ath-pth.c =================================================================== --- trunk/src/ath-pth.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/ath-pth.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -34,6 +34,14 @@ /* The lock we take while checking for lazy lock initialization. */ static pth_mutex_t check_init_lock = PTH_MUTEX_INIT; + +uintptr_t +ath_self (void) +{ + return (uintptr_t) pth_self (); +} + + /* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if it is not already initialized. */ static int Modified: trunk/src/ath-pthread.c =================================================================== --- trunk/src/ath-pthread.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/ath-pthread.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -77,6 +77,13 @@ } +uintptr_t +ath_self (void) +{ + return (uintptr_t) pthread_self (); +} + + int ath_mutex_init (ath_mutex_t *lock) { Modified: trunk/src/ath.c =================================================================== --- trunk/src/ath.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/ath.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -42,6 +42,33 @@ #define MUTEX_DESTROYED ((ath_mutex_t) 2) +#ifdef HAVE_W32_SYSTEM +#include +uintptr_t +ath_self (void) +{ + return (uintptr_t) GetCurrentThreadID (); +} +#else +# ifdef __linux +#include +#include +uintptr_t +ath_self (void) +{ + /* Just to catch users who don't use gpgme-pthread. */ + return (uintptr_t) syscall (SYS_gettid); +} +# else +uintptr_t +ath_self (void) +{ + return (uintptr_t) getpid (); +} +# endif +#endif + + int ath_mutex_init (ath_mutex_t *lock) { Modified: trunk/src/ath.h =================================================================== --- trunk/src/ath.h 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/ath.h 2009-11-04 18:13:44 UTC (rev 1416) @@ -21,6 +21,9 @@ #ifndef ATH_H #define ATH_H +#ifdef HAVE_STDINT_H +#include +#endif #ifdef HAVE_W32_SYSTEM /* fixme: Check how we did it in libgcrypt. */ struct msghdr { int dummy; }; @@ -68,6 +71,8 @@ typedef void *ath_mutex_t; #define ATH_MUTEX_INITIALIZER 0; +uintptr_t ath_self (void); + /* Functions for mutual exclusion. */ int ath_mutex_init (ath_mutex_t *mutex); int ath_mutex_destroy (ath_mutex_t *mutex); Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/debug.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -29,6 +29,7 @@ #include #include #include +#include #ifndef HAVE_DOSISH_SYSTEM # include # include @@ -36,11 +37,8 @@ #endif #include -#ifdef HAVE_ASSUAN_H -#include "assuan.h" -#endif - #include "util.h" +#include "ath.h" #include "sema.h" #include "debug.h" @@ -57,6 +55,28 @@ static FILE *errfp; +#ifdef __GNUC__ +#define FRAME_NR +static __thread int frame_nr = 0; +#endif + +void +_gpgme_debug_frame_begin (void) +{ +#ifdef FRAME_NR + frame_nr++; +#endif +} + +void _gpgme_debug_frame_end (void) +{ +#ifdef FRAME_NR + frame_nr--; +#endif +} + + + /* Remove leading and trailing white spaces. */ static char * trim_spaces (char *str) @@ -140,15 +160,11 @@ } free (e); } - - if (debug_level > 0) - fprintf (errfp, "gpgme_debug: level=%d\n", debug_level); -#ifdef HAVE_ASSUAN_H - assuan_set_assuan_log_prefix ("gpgme-assuan"); - assuan_set_assuan_log_stream (debug_level > 0 ? errfp : NULL); -#endif /* HAVE_ASSUAN_H*/ } UNLOCK (debug_lock); + + if (debug_level > 0) + _gpgme_debug (DEBUG_INIT, "gpgme_debug: level=%d\n", debug_level); } @@ -173,13 +189,37 @@ int saved_errno; saved_errno = errno; - - debug_init (); if (debug_level < level) return; va_start (arg_ptr, format); LOCK (debug_lock); + { + struct tm *tp; + time_t atime = time (NULL); + + tp = localtime (&atime); + fprintf (errfp, "GPGME %04d-%02d-%02d %02d:%02d:%02d <0x%04llx> ", + 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec, + (unsigned long long) ath_self ()); + } +#ifdef FRAME_NR + { + char spaces[] = " "; + int nr_spaces = sizeof (spaces) - 1; + int nr_columns; + + nr_columns = 2 * (frame_nr - 1); + if (nr_columns > nr_spaces) + nr_columns = nr_spaces; + if (nr_columns < 0) + nr_columns = 0; + spaces[nr_columns] = '\0'; + fprintf (errfp, "%s", spaces); + } +#endif + vfprintf (errfp, format, arg_ptr); va_end (arg_ptr); if(format && *format && format[strlen (format) - 1] != '\n') @@ -199,7 +239,6 @@ va_list arg_ptr; int res; - debug_init (); if (debug_level < level) { /* Disable logging of this line. */ @@ -265,8 +304,7 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, - const char *const func, const char *const tagname, - const void *const tag, const char *const buffer, + const char *const func, const char *const buffer, size_t len) { int idx = 0; @@ -302,6 +340,6 @@ *(strp++) = ' '; *(strp2) = '\0'; - _gpgme_debug (lvl, fmt, func, tagname, tag, str); + _gpgme_debug (lvl, fmt, func, str); } } Modified: trunk/src/debug.h =================================================================== --- trunk/src/debug.h 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/debug.h 2009-11-04 18:13:44 UTC (rev 1416) @@ -72,10 +72,13 @@ void _gpgme_debug_end (void **helper); void _gpgme_debug_buffer (int lvl, const char *const fmt, - const char *const func, const char *const tagname, - const void *const tag, const char *const buffer, + const char *const func, const char *const buffer, size_t len); +void _gpgme_debug_frame_begin (void); +void _gpgme_debug_frame_end (void); + + /* Trace support. */ @@ -86,159 +89,159 @@ int _gpgme_trace_level = lvl; \ const char *const _gpgme_trace_func = name; \ const char *const _gpgme_trace_tagname = STRINGIFY (tag); \ - void *_gpgme_trace_tag = (void *) (uintptr_t) tag + void *_gpgme_trace_tag = (void *) (uintptr_t) tag; \ + _gpgme_debug_frame_begin () #define TRACE_BEG(lvl, name, tag) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag), 0 #define TRACE_BEG0(lvl, name, tag, fmt) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag), 0 #define TRACE_BEG1(lvl, name, tag, fmt, arg1) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1), 0 #define TRACE_BEG2(lvl, name, tag, fmt, arg1, arg2) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2), 0 #define TRACE_BEG3(lvl, name, tag, fmt, arg1, arg2, arg3) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3), 0 #define TRACE_BEG4(lvl, name, tag, fmt, arg1, arg2, arg3, arg4) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4), 0 #define TRACE_BEG5(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5), 0 + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4, arg5), 0 #define TRACE_BEG7(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \ arg5, arg6, arg7) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5, \ + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4, arg5, \ arg6, arg7), 0 #define TRACE_BEG8(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \ arg5, arg6, arg7, arg8) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: enter: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5, \ + _gpgme_debug (_gpgme_trace_level, "%s: enter: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4, arg5, \ arg6, arg7, arg8), 0 #define TRACE(lvl, name, tag) \ - _gpgme_debug (lvl, "[%s=%p] %s: call\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag), \ + _gpgme_debug_frame_end (), 0 #define TRACE0(lvl, name, tag, fmt) \ - _gpgme_debug (lvl, "[%s=%p] %s: call: " fmt "\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p, " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag), \ + _gpgme_debug_frame_end (), 0 #define TRACE1(lvl, name, tag, fmt, arg1) \ - _gpgme_debug (lvl, "[%s=%p] %s: call: " fmt "\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name, arg1), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p, " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1), \ + _gpgme_debug_frame_end (), 0 #define TRACE2(lvl, name, tag, fmt, arg1, arg2) \ - _gpgme_debug (lvl, "[%s=%p] %s: call: " fmt "\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name, arg1, \ - arg2), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p, " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2), _gpgme_debug_frame_end (), 0 #define TRACE3(lvl, name, tag, fmt, arg1, arg2, arg3) \ - _gpgme_debug (lvl, "[%s=%p] %s: call: " fmt "\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name, arg1, \ - arg2, arg3), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p, " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2, arg3), _gpgme_debug_frame_end (), 0 #define TRACE6(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ - _gpgme_debug (lvl, "[%s=%p] %s: call: " fmt "\n", \ - STRINGIFY (tag), (void *) (uintptr_t) tag, name, arg1, \ - arg2, arg3, arg4, arg5, arg6), 0 + _gpgme_debug_frame_begin (), \ + _gpgme_debug (lvl, "%s: call: %s=%p, " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2, arg3, arg4, arg5, arg6), \ + _gpgme_debug_frame_end (), 0 #define TRACE_ERR(err) \ err == 0 ? (TRACE_SUC ()) : \ - (_gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: error: %s <%s>\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ + (_gpgme_debug (_gpgme_trace_level, "%s: error: %s <%s>\n", \ _gpgme_trace_func, gpgme_strerror (err), \ - gpgme_strsource (err)), (err)) + gpgme_strsource (err)), _gpgme_debug_frame_end (), (err)) /* The cast to void suppresses GCC warnings. */ #define TRACE_SYSRES(res) \ res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ - (_gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: error: %s\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, strerror (errno)), (res)) + (_gpgme_debug (_gpgme_trace_level, "%s: error: %s\n", \ + _gpgme_trace_func, strerror (errno)), _gpgme_debug_frame_end (), (res)) #define TRACE_SYSERR(res) \ res == 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ - (_gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: error: %s\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, strerror (res)), (res)) + (_gpgme_debug (_gpgme_trace_level, "%s: error: %s\n", \ + _gpgme_trace_func, strerror (res)), \ + _gpgme_debug_frame_end (), (res)) #define TRACE_SUC() \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: leave\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func), 0 + _gpgme_debug (_gpgme_trace_level, "%s: leave\n", \ + _gpgme_trace_func), _gpgme_debug_frame_end (), 0 #define TRACE_SUC0(fmt) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: leave: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func), 0 + _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \ + _gpgme_trace_func), _gpgme_debug_frame_end (), 0 #define TRACE_SUC1(fmt, arg1) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: leave: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1), 0 + _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \ + _gpgme_trace_func, arg1), _gpgme_debug_frame_end (), 0 #define TRACE_SUC2(fmt, arg1, arg2) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: leave: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2), 0 + _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \ + _gpgme_trace_func, arg1, arg2), _gpgme_debug_frame_end (), 0 #define TRACE_SUC5(fmt, arg1, arg2, arg3, arg4, arg5) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: leave: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5), 0 + _gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \ + _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5), \ + _gpgme_debug_frame_end (), 0 #define TRACE_LOG(fmt) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag), 0 #define TRACE_LOG1(fmt, arg1) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1), 0 #define TRACE_LOG2(fmt, arg1, arg2) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2), 0 #define TRACE_LOG3(fmt, arg1, arg2, arg3) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3), 0 #define TRACE_LOG4(fmt, arg1, arg2, arg3, arg4) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4), 0 #define TRACE_LOG5(fmt, arg1, arg2, arg3, arg4, arg5) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5), 0 + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4, arg5), 0 #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ - _gpgme_debug (_gpgme_trace_level, "[%s=%p] %s: check: " fmt "\n", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func, arg1, arg2, arg3, arg4, arg5, \ + _gpgme_debug (_gpgme_trace_level, "%s: check: %s=%p, " fmt "\n", \ + _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ + arg1, arg2, arg3, arg4, arg5, \ arg6), 0 -#define TRACE_LOGBUF(buf, len) \ - _gpgme_debug_buffer (_gpgme_trace_level, "[%s=%p] %s: check: %s", \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ +#define TRACE_LOGBUF(buf, len) \ + _gpgme_debug_buffer (_gpgme_trace_level, "%s: check: %s", \ _gpgme_trace_func, buf, len) #define TRACE_SEQ(hlp,fmt) \ _gpgme_debug_begin (&(hlp), _gpgme_trace_level, \ - "[%s=%p] %s: check: " fmt, \ - _gpgme_trace_tagname, _gpgme_trace_tag, \ - _gpgme_trace_func) + "%s: check: %s=%p, " fmt, _gpgme_trace_func, \ + _gpgme_trace_tagname, _gpgme_trace_tag) #define TRACE_ADD0(hlp,fmt) \ _gpgme_debug_add (&(hlp), fmt) #define TRACE_ADD1(hlp,fmt,a) \ Modified: trunk/src/posix-io.c =================================================================== --- trunk/src/posix-io.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/posix-io.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -273,7 +273,7 @@ fds = 1024; } - TRACE2 (DEBUG_SYSIO, "gpgme:max_fds", NULL, "max fds=%i (%s)", fds, source); + TRACE2 (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%i (%s)", fds, source); return fds; } Modified: trunk/src/version.c =================================================================== --- trunk/src/version.c 2009-11-04 10:43:42 UTC (rev 1415) +++ trunk/src/version.c 2009-11-04 18:13:44 UTC (rev 1416) @@ -73,9 +73,6 @@ #endif _gpgme_sema_subsystem_init (); -#ifdef HAVE_ASSUAN_H - assuan_set_assuan_err_source (GPG_ERR_SOURCE_GPGME); -#endif /*HAVE_ASSUAN_H*/ _gpgme_debug_subsystem_init (); _gpgme_io_subsystem_init (); #if defined(HAVE_W32_SYSTEM) && defined(HAVE_ASSUAN_H) @@ -196,7 +193,7 @@ before using the trace facility. If we won't the trace would automagically initialize the debug system with out the locks being initialized and missing the assuan log level setting. */ - TRACE2 (DEBUG_INIT, "gpgme_check_version: ", 0, + TRACE2 (DEBUG_INIT, "gpgme_check_version", 0, "req_version=%s, VERSION=%s", req_version? req_version:"(null)", VERSION); @@ -221,13 +218,13 @@ return result; /* Catch-22, see above. */ - TRACE2 (DEBUG_INIT, "gpgme_check_version_internal: ", 0, + TRACE2 (DEBUG_INIT, "gpgme_check_version_internal", 0, "req_version=%s, offset_sig_validity=%i", req_version ? req_version : "(null)", offset_sig_validity); if (offset_sig_validity != offsetof (struct _gpgme_signature, validity)) { - TRACE1 (DEBUG_INIT, "gpgme_check_version_internal: ", 0, + TRACE1 (DEBUG_INIT, "gpgme_check_version_internal", 0, "offset_sig_validity mismatch: expected %i", offsetof (struct _gpgme_signature, validity)); _gpgme_selftest = GPG_ERR_SELFTEST_FAILED; From cvs at cvs.gnupg.org Thu Nov 5 03:15:05 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 03:15:05 +0100 Subject: [svn] assuan - r315 - in trunk: . doc src Message-ID: Author: marcus Date: 2009-11-05 03:15:04 +0100 (Thu, 05 Nov 2009) New Revision: 315 Modified: trunk/NEWS trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan.h trunk/src/debug.c Log: doc/ 2009-11-05 Marcus Brinkmann * assuan.texi (External I/O Loop Server): Document change to assuan_process_next. src/ 2009-11-05 Marcus Brinkmann * assuan-defs.h (assuan_context_t): Add member PROCESS_DONE. * assuan.h (assuan_process_next): Add argument DONE to prototype. * assuan-handler.c (assuan_process_next): Likewise, handle it. (std_handler_bye): Set PROCESS_DONE. (assuan_process_done): Handle PROCESS_DONE in the no error case. (assuan_process): Use PROCESS_DONE. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/doc/ChangeLog 2009-11-05 02:15:04 UTC (rev 315) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * assuan.texi (External I/O Loop Server): Document change to + assuan_process_next. + 2009-10-16 Marcus Brinkmann * assuan.texi: Remove documentation for thread support. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/src/ChangeLog 2009-11-05 02:15:04 UTC (rev 315) @@ -1,3 +1,16 @@ +2009-11-05 Marcus Brinkmann + + * assuan-defs.h (assuan_context_t): Add member PROCESS_DONE. + * assuan.h (assuan_process_next): Add argument DONE to prototype. + * assuan-handler.c (assuan_process_next): Likewise, handle it. + (std_handler_bye): Set PROCESS_DONE. + (assuan_process_done): Handle PROCESS_DONE in the no error case. + (assuan_process): Use PROCESS_DONE. + +2009-11-04 Marcus Brinkmann + + * debug.c (_assuan_debug): Free MSG. + 2009-11-04 Werner Koch * Makefile.am (common_sources): Add debug.h. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/NEWS 2009-11-05 02:15:04 UTC (rev 315) @@ -75,6 +75,7 @@ assuan_register_cancel_notify CHANGED: Handler gets line and returns err now. assuan_register_input_notify CHANGED: Handler returns error now. assuan_register_output_notify CHANGED: Handler returns error now. +assuan_process_next CHANGED: New DONE argument instead EOF return. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/doc/assuan.texi 2009-11-05 02:15:04 UTC (rev 315) @@ -1524,8 +1524,8 @@ readable, but Assuan does not check this. The function @code{assuan_process_next} returns 0 if it can not make -progress reliably, and it returns an end of file error value if the -client closed the connection. See below for more information on this +progress reliably, and it returns true in @code{done} if the client +closed the connection. See below for more information on this function. @item @@ -1562,11 +1562,10 @@ operations, the server should send progress status messages to the client in regular intervals to notice when the client disconnects. - at deftypefun gpg_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}) + at deftypefun gpg_error_t assuan_process_next (@w{assuan_context_t @var{ctx}}, @w{int *@var{done}}) This is the same as @code{assuan_process} but the caller has to provide the outer loop. He should loop as long as the return code is -zero and stop otherwise; @code{-1} or @code{GPG_ERR_EOF} indicate a -regular end. +zero and @var{done} is false. @end deftypefun @deftypefun gpg_error_t assuan_process_done (@w{assuan_context_t @var{ctx}}, @w{gpg_error_t @var{rc}}) Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/src/assuan-defs.h 2009-11-05 02:15:04 UTC (rev 315) @@ -124,6 +124,7 @@ int is_server; /* Set if this is context belongs to a server */ int in_inquire; int in_process_next; + int process_done; int in_command; /* The following members are used by assuan_inquire_ext. */ Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/src/assuan-handler.c 2009-11-05 02:15:04 UTC (rev 315) @@ -125,7 +125,8 @@ assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); /* pretty simple :-) */ - return PROCESS_DONE (ctx, _assuan_error (ctx, GPG_ERR_EOF)); + ctx->process_done = 1; + return PROCESS_DONE (ctx, 0); } static gpg_error_t @@ -592,18 +593,19 @@ /* Error handling. */ if (!rc) { - rc = assuan_write_line (ctx, ctx->okay_line ? ctx->okay_line : "OK"); + if (ctx->process_done) + { + /* No error checking because the peer may have already + disconnect. */ + assuan_write_line (ctx, "OK closing connection"); + ctx->finish_handler (ctx); + } + else + rc = assuan_write_line (ctx, ctx->okay_line ? ctx->okay_line : "OK"); } - else if (gpg_err_code (rc) == GPG_ERR_EOF) - { /* No error checking because the peer may have already disconnect. */ - assuan_write_line (ctx, "OK closing connection"); - ctx->finish_handler (ctx); - } else { - char errline[300]; - - const char *text = ctx->err_no == rc ? ctx->err_str : NULL; + char errline const char *text = ctx->err_no == rc ? ctx->err_str : NULL; char ebuf[50]; gpg_strerror_r (rc, ebuf, sizeof (ebuf)); @@ -686,19 +688,25 @@ ready for reading. If the equivalent to EWOULDBLOCK is returned (this should be done by the command handler), assuan_process_next should be invoked the next time the connected FD is readable. - Eventually, the caller will finish by invoking - assuan_process_done. */ + Eventually, the caller will finish by invoking assuan_process_done. + DONE is set to 1 if the connection has ended. */ gpg_error_t -assuan_process_next (assuan_context_t ctx) +assuan_process_next (assuan_context_t ctx, int *done) { gpg_error_t rc; + if (done) + *done = 0; + ctx->process_done = 0; do { rc = process_next (ctx); } - while (!rc && assuan_pending_line (ctx)); + while (!rc && !ctx->process_done && assuan_pending_line (ctx)); + if (done) + *done = !!ctx->process_done; + return rc; } @@ -747,13 +755,11 @@ { gpg_error_t rc; + ctx->process_done = 0; do { rc = process_request (ctx); - } while (!rc); + } while (!rc && !ctx->process_done); - if (gpg_err_code (rc) == GPG_ERR_EOF) - rc = 0; - return rc; } Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/src/assuan.h 2009-11-05 02:15:04 UTC (rev 315) @@ -327,7 +327,7 @@ const char*)); gpg_error_t assuan_process (assuan_context_t ctx); -gpg_error_t assuan_process_next (assuan_context_t ctx); +gpg_error_t assuan_process_next (assuan_context_t ctx, int *done); gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc); int assuan_get_active_fds (assuan_context_t ctx, int what, assuan_fd_t *fdarray, int fdarraysize); Modified: trunk/src/debug.c =================================================================== --- trunk/src/debug.c 2009-11-04 10:00:24 UTC (rev 314) +++ trunk/src/debug.c 2009-11-05 02:15:04 UTC (rev 315) @@ -59,6 +59,7 @@ if (res < 0) return; ctx->log_cb (ctx, ctx->log_cb_data, cat, msg); + free (msg); errno = saved_errno; } From cvs at cvs.gnupg.org Thu Nov 5 03:17:08 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 03:17:08 +0100 Subject: [svn] gpgme - r1417 - trunk/src Message-ID: Author: marcus Date: 2009-11-05 03:17:07 +0100 (Thu, 05 Nov 2009) New Revision: 1417 Modified: trunk/src/ChangeLog trunk/src/decrypt-verify.c trunk/src/decrypt.c trunk/src/delete.c trunk/src/edit.c trunk/src/encrypt-sign.c trunk/src/encrypt.c trunk/src/export.c trunk/src/genkey.c trunk/src/getauditlog.c trunk/src/gpgme-tool.c trunk/src/import.c trunk/src/opassuan.c trunk/src/sign.c trunk/src/verify.c trunk/src/vfs-create.c trunk/src/vfs-mount.c Log: 2009-11-05 Marcus Brinkmann * decrypt.c (gpgme_op_decrypt_start): Fix use of debug macro. * decrypt-verify.c (gpgme_op_decrypt_verify_start): Likewise. * delete.c (gpgme_op_delete_start): Likewise. * edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): Likewise. * encrypt.c (gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (gpgme_op_encrypt_sign_start): Likewise. * export.c (gpgme_op_export_start, gpgme_op_export_ext_start) (gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise. * genkey.c (gpgme_op_genkey_start): Likewise. * getauditlog.c (gpgme_op_getauditlog_start): Likewise. * import.c (gpgme_op_import_start, gpgme_op_import_keys_start): Likewise. * opassuan.c (gpgme_op_assuan_transact_start): Likewise. * sign.c (gpgme_op_sign_start): Likewise. * verify.c (gpgme_op_verify_start): Likewise. * vfs-create.c (gpgme_op_vfs_create): Likewise. * vfs-mount.c (gpgme_op_vfs_mount): Likewise. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/ChangeLog 2009-11-05 02:17:07 UTC (rev 1417) @@ -1,3 +1,24 @@ +2009-11-05 Marcus Brinkmann + + * decrypt.c (gpgme_op_decrypt_start): Fix use of debug macro. + * decrypt-verify.c (gpgme_op_decrypt_verify_start): Likewise. + * delete.c (gpgme_op_delete_start): Likewise. + * edit.c (gpgme_op_edit_start, gpgme_op_card_edit_start): + Likewise. + * encrypt.c (gpgme_op_encrypt_start): Likewise. + * encrypt-sign.c (gpgme_op_encrypt_sign_start): Likewise. + * export.c (gpgme_op_export_start, gpgme_op_export_ext_start) + (gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise. + * genkey.c (gpgme_op_genkey_start): Likewise. + * getauditlog.c (gpgme_op_getauditlog_start): Likewise. + * import.c (gpgme_op_import_start, gpgme_op_import_keys_start): + Likewise. + * opassuan.c (gpgme_op_assuan_transact_start): Likewise. + * sign.c (gpgme_op_sign_start): Likewise. + * verify.c (gpgme_op_verify_start): Likewise. + * vfs-create.c (gpgme_op_vfs_create): Likewise. + * vfs-mount.c (gpgme_op_vfs_mount): Likewise. + 2009-11-04 Marcus Brinkmann * ath.h (ath_self): New prototype. Include Modified: trunk/src/decrypt-verify.c =================================================================== --- trunk/src/decrypt-verify.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/decrypt-verify.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -87,9 +87,12 @@ gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain) { + gpgme_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_verify_start", ctx, "cipher=%p, plain=%p", cipher, plain); - return TRACE_ERR (decrypt_verify_start (ctx, 0, cipher, plain)); + err = decrypt_verify_start (ctx, 0, cipher, plain); + return TRACE_ERR (err); } Modified: trunk/src/decrypt.c =================================================================== --- trunk/src/decrypt.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/decrypt.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -365,9 +365,12 @@ gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain) { + gpgme_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx, "cipher=%p, plain=%p", cipher, plain); - return TRACE_ERR (decrypt_start (ctx, 0, cipher, plain)); + err = decrypt_start (ctx, 0, cipher, plain); + return TRACE_ERR (err); } Modified: trunk/src/delete.c =================================================================== --- trunk/src/delete.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/delete.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -94,11 +94,14 @@ gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret) { + gpgme_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_delete", ctx, "key=%p (%s), allow_secret=%i", key, (key->subkeys && key->subkeys->fpr) ? key->subkeys->fpr : "invalid", allow_secret); - return TRACE_ERR (delete_start (ctx, 0, key, allow_secret)); + err = delete_start (ctx, 0, key, allow_secret); + return TRACE_ERR (err); } Modified: trunk/src/edit.c =================================================================== --- trunk/src/edit.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/edit.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -139,11 +139,14 @@ gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { + gpgme_error_t err; + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_edit_start", ctx, "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, (key->subkeys && key->subkeys->fpr) ? key->subkeys->fpr : "invalid", fnc, fnc_value, out); - return TRACE_ERR (edit_start (ctx, 0, 0, key, fnc, fnc_value, out)); + err = edit_start (ctx, 0, 0, key, fnc, fnc_value, out); + return err; } @@ -173,11 +176,14 @@ gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) { + gpgme_error_t err; + TRACE_BEG5 (DEBUG_CTX, "gpgme_op_card_edit_start", ctx, "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key, (key->subkeys && key->subkeys->fpr) ? key->subkeys->fpr : "invalid", fnc, fnc_value, out); - return TRACE_ERR (edit_start (ctx, 0, 1, key, fnc, fnc_value, out)); + err = edit_start (ctx, 0, 1, key, fnc, fnc_value, out); + return err; } Modified: trunk/src/encrypt-sign.c =================================================================== --- trunk/src/encrypt-sign.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/encrypt-sign.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -92,6 +92,8 @@ gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { + gpgme_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_sign_start", ctx, "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); @@ -108,7 +110,8 @@ } } - return TRACE_ERR (encrypt_sign_start (ctx, 0, recp, flags, plain, cipher)); + err = encrypt_sign_start (ctx, 0, recp, flags, plain, cipher); + return err; } Modified: trunk/src/encrypt.c =================================================================== --- trunk/src/encrypt.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/encrypt.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -227,6 +227,8 @@ gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher) { + gpgme_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_start", ctx, "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher); @@ -243,7 +245,8 @@ } } - return TRACE_ERR (encrypt_start (ctx, 0, recp, flags, plain, cipher)); + err = encrypt_start (ctx, 0, recp, flags, plain, cipher); + return TRACE_ERR (err); } Modified: trunk/src/export.c =================================================================== --- trunk/src/export.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/export.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -75,9 +75,12 @@ gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern, gpgme_export_mode_t mode, gpgme_data_t keydata) { + gpgme_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_export_start", ctx, "pattern=%s, mode=0x%x, keydata=%p", pattern, mode, keydata); - return TRACE_ERR (export_start (ctx, 0, pattern, mode, keydata)); + err = export_start (ctx, 0, pattern, mode, keydata); + return TRACE_ERR (err); } @@ -134,6 +137,8 @@ gpgme_op_export_ext_start (gpgme_ctx_t ctx, const char *pattern[], gpgme_export_mode_t mode, gpgme_data_t keydata) { + gpgme_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_ext_start", ctx, "mode=0x%x, keydata=%p", mode, keydata); @@ -148,7 +153,8 @@ } } - return TRACE_ERR (export_ext_start (ctx, 0, pattern, mode, keydata)); + err = export_ext_start (ctx, 0, pattern, mode, keydata); + return TRACE_ERR (err); } @@ -244,6 +250,8 @@ gpgme_export_mode_t mode, gpgme_data_t keydata) { + gpg_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_keys_start", ctx, "mode=0x%x, keydata=%p", mode, keydata); @@ -260,7 +268,8 @@ } } - return TRACE_ERR (export_keys_start (ctx, 0, keys, mode, keydata)); + err = export_keys_start (ctx, 0, keys, mode, keydata); + return TRACE_ERR (err); } gpgme_error_t @@ -290,6 +299,6 @@ err = export_keys_start (ctx, 1, keys, mode, keydata); if (!err) err = _gpgme_wait_one (ctx); - return err; + return TRACE_ERR (err); } Modified: trunk/src/genkey.c =================================================================== --- trunk/src/genkey.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/genkey.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -197,10 +197,13 @@ gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey, gpgme_data_t seckey) { + gpgme_error_t err; + TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey_start", ctx, "pubkey=%p, seckey=%p", pubkey, seckey); TRACE_LOGBUF (parms, strlen (parms)); - return TRACE_ERR (genkey_start (ctx, 0, parms, pubkey, seckey)); + err = genkey_start (ctx, 0, parms, pubkey, seckey); + return TRACE_ERR (err); } Modified: trunk/src/getauditlog.c =================================================================== --- trunk/src/getauditlog.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/getauditlog.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -1,3 +1,4 @@ + /* getauditlog.c - Retrieve the audit log. Copyright (C) 2007 g10 Code GmbH @@ -63,9 +64,11 @@ gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags) { + gpg_error_t err; TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog_start", ctx, "output=%p, flags=0x%x", output, flags); - return TRACE_ERR (getauditlog_start (ctx, 0, output, flags)); + err = getauditlog_start (ctx, 0, output, flags); + return TRACE_ERR (err); } Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/gpgme-tool.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -1041,7 +1041,7 @@ gpg_error_t err; gpg_error_t op_err; err = gpgme_op_vfs_mount (gt->ctx, container_file, mount_dir, flags, &op_err); - return err || op_err; + return err ? err : op_err; } @@ -1053,7 +1053,7 @@ err = gpgme_op_vfs_create (gt->ctx, gt->recipients, container_file, flags, &op_err); gt_recipients_clear (gt); - return err || op_err; + return err ? err : op_err; } Modified: trunk/src/import.c =================================================================== --- trunk/src/import.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/import.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -283,10 +283,13 @@ gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata) { + gpg_error_t err; + TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import_start", ctx, "keydata=%p", keydata); - return TRACE_ERR (_gpgme_op_import_start (ctx, 0, keydata)); + err = _gpgme_op_import_start (ctx, 0, keydata); + return TRACE_ERR (err); } @@ -358,6 +361,8 @@ gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t *keys) { + gpg_error_t err; + TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys_start", ctx); if (_gpgme_debug_trace () && keys) { @@ -372,7 +377,8 @@ } } - return TRACE_ERR (_gpgme_op_import_keys_start (ctx, 0, keys)); + err = _gpgme_op_import_keys_start (ctx, 0, keys); + return TRACE_ERR (err); } Modified: trunk/src/opassuan.c =================================================================== --- trunk/src/opassuan.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/opassuan.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -69,15 +69,16 @@ gpgme_assuan_status_cb_t status_cb, void *status_cb_value) { + gpg_error_t err; + TRACE_BEG7 (DEBUG_CTX, "gpgme_op_assuan_transact_start", ctx, "command=%s, data_cb=%p/%p, inq_cb=%p/%p, status_cb=%p/%p", command, data_cb, data_cb_value, inq_cb, inq_cb_value, status_cb, status_cb_value); - return TRACE_ERR (opassuan_start (ctx, 0, command, - data_cb, data_cb_value, - inq_cb, inq_cb_value, - status_cb, status_cb_value)); + err = opassuan_start (ctx, 0, command, data_cb, data_cb_value, + inq_cb, inq_cb_value, status_cb, status_cb_value); + return TRACE_ERR (err); } Modified: trunk/src/sign.c =================================================================== --- trunk/src/sign.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/sign.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -386,9 +386,11 @@ gpgme_op_sign_start (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, gpgme_sig_mode_t mode) { + gpg_error_t err; TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx, "plain=%p, sig=%p, mode=%i", plain, sig, mode); - return TRACE_ERR (sign_start (ctx, 0, plain, sig, mode)); + err = sign_start (ctx, 0, plain, sig, mode); + return TRACE_ERR (err); } Modified: trunk/src/verify.c =================================================================== --- trunk/src/verify.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/verify.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -832,10 +832,12 @@ gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) { + gpg_error_t err; TRACE_BEG3 (DEBUG_CTX, "gpgme_op_verify_start", ctx, "sig=%p, signed_text=%p, plaintext=%p", sig, signed_text, plaintext); - return TRACE_ERR (verify_start (ctx, 0, sig, signed_text, plaintext)); + err = verify_start (ctx, 0, sig, signed_text, plaintext); + return TRACE_ERR (err); } Modified: trunk/src/vfs-create.c =================================================================== --- trunk/src/vfs-create.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/vfs-create.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -170,6 +170,8 @@ const char *container_file, unsigned int flags, gpgme_error_t *op_err) { + gpg_error_t err; + TRACE_BEG3 (DEBUG_CTX, "gpgme_op_vfs_create", ctx, "container_file=%s, flags=0x%x, op_err=%p", container_file, flags, op_err); @@ -177,7 +179,7 @@ if (_gpgme_debug_trace () && recp) { int i = 0; - + while (recp[i]) { TRACE_LOG3 ("recipient[%i] = %p (%s)", i, recp[i], @@ -187,7 +189,7 @@ } } - return TRACE_ERR (_gpgme_op_vfs_create (ctx, recp, container_file, - flags, op_err)); + err = _gpgme_op_vfs_create (ctx, recp, container_file, flags, op_err); + return TRACE_ERR (err); } Modified: trunk/src/vfs-mount.c =================================================================== --- trunk/src/vfs-mount.c 2009-11-04 18:13:44 UTC (rev 1416) +++ trunk/src/vfs-mount.c 2009-11-05 02:17:07 UTC (rev 1417) @@ -201,10 +201,12 @@ const char *mount_dir, unsigned int flags, gpgme_error_t *op_err) { + gpg_error_t err; + TRACE_BEG4 (DEBUG_CTX, "gpgme_op_vfs_mount", ctx, "container=%s, mount_dir=%s, flags=0x%x, op_err=%p", container_file, mount_dir, flags, op_err); - return TRACE_ERR (_gpgme_op_vfs_mount (ctx, container_file, mount_dir, - flags, op_err)); + err = _gpgme_op_vfs_mount (ctx, container_file, mount_dir, flags, op_err); + return TRACE_ERR (err); } From cvs at cvs.gnupg.org Thu Nov 5 03:18:31 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 03:18:31 +0100 Subject: [svn] GnuPG - r5195 - trunk/g13 Message-ID: Author: marcus Date: 2009-11-05 03:18:31 +0100 (Thu, 05 Nov 2009) New Revision: 5195 Modified: trunk/g13/g13.c Log: Initialize opt.session_env. Modified: trunk/g13/g13.c =================================================================== --- trunk/g13/g13.c 2009-11-04 15:31:52 UTC (rev 5194) +++ trunk/g13/g13.c 2009-11-05 02:18:31 UTC (rev 5195) @@ -369,6 +369,11 @@ create_dotlock (NULL); /* Register locking cleanup. */ + opt.session_env = session_env_new (); + if (!opt.session_env) + log_fatal ("error allocating session environment block: %s\n", + strerror (errno)); + opt.homedir = default_homedir (); /* First check whether we have a config file on the commandline. */ From cvs at cvs.gnupg.org Thu Nov 5 03:39:32 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 03:39:32 +0100 Subject: [svn] gpgme - r1418 - trunk/src Message-ID: Author: marcus Date: 2009-11-05 03:39:31 +0100 (Thu, 05 Nov 2009) New Revision: 1418 Modified: trunk/src/ChangeLog trunk/src/assuan-support.c trunk/src/posix-io.c trunk/src/priv-io.h trunk/src/w32-glib-io.c trunk/src/w32-io.c Log: 2009-11-05 Marcus Brinkmann * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. * w32-io.c (_gpgme_io_spawn): Implement this flag. * posix-io.c (_gpgme_io_spawn): Likewise. * w32-glib-io.c (_gpgme_io_spawn): Likewise. * assuan-support.c (my_spawn): Set this flag. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/ChangeLog 2009-11-05 02:39:31 UTC (rev 1418) @@ -1,5 +1,11 @@ 2009-11-05 Marcus Brinkmann + * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. + * w32-io.c (_gpgme_io_spawn): Implement this flag. + * posix-io.c (_gpgme_io_spawn): Likewise. + * w32-glib-io.c (_gpgme_io_spawn): Likewise. + * assuan-support.c (my_spawn): Set this flag. + * decrypt.c (gpgme_op_decrypt_start): Fix use of debug macro. * decrypt-verify.c (gpgme_op_decrypt_verify_start): Likewise. * delete.c (gpgme_op_delete_start): Likewise. Modified: trunk/src/assuan-support.c =================================================================== --- trunk/src/assuan-support.c 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/assuan-support.c 2009-11-05 02:39:31 UTC (rev 1418) @@ -152,7 +152,7 @@ fd_items[i].fd = -1; fd_items[i].dup_to = -1; - err = _gpgme_io_spawn (name, argv, 0, fd_items, r_pid); + err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items, r_pid); if (! err) { i = 0; Modified: trunk/src/posix-io.c =================================================================== --- trunk/src/posix-io.c 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/posix-io.c 2009-11-05 02:39:31 UTC (rev 1418) @@ -454,7 +454,8 @@ for (i = 0; fd_list[i].fd != -1; i++) { - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + _gpgme_io_close (fd_list[i].fd); /* No handle translation. */ fd_list[i].peer_name = fd_list[i].fd; } Modified: trunk/src/priv-io.h =================================================================== --- trunk/src/priv-io.h 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/priv-io.h 2009-11-05 02:39:31 UTC (rev 1418) @@ -68,6 +68,8 @@ /* A flag to tell the spawn function to allow the child process to set the foreground window. */ #define IOSPAWN_FLAG_ALLOW_SET_FG 1 +/* Don't close any child FDs. */ +#define IOSPAWN_FLAG_NOCLOSE 2 /* Spawn the executable PATH with ARGV as arguments. After forking close all fds except for those in FD_LIST in the child, then Modified: trunk/src/w32-glib-io.c =================================================================== --- trunk/src/w32-glib-io.c 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/w32-glib-io.c 2009-11-05 02:39:31 UTC (rev 1418) @@ -777,8 +777,11 @@ TRACE_LOG1 ("CloseHandle of process failed: ec=%d", (int) GetLastError ()); - for (i = 0; fd_list[i].fd != -1; i++) - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + { + for (i = 0; fd_list[i].fd != -1; i++) + _gpgme_io_close (fd_list[i].fd); + } for (i = 0; fd_list[i].fd != -1; i++) if (fd_list[i].dup_to == -1) Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2009-11-05 02:17:07 UTC (rev 1417) +++ trunk/src/w32-io.c 2009-11-05 02:39:31 UTC (rev 1418) @@ -1234,8 +1234,11 @@ TRACE_LOG1 ("CloseHandle of process failed: ec=%d", (int) GetLastError ()); - for (i = 0; fd_list[i].fd != -1; i++) - _gpgme_io_close (fd_list[i].fd); + if (! (flags & IOSPAWN_FLAG_NOCLOSE)) + { + for (i = 0; fd_list[i].fd != -1; i++) + _gpgme_io_close (fd_list[i].fd); + } for (i = 0; fd_list[i].fd != -1; i++) if (fd_list[i].dup_to == -1) From cvs at cvs.gnupg.org Thu Nov 5 03:53:14 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 03:53:14 +0100 Subject: [svn] assuan - r316 - trunk/src Message-ID: Author: marcus Date: 2009-11-05 03:53:14 +0100 (Thu, 05 Nov 2009) New Revision: 316 Modified: trunk/src/assuan-handler.c Log: Fix last commit. Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-11-05 02:15:04 UTC (rev 315) +++ trunk/src/assuan-handler.c 2009-11-05 02:53:14 UTC (rev 316) @@ -605,7 +605,8 @@ } else { - char errline const char *text = ctx->err_no == rc ? ctx->err_str : NULL; + char errline[300]; + const char *text = ctx->err_no == rc ? ctx->err_str : NULL; char ebuf[50]; gpg_strerror_r (rc, ebuf, sizeof (ebuf)); From cvs at cvs.gnupg.org Thu Nov 5 13:00:36 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 13:00:36 +0100 Subject: [svn] assuan - r317 - in trunk: . doc src tests Message-ID: Author: marcus Date: 2009-11-05 13:00:35 +0100 (Thu, 05 Nov 2009) New Revision: 317 Modified: trunk/ChangeLog trunk/NEWS trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-connect.c trunk/src/assuan-defs.h trunk/src/assuan-pipe-connect.c trunk/src/assuan-socket-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan.h trunk/src/context.c trunk/src/libassuan.def trunk/src/libassuan.vers trunk/tests/fdpassing.c Log: 2009-11-05 Marcus Brinkmann * tests/fdpassing.c (main): Call assuan_pipe_connect instead of assuan_pipe_connect_ext. doc/ 2009-11-05 Marcus Brinkmann * assuan.texi (Client code): Document ASSUAN_PIPE_CONNECT_FDPASSING and ASSUAN_PIPE_CONNECT_DETACHED. (Server code): Document ASSUAN_SOCKET_SERVER_FDPASSING and ASSUAN_SOCKET_SERVER_ACCEPTED. (Utilities): Update documentation of assuan_get_peercred. src/ 2009-11-05 Marcus Brinkmann * assuan.h (struct _assuan_peercred, assuan_peercred_t): New. (assuan_get_peercred): Define on all systems, return assuan_peercred_t. * assuan-defs.h (struct assuan_context_s): Move valid flag out of peercred struct, use struct _assuan_peercred. * libassuan.def: Add assuan_get_peercred. * assuan-connect.c (assuan_get_peercred): Moved to ... * context.c (assuan_get_peercred): ... here. Reimplement. * assuan-socket-server.c (accept_connection_bottom): Adjust access to peercred in context. * assuan.h (ASSUAN_PIPE_CONNECT_FDPASSING) (ASSUAN_PIPE_CONNECT_DETACHED, ASSUAN_SOCKET_SERVER_FDPASSING) (ASSUAN_SOCKET_SERVER_ACCEPTED, ASSUAN_SOCKET_CONNECT_FDPASSING): New. (assuan_pipe_connect_ext): Renamed to ... (assuan_pipe_connect): ... this, overwriting old prototype. (assuan_socket_connect_ext): Renamed to ... (assuan_socket_connect): ... this, overwriting old prototype. (assuan_init_socket_server_ext): Renamed to ... (assuan_init_socket_server): ... this, overwriting old prototype. * assuan-pipe-connect.c: Likewise for functions. * assuan-socket-connect.c: Likewise. * assuan-socket-server.c: Likewise. * libassuan.def (assuan_init_socket_server_ext) (assuan_pipe_connect_ext, assuan_socket_connect_ext): Removed. * libassuan.vers: Likewise. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/ChangeLog 2009-11-05 12:00:35 UTC (rev 317) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * tests/fdpassing.c (main): Call assuan_pipe_connect instead + of assuan_pipe_connect_ext. + 2009-11-04 Werner Koch * tests/fdpassing.c (register_commands): Add NULL arg to Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/doc/ChangeLog 2009-11-05 12:00:35 UTC (rev 317) @@ -1,5 +1,13 @@ 2009-11-05 Marcus Brinkmann + * assuan.texi: Update assuan_pipe_connect, assuan_socket_connect + and assuan_init_socket_connect. + (Client code): Document ASSUAN_PIPE_CONNECT_FDPASSING and + ASSUAN_PIPE_CONNECT_DETACHED. + (Server code): Document ASSUAN_SOCKET_SERVER_FDPASSING and + ASSUAN_SOCKET_SERVER_ACCEPTED. + (Utilities): Update documentation of assuan_get_peercred. + * assuan.texi (External I/O Loop Server): Document change to assuan_process_next. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/ChangeLog 2009-11-05 12:00:35 UTC (rev 317) @@ -1,5 +1,31 @@ 2009-11-05 Marcus Brinkmann + * assuan.h (struct _assuan_peercred, assuan_peercred_t): New. + (assuan_get_peercred): Define on all systems, return + assuan_peercred_t. + * assuan-defs.h (struct assuan_context_s): Move valid flag out of + peercred struct, use struct _assuan_peercred. + * libassuan.def: Add assuan_get_peercred. + * assuan-connect.c (assuan_get_peercred): Moved to ... + * context.c (assuan_get_peercred): ... here. Reimplement. + * assuan-socket-server.c (accept_connection_bottom): Adjust access + to peercred in context. + * assuan.h (ASSUAN_PIPE_CONNECT_FDPASSING) + (ASSUAN_PIPE_CONNECT_DETACHED, ASSUAN_SOCKET_SERVER_FDPASSING) + (ASSUAN_SOCKET_SERVER_ACCEPTED, ASSUAN_SOCKET_CONNECT_FDPASSING): New. + (assuan_pipe_connect_ext): Renamed to ... + (assuan_pipe_connect): ... this, overwriting old prototype. + (assuan_socket_connect_ext): Renamed to ... + (assuan_socket_connect): ... this, overwriting old prototype. + (assuan_init_socket_server_ext): Renamed to ... + (assuan_init_socket_server): ... this, overwriting old prototype. + * assuan-pipe-connect.c: Likewise for functions. + * assuan-socket-connect.c: Likewise. + * assuan-socket-server.c: Likewise. + * libassuan.def (assuan_init_socket_server_ext) + (assuan_pipe_connect_ext, assuan_socket_connect_ext): Removed. + * libassuan.vers: Likewise. + * assuan-defs.h (assuan_context_t): Add member PROCESS_DONE. * assuan.h (assuan_process_next): Add argument DONE to prototype. * assuan-handler.c (assuan_process_next): Likewise, handle it. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/NEWS 2009-11-05 12:00:35 UTC (rev 317) @@ -10,12 +10,12 @@ context with assuan_new and use that. Instead of assuan_disconnect or assuan_deinit_server, call assuan_release. Use assuan_set_gpg_err_source instead of assuan_set_assuan_err_source. - If you use assuan_pipe_connect or assuan_pipe_connect_ext with NAME - of NULL, you have to provide a non-NULL ARGV argument and check - that against "server" or "client" to determine which end you got - after fork(). If you use the assuan sock interface, you must call - assuan_sock_init after setting global context defaults. Add a NULL - as the last arg to assuan_register_command. + If you use assuan_pipe_connect with NAME of NULL, you have to + provide a non-NULL ARGV argument and check that against "server" or + "client" to determine which end you got after fork(). If you use + the assuan sock interface, you must call assuan_sock_init after + setting global context defaults. Add a NULL as the last arg to + assuan_register_command. * Pth support has changed. This now follows the same style as libgcrypt by setting system hook callbacks. @@ -44,13 +44,15 @@ assuan_new NEW assuan_release NEW assuan_init_socket_server CHANGED: Take ctx arg instead of pointer to ctx. -assuan_init_socket_server_ext CHANGED: Take ctx arg instead of pointer to ctx. + CHANGED: As assuan_init_socket_server_ext was. +assuan_init_socket_server_ext REMOVED assuan_socket_connect CHANGED: Take ctx arg instead of pointer to ctx. -assuan_socket_connect_ext CHANGED: Take ctx arg instead of pointer to ctx. + CHANGED: Is what assuan_socket_connect_ext was. +assuan_socket_connect_ext REMOVED assuan_pipe_connect CHANGED: Take ctx arg instead of pointer to ctx. If NAME is NULL, ARGV will contain fork result. -assuan_pipe_connect_ext CHANGED: Take ctx arg instead of pointer to ctx. - If NAME is NULL, ARGV will contain fork result. + CHANGED: Is now what assuan_pipe_connect_ext was. +assuan_pipe_connect_ext REMOVED assuan_init_pipe_server CHANGED: Take ctx arg instead of pointer to ctx. assuan_set_io_hooks REMOVED: Will come back in expanded form. assuan_io_hooks_t REMOVED: Will come back in expanded form. @@ -76,6 +78,13 @@ assuan_register_input_notify CHANGED: Handler returns error now. assuan_register_output_notify CHANGED: Handler returns error now. assuan_process_next CHANGED: New DONE argument instead EOF return. +ASSUAN_PIPE_CONNECT_FDPASSING NEW +ASSUAN_PIPE_CONNECT_DETACHED NEW +ASSUAN_SOCKET_SERVER_FDPASSING NEW +ASSUAN_SOCKET_SERVER_ACCEPTED NEW +ASSUAN_SOCKET_CONNECT_FDPASSING NEW +assuan_peercred_t NEW +assuan_get_peercred CHANGED: Return assuan_peercred_t. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/doc/assuan.texi 2009-11-05 12:00:35 UTC (rev 317) @@ -937,7 +937,7 @@ sockets, the full-fledged variant of the above function should be used: - at deftypefun gpg_error_t assuan_pipe_connect_ext (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{assuan_fd_t *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{assuan_fd_t *@var{fd_child_list}}, @w{void (*@var{atfork}) (void *, int)}, @w{void *@var{atforkvalue}}, @w{unsigned int @var{flags}}) A call to this functions forks the current process and executes the program @var{name}, passing the arguments given in the NULL-terminated @@ -961,7 +961,7 @@ @var{flags} is a bit vector and controls how the function acts: @table @code - at item bit 0 (value 1) + at item ASSUAN_PIPE_CONNECT_FDPASSING If cleared a simple pipe based server is expected and the function behaves similar to @code{assuan_pipe_connect}. @@ -969,7 +969,7 @@ usually created using the @code{socketpair} function. It also enables features only available with such servers. - at item bit 7 (value 128) + at item ASSUAN_PIPE_CONNECT_DETACHED If set and there is a need to start the server it will be started as a background process. This flag is useful under W32 systems, so that no new console is created and pops up a console window when starting the server @@ -977,39 +977,23 @@ @end deftypefun -For a pipe-based server you can also use the following legacy function: - - at deftypefun gpg_error_t assuan_pipe_connect (@w{assuan_context_t *@var{ctx}}, at w{const char *@var{name}}, @w{const char *@var{argv}[]}, @w{int *@var{fd_child_list}}) - -A call to @code{assuan_pipe_connect} is equivalent to a call to - at code{assuan_pipe_connect_ext} with @code{flags} being 0 and without -an at-fork handler. - at end deftypefun - If you are using a long running server listening either on a TCP or a Unix domain socket, the following function is used to connect to the server: - at deftypefun gpg_error_t assuan_socket_connect_ext (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}, @w{unsigned int @var{flags}}) Make a connection to the Unix domain socket @var{name} and return a new Assuan context at @var{ctx}. @var{server_pid} is currently not used but may become handy in the future; if you don't know the server's process ID (PID), pass @code{-1}. With @var{flags} set to - at code{1}, @code{sendmsg} and @code{recvmesg} are used for input and -output and thereby enable the use of descriptor passing. + at code{ASSUAN_SOCKET_CONNECT_FDPASSIN}, @code{sendmsg} and + at code{recvmesg} are used for input and output and thereby enable the +use of descriptor passing. Connecting to a TCP server is not yet implemented. Standard URL schemes are reserved for @var{name} specifying a TCP server. @end deftypefun - at deftypefun gpg_error_t assuan_socket_connect (@w{assuan_context_t *@var{ctx}}, @w{const char *@var{name}}, @w{pid_t @var{server_pid}}) - -A call to @code{assuan_socket_connect} is equivalent to a call to - at code{assuan_socket_connect_ext} with @code{flags} being 0. - -Same as above but no way to specify flags. - at end deftypefun - Eventually, after using the Assuan connection, the resources should be deallocated: @@ -1132,7 +1116,7 @@ rc = assuan_init_pipe_server (&ctx, filedes); @} else - rc = assuan_init_socket_server_ext (&ctx, fd, 2); + rc = assuan_init_socket_server (&ctx, fd, 2); if (rc) @{ fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc)); @@ -1167,17 +1151,17 @@ If a file descriptor has been passed, the assuan context gets initialized by the function: - at deftypefun gpg_error_t assuan_init_socket_server_ext (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) The function takes the file descriptor @var{fd} which is expected to be associated with a socket and returns a new Assuan context at @var{r_ctx}. The following bits are currently defined for @var{flags}: @table @code - at item Bit 0 + at item ASSUAN_SOCKET_SERVER_FDPASSING If set, @code{sendmsg} and @code{recvmesg} are used for input and output and thus enabling the use of descriptor passing. - at item Bit 1 + at item ASSUAN_SOCKET_SERVER_ACCEPTED If set, @var{fd} refers to an already accepted socket. That is, Libassuan won't call @var{accept} for it. It is suggested to set this bit as it allows better control of the connection state. @@ -1190,16 +1174,16 @@ @noindent On the Windows platform the following function needs to be called after -assuan_init_socket_server_ext: + at code{assuan_init_socket_server}: @deftypefun void assuan_set_sock_nonce ( @ @w{assuan_context_t @var{ctx}}, @ @w{assuan_sock_nonce_t *@var{nonce}}) -Save a copy of @var{nonce} in context @var{ctx}. This should be used to -register the server's nonce with a context established by -assuan_init_socket_server. It is actually only needed for Windows but -it does not harm to use it on other systems as well. +Save a copy of @var{nonce} in context @var{ctx}. This should be used +to register the server's nonce with a context established by + at code{assuan_init_socket_server}. It is actually only needed for +Windows but it does not harm to use it on other systems as well. @end deftypefun @@ -1504,7 +1488,7 @@ should just implement the bind/connect/listen/accept stage yourself. You can register the listen FD with your main event loop, accept the connection when it becomes ready, and finally call - at code{assuan_init_socket_server_ext} with the final argument being 2 + at code{assuan_init_socket_server} with the final argument being 2 to create an Assuan context for this connection. This way you can also handle multiple connections in parallel. The reference implementation for this approach is DirMngr. @@ -1726,13 +1710,29 @@ @end deftypefun - at deftypefun gpg_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}}) + at deftp {Data type} {assuan_peercred_t} +This structure is used to store the peer credentials. The available +members depend on the operating system. + at table @code + at item pid_t pid +The process ID of the peer. + + at item uid_t uid +The user ID of the peer process. + + at item gid_t gid +The group ID of the peer process. + at end table + at end deftp + + + at deftypefun gpg_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{assuan_peercred_t *@var{peercred}}) Return user credentials of the peer. This will work only on certain -systems and only when connected over a socket. If you are not -interested in some of the values, pass @code{NULL} instead of the -address of an appropriate variable. @var{pid}, @var{uid} and @var{gid} -are only set if the function succeeds and returns with @code{0}. +systems and only when connected over a socket. On success, a pointer +to the peer credentials is stored in @var{peercred}. The information +is only valid as long as the state of the connection is unchanged (at +least until the next assuan call to the same context). As of now only the server is able to retrieve this information. Note, that for getting the pid of the peer @code{assuan_get_pid} is usually Modified: trunk/src/assuan-connect.c =================================================================== --- trunk/src/assuan-connect.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan-connect.c 2009-11-05 12:00:35 UTC (rev 317) @@ -61,29 +61,3 @@ { return (ctx && ctx->pid) ? ctx->pid : -1; } - - -#ifndef HAVE_W32_SYSTEM -/* Return user credentials. PID, UID and GID may be given as NULL if - you are not interested in a value. For getting the pid of the - peer the assuan_get_pid is usually better suited. */ -gpg_error_t -assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) -{ - if (!ctx) - return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); - if (!ctx->peercred.valid) - return _assuan_error (ctx, GPG_ERR_ASS_GENERAL); - -#ifdef HAVE_SO_PEERCRED - if (pid) - *pid = ctx->peercred.pid; - if (uid) - *uid = ctx->peercred.uid; - if (gid) - *gid = ctx->peercred.gid; -#endif - - return 0; -} -#endif /* HAVE_W32_SYSTEM */ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan-defs.h 2009-11-05 12:00:35 UTC (rev 317) @@ -95,6 +95,9 @@ /* Callback handlers replacing system I/O functions. */ struct assuan_system_hooks system; + int peercred_valid; /* Whether this structure has valid information. */ + struct _assuan_peercred peercred; + /* Now come the members specific to subsystems or engines. FIXME: This is not developed yet. See below for the legacy members. */ struct @@ -169,15 +172,6 @@ assuan_sock_nonce_t listen_nonce; /* Used with LISTEN_FD. */ assuan_fd_t connected_fd; /* helper */ - struct { - int valid; /* Whether this structure has valid information. */ -#ifdef HAVE_SO_PEERCRED - pid_t pid; /* The pid of the peer. */ - uid_t uid; /* The uid of the peer. */ - gid_t gid; /* The gid of the peer. */ -#endif /* HAVE_SO_PEERCRED */ - } peercred; - /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; struct sockaddr_un serveraddr; Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan-pipe-connect.c 2009-11-05 12:00:35 UTC (rev 317) @@ -380,21 +380,6 @@ #endif /*!HAVE_W32_SYSTEM*/ -/* Connect to a server over a pipe, creating the assuan context and - returning it in CTX. The server filename is NAME, the argument - vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file - descriptors not to close in the child. */ -gpg_error_t -assuan_pipe_connect (assuan_context_t ctx, const char *name, - const char *argv[], int *fd_child_list) -{ - TRACE1 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect", ctx, - "name=%s", name ? name : "(null)"); - - return pipe_connect (ctx, name, argv, fd_child_list, NULL, NULL, 0); -} - - /* Connect to a server over a full-duplex socket (i.e. created by socketpair), creating the assuan context and returning it in CTX. The server filename is NAME, the argument vector in ARGV. @@ -425,11 +410,11 @@ "server" in *ARGV (but it is sufficient to check only the first character). */ gpg_error_t -assuan_pipe_connect_ext (assuan_context_t ctx, - const char *name, const char *argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue, unsigned int flags) +assuan_pipe_connect (assuan_context_t ctx, + const char *name, const char *argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue, unsigned int flags) { TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect_ext", ctx, "name=%s,flags=0x%x", name ? name : "(null)", flags); Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan-socket-connect.c 2009-11-05 12:00:35 UTC (rev 317) @@ -78,23 +78,11 @@ /* Make a connection to the Unix domain socket NAME and return a new Assuan context in CTX. SERVER_PID is currently not used but may - become handy in the future. */ -gpg_error_t -assuan_socket_connect (assuan_context_t ctx, - const char *name, pid_t server_pid) -{ - return assuan_socket_connect_ext (ctx, name, server_pid, 0); -} - - -/* Make a connection to the Unix domain socket NAME and return a new - Assuan context in CTX. SERVER_PID is currently not used but may become handy in the future. With flags set to 1 sendmsg and recvmsg are used. */ gpg_error_t -assuan_socket_connect_ext (assuan_context_t ctx, - const char *name, pid_t server_pid, - unsigned int flags) +assuan_socket_connect (assuan_context_t ctx, const char *name, + pid_t server_pid, unsigned int flags) { gpg_error_t err; assuan_fd_t fd; Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan-socket-server.c 2009-11-05 12:00:35 UTC (rev 317) @@ -46,7 +46,7 @@ { assuan_fd_t fd = ctx->connected_fd; - ctx->peercred.valid = 0; + ctx->peercred_valid = 0; #ifdef HAVE_SO_PEERCRED { struct ucred cr; @@ -57,7 +57,7 @@ ctx->peercred.pid = cr.pid; ctx->peercred.uid = cr.uid; ctx->peercred.gid = cr.gid; - ctx->peercred.valid = 1; + ctx->peercred_valid = 1; /* This overrides any already set PID if the function returns a valid one. */ @@ -137,22 +137,14 @@ ctx->cmdtbl = NULL; } -/* Initialize a server for the socket LISTEN_FD which has already be - put into listen mode */ -gpg_error_t -assuan_init_socket_server (assuan_context_t ctx, assuan_fd_t listen_fd) -{ - return assuan_init_socket_server_ext (ctx, listen_fd, 0); -} - /* Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing 1 - FD has already been accepted. */ gpg_error_t -assuan_init_socket_server_ext (assuan_context_t ctx, assuan_fd_t fd, - unsigned int flags) +assuan_init_socket_server (assuan_context_t ctx, assuan_fd_t fd, + unsigned int flags) { gpg_error_t rc; Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/assuan.h 2009-11-05 12:00:35 UTC (rev 317) @@ -361,43 +361,44 @@ gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, int filedes[2]); /*-- assuan-socket-server.c --*/ +#define ASSUAN_SOCKET_SERVER_FDPASSING 1 +#define ASSUAN_SOCKET_SERVER_ACCEPTED 2 gpg_error_t assuan_init_socket_server (assuan_context_t ctx, - assuan_fd_t listen_fd); -gpg_error_t assuan_init_socket_server_ext (assuan_context_t ctx, - assuan_fd_t fd, - unsigned int flags); + assuan_fd_t listen_fd, + unsigned int flags); void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce); /*-- assuan-pipe-connect.c --*/ +#define ASSUAN_PIPE_CONNECT_FDPASSING 1 +#define ASSUAN_PIPE_CONNECT_DETACHED 128 gpg_error_t assuan_pipe_connect (assuan_context_t ctx, const char *name, const char *argv[], - assuan_fd_t *fd_child_list); -gpg_error_t assuan_pipe_connect_ext (assuan_context_t ctx, - const char *name, - const char *argv[], - assuan_fd_t *fd_child_list, - void (*atfork) (void *, int), - void *atforkvalue, - unsigned int flags); + assuan_fd_t *fd_child_list, + void (*atfork) (void *, int), + void *atforkvalue, + unsigned int flags); /*-- assuan-socket-connect.c --*/ -gpg_error_t assuan_socket_connect (assuan_context_t ctx, - const char *name, - pid_t server_pid); +#define ASSUAN_SOCKET_CONNECT_FDPASSING 1 +gpg_error_t assuan_socket_connect (assuan_context_t ctx, const char *name, + pid_t server_pid, unsigned int flags); -gpg_error_t assuan_socket_connect_ext (assuan_context_t ctx, - const char *name, - pid_t server_pid, - unsigned int flags); - /*-- assuan-connect.c --*/ pid_t assuan_get_pid (assuan_context_t ctx); +struct _assuan_peercred +{ #ifndef _WIN32 -gpg_error_t assuan_get_peercred (assuan_context_t ctx, - pid_t *pid, uid_t *uid, gid_t *gid); + pid_t pid; + uid_t uid; + gid_t gid; #endif +}; +typedef struct _assuan_peercred *assuan_peercred_t; +gpg_error_t assuan_get_peercred (assuan_context_t ctx, + assuan_peercred_t *peercred); + /*-- assuan-client.c --*/ gpg_error_t assuan_transact (assuan_context_t ctx, Modified: trunk/src/context.c =================================================================== --- trunk/src/context.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/context.c 2009-11-05 12:00:35 UTC (rev 317) @@ -169,3 +169,19 @@ ctx->err_str = text; return err; } + + +/* Return user credentials. For getting the pid of the peer the + assuan_get_pid is usually better suited. */ +gpg_error_t +assuan_get_peercred (assuan_context_t ctx, assuan_peercred_t *peercred) +{ + if (!ctx) + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); + if (!ctx->peercred_valid) + return _assuan_error (ctx, GPG_ERR_ASS_GENERAL); + + *peercred = &ctx->peercred; + + return 0; +} Modified: trunk/src/libassuan.def =================================================================== --- trunk/src/libassuan.def 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/libassuan.def 2009-11-05 12:00:35 UTC (rev 317) @@ -36,64 +36,62 @@ assuan_get_log_cb @15 assuan_get_malloc_hooks @16 assuan_get_output_fd @17 - assuan_get_pid @18 - assuan_get_pointer @19 - assuan_init_pipe_server @20 - assuan_init_socket_server @21 - assuan_init_socket_server_ext @22 + assuan_get_peercred @18 + assuan_get_pid @19 + assuan_get_pointer @20 + assuan_init_pipe_server @21 + assuan_init_socket_server @22 assuan_inquire @23 assuan_inquire_ext @24 assuan_new @25 assuan_new_ext @26 assuan_pending_line @27 assuan_pipe_connect @28 - assuan_pipe_connect_ext @29 - assuan_process @30 - assuan_process_done @31 - assuan_process_next @32 - assuan_read_line @33 - assuan_receivefd @34 - assuan_register_bye_notify @35 - assuan_register_cancel_notify @36 - assuan_register_command @37 - assuan_register_input_notify @38 - assuan_register_option_handler @39 - assuan_register_output_notify @40 - assuan_register_post_cmd_notify @41 - assuan_register_reset_notify @42 - assuan_release @43 - assuan_send_data @44 - assuan_sendfd @45 - assuan_set_assuan_log_prefix @46 - assuan_set_error @47 - assuan_set_flag @48 - assuan_set_gpg_err_source @49 - assuan_set_hello_line @50 - assuan_set_io_monitor @51 - assuan_set_log_cb @52 - assuan_set_log_stream @53 - assuan_set_malloc_hooks @54 - assuan_set_okay_line @55 - assuan_set_pointer @56 - assuan_set_system_hooks @57 - assuan_sock_bind @58 - assuan_sock_check_nonce @59 - assuan_sock_close @60 - assuan_sock_connect @61 - assuan_sock_deinit @62 - assuan_sock_get_nonce @63 - assuan_sock_init @64 - assuan_sock_new @65 - assuan_socket_connect @66 - assuan_socket_connect_ext @67 - assuan_transact @68 - assuan_write_line @69 - assuan_write_status @70 - __assuan_close @71 - __assuan_pipe @72 - __assuan_socketpair @73 - __assuan_spawn @74 - __assuan_usleep @75 + assuan_process @29 + assuan_process_done @30 + assuan_process_next @31 + assuan_read_line @32 + assuan_receivefd @33 + assuan_register_bye_notify @34 + assuan_register_cancel_notify @35 + assuan_register_command @36 + assuan_register_input_notify @37 + assuan_register_option_handler @38 + assuan_register_output_notify @39 + assuan_register_post_cmd_notify @40 + assuan_register_reset_notify @41 + assuan_release @42 + assuan_send_data @43 + assuan_sendfd @44 + assuan_set_assuan_log_prefix @45 + assuan_set_error @46 + assuan_set_flag @47 + assuan_set_gpg_err_source @48 + assuan_set_hello_line @49 + assuan_set_io_monitor @50 + assuan_set_log_cb @51 + assuan_set_log_stream @52 + assuan_set_malloc_hooks @53 + assuan_set_okay_line @54 + assuan_set_pointer @55 + assuan_set_system_hooks @56 + assuan_sock_bind @57 + assuan_sock_check_nonce @58 + assuan_sock_close @59 + assuan_sock_connect @60 + assuan_sock_deinit @61 + assuan_sock_get_nonce @62 + assuan_sock_init @63 + assuan_sock_new @64 + assuan_socket_connect @65 + assuan_transact @66 + assuan_write_line @67 + assuan_write_status @68 + __assuan_close @69 + __assuan_pipe @70 + __assuan_socketpair @71 + __assuan_spawn @72 + __assuan_usleep @73 ; END Modified: trunk/src/libassuan.vers =================================================================== --- trunk/src/libassuan.vers 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/src/libassuan.vers 2009-11-05 12:00:35 UTC (rev 317) @@ -44,7 +44,6 @@ assuan_get_pointer; assuan_init_pipe_server; assuan_init_socket_server; - assuan_init_socket_server_ext; assuan_inquire; assuan_inquire_ext; assuan_new; @@ -52,7 +51,6 @@ assuan_new_ext; assuan_pending_line; assuan_pipe_connect; - assuan_pipe_connect_ext; assuan_process; assuan_process_done; assuan_process_next; @@ -91,7 +89,6 @@ assuan_sock_init; assuan_sock_new; assuan_socket_connect; - assuan_socket_connect_ext; assuan_transact; assuan_write_line; assuan_write_status; Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2009-11-05 02:53:14 UTC (rev 316) +++ trunk/tests/fdpassing.c 2009-11-05 12:00:35 UTC (rev 317) @@ -288,9 +288,9 @@ if (err) log_fatal ("assuan_new failed: %s\n", gpg_strerror (err)); - err = assuan_pipe_connect_ext (ctx, with_exec? "./fdpassing":NULL, - with_exec ? arglist : &loc, - no_close_fds, NULL, NULL, 1); + err = assuan_pipe_connect (ctx, with_exec? "./fdpassing":NULL, + with_exec ? arglist : &loc, + no_close_fds, NULL, NULL, 1); if (err) { log_error ("assuan_pipe_connect failed: %s\n", gpg_strerror (err)); From cvs at cvs.gnupg.org Thu Nov 5 13:02:19 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 13:02:19 +0100 Subject: [svn] dirmngr - r330 - in trunk: . src tests Message-ID: Author: marcus Date: 2009-11-05 13:02:19 +0100 (Thu, 05 Nov 2009) New Revision: 330 Modified: trunk/ChangeLog trunk/src/ChangeLog trunk/src/dirmngr-client.c trunk/src/server.c trunk/tests/test-dirmngr.c Log: 2009-11-05 Marcus Brinkmann * tests/test-dirmngr.c (start_dirmngr): Update use assuan_pipe_connect. src/ 2009-11-05 Marcus Brinkmann * server.c (start_command_handler): Update use of assuan_init_socket_server. * dirmngr-client.c (start_dirmngr): Update use of assuan_pipe_connect and assuan_socket_connect. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-04 10:32:21 UTC (rev 329) +++ trunk/ChangeLog 2009-11-05 12:02:19 UTC (rev 330) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * tests/test-dirmngr.c (start_dirmngr): Update use + assuan_pipe_connect. + 2009-10-16 Marcus Brinkmann * configure.ac: Test for libassuan instead of libassuan-pth. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-04 10:32:21 UTC (rev 329) +++ trunk/src/ChangeLog 2009-11-05 12:02:19 UTC (rev 330) @@ -1,3 +1,10 @@ +2009-11-05 Marcus Brinkmann + + * server.c (start_command_handler): Update use of + assuan_init_socket_server. + * dirmngr-client.c (start_dirmngr): Update use of + assuan_pipe_connect and assuan_socket_connect. + 2009-11-04 Werner Koch * server.c (register_commands): Add help arg to Modified: trunk/src/dirmngr-client.c =================================================================== --- trunk/src/dirmngr-client.c 2009-11-04 10:32:21 UTC (rev 329) +++ trunk/src/dirmngr-client.c 2009-11-05 12:02:19 UTC (rev 330) @@ -505,7 +505,7 @@ /* Connect to the agent and perform initial handshaking. */ rc = assuan_pipe_connect (ctx, opt.dirmngr_program, argv, - no_close_list); + no_close_list, NULL, NULL, 0); } else /* Connect to a daemon. */ { @@ -544,7 +544,7 @@ else pid = -1; - rc = assuan_socket_connect (ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); xfree (infostr); if (gpg_err_code(rc) == GPG_ERR_ASS_CONNECT_FAILED && !only_daemon) { Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2009-11-04 10:32:21 UTC (rev 329) +++ trunk/src/server.c 2009-11-05 12:02:19 UTC (rev 330) @@ -1369,7 +1369,7 @@ } else { - rc = assuan_init_socket_server_ext (ctx, fd, 2); + rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED); } if (rc) @@ -1433,13 +1433,12 @@ #ifndef HAVE_W32_SYSTEM if (opt.verbose) { - pid_t apid; - uid_t auid; - gid_t agid; + assuan_peercred_t peercred; - if (!assuan_get_peercred (ctx, &apid, &auid, &agid)) + if (!assuan_get_peercred (ctx, &peercred)) log_info ("connection from process %ld (%ld:%ld)\n", - (long)apid, (long)auid, (long)agid); + (long)peercred->pid, (long)peercred->uid, + (long)peercred->gid); } #endif Modified: trunk/tests/test-dirmngr.c =================================================================== --- trunk/tests/test-dirmngr.c 2009-11-04 10:32:21 UTC (rev 329) +++ trunk/tests/test-dirmngr.c 2009-11-05 12:02:19 UTC (rev 330) @@ -62,7 +62,7 @@ return -1; } - rc = assuan_pipe_connect (ctx, pgmname, argv, 0); + rc = assuan_pipe_connect (ctx, pgmname, argv, NULL, NULL, NULL, 0); if (rc) { assuan_release (ctx); From cvs at cvs.gnupg.org Thu Nov 5 13:06:55 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 13:06:55 +0100 Subject: [svn] GnuPG - r5196 - in trunk: agent common g13 scd sm tools Message-ID: Author: marcus Date: 2009-11-05 13:06:45 +0100 (Thu, 05 Nov 2009) New Revision: 5196 Modified: trunk/agent/ChangeLog trunk/agent/call-pinentry.c trunk/agent/call-scd.c trunk/agent/command.c trunk/agent/gpg-agent.c trunk/common/ChangeLog trunk/common/asshelp.c trunk/g13/ChangeLog trunk/g13/call-gpg.c trunk/scd/ChangeLog trunk/scd/command.c trunk/sm/ChangeLog trunk/sm/call-dirmngr.c trunk/tools/ChangeLog trunk/tools/gpg-connect-agent.c Log: agent/ 2009-11-05 Marcus Brinkmann * call-pinentry.c (start_pinentry): Call assuan_pipe_connect, not assuan_pipe_connect_ext. * command.c (start_command_handler): Change assuan_init_socket_server_ext into assuan_init_socket_server. * call-scd.c (start_scd): Update use of assuan_socket_connect and assuan_pipe_connect. * gpg-agent.c (check_own_socket_thread, check_for_running_agent): Update use of assuan_socket_connect. common/ 2009-11-05 Marcus Brinkmann * asshelp.c (start_new_gpg_agent): Update use of assuan_socket_connect and assuan_pipe_connect. scd/ 2009-11-05 Marcus Brinkmann * command.c (scd_command_handler): Call assuan_init_socket_server, not assuan_init_socket_server_ext. sm/ 2009-11-05 Marcus Brinkmann * call-dirmngr.c (start_dirmngr_ext): Update use of assuan_pipe_connect and assuan_socket_connect. tools/ 2009-11-05 Marcus Brinkmann * gpg-connect-agent.c (start_agent): Update use of assuan_socket_connect and assuan_pipe_connect. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/agent/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,3 +1,14 @@ +2009-11-05 Marcus Brinkmann + + * call-pinentry.c (start_pinentry): Call assuan_pipe_connect, not + assuan_pipe_connect_ext. + * command.c (start_command_handler): Change + assuan_init_socket_server_ext into assuan_init_socket_server. + * call-scd.c (start_scd): Update use of assuan_socket_connect and + assuan_pipe_connect. + * gpg-agent.c (check_own_socket_thread, check_for_running_agent): + Update use of assuan_socket_connect. + 2009-11-04 Werner Koch * command.c (register_commands): Add help arg to Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/common/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * asshelp.c (start_new_gpg_agent): Update use of + assuan_socket_connect and assuan_pipe_connect. + 2009-11-02 Marcus Brinkmann * get-passphrase.c (default_inq_cb, membuf_data_cb): Change return Modified: trunk/g13/ChangeLog =================================================================== --- trunk/g13/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/g13/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,4 +1,4 @@ -2009-11-04 Werner Koch +009-11-04 Werner Koch Under initial development - no need for a ChangeLog. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/scd/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * command.c (scd_command_handler): Call assuan_init_socket_server, + not assuan_init_socket_server_ext. + 2009-11-04 Werner Koch * command.c (register_commands): Add help arg to Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/sm/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * call-dirmngr.c (start_dirmngr_ext): Update use of + assuan_pipe_connect and assuan_socket_connect. + 2009-11-04 Werner Koch * server.c (register_commands): Add help arg to Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/tools/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) @@ -1,3 +1,8 @@ +2009-11-05 Marcus Brinkmann + + * gpg-connect-agent.c (start_agent): Update use of + assuan_socket_connect and assuan_pipe_connect. + 2009-11-04 Werner Koch * gpg-connect-agent.c (read_and_print_response): Add arg WITHHASH. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/agent/call-pinentry.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -320,8 +320,9 @@ that atfork is used to change the environment for pinentry. We start the server in detached mode to suppress the console window under Windows. */ - rc = assuan_pipe_connect_ext (ctx, opt.pinentry_program, argv, - no_close_list, atfork_cb, ctrl, 128); + rc = assuan_pipe_connect (ctx, opt.pinentry_program, argv, + no_close_list, atfork_cb, ctrl, + ASSUAN_PIPE_CONNECT_DETACHED); if (rc) { log_error ("can't connect to the PIN entry module: %s\n", Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/agent/call-scd.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -278,7 +278,7 @@ if (socket_name) { - rc = assuan_socket_connect (ctx, socket_name, 0); + rc = assuan_socket_connect (ctx, socket_name, 0, 0); if (rc) { log_error ("can't connect to socket `%s': %s\n", @@ -341,8 +341,8 @@ /* Connect to the pinentry and perform initial handshaking. Use detached flag (128) so that under W32 SCDAEMON does not show up a new window. */ - rc = assuan_pipe_connect_ext (ctx, opt.scdaemon_program, argv, - no_close_list, atfork_cb, NULL, 128); + rc = assuan_pipe_connect (ctx, opt.scdaemon_program, argv, + no_close_list, atfork_cb, NULL, 128); if (rc) { log_error ("can't connect to the SCdaemon: %s\n", Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/agent/command.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -1924,13 +1924,13 @@ } else if (listen_fd != GNUPG_INVALID_FD) { - rc = assuan_init_socket_server_ext (ctx, listen_fd, 0); + rc = assuan_init_socket_server (ctx, listen_fd, 0); /* FIXME: Need to call assuan_sock_set_nonce for Windows. But this branch is currently not used. */ } else { - rc = assuan_init_socket_server_ext (ctx, fd, 2); + rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED); } if (rc) { Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/agent/gpg-agent.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -2082,7 +2082,7 @@ goto leave; } - rc = assuan_socket_connect (ctx, sockname, (pid_t)(-1)); + rc = assuan_socket_connect (ctx, sockname, (pid_t)(-1), 0); if (rc) { log_error ("can't connect my own socket: %s\n", gpg_strerror (rc)); @@ -2220,7 +2220,7 @@ rc = assuan_new (&ctx); if (! rc) - rc = assuan_socket_connect (ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); xfree (infostr); if (rc) { Modified: trunk/common/asshelp.c =================================================================== --- trunk/common/asshelp.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/common/asshelp.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -199,7 +199,7 @@ /* First check whether we can connect at the standard socket. */ sockname = make_filename (homedir, "S.gpg-agent", NULL); - rc = assuan_socket_connect (ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0, 0); if (rc) { @@ -274,7 +274,7 @@ /* Connect to the agent and perform initial handshaking. */ rc = assuan_pipe_connect (ctx, agent_program, argv, - no_close_list); + no_close_list, NULL, NULL, 0); } #endif /*!HAVE_W32_SYSTEM*/ } @@ -307,7 +307,7 @@ goto restart; } - rc = assuan_socket_connect (ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); xfree (infostr); if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED) { Modified: trunk/g13/call-gpg.c =================================================================== --- trunk/g13/call-gpg.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/g13/call-gpg.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -101,7 +101,8 @@ no_close_list[i] = -1; /* Connect to GPG and perform initial handshaking. */ - err = assuan_pipe_connect (ctx, opt.gpg_program, argv, no_close_list); + err = assuan_pipe_connect (ctx, opt.gpg_program, argv, no_close_list, + NULL, NULL, 0); if (err) { assuan_release (ctx); Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/scd/command.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -1921,7 +1921,8 @@ } else { - rc = assuan_init_socket_server_ext (ctx, INT2FD(fd), 2); + rc = assuan_init_socket_server (ctx, INT2FD(fd), + ASSUAN_SOCKET_SERVER_ACCEPTED); } if (rc) { Modified: trunk/sm/call-dirmngr.c =================================================================== --- trunk/sm/call-dirmngr.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/sm/call-dirmngr.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -264,7 +264,7 @@ /* connect to the agent and perform initial handshaking */ rc = assuan_pipe_connect (ctx, opt.dirmngr_program, argv, - no_close_list); + no_close_list, NULL, NULL, 0); } else { @@ -297,7 +297,7 @@ else pid = -1; - rc = assuan_socket_connect (ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); #ifdef HAVE_W32_SYSTEM if (rc) log_debug ("connecting dirmngr at `%s' failed\n", infostr); Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2009-11-05 02:18:31 UTC (rev 5195) +++ trunk/tools/gpg-connect-agent.c 2009-11-05 12:06:45 UTC (rev 5196) @@ -1160,7 +1160,7 @@ opt.homedir = default_homedir (); - opt.connect_flags = 1; /* Use extended connect mode. */ + opt.connect_flags = 1; /* Parse the command line. */ pargs.argc = &argc; @@ -1233,9 +1233,9 @@ exit (1); } - rc = assuan_pipe_connect_ext (ctx, *argv, (const char **)argv, - no_close, NULL, NULL, - opt.connect_flags); + rc = assuan_pipe_connect + (ctx, *argv, (const char **)argv, no_close, NULL, NULL, + (opt.connect_flags & 1) ? ASSUAN_PIPE_CONNECT_FDPASSING : 0); if (rc) { log_error ("assuan_pipe_connect_ext failed: %s\n", @@ -1256,8 +1256,9 @@ exit (1); } - rc = assuan_socket_connect_ext (ctx, opt.raw_socket, 0, - opt.connect_flags); + rc = assuan_socket_connect + (ctx, opt.raw_socket, 0, + (opt.connect_flags & 1) ? ASSUAN_SOCKET_CONNECT_FDPASSING : 0); if (rc) { log_error ("can't connect to socket `%s': %s\n", @@ -2114,7 +2115,7 @@ /* Check whether we can connect at the standard socket. */ sockname = make_filename (opt.homedir, "S.gpg-agent", NULL); - rc = assuan_socket_connect (ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0, 0); #ifdef HAVE_W32_SYSTEM /* If we failed to connect under Windows, we fire up the agent. */ @@ -2148,7 +2149,7 @@ exit (1); } - rc = assuan_socket_connect (ctx, sockname, 0); + rc = assuan_socket_connect (ctx, sockname, 0, 0); } if (rc) rc = save_rc; @@ -2188,7 +2189,7 @@ exit (1); } - rc = assuan_socket_connect (ctx, infostr, pid); + rc = assuan_socket_connect (ctx, infostr, pid, 0); xfree (infostr); } From cvs at cvs.gnupg.org Thu Nov 5 13:10:04 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Nov 2009 13:10:04 +0100 Subject: [svn] gpgme - r1419 - trunk/src Message-ID: Author: marcus Date: 2009-11-05 13:10:04 +0100 (Thu, 05 Nov 2009) New Revision: 1419 Modified: trunk/src/ChangeLog trunk/src/engine-assuan.c trunk/src/engine-g13.c trunk/src/engine-gpgsm.c Log: 2009-11-05 Marcus Brinkmann * engine-assuan.c (llass_new): Update use of assuan_socket_connect. * engine-gpgsm.c (gpgsm_new): Update use of assuan_pipe_connect. * engine-g13.c (g13_new): Likewise. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-05 02:39:31 UTC (rev 1418) +++ trunk/src/ChangeLog 2009-11-05 12:10:04 UTC (rev 1419) @@ -1,5 +1,9 @@ 2009-11-05 Marcus Brinkmann + * engine-assuan.c (llass_new): Update use of assuan_socket_connect. + * engine-gpgsm.c (gpgsm_new): Update use of assuan_pipe_connect. + * engine-g13.c (g13_new): Likewise. + * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. * w32-io.c (_gpgme_io_spawn): Implement this flag. * posix-io.c (_gpgme_io_spawn): Likewise. Modified: trunk/src/engine-assuan.c =================================================================== --- trunk/src/engine-assuan.c 2009-11-05 02:39:31 UTC (rev 1418) +++ trunk/src/engine-assuan.c 2009-11-05 12:10:04 UTC (rev 1419) @@ -240,7 +240,7 @@ goto leave; assuan_ctx_set_system_hooks (llass->assuan_ctx, &_gpgme_assuan_system_hooks); - err = assuan_socket_connect (llass->assuan_ctx, file_name, 0); + err = assuan_socket_connect (llass->assuan_ctx, file_name, 0, 0); if (err) goto leave; Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2009-11-05 02:39:31 UTC (rev 1418) +++ trunk/src/engine-g13.c 2009-11-05 12:10:04 UTC (rev 1419) @@ -248,13 +248,13 @@ assuan_ctx_set_system_hooks (g13->assuan_ctx, &_gpgme_assuan_system_hooks); #if USE_DESCRIPTOR_PASSING - err = assuan_pipe_connect_ext + err = assuan_pipe_connect (g13->assuan_ctx, file_name ? file_name : _gpgme_get_g13_path (), - argv, NULL, NULL, NULL, 1); + argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING); #else err = assuan_pipe_connect (g13->assuan_ctx, file_name ? file_name : _gpgme_get_g13_path (), - argv, NULL); + argv, NULL, NULL, NULL, 0); #endif if (err) goto leave; Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-05 02:39:31 UTC (rev 1418) +++ trunk/src/engine-gpgsm.c 2009-11-05 12:10:04 UTC (rev 1419) @@ -332,13 +332,13 @@ assuan_ctx_set_system_hooks (gpgsm->assuan_ctx, &_gpgme_assuan_system_hooks); #if USE_DESCRIPTOR_PASSING - err = assuan_pipe_connect_ext + err = assuan_pipe_connect (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (), - argv, NULL, NULL, NULL, 1); + argv, NULL, NULL, NULL, ASSUAN_PIPE_CONNECT_FDPASSING); #else err = assuan_pipe_connect (gpgsm->assuan_ctx, file_name ? file_name : _gpgme_get_gpgsm_path (), - argv, child_fds); + argv, child_fds, NULL, NULL, 0); /* On Windows, handles are inserted in the spawned process with DuplicateHandle, and child_fds contains the server-local names From cvs at cvs.gnupg.org Fri Nov 6 01:13:00 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 06 Nov 2009 01:13:00 +0100 Subject: [svn] gpgme - r1420 - trunk/src Message-ID: Author: marcus Date: 2009-11-06 01:12:59 +0100 (Fri, 06 Nov 2009) New Revision: 1420 Modified: trunk/src/ChangeLog trunk/src/engine-g13.c trunk/src/vfs-mount.c Log: 2009-11-05 Marcus Brinkmann * engine-g13.c (struct engine_g13): Remove members RESULT_CB and RESULT_CB_VALUE. (g13_assuan_simple_command, status_handler): Don't use those anymore. (g13_transact): Remove them from argument list, too. * vfs-mount.c (_gpgme_vfs_mount_status_handler): New function. (_gpgme_op_vfs_mount): Pass it to transact. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-05 12:10:04 UTC (rev 1419) +++ trunk/src/ChangeLog 2009-11-06 00:12:59 UTC (rev 1420) @@ -1,5 +1,12 @@ 2009-11-05 Marcus Brinkmann + * engine-g13.c (struct engine_g13): Remove members RESULT_CB and + RESULT_CB_VALUE. + (g13_assuan_simple_command, status_handler): Don't use those anymore. + (g13_transact): Remove them from argument list, too. + * vfs-mount.c (_gpgme_vfs_mount_status_handler): New function. + (_gpgme_op_vfs_mount): Pass it to transact. + * engine-assuan.c (llass_new): Update use of assuan_socket_connect. * engine-gpgsm.c (gpgsm_new): Update use of assuan_pipe_connect. * engine-g13.c (g13_new): Likewise. Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2009-11-05 12:10:04 UTC (rev 1419) +++ trunk/src/engine-g13.c 2009-11-06 00:12:59 UTC (rev 1420) @@ -69,10 +69,6 @@ struct gpgme_io_cbs io_cbs; - /* Internal callbacks. */ - engine_assuan_result_cb_t result_cb; - void *result_cb_value; - /* User provided callbacks. */ struct { gpgme_assuan_data_cb_t data_cb; @@ -398,8 +394,8 @@ static gpgme_error_t g13_assuan_simple_command (assuan_context_t ctx, char *cmd, - engine_status_handler_t status_fnc, - void *status_fnc_value) + engine_status_handler_t status_fnc, + void *status_fnc_value) { gpg_error_t err; char *line; @@ -480,17 +476,13 @@ "fd 0x%x: ERR line: %s", fd, err ? gpg_strerror (err) : "ok"); - /* In g13, command execution errors are not fatal, as we use + /* Command execution errors are not fatal, as we use a session based protocol. */ - if (g13->result_cb) - err = g13->result_cb (g13->result_cb_value, err); - else - err = 0; - if (!err) - { - _gpgme_io_close (g13->status_cb.fd); - return 0; - } + data->op_err = err; + + /* The caller will do the rest (namely, call cancel_op, + which closes status_fd). */ + return 0; } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' @@ -498,15 +490,9 @@ { TRACE1 (DEBUG_CTX, "gpgme:status_handler", g13, "fd 0x%x: OK line", fd); - if (g13->result_cb) - err = g13->result_cb (g13->result_cb_value, 0); - else - err = 0; - if (!err) - { - _gpgme_io_close (g13->status_cb.fd); - return 0; - } + + _gpgme_io_close (g13->status_cb.fd); + return 0; } else if (linelen > 2 && line[0] == 'D' && line[1] == ' ') @@ -704,8 +690,6 @@ static gpgme_error_t g13_transact (void *engine, const char *command, - engine_assuan_result_cb_t result_cb, - void *result_cb_value, gpgme_assuan_data_cb_t data_cb, void *data_cb_value, gpgme_assuan_inquire_cb_t inq_cb, @@ -719,8 +703,6 @@ if (!g13 || !command || !*command) return gpg_error (GPG_ERR_INV_VALUE); - g13->result_cb = result_cb; - g13->result_cb_value = result_cb_value; g13->user.data_cb = data_cb; g13->user.data_cb_value = data_cb_value; g13->user.inq_cb = inq_cb; Modified: trunk/src/vfs-mount.c =================================================================== --- trunk/src/vfs-mount.c 2009-11-05 12:10:04 UTC (rev 1419) +++ trunk/src/vfs-mount.c 2009-11-06 00:12:59 UTC (rev 1420) @@ -56,6 +56,30 @@ static gpgme_error_t +_gpgme_vfs_mount_status_handler (void *priv, const char *code, const char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_VFS_MOUNT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + if (! strcasecmp ("MOUNTPOINT", code)) + { + if (opd->result.mount_dir) + free (opd->result.mount_dir); + opd->result.mount_dir = strdup (args); + } + + return 0; +} + + +static gpgme_error_t vfs_start (gpgme_ctx_t ctx, int synchronous, const char *command, gpgme_assuan_data_cb_t data_cb, @@ -190,7 +214,7 @@ } err = gpgme_op_vfs_transact (ctx, cmd, NULL, NULL, NULL, NULL, - NULL, NULL, op_err); + _gpgme_vfs_mount_status_handler, ctx, op_err); free (cmd); return err; From cvs at cvs.gnupg.org Fri Nov 6 01:44:44 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 06 Nov 2009 01:44:44 +0100 Subject: [svn] gpgme - r1421 - trunk/src Message-ID: Author: marcus Date: 2009-11-06 01:44:44 +0100 (Fri, 06 Nov 2009) New Revision: 1421 Modified: trunk/src/ChangeLog trunk/src/gpgme-tool.c Log: 2009-11-06 Marcus Brinkmann * gpgme-tool.c (struct gpgme_tool): New members write_data and write_data_hook. (gt_write_data): New function. (gt_result): Output vfs_mount result. (server_write_data): New function. (gpgme_server): Initialize write_data members. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-06 00:12:59 UTC (rev 1420) +++ trunk/src/ChangeLog 2009-11-06 00:44:44 UTC (rev 1421) @@ -1,3 +1,12 @@ +2009-11-06 Marcus Brinkmann + + * gpgme-tool.c (struct gpgme_tool): New members write_data and + write_data_hook. + (gt_write_data): New function. + (gt_result): Output vfs_mount result. + (server_write_data): New function. + (gpgme_server): Initialize write_data members. + 2009-11-05 Marcus Brinkmann * engine-g13.c (struct engine_g13): Remove members RESULT_CB and Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-06 00:12:59 UTC (rev 1420) +++ trunk/src/gpgme-tool.c 2009-11-06 00:44:44 UTC (rev 1421) @@ -35,6 +35,8 @@ #include #endif +#include + #include "gpgme.h" @@ -509,6 +511,8 @@ gpg_error_t (*write_status) (void *hook, const char *status, const char *msg); void *write_status_hook; + gpg_error_t (*write_data) (void *hook, const void *buf, size_t len); + void *write_data_hook; }; typedef struct gpgme_tool *gpgme_tool_t; @@ -739,6 +743,13 @@ gpg_error_t +gt_write_data (gpgme_tool_t gt, void *buf, size_t len) +{ + return gt->write_data (gt->write_data_hook, buf, len); +} + + +gpg_error_t gt_get_engine_info (gpgme_tool_t gt, gpgme_protocol_t proto) { gpgme_engine_info_t info; @@ -1085,6 +1096,18 @@ } } } + if (flags & GT_RESULT_VFS_MOUNT) + { + gpgme_vfs_mount_result_t res = gpgme_op_vfs_mount_result (gt->ctx); + if (res) + { + gt_write_data (gt, "vfs_mount\n", 10); + gt_write_data (gt, "mount_dir:", 10); + gt_write_data (gt, res->mount_dir, strlen (res->mount_dir)); + gt_write_data (gt, "\n", 1); + } + } + return 0; } @@ -1113,6 +1136,14 @@ } +gpg_error_t +server_write_data (void *hook, const void *buf, size_t len) +{ + struct server *server = hook; + return assuan_send_data (server->assuan_ctx, buf, len); +} + + static gpgme_data_encoding_t server_data_encoding (const char *line) { @@ -1999,6 +2030,8 @@ server.gt = gt; gt->write_status = server_write_status; gt->write_status_hook = &server; + gt->write_data = server_write_data; + gt->write_data_hook = &server; /* We use a pipe based server so that we can work from scripts. assuan_init_pipe_server will automagically detect when we are From cvs at cvs.gnupg.org Mon Nov 9 22:17:58 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Nov 2009 22:17:58 +0100 Subject: [svn] gpgme - r1422 - trunk/src Message-ID: Author: marcus Date: 2009-11-09 22:17:58 +0100 (Mon, 09 Nov 2009) New Revision: 1422 Modified: trunk/src/ChangeLog trunk/src/engine-gpgsm.c Log: 2009-11-09 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Close server side FDs. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-06 00:44:44 UTC (rev 1421) +++ trunk/src/ChangeLog 2009-11-09 21:17:58 UTC (rev 1422) @@ -1,3 +1,7 @@ +2009-11-09 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_new): Close server side FDs. + 2009-11-06 Marcus Brinkmann * gpgme-tool.c (struct gpgme_tool): New members write_data and Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-06 00:44:44 UTC (rev 1421) +++ trunk/src/engine-gpgsm.c 2009-11-09 21:17:58 UTC (rev 1422) @@ -364,9 +364,9 @@ /* assuan_pipe_connect in this case uses _gpgme_io_spawn which closes the child fds for us. */ - gpgsm->input_cb.server_fd = -1; - gpgsm->output_cb.server_fd = -1; - gpgsm->message_cb.server_fd = -1; + _gpgme_io_close (gpgsm->input_cb.server_fd); + _gpgme_io_close (gpgsm->output_cb.server_fd); + _gpgme_io_close (gpgsm->message_cb.server_fd); err = _gpgme_getenv ("DISPLAY", &dft_display); if (err) From cvs at cvs.gnupg.org Mon Nov 9 22:19:03 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Nov 2009 22:19:03 +0100 Subject: [svn] gpgme - r1423 - trunk/src Message-ID: Author: marcus Date: 2009-11-09 22:19:03 +0100 (Mon, 09 Nov 2009) New Revision: 1423 Modified: trunk/src/engine-gpgsm.c Log: Remove comment. Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-09 21:17:58 UTC (rev 1422) +++ trunk/src/engine-gpgsm.c 2009-11-09 21:19:03 UTC (rev 1423) @@ -362,8 +362,6 @@ if (err) goto leave; - /* assuan_pipe_connect in this case uses _gpgme_io_spawn which - closes the child fds for us. */ _gpgme_io_close (gpgsm->input_cb.server_fd); _gpgme_io_close (gpgsm->output_cb.server_fd); _gpgme_io_close (gpgsm->message_cb.server_fd); From cvs at cvs.gnupg.org Mon Nov 9 22:21:12 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Nov 2009 22:21:12 +0100 Subject: [svn] gpgme - r1424 - trunk/src Message-ID: Author: marcus Date: 2009-11-09 22:21:12 +0100 (Mon, 09 Nov 2009) New Revision: 1424 Modified: trunk/src/engine-gpgsm.c Log: Fix last change. Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-09 21:19:03 UTC (rev 1423) +++ trunk/src/engine-gpgsm.c 2009-11-09 21:21:12 UTC (rev 1424) @@ -362,10 +362,6 @@ if (err) goto leave; - _gpgme_io_close (gpgsm->input_cb.server_fd); - _gpgme_io_close (gpgsm->output_cb.server_fd); - _gpgme_io_close (gpgsm->message_cb.server_fd); - err = _gpgme_getenv ("DISPLAY", &dft_display); if (err) goto leave; From cvs at cvs.gnupg.org Tue Nov 10 10:04:18 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 10:04:18 +0100 Subject: [svn] GnuPG - r5197 - trunk/sm Message-ID: Author: marcus Date: 2009-11-10 10:04:17 +0100 (Tue, 10 Nov 2009) New Revision: 5197 Modified: trunk/sm/ChangeLog trunk/sm/server.c Log: 2009-11-10 Marcus Brinkmann * server.c (cmd_getauditlog): Don't dup FD for es_fdopen_nc as this leaks the FD here. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-05 12:06:45 UTC (rev 5196) +++ trunk/sm/ChangeLog 2009-11-10 09:04:17 UTC (rev 5197) @@ -1,3 +1,8 @@ +2009-11-10 Marcus Brinkmann + + * server.c (cmd_getauditlog): Don't dup FD for es_fdopen_nc as + this leaks the FD here. + 2009-11-05 Marcus Brinkmann * call-dirmngr.c (start_dirmngr_ext): Update use of Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2009-11-05 12:06:45 UTC (rev 5196) +++ trunk/sm/server.c 2009-11-10 09:04:17 UTC (rev 5197) @@ -1050,7 +1050,7 @@ if (out_fd == -1) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); - out_stream = es_fdopen_nc ( dup (out_fd), "w"); + out_stream = es_fdopen_nc (out_fd, "w"); if (!out_stream) { return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen() failed"); From cvs at cvs.gnupg.org Tue Nov 10 10:04:51 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 10:04:51 +0100 Subject: [svn] assuan - r318 - trunk/src Message-ID: Author: marcus Date: 2009-11-10 10:04:50 +0100 (Tue, 10 Nov 2009) New Revision: 318 Modified: trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-uds.c Log: 2009-11-10 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Rename CTX->process_done to CTX->process_complete for clarity. Remove buffer variables from UDS. * assuan-pipe-connect.c (socketpair_connect): Allow FD_CHILD_LIST to be NULL. * assuan-handler.c: Rename CTX->process_done to CTX->process_complete for clarity. (process_request, process_next): Handle EOF. * assuan-uds.c (uds_reader): Remove buffering, which breaks the pending line algorithm in assuan-buffer.c. (_assuan_init_uds_io, _assuan_uds_deinit): Remove buffering. * assuan-buffer.c (_assuan_read_line): Add comment. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/ChangeLog 2009-11-10 09:04:50 UTC (rev 318) @@ -1,3 +1,18 @@ +2009-11-10 Marcus Brinkmann + + * assuan-defs.h (struct assuan_context_s): Rename + CTX->process_done to CTX->process_complete for clarity. Remove + buffer variables from UDS. + * assuan-pipe-connect.c (socketpair_connect): Allow FD_CHILD_LIST + to be NULL. + * assuan-handler.c: Rename CTX->process_done to + CTX->process_complete for clarity. + (process_request, process_next): Handle EOF. + * assuan-uds.c (uds_reader): Remove buffering, which breaks the + pending line algorithm in assuan-buffer.c. + (_assuan_init_uds_io, _assuan_uds_deinit): Remove buffering. + * assuan-buffer.c (_assuan_read_line): Add comment. + 2009-11-05 Marcus Brinkmann * assuan.h (struct _assuan_peercred, assuan_peercred_t): New. Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/assuan-buffer.c 2009-11-10 09:04:50 UTC (rev 318) @@ -79,6 +79,7 @@ *r_eof = 1; break; /* allow incomplete lines */ } + p = buf; nleft -= n; buf += n; @@ -88,7 +89,6 @@ if (p) break; /* at least one full line available - that's enough for now */ } - return 0; } @@ -142,7 +142,9 @@ if (saved_errno == EAGAIN) { - /* We have to save a partial line. */ + /* We have to save a partial line. Due to readline's + behaviour, we know that this is not a complete line yet + (no newline). So we don't set PENDING to true. */ memcpy (ctx->inbound.attic.line, line, atticlen + nread); ctx->inbound.attic.pending = 0; ctx->inbound.attic.linelen = atticlen + nread; @@ -253,6 +255,7 @@ *line = ctx->inbound.line; *linelen = ctx->inbound.linelen; + return err; } Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/assuan-defs.h 2009-11-10 09:04:50 UTC (rev 318) @@ -127,7 +127,7 @@ int is_server; /* Set if this is context belongs to a server */ int in_inquire; int in_process_next; - int process_done; + int process_complete; int in_command; /* The following members are used by assuan_inquire_ext. */ @@ -176,15 +176,8 @@ struct sockaddr_un myaddr; struct sockaddr_un serveraddr; - /* Structure used for unix domain socket buffering. FIXME: We don't - use datagrams anymore thus we could get away with a simpler - buffering approach. */ + /* Structure used for unix domain sockets. */ struct { - void *buffer; /* Malloced buffer. */ - int bufferallocated; /* Memory allocated. */ - int bufferoffset; /* Offset of start of buffer. */ - int buffersize; /* Bytes buffered. */ - assuan_fd_t pendingfds[5]; /* Array to save received descriptors. */ int pendingfdscount; /* Number of received descriptors. */ } uds; Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/assuan-handler.c 2009-11-10 09:04:50 UTC (rev 318) @@ -125,7 +125,7 @@ assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); /* pretty simple :-) */ - ctx->process_done = 1; + ctx->process_complete = 1; return PROCESS_DONE (ctx, 0); } @@ -593,7 +593,7 @@ /* Error handling. */ if (!rc) { - if (ctx->process_done) + if (ctx->process_complete) { /* No error checking because the peer may have already disconnect. */ @@ -643,6 +643,11 @@ rc = _assuan_read_line (ctx); if (_assuan_error_is_eagain (ctx, rc)) return 0; + if (gpg_err_code (rc) == GPG_ERR_EOF) + { + ctx->process_complete = 1; + return 0; + } if (rc) return rc; if (*ctx->inbound.line == '#' || !ctx->inbound.linelen) @@ -698,15 +703,15 @@ if (done) *done = 0; - ctx->process_done = 0; + ctx->process_complete = 0; do { rc = process_next (ctx); } - while (!rc && !ctx->process_done && assuan_pending_line (ctx)); + while (!rc && !ctx->process_complete && assuan_pending_line (ctx)); if (done) - *done = !!ctx->process_done; + *done = !!ctx->process_complete; return rc; } @@ -726,6 +731,11 @@ rc = _assuan_read_line (ctx); } while (_assuan_error_is_eagain (ctx, rc)); + if (gpg_err_code (rc) == GPG_ERR_EOF) + { + ctx->process_complete = 1; + return 0; + } if (rc) return rc; if (*ctx->inbound.line == '#' || !ctx->inbound.linelen) @@ -756,10 +766,10 @@ { gpg_error_t rc; - ctx->process_done = 0; + ctx->process_complete = 0; do { rc = process_request (ctx); - } while (!rc && !ctx->process_done); + } while (!rc && !ctx->process_complete); return rc; } Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/assuan-pipe-connect.c 2009-11-10 09:04:50 UTC (rev 318) @@ -317,12 +317,15 @@ sprintf (mypidstr, "%lu", (unsigned long)getpid ()); - while (fd_child_list[child_fds_cnt] != ASSUAN_INVALID_FD) - child_fds_cnt++; + if (fd_child_list) + while (fd_child_list[child_fds_cnt] != ASSUAN_INVALID_FD) + child_fds_cnt++; child_fds = _assuan_malloc (ctx, (child_fds_cnt + 2) * sizeof (int)); if (! child_fds) return TRACE_ERR (gpg_err_code_from_syserror ()); - memcpy (&child_fds[1], fd_child_list, (child_fds_cnt + 1) * sizeof (int)); + child_fds[1] = ASSUAN_INVALID_FD; + if (fd_child_list) + memcpy (&child_fds[1], fd_child_list, (child_fds_cnt + 1) * sizeof (int)); if (_assuan_socketpair (ctx, AF_LOCAL, SOCK_STREAM, 0, fds)) { @@ -333,7 +336,6 @@ atp.peer_fd = fds[1]; child_fds[0] = fds[1]; - rc = _assuan_spawn (ctx, &pid, name, argv, ASSUAN_INVALID_FD, ASSUAN_INVALID_FD, child_fds, at_socketpair_fork_cb, &atp, 0); @@ -351,9 +353,12 @@ of the peer socketpair fd (fd_child_list[0]) must be done by the wrapper program based on the environment variable _assuan_connection_fd. */ - for (idx = 0; fd_child_list[idx] != -1; idx++) - /* We add 1 to skip over the socketpair end. */ - fd_child_list[idx] = child_fds[idx + 1]; + if (fd_child_list) + { + for (idx = 0; fd_child_list[idx] != -1; idx++) + /* We add 1 to skip over the socketpair end. */ + fd_child_list[idx] = child_fds[idx + 1]; + } /* If this is the server child process, exit early. */ if (! name && (*argv)[0] == 's') Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2009-11-05 12:00:35 UTC (rev 317) +++ trunk/src/assuan-uds.c 2009-11-10 09:04:50 UTC (rev 318) @@ -64,24 +64,15 @@ #endif /*USE_DESCRIPTOR_PASSING*/ -/* Read from a unix domain socket using sendmsg. - - FIXME: We don't need the buffering. It is a leftover from the time - when we used datagrams. */ +/* Read from a unix domain socket using sendmsg. */ static ssize_t uds_reader (assuan_context_t ctx, void *buf, size_t buflen) { #ifndef HAVE_W32_SYSTEM - int len = ctx->uds.buffersize; - - if (!ctx->uds.bufferallocated) - { - ctx->uds.buffer = _assuan_malloc (ctx, 2048); - if (!ctx->uds.buffer) - return gpg_error_from_syserror (); - ctx->uds.bufferallocated = 2048; - } - + int len = 0; + /* This loop should be OK. As FDs are followed by data, the + readable status of the socket does not change and no new + select/event-loop round is necessary. */ while (!len) /* No data is buffered. */ { struct msghdr msg; @@ -100,8 +91,8 @@ msg.msg_namelen = 0; msg.msg_iov = &iovec; msg.msg_iovlen = 1; - iovec.iov_base = ctx->uds.buffer; - iovec.iov_len = ctx->uds.bufferallocated; + iovec.iov_base = buf; + iovec.iov_len = buflen; #ifdef USE_DESCRIPTOR_PASSING msg.msg_control = control_u.control; msg.msg_controllen = sizeof (control_u.control); @@ -113,9 +104,6 @@ if (len == 0) return 0; - ctx->uds.buffersize = len; - ctx->uds.bufferoffset = 0; - #ifdef USE_DESCRIPTOR_PASSING cmptr = CMSG_FIRSTHDR (&msg); if (cmptr && cmptr->cmsg_len == CMSG_LEN (sizeof(int))) @@ -142,17 +130,6 @@ #endif /*USE_DESCRIPTOR_PASSING*/ } - /* Return some data to the user. */ - - if (len > buflen) /* We have more than the user requested. */ - len = buflen; - - memcpy (buf, (char*)ctx->uds.buffer + ctx->uds.bufferoffset, len); - ctx->uds.buffersize -= len; - assert (ctx->uds.buffersize >= 0); - ctx->uds.bufferoffset += len; - assert (ctx->uds.bufferoffset <= ctx->uds.bufferallocated); - return len; #else /*HAVE_W32_SYSTEM*/ int res = recvfrom (HANDLE2SOCKET(ctx->inbound.fd), buf, buflen, 0, NULL, NULL); @@ -291,14 +268,6 @@ { /* First call the finish_handler which should close descriptors etc. */ ctx->finish_handler (ctx); - - if (ctx->uds.buffer) - { - assert (ctx->uds.bufferallocated); - ctx->uds.bufferallocated = 0; - _assuan_free (ctx, ctx->uds.buffer); - } - _assuan_uds_close_fds (ctx); } @@ -312,10 +281,6 @@ ctx->engine.sendfd = uds_sendfd; ctx->engine.receivefd = uds_receivefd; - ctx->uds.buffer = 0; - ctx->uds.bufferoffset = 0; - ctx->uds.buffersize = 0; - ctx->uds.bufferallocated = 0; ctx->uds.pendingfdscount = 0; } From cvs at cvs.gnupg.org Tue Nov 10 10:07:20 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 10:07:20 +0100 Subject: [svn] gpgme - r1425 - in trunk: . m4 src Message-ID: Author: marcus Date: 2009-11-10 10:07:19 +0100 (Tue, 10 Nov 2009) New Revision: 1425 Added: trunk/src/engine-uiserver.c Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/configure.ac trunk/m4/ChangeLog trunk/m4/libassuan.m4 trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-support.c trunk/src/decrypt-verify.c trunk/src/dirinfo.c trunk/src/engine-assuan.c trunk/src/engine-backend.h trunk/src/engine-g13.c trunk/src/engine-gpg.c trunk/src/engine-gpgconf.c trunk/src/engine-gpgsm.c trunk/src/engine.c trunk/src/engine.h trunk/src/gpgme-tool.c trunk/src/gpgme.c trunk/src/gpgme.def trunk/src/gpgme.h.in trunk/src/key.c trunk/src/keylist.c trunk/src/libgpgme.vers trunk/src/ops.h trunk/src/posix-io.c trunk/src/posix-util.c trunk/src/priv-io.h trunk/src/util.h trunk/src/version.c trunk/src/w32-glib-io.c trunk/src/w32-io.c trunk/src/w32-qt-io.cpp trunk/src/w32-util.c Log: 2009-11-10 Marcus Brinkmann * configure.ac: Activate UIServer if FD passing is enabled and Assuan is available. m4/ 2009-11-10 Marcus Brinkmann * libassuan.m4: Fix LIBASSUAN_VERSION. src/ 2009-11-10 Marcus Brinkmann * Makefile.am (uiserver_components): New variable. (main_sources): Add it. * ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument, implement it. Adjust callers. (gpgme_key_from_uid): New function. * gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT. (gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE, GPGME_ENCRYPT_EXPECT_SIGN. (gpgme_set_sub_protocol, gpgme_key_from_uid): New functions. * libgpgme.vers, gpgme.def: Add new functions. * gpgme.c (gpgme_set_protocol): Add UIServer protocol. (gpgme_set_sub_protocol): New function. (gpgme_get_protocol_name): Add UIServer and default protocol. * assuan-support.c: Return correct error values, implement socketpair for POSIX. * priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c, w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE arguments. Implement it for POSIX. Adjust all callers. * engine.h, engine-backend.h (_gpgme_engine_set_protocol) (_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all users. * engine.c (engine_ops, gpgme_get_engine_info): Add UIServer engine. (_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New function. * decrypt-verify.c (decrypt_verify_start): Call _gpgme_engine_op_decrypt_verify. * util.h, posix-util.c, w32-util.c (_gpgme_get_uiserver_socket_path): New function. * engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation. * gpgme-tool.c: Some support for UIServer protocol. * engine-uiserver.c: New file. [The diff below has been truncated] Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/ChangeLog 2009-11-10 09:07:19 UTC (rev 1425) @@ -1,3 +1,8 @@ +2009-11-10 Marcus Brinkmann + + * configure.ac: Activate UIServer if FD passing is enabled and + Assuan is available. + 2009-10-30 Marcus Brinkmann * configure.ac: Check for argp.h and error_t. Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/m4/ChangeLog 2009-11-10 09:07:19 UTC (rev 1425) @@ -1,3 +1,7 @@ +2009-11-10 Marcus Brinkmann + + * libassuan.m4: Fix LIBASSUAN_VERSION. + 2006-06-08 Marcus Brinkmann * pth.m4: Add --all to pth-config invocation. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/ChangeLog 2009-11-10 09:07:19 UTC (rev 1425) @@ -1,3 +1,38 @@ +2009-11-10 Marcus Brinkmann + + * Makefile.am (uiserver_components): New variable. + (main_sources): Add it. + * ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument, + implement it. Adjust callers. + (gpgme_key_from_uid): New function. + * gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT. + (gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE, + GPGME_ENCRYPT_EXPECT_SIGN. + (gpgme_set_sub_protocol, gpgme_key_from_uid): New functions. + * libgpgme.vers, gpgme.def: Add new functions. + * gpgme.c (gpgme_set_protocol): Add UIServer protocol. + (gpgme_set_sub_protocol): New function. + (gpgme_get_protocol_name): Add UIServer and default protocol. + * assuan-support.c: Return correct error values, implement + socketpair for POSIX. + * priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c, + w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE + arguments. Implement it for POSIX. Adjust all callers. + * engine.h, engine-backend.h (_gpgme_engine_set_protocol) + (_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all + users. + * engine.c (engine_ops, gpgme_get_engine_info): Add UIServer + engine. + (_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New + function. + * decrypt-verify.c (decrypt_verify_start): Call + _gpgme_engine_op_decrypt_verify. + * util.h, posix-util.c, + w32-util.c (_gpgme_get_uiserver_socket_path): New function. + * engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation. + * gpgme-tool.c: Some support for UIServer protocol. + * engine-uiserver.c: New file. + 2009-11-09 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Close server side FDs. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/NEWS 2009-11-10 09:07:19 UTC (rev 1425) @@ -8,6 +8,8 @@ * New engine GPGME_PROTOCOL_G13 to support the new g13 tool. + * New engine GPGME_PROTOCOL_UISERVER to support UI Servers. + * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_STATUS_INV_SGNR NEW Modified: trunk/TODO =================================================================== --- trunk/TODO 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/TODO 2009-11-10 09:07:19 UTC (rev 1425) @@ -1,5 +1,10 @@ Hey Emacs, this is -*- org -*- mode! +* Document all the new stuff. +* Fix the remaining UI Server problems: +** VERIFY --silent support. +** ENCRYPT/DECRYPT/VERIFY/SIGN reset the engine, shouldn't be done with UISERVER? + * IMPORTANT ** When using descriptor passing, we need to set the fd to blocking before issueing simple commands, because we are mixing synchronous Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/configure.ac 2009-11-10 09:07:19 UTC (rev 1425) @@ -338,7 +338,7 @@ AC_DEFINE_UNQUOTED(NEED_GPGCONF_VERSION, "$NEED_GPGCONF_VERSION", [Min. needed GPGCONF version.]) AC_DEFINE_UNQUOTED(NEED_G13_VERSION, "$NEED_G13_VERSION", - [Min. needed G13 version.]) + [Min. needed G13 version.]) NO_OVERRIDE=no @@ -634,14 +634,7 @@ run_gpgconf_test=$enableval) AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes") -# Only build if supported. -AM_CONDITIONAL(BUILD_GPGCONF, test "$GPGCONF" != "no") -if test "$GPGCONF" != "no"; then - AC_DEFINE(HAVE_GPGCONF, 1, - [Defined if we are building with gpgconf support.]) -fi - NO_OVERRIDE=no AC_ARG_WITH(g13, AC_HELP_STRING([--with-g13=PATH], @@ -737,14 +730,7 @@ run_g13_test=$enableval) AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes") -# Only build if supported. -AM_CONDITIONAL(BUILD_G13, test "$G13" != "no") -if test "$G13" != "no"; then - AC_DEFINE(HAVE_G13, 1, - [Defined if we are building with g13 support.]) -fi - # Check for funopen AC_CHECK_FUNCS(funopen) if test $ac_cv_func_funopen != yes; then @@ -803,6 +789,17 @@ AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") +uiserver=no +if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then + uiserver=yes +fi +if test "$uiserver" != "no"; then + AC_DEFINE(ENABLE_UISERVER, 1, + [Defined if we are building with uiserver support.]) +fi +AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no") + + AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") # Generate values for the DLL version info @@ -912,6 +909,9 @@ Assuan version: $LIBASSUAN_VERSION + UI Server: $uiserver + FD Passing: $use_descriptor_passing + GPGME Pthread: $have_pthread GPGME Pth: $have_pth " Modified: trunk/m4/libassuan.m4 =================================================================== --- trunk/m4/libassuan.m4 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/m4/libassuan.m4 2009-11-10 09:07:19 UTC (rev 1425) @@ -63,7 +63,7 @@ if test $ok = yes; then LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags` LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs` - LIBASSUAN_VERSION="$LIBASSUAN_CONFIG_VERSION" + LIBASSUAN_VERSION="$libassuan_config_version" AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/Makefile.am 2009-11-10 09:07:19 UTC (rev 1425) @@ -92,6 +92,13 @@ g13_components = endif +if HAVE_UISERVER +uiserver_components = engine-uiserver.c +else +uiserver_components = +endif + + # These are the source files common to all library versions. We used # to build a non-installed library for that, but that does not work # correctly on all platforms (in particular, one can not specify the @@ -111,6 +118,7 @@ opassuan.c \ engine.h engine-backend.h engine.c engine-gpg.c status-table.h \ $(gpgsm_components) $(assuan_components) $(gpgconf_components) \ + $(uiserver_components) \ $(g13_components) vfs-mount.c vfs-create.c \ gpgconf.c \ sema.h priv-io.h $(system_components) dirinfo.c \ Modified: trunk/src/assuan-support.c =================================================================== --- trunk/src/assuan-support.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/assuan-support.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -4,6 +4,7 @@ #include #include +#include #include "assuan.h" @@ -76,7 +77,8 @@ int flags) { #ifdef HAVE_W32_SYSTEM - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + errno = ENOSYS; + return -1; #else return _gpgme_io_recvmsg (fd, msg, flags); #endif @@ -89,7 +91,8 @@ int flags) { #ifdef HAVE_W32_SYSTEM - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + errno = ENOSYS; + return -1; #else return _gpgme_io_sendmsg (fd, msg, flags); #endif @@ -107,14 +110,17 @@ void (*atfork) (void *opaque, int reserved), void *atforkvalue, unsigned int flags) { - gpg_error_t err; + int err; struct spawn_fd_item_s *fd_items; int i; assert (name); if (! name) - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + { + errno = ENOSYS; + return -1; + } i = 0; if (fd_child_list) @@ -126,7 +132,7 @@ i += 3; fd_items = malloc (sizeof (struct spawn_fd_item_s) * i); if (! fd_items) - return gpg_error_from_syserror (); + return -1; i = 0; if (fd_child_list) { @@ -152,7 +158,8 @@ fd_items[i].fd = -1; fd_items[i].dup_to = -1; - err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items, r_pid); + err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items, + atfork, atforkvalue, r_pid); if (! err) { i = 0; @@ -195,8 +202,13 @@ my_socketpair (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) { - assert ("Should never happen."); - return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#ifdef HAVE_W32_SYSTEM + errno = ENOSYS; + return -1; +#else + /* FIXME: Debug output missing. */ + return __assuan_socketpair (ctx, namespace, style, protocol, filedes); +#endif } Modified: trunk/src/decrypt-verify.c =================================================================== --- trunk/src/decrypt-verify.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/decrypt-verify.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -77,7 +77,7 @@ _gpgme_engine_set_status_handler (ctx->engine, decrypt_verify_status_handler, ctx); - return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain); + return _gpgme_engine_op_decrypt_verify (ctx->engine, cipher, plain); } Modified: trunk/src/dirinfo.c =================================================================== --- trunk/src/dirinfo.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/dirinfo.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -102,7 +102,7 @@ cfd[0].fd = rp[1]; - status = _gpgme_io_spawn (pgmname, argv, 0, cfd, NULL); + status = _gpgme_io_spawn (pgmname, argv, 0, cfd, NULL, NULL, NULL); if (status < 0) { _gpgme_io_close (rp[0]); Modified: trunk/src/engine-assuan.c =================================================================== --- trunk/src/engine-assuan.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-assuan.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -743,7 +743,9 @@ NULL, /* set_command_handler */ NULL, /* set_colon_line_handler */ llass_set_locale, + NULL, /* set_protocol */ NULL, /* decrypt */ + NULL, /* decrypt_verify */ NULL, /* delete */ NULL, /* edit */ NULL, /* encrypt */ Modified: trunk/src/engine-backend.h =================================================================== --- trunk/src/engine-backend.h 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-backend.h 2009-11-10 09:07:19 UTC (rev 1425) @@ -58,8 +58,11 @@ engine_colon_line_handler_t fnc, void *fnc_value); gpgme_error_t (*set_locale) (void *engine, int category, const char *value); + gpgme_error_t (*set_protocol) (void *engine, gpgme_protocol_t protocol); gpgme_error_t (*decrypt) (void *engine, gpgme_data_t ciph, gpgme_data_t plain); + gpgme_error_t (*decrypt_verify) (void *engine, gpgme_data_t ciph, + gpgme_data_t plain); gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret); gpgme_error_t (*edit) (void *engine, int type, gpgme_key_t key, gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */); @@ -88,12 +91,11 @@ gpgme_keylist_mode_t mode); gpgme_error_t (*sign) (void *engine, gpgme_data_t in, gpgme_data_t out, gpgme_sig_mode_t mode, int use_armor, - int use_textmode, - int include_certs, gpgme_ctx_t ctx /* FIXME */); + int use_textmode, int include_certs, + gpgme_ctx_t ctx /* FIXME */); gpgme_error_t (*trustlist) (void *engine, const char *pattern); gpgme_error_t (*verify) (void *engine, gpgme_data_t sig, - gpgme_data_t signed_text, - gpgme_data_t plaintext); + gpgme_data_t signed_text, gpgme_data_t plaintext); gpgme_error_t (*getauditlog) (void *engine, gpgme_data_t output, unsigned int flags); gpgme_error_t (*opassuan_transact) (void *engine, @@ -132,5 +134,8 @@ #ifdef ENABLE_G13 extern struct engine_ops _gpgme_engine_ops_g13; /* Crypto VFS. */ #endif +#ifdef ENABLE_UISERVER +extern struct engine_ops _gpgme_engine_ops_uiserver; +#endif #endif /* ENGINE_BACKEND_H */ Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-g13.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -757,7 +757,9 @@ NULL, /* set_command_handler */ NULL, /* set_colon_line_handler */ g13_set_locale, + NULL, /* set_protocol */ NULL, /* decrypt */ + NULL, /* decrypt_verify */ NULL, /* delete */ NULL, /* edit */ NULL, /* encrypt */ Modified: trunk/src/engine-gpg.c =================================================================== --- trunk/src/engine-gpg.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-gpg.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -1332,7 +1332,7 @@ status = _gpgme_io_spawn (gpg->file_name ? gpg->file_name : _gpgme_get_gpg_path (), gpg->argv, IOSPAWN_FLAG_ALLOW_SET_FG, - fd_list, &pid); + fd_list, NULL, NULL, &pid); saved_errno = errno; free (fd_list); @@ -2347,7 +2347,9 @@ gpg_set_command_handler, gpg_set_colon_line_handler, gpg_set_locale, + NULL, /* set_protocol */ gpg_decrypt, + gpg_decrypt, /* decrypt_verify */ gpg_delete, gpg_edit, gpg_encrypt, Modified: trunk/src/engine-gpgconf.c =================================================================== --- trunk/src/engine-gpgconf.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-gpgconf.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -221,7 +221,7 @@ cfd[0].fd = rp[1]; - status = _gpgme_io_spawn (gpgconf->file_name, argv, 0, cfd, NULL); + status = _gpgme_io_spawn (gpgconf->file_name, argv, 0, cfd, NULL, NULL, NULL); if (status < 0) { _gpgme_io_close (rp[0]); @@ -659,7 +659,7 @@ cfd[0].fd = rp[0]; - status = _gpgme_io_spawn (gpgconf->file_name, argv, 0, cfd, NULL); + status = _gpgme_io_spawn (gpgconf->file_name, argv, 0, cfd, NULL, NULL, NULL); if (status < 0) { _gpgme_io_close (rp[0]); @@ -897,7 +897,9 @@ NULL, /* set_command_handler */ NULL, /* set_colon_line_handler */ NULL, /* set_locale */ + NULL, /* set_protocol */ NULL, /* decrypt */ + NULL, /* decrypt_verify */ NULL, /* delete */ NULL, /* edit */ NULL, /* encrypt */ Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-09 21:21:12 UTC (rev 1424) +++ trunk/src/engine-gpgsm.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -38,6 +38,7 @@ #include "wait.h" #include "priv-io.h" #include "sema.h" +#include "data.h" #include "assuan.h" #include "status-table.h" @@ -657,7 +658,7 @@ { int fds[2]; - if (_gpgme_io_pipe (fds, 0) < 0) + if (_gpgme_io_pipe (fds, dir) < 0) return gpg_error_from_errno (errno); iocb_data->fd = dir ? fds[0] : fds[1]; @@ -1914,8 +1915,10 @@ NULL, /* set_command_handler */ gpgsm_set_colon_line_handler, gpgsm_set_locale, + NULL, /* set_protocol */ gpgsm_decrypt, - gpgsm_delete, + gpgsm_decrypt, + gpgsm_delete, /* decrypt_verify */ NULL, /* edit */ gpgsm_encrypt, NULL, /* encrypt_sign */ Added: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c (rev 0) +++ trunk/src/engine-uiserver.c 2009-11-10 09:07:19 UTC (rev 1425) @@ -0,0 +1,1361 @@ +/* engine-uiserver.c - Uiserver engine. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* Peculiar: Use special keys from email address for recipient and + signer (==sender). Use no data objects with encryption for + prep_encrypt. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include /* FIXME */ +#include + +#include "gpgme.h" +#include "util.h" +#include "ops.h" +#include "wait.h" +#include "priv-io.h" +#include "sema.h" +#include "data.h" + +#include "assuan.h" +#include "status-table.h" +#include "debug.h" + +#include "engine-backend.h" + + +typedef struct +{ + int fd; /* FD we talk about. */ + int server_fd;/* Server FD for this connection. */ + int dir; /* Inbound/Outbound, maybe given implicit? */ + void *data; /* Handler-specific data. */ + void *tag; /* ID from the user for gpgme_remove_io_callback. */ + char server_fd_str[15]; /* Same as SERVER_FD but as a string. We + need this because _gpgme_io_fd2str can't + be used on a closed descriptor. */ +} iocb_data_t; + + +struct engine_uiserver +{ + assuan_context_t assuan_ctx; + + int lc_ctype_set; + int lc_messages_set; + gpgme_protocol_t protocol; + + iocb_data_t status_cb; + + /* Input, output etc are from the servers perspective. */ + iocb_data_t input_cb; + gpgme_data_t input_helper_data; /* Input helper data object. */ + void *input_helper_memory; /* Input helper memory block. */ + + iocb_data_t output_cb; + + iocb_data_t message_cb; + + struct + { + engine_status_handler_t fnc; + void *fnc_value; + } status; + + struct + { + engine_colon_line_handler_t fnc; + void *fnc_value; + struct + { + char *line; + int linesize; + int linelen; + } attic; + int any; /* any data line seen */ + } colon; + + gpgme_data_t inline_data; /* Used to collect D lines. */ + + struct gpgme_io_cbs io_cbs; +}; + +typedef struct engine_uiserver *engine_uiserver_t; + + +static void uiserver_io_event (void *engine, + gpgme_event_io_t type, void *type_data); + + + +static char * +uiserver_get_version (const char *file_name) +{ + return strdup ("1.0"); +} + + +static const char * +uiserver_get_req_version (void) +{ + return "1.0"; +} + + +static void +close_notify_handler (int fd, void *opaque) +{ + engine_uiserver_t uiserver = opaque; + + assert (fd != -1); + if (uiserver->status_cb.fd == fd) + { + if (uiserver->status_cb.tag) + (*uiserver->io_cbs.remove) (uiserver->status_cb.tag); + uiserver->status_cb.fd = -1; + uiserver->status_cb.tag = NULL; + } + else if (uiserver->input_cb.fd == fd) + { + if (uiserver->input_cb.tag) + (*uiserver->io_cbs.remove) (uiserver->input_cb.tag); + uiserver->input_cb.fd = -1; + uiserver->input_cb.tag = NULL; + if (uiserver->input_helper_data) + { + gpgme_data_release (uiserver->input_helper_data); + uiserver->input_helper_data = NULL; + } + if (uiserver->input_helper_memory) + { + free (uiserver->input_helper_memory); + uiserver->input_helper_memory = NULL; + } + } + else if (uiserver->output_cb.fd == fd) + { + if (uiserver->output_cb.tag) + (*uiserver->io_cbs.remove) (uiserver->output_cb.tag); + uiserver->output_cb.fd = -1; + uiserver->output_cb.tag = NULL; + } + else if (uiserver->message_cb.fd == fd) + { + if (uiserver->message_cb.tag) + (*uiserver->io_cbs.remove) (uiserver->message_cb.tag); + uiserver->message_cb.fd = -1; + uiserver->message_cb.tag = NULL; + } +} + + +/* This is the default inquiry callback. We use it to handle the + Pinentry notifications. */ +static gpgme_error_t +default_inq_cb (engine_uiserver_t uiserver, const char *line) +{ + if (!strncmp (line, "PINENTRY_LAUNCHED", 17) && (line[17]==' '||!line[17])) + { + _gpgme_allow_set_foreground_window ((pid_t)strtoul (line+17, NULL, 10)); + } + + return 0; +} + + +static gpgme_error_t +uiserver_cancel (void *engine) +{ + engine_uiserver_t uiserver = engine; + + if (!uiserver) + return gpg_error (GPG_ERR_INV_VALUE); + + if (uiserver->status_cb.fd != -1) + _gpgme_io_close (uiserver->status_cb.fd); + if (uiserver->input_cb.fd != -1) + _gpgme_io_close (uiserver->input_cb.fd); + if (uiserver->output_cb.fd != -1) + _gpgme_io_close (uiserver->output_cb.fd); + if (uiserver->message_cb.fd != -1) + _gpgme_io_close (uiserver->message_cb.fd); + + if (uiserver->assuan_ctx) + { + assuan_release (uiserver->assuan_ctx); + uiserver->assuan_ctx = NULL; + } + + return 0; +} + + +static void +uiserver_release (void *engine) +{ + engine_uiserver_t uiserver = engine; + + if (!uiserver) + return; + + uiserver_cancel (engine); + + free (uiserver->colon.attic.line); + free (uiserver); +} + + +static gpgme_error_t +uiserver_new (void **engine, const char *file_name, const char *home_dir) +{ + gpgme_error_t err = 0; + engine_uiserver_t uiserver; + char *dft_display = NULL; + char dft_ttyname[64]; + char *dft_ttytype = NULL; + char *optstr; + + uiserver = calloc (1, sizeof *uiserver); + if (!uiserver) + return gpg_error_from_syserror (); + + uiserver->protocol = GPGME_PROTOCOL_DEFAULT; + uiserver->status_cb.fd = -1; + uiserver->status_cb.dir = 1; + uiserver->status_cb.tag = 0; + uiserver->status_cb.data = uiserver; + + uiserver->input_cb.fd = -1; + uiserver->input_cb.dir = 0; + uiserver->input_cb.tag = 0; + uiserver->input_cb.server_fd = -1; + *uiserver->input_cb.server_fd_str = 0; + uiserver->output_cb.fd = -1; + uiserver->output_cb.dir = 1; + uiserver->output_cb.tag = 0; + uiserver->output_cb.server_fd = -1; + *uiserver->output_cb.server_fd_str = 0; + uiserver->message_cb.fd = -1; + uiserver->message_cb.dir = 0; + uiserver->message_cb.tag = 0; + uiserver->message_cb.server_fd = -1; + *uiserver->message_cb.server_fd_str = 0; + + uiserver->status.fnc = 0; + uiserver->colon.fnc = 0; + uiserver->colon.attic.line = 0; + uiserver->colon.attic.linesize = 0; + uiserver->colon.attic.linelen = 0; + uiserver->colon.any = 0; + + uiserver->inline_data = NULL; + + uiserver->io_cbs.add = NULL; + uiserver->io_cbs.add_priv = NULL; + uiserver->io_cbs.remove = NULL; + uiserver->io_cbs.event = NULL; + uiserver->io_cbs.event_priv = NULL; + + err = assuan_new_ext (&uiserver->assuan_ctx, GPG_ERR_SOURCE_GPGME, + &_gpgme_assuan_malloc_hooks, _gpgme_assuan_log_cb, + NULL); + if (err) + goto leave; + assuan_ctx_set_system_hooks (uiserver->assuan_ctx, + &_gpgme_assuan_system_hooks); + + err = assuan_socket_connect (uiserver->assuan_ctx, + file_name ? + file_name : _gpgme_get_uiserver_socket_path (), + 0, 0); + if (err) + goto leave; + + err = _gpgme_getenv ("DISPLAY", &dft_display); + if (err) + goto leave; + if (dft_display) + { + if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) + { + free (dft_display); + err = gpg_error_from_errno (errno); + goto leave; + } + free (dft_display); + + err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL, + NULL, NULL, NULL); + free (optstr); + if (err) + goto leave; + } + + if (isatty (1)) + { + int rc; + + rc = ttyname_r (1, dft_ttyname, sizeof (dft_ttyname)); + if (rc) + { + err = gpg_error_from_errno (rc); + goto leave; + } + else + { + if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0) + { + err = gpg_error_from_errno (errno); + goto leave; + } + err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, NULL, + NULL, NULL, NULL); + free (optstr); + if (err) + goto leave; + + err = _gpgme_getenv ("TERM", &dft_ttytype); + if (err) + goto leave; + if (dft_ttytype) + { + if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0) + { + free (dft_ttytype); + err = gpg_error_from_errno (errno); + goto leave; + } + free (dft_ttytype); + + err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, + NULL, NULL, NULL, NULL); + free (optstr); + if (err) + goto leave; + } + } + } + +#ifdef HAVE_W32_SYSTEM + /* Under Windows we need to use AllowSetForegroundWindow. Tell + uiserver to tell us when it needs it. */ + if (!err) + { + err = assuan_transact (uiserver->assuan_ctx, "OPTION allow-pinentry-notify", + NULL, NULL, NULL, NULL, NULL, NULL); + if (gpg_err_code (err) == GPG_ERR_UNKNOWN_OPTION) + err = 0; /* This is a new feature of uiserver. */ + } +#endif /*HAVE_W32_SYSTEM*/ + + leave: + if (err) + uiserver_release (uiserver); + else + *engine = uiserver; + + return err; +} + + +static gpgme_error_t +uiserver_set_locale (void *engine, int category, const char *value) +{ + engine_uiserver_t uiserver = engine; + gpgme_error_t err; + char *optstr; + char *catstr; + + /* FIXME: If value is NULL, we need to reset the option to default. + But we can't do this. So we error out here. UISERVER needs support + for this. */ + if (category == LC_CTYPE) + { + catstr = "lc-ctype"; + if (!value && uiserver->lc_ctype_set) + return gpg_error (GPG_ERR_INV_VALUE); + if (value) + uiserver->lc_ctype_set = 1; + } +#ifdef LC_MESSAGES + else if (category == LC_MESSAGES) + { + catstr = "lc-messages"; + if (!value && uiserver->lc_messages_set) + return gpg_error (GPG_ERR_INV_VALUE); + if (value) + uiserver->lc_messages_set = 1; + } +#endif /* LC_MESSAGES */ + else + return gpg_error (GPG_ERR_INV_VALUE); + + /* FIXME: Reset value to default. */ + if (!value) + return 0; + + if (asprintf (&optstr, "OPTION %s=%s", catstr, value) < 0) + err = gpg_error_from_errno (errno); + else + { + err = assuan_transact (uiserver->assuan_ctx, optstr, NULL, NULL, + NULL, NULL, NULL, NULL); + free (optstr); + } + + return err; +} + + +static gpgme_error_t +uiserver_set_protocol (void *engine, gpgme_protocol_t protocol) +{ + engine_uiserver_t uiserver = engine; + + if (protocol != GPGME_PROTOCOL_OpenPGP + && protocol != GPGME_PROTOCOL_CMS + && protocol != GPGME_PROTOCOL_DEFAULT) + return gpg_error (GPG_ERR_INV_VALUE); + + uiserver->protocol = protocol; + return 0; +} + + +/* Forward declaration. */ +static gpgme_status_code_t parse_status (const char *name); + +static gpgme_error_t +uiserver_assuan_simple_command (assuan_context_t ctx, char *cmd, + engine_status_handler_t status_fnc, + void *status_fnc_value) +{ + gpg_error_t err; + char *line; + size_t linelen; + + err = assuan_write_line (ctx, cmd); + if (err) + return err; + + do + { + err = assuan_read_line (ctx, &line, &linelen); + if (err) + return err; + + if (*line == '#' || !linelen) + continue; + + if (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + return 0; + else if (linelen >= 4 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && line[3] == ' ') + err = atoi (&line[4]); + else if (linelen >= 2 + && line[0] == 'S' && line[1] == ' ') + { + char *rest; + gpgme_status_code_t r; + + rest = strchr (line + 2, ' '); + if (!rest) + rest = line + linelen; /* set to an empty string */ + else + *(rest++) = 0; + + r = parse_status (line + 2); + + if (r >= 0 && status_fnc) + err = status_fnc (status_fnc_value, r, rest); + else + err = gpg_error (GPG_ERR_GENERAL); + } + else + err = gpg_error (GPG_ERR_GENERAL); + } + while (!err); + + return err; +} + + +typedef enum { INPUT_FD, OUTPUT_FD, MESSAGE_FD } fd_type_t; + +#define COMMANDLINELEN 40 +static gpgme_error_t +uiserver_set_fd (engine_uiserver_t uiserver, fd_type_t fd_type, const char *opt) +{ + gpg_error_t err = 0; + char line[COMMANDLINELEN]; + char *which; + iocb_data_t *iocb_data; + int dir; + + switch (fd_type) + { + case INPUT_FD: + which = "INPUT"; + iocb_data = &uiserver->input_cb; + break; + + case OUTPUT_FD: + which = "OUTPUT"; + iocb_data = &uiserver->output_cb; + break; + + case MESSAGE_FD: + which = "MESSAGE"; + iocb_data = &uiserver->message_cb; + break; + + default: + return gpg_error (GPG_ERR_INV_VALUE); + } + + dir = iocb_data->dir; + + /* We try to short-cut the communication by giving UISERVER direct + access to the file descriptor, rather than using a pipe. */ + iocb_data->server_fd = _gpgme_data_get_fd (iocb_data->data); + if (iocb_data->server_fd < 0) + { + int fds[2]; + + if (_gpgme_io_pipe (fds, 0) < 0) + return gpg_error_from_errno (errno); + + iocb_data->fd = dir ? fds[0] : fds[1]; + iocb_data->server_fd = dir ? fds[1] : fds[0]; + + if (_gpgme_io_set_close_notify (iocb_data->fd, + close_notify_handler, uiserver)) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave_set_fd; + } + } + + err = assuan_sendfd (uiserver->assuan_ctx, iocb_data->server_fd); + if (err) + goto leave_set_fd; + + _gpgme_io_close (iocb_data->server_fd); + iocb_data->server_fd = -1; + + if (opt) + snprintf (line, COMMANDLINELEN, "%s FD %s", which, opt); + else + snprintf (line, COMMANDLINELEN, "%s FD", which); + + err = uiserver_assuan_simple_command (uiserver->assuan_ctx, line, NULL, NULL); + + leave_set_fd: + if (err) + { + _gpgme_io_close (iocb_data->fd); + iocb_data->fd = -1; + if (iocb_data->server_fd != -1) + { + _gpgme_io_close (iocb_data->server_fd); + iocb_data->server_fd = -1; + } + } + + return err; +} + + +static const char * +map_data_enc (gpgme_data_t d) +{ + switch (gpgme_data_get_encoding (d)) + { + case GPGME_DATA_ENCODING_NONE: + break; + case GPGME_DATA_ENCODING_BINARY: + return "--binary"; + case GPGME_DATA_ENCODING_BASE64: + return "--base64"; + case GPGME_DATA_ENCODING_ARMOR: + return "--armor"; + default: + break; + } + return NULL; +} + + +static int +status_cmp (const void *ap, const void *bp) +{ + const struct status_table_s *a = ap; + const struct status_table_s *b = bp; + + return strcmp (a->name, b->name); +} + + +static gpgme_status_code_t +parse_status (const char *name) +{ + struct status_table_s t, *r; + t.name = name; + r = bsearch (&t, status_table, DIM(status_table) - 1, + sizeof t, status_cmp); + return r ? r->code : -1; +} + + +static gpgme_error_t +status_handler (void *opaque, int fd) +{ + struct io_cb_data *data = (struct io_cb_data *) opaque; + engine_uiserver_t uiserver = (engine_uiserver_t) data->handler_value; + gpgme_error_t err = 0; + char *line; + size_t linelen; + + do + { + err = assuan_read_line (uiserver->assuan_ctx, &line, &linelen); + if (err) + { + /* Try our best to terminate the connection friendly. */ + /* assuan_write_line (uiserver->assuan_ctx, "BYE"); */ + TRACE3 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: error from assuan (%d) getting status line : %s", + fd, err, gpg_strerror (err)); + } + else if (linelen >= 3 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && (line[3] == '\0' || line[3] == ' ')) + { + if (line[3] == ' ') + err = atoi (&line[4]); + if (! err) + err = gpg_error (GPG_ERR_GENERAL); + TRACE2 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: ERR line - mapped to: %s", + fd, err ? gpg_strerror (err) : "ok"); + /* Try our best to terminate the connection friendly. */ + /* assuan_write_line (uiserver->assuan_ctx, "BYE"); */ + } + else if (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + { + if (uiserver->status.fnc) + err = uiserver->status.fnc (uiserver->status.fnc_value, + GPGME_STATUS_EOF, ""); + + if (!err && uiserver->colon.fnc && uiserver->colon.any) + { + /* We must tell a colon function about the EOF. We do + this only when we have seen any data lines. Note + that this inlined use of colon data lines will + eventually be changed into using a regular data + channel. */ + uiserver->colon.any = 0; + err = uiserver->colon.fnc (uiserver->colon.fnc_value, NULL); + } + TRACE2 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: OK line - final status: %s", + fd, err ? gpg_strerror (err) : "ok"); + _gpgme_io_close (uiserver->status_cb.fd); + return err; + } + else if (linelen > 2 + && line[0] == 'D' && line[1] == ' ' + && uiserver->colon.fnc) + { + /* We are using the colon handler even for plain inline data + - strange name for that function but for historic reasons + we keep it. */ + /* FIXME We can't use this for binary data because we + assume this is a string. For the current usage of colon + output it is correct. */ + char *src = line + 2; + char *end = line + linelen; + char *dst; + char **aline = &uiserver->colon.attic.line; + int *alinelen = &uiserver->colon.attic.linelen; + + if (uiserver->colon.attic.linesize < *alinelen + linelen + 1) + { + char *newline = realloc (*aline, *alinelen + linelen + 1); + if (!newline) + err = gpg_error_from_errno (errno); + else + { + *aline = newline; + uiserver->colon.attic.linesize += linelen + 1; + } + } + if (!err) + { + dst = *aline + *alinelen; + + while (!err && src < end) + { + if (*src == '%' && src + 2 < end) + { + /* Handle escaped characters. */ + ++src; + *dst = _gpgme_hextobyte (src); + (*alinelen)++; + src += 2; + } + else + { + *dst = *src++; + (*alinelen)++; + } + + if (*dst == '\n') + { + /* Terminate the pending line, pass it to the colon + handler and reset it. */ + + uiserver->colon.any = 1; + if (*alinelen > 1 && *(dst - 1) == '\r') + dst--; + *dst = '\0'; + + /* FIXME How should we handle the return code? */ + err = uiserver->colon.fnc (uiserver->colon.fnc_value, *aline); + if (!err) + { + dst = *aline; + *alinelen = 0; + } + } + else + dst++; + } + } + TRACE2 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: D line; final status: %s", + fd, err? gpg_strerror (err):"ok"); + } + else if (linelen > 2 + && line[0] == 'D' && line[1] == ' ' + && uiserver->inline_data) + { + char *src = line + 2; + char *end = line + linelen; + char *dst = src; + ssize_t nwritten; + + linelen = 0; + while (src < end) + { + if (*src == '%' && src + 2 < end) + { + /* Handle escaped characters. */ + ++src; + *dst++ = _gpgme_hextobyte (src); + src += 2; + } + else + *dst++ = *src++; + + linelen++; + } + + src = line + 2; + while (linelen > 0) + { + nwritten = gpgme_data_write (uiserver->inline_data, src, linelen); + if (!nwritten || (nwritten < 0 && errno != EINTR) + || nwritten > linelen) + { + err = gpg_error_from_errno (errno); + break; + } + src += nwritten; + linelen -= nwritten; + } + + TRACE2 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: D inlinedata; final status: %s", + fd, err? gpg_strerror (err):"ok"); + } + else if (linelen > 2 + && line[0] == 'S' && line[1] == ' ') + { + char *rest; + gpgme_status_code_t r; + + rest = strchr (line + 2, ' '); + if (!rest) + rest = line + linelen; /* set to an empty string */ + else + *(rest++) = 0; + + r = parse_status (line + 2); + + if (r >= 0) + { + if (uiserver->status.fnc) + err = uiserver->status.fnc (uiserver->status.fnc_value, r, rest); + } + else + fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); + TRACE3 (DEBUG_CTX, "gpgme:status_handler", uiserver, + "fd 0x%x: S line (%s) - final status: %s", + fd, line+2, err? gpg_strerror (err):"ok"); + } + else if (linelen >= 7 + && line[0] == 'I' && line[1] == 'N' && line[2] == 'Q' + && line[3] == 'U' && line[4] == 'I' && line[5] == 'R' + && line[6] == 'E' + && (line[7] == '\0' || line[7] == ' ')) + { + char *keyword = line+7; + + while (*keyword == ' ') + keyword++;; + default_inq_cb (uiserver, keyword); + assuan_write_line (uiserver->assuan_ctx, "END"); + } + + } + while (!err && assuan_pending_line (uiserver->assuan_ctx)); + + return err; +} + + +static gpgme_error_t +add_io_cb (engine_uiserver_t uiserver, iocb_data_t *iocbd, gpgme_io_cb_t handler) +{ + gpgme_error_t err; + + TRACE_BEG2 (DEBUG_ENGINE, "engine-uiserver:add_io_cb", uiserver, + "fd %d, dir %d", iocbd->fd, iocbd->dir); + err = (*uiserver->io_cbs.add) (uiserver->io_cbs.add_priv, + iocbd->fd, iocbd->dir, + handler, iocbd->data, &iocbd->tag); + if (err) + return TRACE_ERR (err); + if (!iocbd->dir) + /* FIXME Kludge around poll() problem. */ + err = _gpgme_io_set_nonblocking (iocbd->fd); + return TRACE_ERR (err); +} + + +static gpgme_error_t +start (engine_uiserver_t uiserver, const char *command) +{ + gpgme_error_t err; + int fdlist[5]; + int nfds; + + /* We need to know the fd used by assuan for reads. We do this by + using the assumption that the first returned fd from + assuan_get_active_fds() is always this one. */ + nfds = assuan_get_active_fds (uiserver->assuan_ctx, 0 /* read fds */, + fdlist, DIM (fdlist)); + if (nfds < 1) + return gpg_error (GPG_ERR_GENERAL); /* FIXME */ + + /* We "duplicate" the file descriptor, so we can close it here (we + can't close fdlist[0], as that is closed by libassuan, and + closing it here might cause libassuan to close some unrelated FD + later). Alternatively, we could special case status_fd and + register/unregister it manually as needed, but this increases + code duplication and is more complicated as we can not use the + close notifications etc. A third alternative would be to let + Assuan know that we closed the FD, but that complicates the + Assuan interface. */ + + uiserver->status_cb.fd = _gpgme_io_dup (fdlist[0]); + if (uiserver->status_cb.fd < 0) + return gpg_error_from_syserror (); + + if (_gpgme_io_set_close_notify (uiserver->status_cb.fd, + close_notify_handler, uiserver)) + { + _gpgme_io_close (uiserver->status_cb.fd); + uiserver->status_cb.fd = -1; + return gpg_error (GPG_ERR_GENERAL); + } + + err = add_io_cb (uiserver, &uiserver->status_cb, status_handler); + if (!err && uiserver->input_cb.fd != -1) + err = add_io_cb (uiserver, &uiserver->input_cb, _gpgme_data_outbound_handler); + if (!err && uiserver->output_cb.fd != -1) + err = add_io_cb (uiserver, &uiserver->output_cb, _gpgme_data_inbound_handler); + if (!err && uiserver->message_cb.fd != -1) + err = add_io_cb (uiserver, &uiserver->message_cb, _gpgme_data_outbound_handler); + + if (!err) + err = assuan_write_line (uiserver->assuan_ctx, command); + + if (!err) + uiserver_io_event (uiserver, GPGME_EVENT_START, NULL); + + return err; +} + + +static gpgme_error_t +uiserver_reset (void *engine) +{ + engine_uiserver_t uiserver = engine; + + /* We must send a reset because we need to reset the list of + signers. Note that RESET does not reset OPTION commands. */ + return uiserver_assuan_simple_command (uiserver->assuan_ctx, "RESET", NULL, NULL); +} + + +static gpgme_error_t +_uiserver_decrypt (void *engine, int verify, + gpgme_data_t ciph, gpgme_data_t plain) +{ + engine_uiserver_t uiserver = engine; + gpgme_error_t err; + const char *protocol; + char *cmd; + + if (!uiserver) + return gpg_error (GPG_ERR_INV_VALUE); + if (uiserver->protocol == GPGME_PROTOCOL_DEFAULT) + protocol = ""; + else if (uiserver->protocol == GPGME_PROTOCOL_OpenPGP) + protocol = " --protocol=OpenPGP"; + else if (uiserver->protocol == GPGME_PROTOCOL_CMS) + protocol = " --protocol=CMS"; + else + return gpgme_error (GPG_ERR_UNSUPPORTED_PROTOCOL); + + if (asprintf (&cmd, "DECRYPT%s%s", protocol, + verify ? "" : " --no-verify") < 0) + return gpg_error_from_errno (errno); + + uiserver->input_cb.data = ciph; + err = uiserver_set_fd (uiserver, INPUT_FD, + map_data_enc (uiserver->input_cb.data)); + if (err) + { + free (cmd); + return gpg_error (GPG_ERR_GENERAL); /* FIXME */ + } + uiserver->output_cb.data = plain; + err = uiserver_set_fd (uiserver, OUTPUT_FD, 0); + if (err) + { + free (cmd); + return gpg_error (GPG_ERR_GENERAL); /* FIXME */ + } + uiserver->inline_data = NULL; + + err = start (engine, cmd); + free (cmd); + return err; +} + + +static gpgme_error_t +uiserver_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain) +{ + return _uiserver_decrypt (engine, 0, ciph, plain); +} + + +static gpgme_error_t +uiserver_decrypt_verify (void *engine, gpgme_data_t ciph, gpgme_data_t plain) +{ + return _uiserver_decrypt (engine, 1, ciph, plain); +} + + +static gpgme_error_t +set_recipients (engine_uiserver_t uiserver, gpgme_key_t recp[]) +{ + gpgme_error_t err = 0; + assuan_context_t ctx = uiserver->assuan_ctx; + char *line; + int linelen; + int invalid_recipients = 0; + int i = 0; + + linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ + line = malloc (10 + 40 + 1); + if (!line) + return gpg_error_from_errno (errno); + strcpy (line, "RECIPIENT "); + while (!err && recp[i]) + { + char *fpr; + int newlen; + + if (!recp[i]->subkeys || !recp[i]->subkeys->fpr) + { + invalid_recipients++; + continue; + } + fpr = recp[i]->subkeys->fpr; + + newlen = 11 + strlen (fpr); + if (linelen < newlen) + { + char *newline = realloc (line, newlen); + if (! newline) + { + int saved_errno = errno; + free (line); + return gpg_error_from_errno (saved_errno); + } + line = newline; + linelen = newlen; + } + strcpy (&line[10], fpr); + + err = uiserver_assuan_simple_command (ctx, line, uiserver->status.fnc, + uiserver->status.fnc_value); + /* FIXME: This requires more work. */ + if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY) + invalid_recipients++; + else if (err) + { + free (line); + return err; + } + i++; + } + free (line); + return gpg_error (invalid_recipients + ? GPG_ERR_UNUSABLE_PUBKEY : GPG_ERR_NO_ERROR); +} + + +static gpgme_error_t +uiserver_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, int use_armor) +{ + engine_uiserver_t uiserver = engine; + gpgme_error_t err; + const char *protocol; + char *cmd; From cvs at cvs.gnupg.org Tue Nov 10 15:49:36 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 15:49:36 +0100 Subject: [svn] gpgme - r1426 - trunk/src Message-ID: Author: marcus Date: 2009-11-10 15:49:35 +0100 (Tue, 10 Nov 2009) New Revision: 1426 Modified: trunk/src/ChangeLog trunk/src/context.h trunk/src/gpgme.c trunk/src/gpgme.def trunk/src/gpgme.h.in trunk/src/libgpgme.vers trunk/src/op-support.c Log: 2009-11-10 Marcus Brinkmann * gpgme.h.in (gpgme_get_sub_protocol): Add prototype. * gpgme.def, libgpgme.vers: Add gpgme_get_sub_protocol. * context.h (struct gpgme_context): New member sub_protocol. * gpgme.c (gpgme_set_sub_protocol): Set CTX->sub_protocol. (gpgme_get_sub_protocol): New function. * op-support.c (_gpgme_op_reset): Set sub protocol. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/ChangeLog 2009-11-10 14:49:35 UTC (rev 1426) @@ -1,5 +1,12 @@ 2009-11-10 Marcus Brinkmann + * gpgme.h.in (gpgme_get_sub_protocol): Add prototype. + * gpgme.def, libgpgme.vers: Add gpgme_get_sub_protocol. + * context.h (struct gpgme_context): New member sub_protocol. + * gpgme.c (gpgme_set_sub_protocol): Set CTX->sub_protocol. + (gpgme_get_sub_protocol): New function. + * op-support.c (_gpgme_op_reset): Set sub protocol. + * Makefile.am (uiserver_components): New variable. (main_sources): Add it. * ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument, Modified: trunk/src/context.h =================================================================== --- trunk/src/context.h 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/context.h 2009-11-10 14:49:35 UTC (rev 1426) @@ -89,6 +89,9 @@ /* The running engine process. */ engine_t engine; + /* Engine's sub protocol. */ + gpgme_protocol_t sub_protocol; + /* True if armor mode should be used. */ unsigned int use_armor : 1; Modified: trunk/src/gpgme.c =================================================================== --- trunk/src/gpgme.c 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/gpgme.c 2009-11-10 14:49:35 UTC (rev 1426) @@ -305,13 +305,22 @@ gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) { - gpgme_error_t err; - TRACE_BEG2 (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)", - protocol, gpgme_get_protocol_name (protocol) - ? gpgme_get_protocol_name (protocol) : "invalid"); + TRACE2 (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)", + protocol, gpgme_get_protocol_name (protocol) + ? gpgme_get_protocol_name (protocol) : "invalid"); + ctx->sub_protocol = protocol; + return 0; +} - err = _gpgme_engine_set_protocol (ctx->engine, protocol); - return TRACE_ERR (err); + +gpgme_error_t +gpgme_get_sub_protocol (gpgme_ctx_t ctx) +{ + TRACE2 (DEBUG_CTX, "gpgme_get_sub_protocol", ctx, + "ctx->sub_protocol=%i (%s)", ctx->sub_protocol, + gpgme_get_protocol_name (ctx->sub_protocol) + ? gpgme_get_protocol_name (ctx->sub_protocol) : "invalid"); + return ctx->sub_protocol; } Modified: trunk/src/gpgme.def =================================================================== --- trunk/src/gpgme.def 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/gpgme.def 2009-11-10 14:49:35 UTC (rev 1426) @@ -194,6 +194,7 @@ gpgme_key_from_uid @149 gpgme_set_sub_protocol @150 + gpgme_get_sub_protocol @151 ; END Modified: trunk/src/gpgme.h.in =================================================================== --- trunk/src/gpgme.h.in 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/gpgme.h.in 2009-11-10 14:49:35 UTC (rev 1426) @@ -810,8 +810,10 @@ prococol (for example, an UISERVER can support OpenPGP and CMS). This is reset to the default with gpgme_set_protocol. */ gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx, - gpgme_protocol_t proto); + gpgme_protocol_t proto); +/* Get the sub protocol. */ +gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx); /* Get the string describing protocol PROTO, or NULL if invalid. */ const char *gpgme_get_protocol_name (gpgme_protocol_t proto); Modified: trunk/src/libgpgme.vers =================================================================== --- trunk/src/libgpgme.vers 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/libgpgme.vers 2009-11-10 14:49:35 UTC (rev 1426) @@ -75,6 +75,7 @@ gpgme_key_from_uid; gpgme_set_sub_protocol; + gpgme_get_sub_protocol; }; Modified: trunk/src/op-support.c =================================================================== --- trunk/src/op-support.c 2009-11-10 09:07:19 UTC (rev 1425) +++ trunk/src/op-support.c 2009-11-10 14:49:35 UTC (rev 1426) @@ -130,6 +130,10 @@ } } + err = _gpgme_engine_set_protocol (ctx->engine, ctx->sub_protocol); + if (err) + return err; + if (type == 1 || (type == 2 && !ctx->io_cbs.add)) { /* Use private event loop. */ From cvs at cvs.gnupg.org Tue Nov 10 15:54:39 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 15:54:39 +0100 Subject: [svn] gpgme - r1427 - trunk/src Message-ID: Author: marcus Date: 2009-11-10 15:54:39 +0100 (Tue, 10 Nov 2009) New Revision: 1427 Modified: trunk/src/ChangeLog trunk/src/gpgme-tool.c trunk/src/gpgme.c Log: 2009-11-10 Marcus Brinkmann * gpgme.c (gpgme_new): Set default sub protocol. * gpgme-tool.c: Implement get sub protocol. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 14:49:35 UTC (rev 1426) +++ trunk/src/ChangeLog 2009-11-10 14:54:39 UTC (rev 1427) @@ -1,5 +1,8 @@ 2009-11-10 Marcus Brinkmann + * gpgme.c (gpgme_new): Set default sub protocol. + * gpgme-tool.c: Implement get sub protocol. + * gpgme.h.in (gpgme_get_sub_protocol): Add prototype. * gpgme.def, libgpgme.vers: Add gpgme_get_sub_protocol. * context.h (struct gpgme_context): New member sub_protocol. Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-10 14:49:35 UTC (rev 1426) +++ trunk/src/gpgme-tool.c 2009-11-10 14:54:39 UTC (rev 1427) @@ -799,6 +799,18 @@ gpg_error_t +gt_get_protocol (gpgme_tool_t gt) +{ + gpgme_protocol_t proto = gpgme_get_protocol (gt->ctx); + + gt_write_status (gt, STATUS_PROTOCOL, gpgme_get_protocol_name (proto), + NULL); + + return 0; +} + + +gpg_error_t gt_set_sub_protocol (gpgme_tool_t gt, gpgme_protocol_t proto) { return gpgme_set_sub_protocol (gt->ctx, proto); @@ -806,9 +818,9 @@ gpg_error_t -gt_get_protocol (gpgme_tool_t gt) +gt_get_sub_protocol (gpgme_tool_t gt) { - gpgme_protocol_t proto = gpgme_get_protocol (gt->ctx); + gpgme_protocol_t proto = gpgme_get_sub_protocol (gt->ctx); gt_write_status (gt, STATUS_PROTOCOL, gpgme_get_protocol_name (proto), NULL); @@ -1268,8 +1280,8 @@ struct server *server = assuan_get_pointer (ctx); if (line && *line) return gt_set_sub_protocol (server->gt, gt_protocol_from_name (line)); - /* FIXME. */ - return 0; + else + return gt_get_sub_protocol (server->gt); } Modified: trunk/src/gpgme.c =================================================================== --- trunk/src/gpgme.c 2009-11-10 14:49:35 UTC (rev 1426) +++ trunk/src/gpgme.c 2009-11-10 14:54:39 UTC (rev 1427) @@ -77,6 +77,7 @@ ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; ctx->include_certs = GPGME_INCLUDE_CERTS_DEFAULT; ctx->protocol = GPGME_PROTOCOL_OpenPGP; + ctx->sub_protocol = GPGME_PROTOCOL_DEFAULT; _gpgme_fd_table_init (&ctx->fdt); LOCK (def_lc_lock); From cvs at cvs.gnupg.org Tue Nov 10 16:04:13 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 10 Nov 2009 16:04:13 +0100 Subject: [svn] gpgme - r1428 - trunk/src Message-ID: Author: wk Date: 2009-11-10 16:04:12 +0100 (Tue, 10 Nov 2009) New Revision: 1428 Modified: trunk/src/ChangeLog trunk/src/engine-uiserver.c Log: Pass fdpassing flag to assuan_socket_connect. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 14:54:39 UTC (rev 1427) +++ trunk/src/ChangeLog 2009-11-10 15:04:12 UTC (rev 1428) @@ -1,3 +1,8 @@ +2009-11-10 Werner Koch + + * engine-uiserver.c (uiserver_new): Pass fdpassing flag to + assuan_socket_connect. + 2009-11-10 Marcus Brinkmann * gpgme.c (gpgme_new): Set default sub protocol. Modified: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c 2009-11-10 14:54:39 UTC (rev 1427) +++ trunk/src/engine-uiserver.c 2009-11-10 15:04:12 UTC (rev 1428) @@ -294,7 +294,7 @@ err = assuan_socket_connect (uiserver->assuan_ctx, file_name ? file_name : _gpgme_get_uiserver_socket_path (), - 0, 0); + 0, ASSUAN_SOCKET_SERVER_FDPASSING); if (err) goto leave; From cvs at cvs.gnupg.org Tue Nov 10 17:32:11 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 10 Nov 2009 17:32:11 +0100 Subject: [svn] gpgme - r1429 - trunk/src Message-ID: Author: wk Date: 2009-11-10 17:32:11 +0100 (Tue, 10 Nov 2009) New Revision: 1429 Modified: trunk/src/ChangeLog trunk/src/engine-gpgsm.c trunk/src/engine-uiserver.c trunk/src/op-support.c Log: Make recipients command work. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 15:04:12 UTC (rev 1428) +++ trunk/src/ChangeLog 2009-11-10 16:32:11 UTC (rev 1429) @@ -1,8 +1,15 @@ 2009-11-10 Werner Koch + * op-support.c (_gpgme_op_reset): Ignore GPG_ERR_NOT_IMPLEMENTED + while setting the sub protocol. + * engine-uiserver.c (uiserver_new): Pass fdpassing flag to assuan_socket_connect. + (set_recipients): Replace fingerprint by user id. + * engine-gpgsm.c (set_recipients): Fix non-terminating loop in + case of a missing key. + 2009-11-10 Marcus Brinkmann * gpgme.c (gpgme_new): Set default sub protocol. Modified: trunk/src/engine-gpgsm.c =================================================================== --- trunk/src/engine-gpgsm.c 2009-11-10 15:04:12 UTC (rev 1428) +++ trunk/src/engine-gpgsm.c 2009-11-10 16:32:11 UTC (rev 1429) @@ -1161,14 +1161,14 @@ char *line; int linelen; int invalid_recipients = 0; - int i = 0; + int i; linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ line = malloc (10 + 40 + 1); if (!line) return gpg_error_from_errno (errno); strcpy (line, "RECIPIENT "); - while (!err && recp[i]) + for (i =0; !err && recp[i]; i++) { char *fpr; int newlen; @@ -1205,7 +1205,6 @@ free (line); return err; } - i++; } free (line); return gpg_error (invalid_recipients Modified: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c 2009-11-10 15:04:12 UTC (rev 1428) +++ trunk/src/engine-uiserver.c 2009-11-10 16:32:11 UTC (rev 1429) @@ -1011,26 +1011,26 @@ char *line; int linelen; int invalid_recipients = 0; - int i = 0; + int i; linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ line = malloc (10 + 40 + 1); if (!line) return gpg_error_from_errno (errno); strcpy (line, "RECIPIENT "); - while (!err && recp[i]) + for (i=0; !err && recp[i]; i++) { - char *fpr; + char *uid; int newlen; - if (!recp[i]->subkeys || !recp[i]->subkeys->fpr) + /* We use only the first user ID of the key. */ + if (!recp[i]->uids || !(uid=recp[i]->uids->uid) || !*uid) { invalid_recipients++; continue; } - fpr = recp[i]->subkeys->fpr; - newlen = 11 + strlen (fpr); + newlen = 11 + strlen (uid); if (linelen < newlen) { char *newline = realloc (line, newlen); @@ -1043,11 +1043,12 @@ line = newline; linelen = newlen; } - strcpy (&line[10], fpr); + /* FIXME: need to do proper escaping */ + strcpy (&line[10], uid); err = uiserver_assuan_simple_command (ctx, line, uiserver->status.fnc, - uiserver->status.fnc_value); - /* FIXME: This requires more work. */ + uiserver->status.fnc_value); + /* FIXME: This might requires more work. */ if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY) invalid_recipients++; else if (err) @@ -1055,7 +1056,6 @@ free (line); return err; } - i++; } free (line); return gpg_error (invalid_recipients Modified: trunk/src/op-support.c =================================================================== --- trunk/src/op-support.c 2009-11-10 15:04:12 UTC (rev 1428) +++ trunk/src/op-support.c 2009-11-10 16:32:11 UTC (rev 1429) @@ -131,6 +131,8 @@ } err = _gpgme_engine_set_protocol (ctx->engine, ctx->sub_protocol); + if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED) + err = 0; if (err) return err; From cvs at cvs.gnupg.org Tue Nov 10 17:36:00 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 10 Nov 2009 17:36:00 +0100 Subject: [svn] GnuPG - r5198 - trunk/sm Message-ID: Author: wk Date: 2009-11-10 17:35:59 +0100 (Tue, 10 Nov 2009) New Revision: 5198 Modified: trunk/sm/ChangeLog trunk/sm/certreqgen.c Log: Change fallback keysize to 2048 Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-10 09:04:17 UTC (rev 5197) +++ trunk/sm/ChangeLog 2009-11-10 16:35:59 UTC (rev 5198) @@ -10,6 +10,9 @@ 2009-11-04 Werner Koch + * certreqgen.c (proc_parameters): Change fallback key length to + 2048. + * server.c (register_commands): Add help arg to assuan_register_command. Provide help strings for all commands. Modified: trunk/sm/certreqgen.c =================================================================== --- trunk/sm/certreqgen.c 2009-11-10 09:04:17 UTC (rev 5197) +++ trunk/sm/certreqgen.c 2009-11-10 16:35:59 UTC (rev 5198) @@ -61,7 +61,7 @@ This is a required parameter. For now the only supported algorithm is "rsa". Key-Length: - Length of the key in bits. Default is 1024. + Length of the key in bits. Default is 2048. Key-Grip: hexstring This is optional and used to generate a request for an already existing key. Key-Length will be ignored when given, @@ -83,7 +83,7 @@ $ cat >foo < 4096) && !cardkeyid) From cvs at cvs.gnupg.org Tue Nov 10 18:59:41 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 18:59:41 +0100 Subject: [svn] assuan - r319 - trunk/doc Message-ID: Author: marcus Date: 2009-11-10 18:59:41 +0100 (Tue, 10 Nov 2009) New Revision: 319 Modified: trunk/doc/ChangeLog trunk/doc/assuan.texi Log: 2009-11-10 Marcus Brinkmann * assuan.texi: Various fixes and updates for the new interface. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-10 09:04:50 UTC (rev 318) +++ trunk/doc/ChangeLog 2009-11-10 17:59:41 UTC (rev 319) @@ -1,3 +1,7 @@ +2009-11-10 Marcus Brinkmann + + * assuan.texi: Various fixes and updates for the new interface. + 2009-11-05 Marcus Brinkmann * assuan.texi: Update assuan_pipe_connect, assuan_socket_connect Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-11-10 09:04:50 UTC (rev 318) +++ trunk/doc/assuan.texi 2009-11-10 17:59:41 UTC (rev 319) @@ -624,7 +624,7 @@ One way to call this function is @smallexample -assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); +assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); @end smallexample @end deftypefun @@ -813,6 +813,8 @@ suppressed and the caller is responsible to cleanup the child process. @item ASSUAN_CONFIDENTIAL Uses to return the state of the confidential logging mode. + at item ASSUAN_NO_FIXSIGNALS +Do not modify signal handler for @code{SIGPIPE}. @end table @end deftp @end deftypefun @@ -844,6 +846,100 @@ @end deftypefun + at deftp {Data type} {struct assuan_system_hooks} +This structure is used to store the system callback interface +functions. It has the following members, whose semantics are similar +to the corresponding system functions, but not exactly equivalent. + + at table @code + at item int version +The user should set this to @code{ASSUAN_SYSTEM_HOOKS_VERSION}. This +indicates to the library which members of this structure are present +in case of future extensions. The user should initialize the whole +structure with zero bytes. + + at item void (*usleep) (assuan_context_t ctx, unsigned int usec) +This is the function called by @sc{Assuan} to sleep for @code{USEC} +microseconds. + + at item int (*pipe) (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx) +This is the function called by @sc{Assuan} to create a pipe. The +returned file descriptor @code{fd[inherit_idx]} must be inheritable by +the child process (under Windows, this requires some extra work). + + at item int (*close) (assuan_context_t ctx, assuan_fd_t fd) +This is the function called by @sc{Assuan} to close a file descriptor +created through the system functions. + + at item ssize_t (*read) (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) +This is the function called by @sc{Assuan} to read data from a file +descriptor. It is functionally equivalent to the system @code{read} +function. + + at item ssize_t (*write) (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) +This is the function called by @sc{Assuan} to write data to a file +descriptor. It is functionally equivalent to the system @code{write} +function. + + at item int (*recvmsg) (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags) +This is the function called by @sc{Assuan} to receive a message from a +file descriptor. It is functionally equivalent to the system + at code{recvmsg} function. + + at item int (*sendmsg) (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, int flags); +This is the function called by @sc{Assuan} to send a message to a +file descriptor. It is functionally equivalent to the system + at code{sendmsg} function. + + at item int (*spawn) (assuan_context_t ctx, pid_t *r_pid, const char *name, const char **argv, assuan_fd_t fd_in, assuan_fd_t fd_out, assuan_fd_t *fd_child_list, void (*atfork) (void *opaque, int reserved), void *atforkvalue, unsigned int flags) +This is the function called by @sc{Assuan} to spawn a child process. +The @code{stdin} and @code{stdout} file descriptors are provided in + at code{fd_in} and @code{fd_out} respectively, but can be set to + at code{ASSUAN_INVALID_FD}, in which case they are set to + at code{/dev/null}. On systems which use @code{fork} and @code{exec}, +the @code{atfork} function should be called with @code{atforkvalue} +and @code{0} for flags in the child process right after @code{fork} +returns. @code{fd_child_list} is a @code{ASSUAN_INVALID_FD} +terminated array (or @code{NULL}) and specifies file descriptors to be +inherited by the child process. + +A special situation occurs if @code{name} is a null pointer, in which +case the process should just fork but not call @code{exec}. In this +case, @code{*argv} should be set to @code{"client"} in the parent +process and @code{"server"} in the child process. + + at item pid_t (*waitpid) (assuan_context_t ctx, pid_t pid, int action, int *status, int options) +This is the function called by @sc{Assuan} to wait for the spawned +child process @var{pid} to exit, or, if @var{action} is 1, to just +release all resources associated with @var{pid} (required on Windows +platforms). If @var{action} is 0, this is equivalent to @code{waitpid}. + + at item int (*socketpair) (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) +This is the function called by @sc{Assuan} to create a socketpair. It +is equivalent to @code{socketpair}. + at end table + at end deftp + + + at deftypefun void assuan_set_system_hooks (@w{assuan_system_hooks_t @var{system_hooks}}) +Set the default system hooks to use. There is currently no way to +reset to the default system hooks. + at end deftypefun + + at deftypefun void assuan_ctx_set_system_hooks (@w{assuan_context_t @var{ctx}}, @w{assuan_system_hooks_t @var{system_hooks}}) +Set the system hooks for context @var{ctx}. There is currently no way +to reset tot the default system hooks, create a new context for that. + at end deftypefun + +The following system hook collections are defined by the library for +your convenience: + + at table @code + at item ASSUAN_SYSTEM_PTH +System hooks suitable for use with the GNU Pth library. + at end table + + @node Reading and Writing @section How to communicate with the peer @@ -1040,7 +1136,7 @@ functions are used with this feature: @anchor{function assuan_sendfd} - at deftypefun gpg_error_t assuan_sendfd (@w{assuan_context_t @var{ctx}}, @w{int @var{fd}}) + at deftypefun gpg_error_t assuan_sendfd (@w{assuan_context_t @var{ctx}}, @w{assuan_fd_t @var{fd}}) Send the descriptor @var{fd} to the peer using the context @var{ctx}. The descriptor must be sent before the command is issued that makes @@ -1052,7 +1148,7 @@ @end deftypefun @anchor{function assuan_receivefd} - at deftypefun gpg_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{int *@var{fd}}) + at deftypefun gpg_error_t assuan_receivefd (@w{assuan_context_t @var{ctx}}, @w{assuan_fd_t *@var{fd}}) Receive a descriptor pending for the context @var{ctx} from the peer. The descriptor must be pending before this function is called. To @@ -1116,7 +1212,7 @@ rc = assuan_init_pipe_server (&ctx, filedes); @} else - rc = assuan_init_socket_server (&ctx, fd, 2); + rc = assuan_init_socket_server (&ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED); if (rc) @{ fprintf (stderr, "server init failed: %s\n", gpg_strerror (rc)); @@ -1126,7 +1222,7 @@ @noindent This is the first part of the command handler. In case this is called -as a pipe based server, @var{fd} will be based as @code{fd} and the +as a pipe based server, @var{fd} will be based as @var{fd} and the code assumes that the server's @code{stdin} and @code{stdout} file handles are connected to a pipe. The initialization is thus done using the function: @@ -1142,7 +1238,7 @@ In case the server has been called using a bi-directional pipe (socketpair), @var{filedes} is ignored and the file descriptor is taken from the environment variable @env{_assuan_connection_fd}. You -won't need to know that because @code{assuan_pipe_connect_ext}, used +won't need to know that because @code{assuan_pipe_connect}, used by the client to connect to such a server, automagically sets this variable. @end deftypefun @@ -1206,8 +1302,13 @@ @} @end example + at deftp {Data type} {gpg_error_t (*assuan_handler_t) (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}})} +This is the function invoked by @sc{Assuan} for various command +related callback functions. Some of these callback functions have a +different type, but most use @code{assuan_handler_t}. + at end deftp - at deftypefun gpg_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{int (*@var{handler}) (assuan_context_t, char *)}) + at deftypefun gpg_error_t assuan_register_command (@w{assuan_context_t @var{ctx}}, @w{const char *@var{cmd_string}}, @w{assuan_handler_t @var{handler}}, @w{const char *@var{help_string}}) This registers the command named @var{cmd_string} with the Assuan context @var{ctx}. @var{handler} is the function called by Libassuan @@ -1218,6 +1319,10 @@ @code{CANCEL}, @code{OPTION}, @code{BYE}, @code{AUTH}, @code{RESET} and @code{END}. It is possible, but not recommended, to override these commands. + + at var{help_string} is a help string that is used for automatic +documentation. It should contain a usage line followed by an empty +line and a complete description. @end deftypefun @deftypefun gpg_error_t assuan_register_post_cmd_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}, @w{gpg_error_t @var{err}}) @@ -1228,19 +1333,19 @@ command-related cleanup. @end deftypefun - at deftypefun gpg_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_bye_notify (@w{assuan_context_t @var{ctx}}, @w{assuan_handler_t @var{handler}}) Register function @var{fnc} with context @var{ctx} to be called right before the standard handler for the @code{BYE} command is being called. @end deftypefun - at deftypefun gpg_error_t assuan_register_reset_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_reset_notify (@w{assuan_context_t @var{ctx}}, @w{assuan_handler_t @var{handler}}) Register function @var{fnc} with context @var{ctx} to be called right before the standard handler for the @code{RESET} command is being called. @end deftypefun - at deftypefun gpg_error_t assuan_register_cancel_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t)}) + at deftypefun gpg_error_t assuan_register_cancel_notify (@w{assuan_context_t @var{ctx}}, @w{assuan_handler_t @var{handler}}) Register function @var{fnc} with context @var{ctx} to be called right before the standard handler for the @code{RESET} command is being called. @@ -1258,7 +1363,7 @@ @end deftypefun - at deftypefun gpg_error_t assuan_register_input_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) + at deftypefun gpg_error_t assuan_register_input_notify (@w{assuan_context_t @var{ctx}}, @w{assuan_handler_t @var{handler}}) Although the input function may be overridden with a custom handler, it is often more convenient to use the default handler and to know whether @@ -1269,7 +1374,7 @@ descriptor is available by calling @code{assuan_get_input_fd}. @end deftypefun - at deftypefun gpg_error_t assuan_register_output_notify (@w{assuan_context_t @var{ctx}}, @w{void (*@var{fnc})(assuan_context_t, const char*)}) + at deftypefun gpg_error_t assuan_register_output_notify (@w{assuan_context_t @var{ctx}}, @w{assuan_handler_t @var{handler}}) Although the output function may be overridden with a custom handler, it is often more convenient to use the default handler and to know whether @@ -1488,10 +1593,10 @@ should just implement the bind/connect/listen/accept stage yourself. You can register the listen FD with your main event loop, accept the connection when it becomes ready, and finally call - at code{assuan_init_socket_server} with the final argument being 2 -to create an Assuan context for this connection. This way you can -also handle multiple connections in parallel. The reference -implementation for this approach is DirMngr. + at code{assuan_init_socket_server} with the final argument being + at code{ASSUAN_SOCKET_SERVER_ACCEPTED} to create an Assuan context for this +connection. This way you can also handle multiple connections in +parallel. The reference implementation for this approach is DirMngr. For pipe servers: @code{assuan_init_pipe_server} creates an Assuan context valid for the pipe FDs. @@ -1654,16 +1759,16 @@ @end deftypefun - at deftypefun int assuan_get_input_fd (@w{assuan_context_t @var{ctx}}) + at deftypefun assuan_fd_t assuan_get_input_fd (@w{assuan_context_t @var{ctx}}) Return the file descriptor sent by the client using the last @code{INPUT} -command. Returns @code{-1} if no file descriptor is available. +command. Returns @code{ASSUAN_INVALID_FD} if no file descriptor is available. @end deftypefun - at deftypefun int assuan_get_output_fd (@w{assuan_context_t @var{ctx}}) + at deftypefun assuan_fd_t assuan_get_output_fd (@w{assuan_context_t @var{ctx}}) Return the file descriptor sent by the client using the last - at code{OUTPUT} command. Returns @code{-1} if no file descriptor is + at code{OUTPUT} command. Returns @code{ASSUAN_INVALID_FD} if no file descriptor is available. @end deftypefun @@ -1700,13 +1805,14 @@ @deftypefun pid_t assuan_get_pid (@w{assuan_context_t @var{ctx}}) -This function returns the pid of the connected connected peer. If that -pid is not known @code{-1} is returned. Note that it is not always -possible to learn the pid of the other process. For a pipe based server -the client knows it instantly and a mechanism is in place to let the -server learn it. For socket based servers the pid is only available on -systems providing the @code{SO_PEERCRED} socket option @footnote{to our -knowledge only the Linux kernel has this feature}. +This function returns the pid of the connected connected peer. If +that pid is not known @code{ASSUAN_INVALID_PID} is returned. Note +that it is not always possible to learn the pid of the other +process. For a pipe based server the client knows it instantly and a +mechanism is in place to let the server learn it. For socket based +servers the pid is only available on systems providing the + at code{SO_PEERCRED} socket option @footnote{to our knowledge only the +Linux kernel has this feature}. @end deftypefun From cvs at cvs.gnupg.org Tue Nov 10 19:05:04 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Nov 2009 19:05:04 +0100 Subject: [svn] gpgme - r1430 - trunk/src Message-ID: Author: marcus Date: 2009-11-10 19:05:04 +0100 (Tue, 10 Nov 2009) New Revision: 1430 Modified: trunk/src/ChangeLog trunk/src/op-support.c Log: 2009-11-10 Marcus Brinkmann * op-support.c (_gpgme_op_reset): Instead of last change, only set sub protocol if it is not the default. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 16:32:11 UTC (rev 1429) +++ trunk/src/ChangeLog 2009-11-10 18:05:04 UTC (rev 1430) @@ -1,3 +1,8 @@ +2009-11-10 Marcus Brinkmann + + * op-support.c (_gpgme_op_reset): Instead of last change, only set + sub protocol if it is not the default. + 2009-11-10 Werner Koch * op-support.c (_gpgme_op_reset): Ignore GPG_ERR_NOT_IMPLEMENTED Modified: trunk/src/op-support.c =================================================================== --- trunk/src/op-support.c 2009-11-10 16:32:11 UTC (rev 1429) +++ trunk/src/op-support.c 2009-11-10 18:05:04 UTC (rev 1430) @@ -130,11 +130,12 @@ } } - err = _gpgme_engine_set_protocol (ctx->engine, ctx->sub_protocol); - if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED) - err = 0; - if (err) - return err; + if (ctx->sub_protocol != GPGME_PROTOCOL_DEFAULT) + { + err = _gpgme_engine_set_protocol (ctx->engine, ctx->sub_protocol); + if (err) + return err; + } if (type == 1 || (type == 2 && !ctx->io_cbs.add)) { From cvs at cvs.gnupg.org Tue Nov 17 14:06:05 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 17 Nov 2009 14:06:05 +0100 Subject: [svn] gpgme - r1431 - trunk/src Message-ID: Author: wk Date: 2009-11-17 14:06:05 +0100 (Tue, 17 Nov 2009) New Revision: 1431 Modified: trunk/src/ChangeLog trunk/src/engine-uiserver.c trunk/src/sign.c Log: Fixes for the UI server engine . Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 18:05:04 UTC (rev 1430) +++ trunk/src/ChangeLog 2009-11-17 13:06:05 UTC (rev 1431) @@ -1,3 +1,8 @@ +2009-11-13 + + * sign.c (_gpgme_sign_status_handler): Handle SIG_CREATED_SEEN. + * engine-uiserver.c (uiserver_sign): Make sending SENDER optional. + 2009-11-10 Marcus Brinkmann * op-support.c (_gpgme_op_reset): Instead of last change, only set Modified: trunk/src/engine-uiserver.c =================================================================== --- trunk/src/engine-uiserver.c 2009-11-10 18:05:04 UTC (rev 1430) +++ trunk/src/engine-uiserver.c 2009-11-17 13:06:05 UTC (rev 1431) @@ -1153,6 +1153,7 @@ gpgme_error_t err = 0; const char *protocol; char *cmd; + gpgme_key_t key; if (!uiserver || !in || !out) return gpg_error (GPG_ERR_INV_VALUE); @@ -1169,27 +1170,28 @@ (mode == GPGME_SIG_MODE_DETACH) ? " --detached" : "") < 0) return gpg_error_from_errno (errno); - { - gpgme_key_t key = gpgme_signers_enum (ctx, 0); - const char *s = NULL; - - if (key && key->uids) - s = key->uids->email; - - if (s && strlen (s) < 80) + key = gpgme_signers_enum (ctx, 0); + if (key) + { + const char *s = NULL; + + if (key && key->uids) + s = key->uids->email; + + if (s && strlen (s) < 80) + { + char buf[100]; + + strcpy (stpcpy (buf, "SENDER --info "), s); + err = uiserver_assuan_simple_command (uiserver->assuan_ctx, buf, + uiserver->status.fnc, + uiserver->status.fnc_value); + } + else + err = gpg_error (GPG_ERR_INV_VALUE); + gpgme_key_unref (key); + if (err) { - char buf[100]; - - strcpy (stpcpy (buf, "SENDER --info "), s); - err = uiserver_assuan_simple_command (uiserver->assuan_ctx, buf, - uiserver->status.fnc, - uiserver->status.fnc_value); - } - else - err = gpg_error (GPG_ERR_INV_VALUE); - gpgme_key_unref (key); - if (err) - { free (cmd); return err; } Modified: trunk/src/sign.c =================================================================== --- trunk/src/sign.c 2009-11-10 18:05:04 UTC (rev 1430) +++ trunk/src/sign.c 2009-11-17 13:06:05 UTC (rev 1431) @@ -286,9 +286,13 @@ break; case GPGME_STATUS_EOF: + /* The UI server does not send information about the created + signature. This is irrelevant for this protocol and thus we + should not check for that. */ if (opd->result.invalid_signers) err = gpg_error (GPG_ERR_UNUSABLE_SECKEY); - else if (!opd->sig_created_seen) + else if (!opd->sig_created_seen + && ctx->protocol != GPGME_PROTOCOL_UISERVER) err = gpg_error (GPG_ERR_GENERAL); break; From cvs at cvs.gnupg.org Tue Nov 17 14:46:52 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 17 Nov 2009 14:46:52 +0100 Subject: [svn] dirmngr - r331 - trunk/doc Message-ID: Author: wk Date: 2009-11-17 14:46:52 +0100 (Tue, 17 Nov 2009) New Revision: 331 Modified: trunk/doc/dirmngr.texi Log: Small fix. Spotted by Bernhard Reiter. Modified: trunk/doc/dirmngr.texi =================================================================== --- trunk/doc/dirmngr.texi 2009-11-05 12:02:19 UTC (rev 330) +++ trunk/doc/dirmngr.texi 2009-11-17 13:46:52 UTC (rev 331) @@ -307,7 +307,7 @@ @opindex options Reads configuration from @var{file} instead of from the default per-user configuration file. The default configuration file is named - at file{gpgsm.conf} and expected in the home directory. + at file{dirmngr.conf} and expected in the home directory. @item --homedir @var{dir} @opindex options From cvs at cvs.gnupg.org Fri Nov 20 00:57:35 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 20 Nov 2009 00:57:35 +0100 Subject: [svn] assuan - r320 - in trunk: . src Message-ID: Author: marcus Date: 2009-11-20 00:57:35 +0100 (Fri, 20 Nov 2009) New Revision: 320 Added: trunk/src/client.c trunk/src/server.c Removed: trunk/src/assuan-connect.c Modified: trunk/NEWS trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-defs.h trunk/src/assuan-listen.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan-uds.c trunk/src/context.c Log: 2009-11-19 Marcus Brinkmann * Makefile.am (common_sources): Remove assuan-connect.c and add client.c. * client.c, server.c: New file. * assuan-defs.h (_assuan_disconnect): Remove. (struct assuan_context_s): Remove members deinit_handler. (_assuan_client_release, _assuan_client_finish) (_assuan_server_finish, _assuan_server_release): New. * assuan-socket-server.c (accept_connection_bottom): Use ASSUAN_INVALID_PID, not -1. (finish_connection, deinit_socket_server): Remove. (assuan_init_socket_server): Use _assuan_server_release. * assuan-socket-connect.c (do_finish, do_deinit): Remove. (assuan_socket_connect): Use _assuan_client_release. * assuan-pipe-connect.c (do_finish, do_deinit): Remove. (pipe_connect): Update deinitialization. (socketpair_connect): Here as well. * context.c (assuan_get_pid): New from ... * assuan-connect.c (assuan_get_pid): ... here. Remove this file. * assuan-pipe-server.c (_assuan_deinit_server, accept_connection) (deinit_pipe_server, finish_connection): Remove unused function. * assuan-listen.c (assuan_accept): Check CTX->accept_handler before calling. Initialize RC. Do not call finish handler for pipe server. * assuan-uds.c (_assuan_uds_deinit): Do not call finish handler. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/ChangeLog 2009-11-19 23:57:35 UTC (rev 320) @@ -1,3 +1,30 @@ +2009-11-19 Marcus Brinkmann + + * Makefile.am (common_sources): Remove assuan-connect.c and add + client.c. + * client.c, server.c: New file. + * assuan-defs.h (_assuan_disconnect): Remove. + (struct assuan_context_s): Remove members deinit_handler. + (_assuan_client_release, _assuan_client_finish) + (_assuan_server_finish, _assuan_server_release): New. + * assuan-socket-server.c (accept_connection_bottom): Use + ASSUAN_INVALID_PID, not -1. + (finish_connection, deinit_socket_server): Remove. + (assuan_init_socket_server): Use _assuan_server_release. + * assuan-socket-connect.c (do_finish, do_deinit): Remove. + (assuan_socket_connect): Use _assuan_client_release. + * assuan-pipe-connect.c (do_finish, do_deinit): Remove. + (pipe_connect): Update deinitialization. + (socketpair_connect): Here as well. + * context.c (assuan_get_pid): New from ... + * assuan-connect.c (assuan_get_pid): ... here. Remove this file. + * assuan-pipe-server.c (_assuan_deinit_server, accept_connection) + (deinit_pipe_server, finish_connection): Remove unused function. + * assuan-listen.c (assuan_accept): Check CTX->accept_handler + before calling. Initialize RC. Do not call finish handler for + pipe server. + * assuan-uds.c (_assuan_uds_deinit): Do not call finish handler. + 2009-11-10 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Rename Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/NEWS 2009-11-19 23:57:35 UTC (rev 320) @@ -54,6 +54,7 @@ CHANGED: Is now what assuan_pipe_connect_ext was. assuan_pipe_connect_ext REMOVED assuan_init_pipe_server CHANGED: Take ctx arg instead of pointer to ctx. + CHANGED: Swallows fds (are closed at end). assuan_set_io_hooks REMOVED: Will come back in expanded form. assuan_io_hooks_t REMOVED: Will come back in expanded form. assuan_io_monitor_t CHANGED: Add a hook data argument. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/Makefile.am 2009-11-19 23:57:35 UTC (rev 320) @@ -36,17 +36,14 @@ common_sources = \ assuan-defs.h \ - assuan.c \ - context.c \ - system.c \ - debug.c debug.h \ - conversion.c \ + assuan.c context.c system.c \ + debug.c debug.h conversion.c \ + client.c server.c \ assuan-error.c \ assuan-buffer.c \ assuan-handler.c \ assuan-inquire.c \ assuan-listen.c \ - assuan-connect.c \ assuan-client.c \ assuan-pipe-server.c \ assuan-socket-server.c \ Deleted: trunk/src/assuan-connect.c Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-defs.h 2009-11-19 23:57:35 UTC (rev 320) @@ -182,7 +182,6 @@ int pendingfdscount; /* Number of received descriptors. */ } uds; - void (*deinit_handler)(assuan_context_t); gpg_error_t (*accept_handler)(assuan_context_t); void (*finish_handler)(assuan_context_t); @@ -364,8 +363,13 @@ #endif -void _assuan_disconnect (assuan_context_t ctx); +void _assuan_client_finish (assuan_context_t ctx); +void _assuan_client_release (assuan_context_t ctx); +void _assuan_server_finish (assuan_context_t ctx); +void _assuan_server_release (assuan_context_t ctx); + + /* Encode the C formatted string SRC and return the malloc'ed result. */ char *_assuan_encode_c_string (assuan_context_t ctx, const char *src); Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-listen.c 2009-11-19 23:57:35 UTC (rev 320) @@ -72,7 +72,7 @@ gpg_error_t assuan_accept (assuan_context_t ctx) { - gpg_error_t rc; + gpg_error_t rc = 0; const char *p, *pend; if (!ctx) @@ -80,11 +80,14 @@ if (ctx->pipe_mode > 1) return -1; /* second invocation for pipemode -> terminate */ - ctx->finish_handler (ctx); + if (! ctx->pipe_mode) + { + ctx->finish_handler (ctx); - rc = ctx->accept_handler (ctx); - if (rc) - return rc; + rc = ctx->accept_handler (ctx); + if (rc) + return rc; + } /* Send the hello. */ p = ctx->hello_line; Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-pipe-connect.c 2009-11-19 23:57:35 UTC (rev 320) @@ -84,36 +84,6 @@ } -static void -do_finish (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->inbound.fd); - if (ctx->inbound.fd == ctx->outbound.fd) - ctx->outbound.fd = ASSUAN_INVALID_FD; - ctx->inbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->outbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->outbound.fd); - ctx->outbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->pid != ASSUAN_INVALID_PID && ctx->pid) - { - _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0); - ctx->pid = ASSUAN_INVALID_PID; - } -} - - -static void -do_deinit (assuan_context_t ctx) -{ - do_finish (ctx); -} - - /* Helper for pipe_connect. */ static gpg_error_t initial_handshake (assuan_context_t ctx) @@ -220,16 +190,15 @@ _assuan_close (ctx, rp[1]); _assuan_close (ctx, wp[0]); - ctx->engine.release = _assuan_disconnect; + ctx->engine.release = _assuan_client_release; ctx->engine.readfnc = _assuan_simple_read; ctx->engine.writefnc = _assuan_simple_write; ctx->engine.sendfd = NULL; ctx->engine.receivefd = NULL; + ctx->finish_handler = _assuan_client_finish; ctx->pipe_mode = 1; ctx->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ ctx->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ - ctx->deinit_handler = do_deinit; - ctx->finish_handler = do_finish; ctx->pid = pid; rc = initial_handshake (ctx); @@ -370,11 +339,11 @@ _assuan_close (ctx, fds[1]); + ctx->engine.release = _assuan_client_release; + ctx->finish_handler = _assuan_client_finish; ctx->pipe_mode = 1; ctx->inbound.fd = fds[0]; ctx->outbound.fd = fds[0]; - ctx->deinit_handler = _assuan_uds_deinit; - ctx->finish_handler = do_finish; _assuan_init_uds_io (ctx); err = initial_handshake (ctx); @@ -424,7 +393,7 @@ TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect_ext", ctx, "name=%s,flags=0x%x", name ? name : "(null)", flags); - if ((flags & 1)) + if (flags & ASSUAN_PIPE_CONNECT_FDPASSING) { #ifdef HAVE_W32_SYSTEM return _assuan_error (ctx, GPG_ERR_NOT_IMPLEMENTED); Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-pipe-server.c 2009-11-19 23:57:35 UTC (rev 320) @@ -34,26 +34,6 @@ #include "assuan-defs.h" -static void -deinit_pipe_server (assuan_context_t ctx) -{ - /* nothing to do for this simple server */ -} - -static gpg_error_t -accept_connection (assuan_context_t ctx) -{ - /* This is a NOP for a pipe server */ - return 0; -} - -static void -finish_connection (assuan_context_t ctx) -{ - /* This is a NOP for a pipe server */ -} - - /* Returns true if atoi(S) denotes a valid socket. */ #ifndef HAVE_W32_SYSTEM static int @@ -114,7 +94,7 @@ #endif ctx->is_server = 1; - ctx->engine.release = deinit_pipe_server; + ctx->engine.release = _assuan_server_release; ctx->engine.readfnc = _assuan_simple_read; ctx->engine.writefnc = _assuan_simple_write; ctx->engine.sendfd = NULL; @@ -126,35 +106,13 @@ ctx->pid = (pid_t)ul; else ctx->pid = (pid_t)-1; - ctx->accept_handler = accept_connection; - ctx->finish_handler = finish_connection; - ctx->deinit_handler = deinit_pipe_server; + ctx->accept_handler = NULL; + ctx->finish_handler = _assuan_server_finish; ctx->inbound.fd = infd; ctx->outbound.fd = outfd; if (is_usd) - { - _assuan_init_uds_io (ctx); - ctx->deinit_handler = _assuan_uds_deinit; - } + _assuan_init_uds_io (ctx); return 0; } - - -void -_assuan_deinit_server (assuan_context_t ctx) -{ - /* We use this function pointer to avoid linking other server when - not needed but still allow for a generic deinit function. */ - ctx->deinit_handler (ctx); - ctx->deinit_handler = NULL; - - _assuan_inquire_release (ctx); - _assuan_free (ctx, ctx->hello_line); - ctx->hello_line = NULL; - _assuan_free (ctx, ctx->okay_line); - ctx->okay_line = NULL; - _assuan_free (ctx, ctx->cmdtbl); - ctx->cmdtbl = NULL; -} Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-socket-connect.c 2009-11-19 23:57:35 UTC (rev 320) @@ -52,30 +52,7 @@ + strlen ((ptr)->sun_path)) #endif - -static void -do_finish (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->inbound.fd); - ctx->inbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->outbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->outbound.fd); - ctx->outbound.fd = ASSUAN_INVALID_FD; - } -} - -static void -do_deinit (assuan_context_t ctx) -{ - do_finish (ctx); -} - - /* Make a connection to the Unix domain socket NAME and return a new Assuan context in CTX. SERVER_PID is currently not used but may become handy in the future. With flags set to 1 sendmsg and @@ -130,17 +107,16 @@ return _assuan_error (ctx, GPG_ERR_ASS_CONNECT_FAILED); } - ctx->engine.release = _assuan_disconnect; + ctx->engine.release = _assuan_client_release; ctx->engine.readfnc = _assuan_simple_read; ctx->engine.writefnc = _assuan_simple_write; ctx->engine.sendfd = NULL; ctx->engine.receivefd = NULL; - ctx->deinit_handler = ((flags&1))? _assuan_uds_deinit : do_deinit; - ctx->finish_handler = do_finish; + ctx->finish_handler = _assuan_client_finish; ctx->inbound.fd = fd; ctx->outbound.fd = fd; - if (flags & 1) + if (flags & ASSUAN_SOCKET_CONNECT_FDPASSING) _assuan_init_uds_io (ctx); /* initial handshake */ Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-socket-server.c 2009-11-19 23:57:35 UTC (rev 320) @@ -61,7 +61,7 @@ /* This overrides any already set PID if the function returns a valid one. */ - if (cr.pid != (pid_t)-1 && cr.pid) + if (cr.pid != ASSUAN_INVALID_PID && cr.pid) ctx->pid = cr.pid; } } @@ -107,37 +107,6 @@ } -static void -finish_connection (assuan_context_t ctx) -{ - if (ctx->inbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->inbound.fd); - ctx->inbound.fd = ASSUAN_INVALID_FD; - } - if (ctx->outbound.fd != ASSUAN_INVALID_FD) - { - _assuan_close (ctx, ctx->outbound.fd); - ctx->outbound.fd = ASSUAN_INVALID_FD; - } -} - - -static void -deinit_socket_server (assuan_context_t ctx) -{ - finish_connection (ctx); - - _assuan_inquire_release (ctx); - _assuan_free (ctx, ctx->hello_line); - ctx->hello_line = NULL; - _assuan_free (ctx, ctx->okay_line); - ctx->okay_line = NULL; - _assuan_free (ctx, ctx->cmdtbl); - ctx->cmdtbl = NULL; -} - - /* Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing 1 - FD has already been accepted. @@ -152,13 +121,13 @@ if (rc) return rc; - ctx->engine.release = deinit_socket_server; + ctx->engine.release = _assuan_server_release; ctx->engine.readfnc = _assuan_simple_read; ctx->engine.writefnc = _assuan_simple_write; ctx->engine.sendfd = NULL; ctx->engine.receivefd = NULL; ctx->is_server = 1; - if (flags & 2) + if (flags & ASSUAN_SOCKET_SERVER_ACCEPTED) ctx->pipe_mode = 1; /* We want a second accept to indicate EOF. */ ctx->input_fd = ASSUAN_INVALID_FD; ctx->output_fd = ASSUAN_INVALID_FD; @@ -166,7 +135,7 @@ ctx->inbound.fd = ASSUAN_INVALID_FD; ctx->outbound.fd = ASSUAN_INVALID_FD; - if ((flags & 2)) + if (flags & ASSUAN_SOCKET_SERVER_ACCEPTED) { ctx->listen_fd = ASSUAN_INVALID_FD; ctx->connected_fd = fd; @@ -176,13 +145,12 @@ ctx->listen_fd = fd; ctx->connected_fd = ASSUAN_INVALID_FD; } - ctx->deinit_handler = (flags & 1)? _assuan_uds_deinit:deinit_socket_server; - ctx->accept_handler = ((flags & 2) + ctx->accept_handler = ((flags & ASSUAN_SOCKET_SERVER_ACCEPTED) ? accept_connection_bottom : accept_connection); - ctx->finish_handler = finish_connection; + ctx->finish_handler = _assuan_server_finish; - if ((flags & 1)) + if (flags & ASSUAN_SOCKET_SERVER_FDPASSING) _assuan_init_uds_io (ctx); rc = _assuan_register_std_commands (ctx); Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/assuan-uds.c 2009-11-19 23:57:35 UTC (rev 320) @@ -266,8 +266,6 @@ void _assuan_uds_deinit (assuan_context_t ctx) { - /* First call the finish_handler which should close descriptors etc. */ - ctx->finish_handler (ctx); _assuan_uds_close_fds (ctx); } Added: trunk/src/client.c =================================================================== --- trunk/src/client.c (rev 0) +++ trunk/src/client.c 2009-11-19 23:57:35 UTC (rev 320) @@ -0,0 +1,60 @@ +/* client.c - Functions common to all clients. + Copyright (C) 2009 Free Software Foundation, Inc. + + This file is part of Assuan. + + Assuan is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + Assuan is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, see . + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "assuan-defs.h" +#include "debug.h" + +void +_assuan_client_finish (assuan_context_t ctx) +{ + if (ctx->inbound.fd != ASSUAN_INVALID_FD) + { + _assuan_close (ctx, ctx->inbound.fd); + if (ctx->inbound.fd == ctx->outbound.fd) + ctx->outbound.fd = ASSUAN_INVALID_FD; + ctx->inbound.fd = ASSUAN_INVALID_FD; + } + if (ctx->outbound.fd != ASSUAN_INVALID_FD) + { + _assuan_close (ctx, ctx->outbound.fd); + ctx->outbound.fd = ASSUAN_INVALID_FD; + } + if (ctx->pid != ASSUAN_INVALID_PID && ctx->pid) + { + _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0); + ctx->pid = ASSUAN_INVALID_PID; + } + + _assuan_uds_deinit (ctx); +} + + +/* Disconnect and release the context CTX. */ +void +_assuan_client_release (assuan_context_t ctx) +{ + assuan_write_line (ctx, "BYE"); + + _assuan_client_finish (ctx); +} Modified: trunk/src/context.c =================================================================== --- trunk/src/context.c 2009-11-10 17:59:41 UTC (rev 319) +++ trunk/src/context.c 2009-11-19 23:57:35 UTC (rev 320) @@ -171,6 +171,16 @@ } +/* Return the PID of the peer or ASSUAN_INVALID_PID if not known. + This function works in some situations where assuan_get_ucred + fails. */ +pid_t +assuan_get_pid (assuan_context_t ctx) +{ + return (ctx && ctx->pid) ? ctx->pid : ASSUAN_INVALID_PID; +} + + /* Return user credentials. For getting the pid of the peer the assuan_get_pid is usually better suited. */ gpg_error_t Added: trunk/src/server.c =================================================================== --- trunk/src/server.c (rev 0) +++ trunk/src/server.c 2009-11-19 23:57:35 UTC (rev 320) @@ -0,0 +1,69 @@ +/* server.c - Interfaces for all assuan servers. + Copyright (C) 2009 Free Software Foundation, Inc. + + This file is part of Assuan. + + Assuan is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + Assuan is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this program; if not, see . + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "assuan-defs.h" +#include "debug.h" + + + +/* Disconnect and release the context CTX. */ +void +_assuan_server_finish (assuan_context_t ctx) +{ + if (ctx->inbound.fd != ASSUAN_INVALID_FD) + { + _assuan_close (ctx, ctx->inbound.fd); + if (ctx->inbound.fd == ctx->outbound.fd) + ctx->outbound.fd = ASSUAN_INVALID_FD; + ctx->inbound.fd = ASSUAN_INVALID_FD; + } + if (ctx->outbound.fd != ASSUAN_INVALID_FD) + { + _assuan_close (ctx, ctx->outbound.fd); + ctx->outbound.fd = ASSUAN_INVALID_FD; + } + if (ctx->pid != ASSUAN_INVALID_PID && ctx->pid) + { + _assuan_waitpid (ctx, ctx->pid, ctx->flags.no_waitpid, NULL, 0); + ctx->pid = ASSUAN_INVALID_PID; + } + + _assuan_uds_deinit (ctx); + + _assuan_inquire_release (ctx); +} + + +void +_assuan_server_release (assuan_context_t ctx) +{ + _assuan_server_finish (ctx); + + _assuan_free (ctx, ctx->hello_line); + ctx->hello_line = NULL; + _assuan_free (ctx, ctx->okay_line); + ctx->okay_line = NULL; + _assuan_free (ctx, ctx->cmdtbl); + ctx->cmdtbl = NULL; +} From cvs at cvs.gnupg.org Fri Nov 20 13:09:28 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 20 Nov 2009 13:09:28 +0100 Subject: [svn] GpgOL - r319 - branches Message-ID: Author: wk Date: 2009-11-20 13:09:28 +0100 (Fri, 20 Nov 2009) New Revision: 319 Added: branches/more-oom-based-with-OL2007-probs/ Log: Save the OOM based version which works on OL2003 but not completely on OL2007. From cvs at cvs.gnupg.org Fri Nov 20 13:10:26 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 20 Nov 2009 13:10:26 +0100 Subject: [svn] GpgOL - r320 - in trunk: doc src Message-ID: Author: wk Date: 2009-11-20 13:10:25 +0100 (Fri, 20 Nov 2009) New Revision: 320 Modified: trunk/doc/gpgol.texi trunk/src/inspectors.cpp trunk/src/mailitem.cpp trunk/src/mailitem.h trunk/src/message-events.cpp Log: Saved current experiments Modified: trunk/doc/gpgol.texi =================================================================== --- trunk/doc/gpgol.texi 2009-11-20 12:09:28 UTC (rev 319) +++ trunk/doc/gpgol.texi 2009-11-20 12:10:25 UTC (rev 320) @@ -309,6 +309,8 @@ Tell what the MIME parser is doing @item 256 (0x0100) (mime-data) Print data lines while parsing MIME. + at item 512 (0x0200) (oom) +Verbose object allocation reporting. @end table You may use the regular C-syntax for entering the value. As an alternative you may use the names of the flags, separated by space or Modified: trunk/src/inspectors.cpp =================================================================== --- trunk/src/inspectors.cpp 2009-11-20 12:09:28 UTC (rev 319) +++ trunk/src/inspectors.cpp 2009-11-20 12:10:25 UTC (rev 320) @@ -424,7 +424,7 @@ GpgolInspectorEvents::Activate (void) { LPOOMINSPECTOR inspector; - // LPDISPATCH obj, obj2; + LPDISPATCH obj, obj2; log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); @@ -448,14 +448,14 @@ { m_first_activate_seen = true; add_inspector_controls (inspector); - // obj = get_oom_object (inspector, "get_CurrentItem"); - // if (obj) - // { - // obj2 = install_GpgolItemEvents_sink (obj); - // if (obj2) - // obj2->Release (); - // obj->Release (); - // } + obj = get_oom_object (inspector, "get_CurrentItem"); + if (obj) + { + obj2 = install_GpgolItemEvents_sink (obj); + if (obj2) + obj2->Release (); + obj->Release (); + } } update_crypto_info (inspector); Modified: trunk/src/mailitem.cpp =================================================================== --- trunk/src/mailitem.cpp 2009-11-20 12:09:28 UTC (rev 319) +++ trunk/src/mailitem.cpp 2009-11-20 12:10:25 UTC (rev 320) @@ -28,15 +28,24 @@ #include "oomhelp.h" #include "eventsink.h" #include "mailitem.h" +#include "mymapi.h" +#include "mymapitags.h" +#include "myexchext.h" +#include "mapihelp.h" +#include "message.h" - /* Subclass of ItemEvents so that we can hook into the events. */ BEGIN_EVENT_SINK(GpgolItemEvents, IOOMItemEvents) STDMETHOD(Read)(THIS_ ); STDMETHOD(Write)(THIS_ PBOOL cancel); STDMETHOD(Open)(THIS_ PBOOL cancel); STDMETHOD(Close)(THIS_ PBOOL cancel); -EVENT_SINK_DEFAULT_CTOR(GpgolItemEvents) + STDMETHOD(Send)(THIS_ PBOOL cancel); + bool m_send_seen; +EVENT_SINK_CTOR(GpgolItemEvents) +{ + m_send_seen = false; +} EVENT_SINK_DEFAULT_DTOR(GpgolItemEvents) EVENT_SINK_INVOKE(GpgolItemEvents) { @@ -57,7 +66,10 @@ } break; + case 0xf002: + case 0xf003: case 0xf004: + case 0xf005: if (!(flags & DISPATCH_METHOD)) goto badflags; if (!parms) @@ -74,6 +86,7 @@ case 0xf002: Write (&cancel_default); break; case 0xf003: Open (&cancel_default); break; case 0xf004: Close (&cancel_default); break; + case 0xf005: Send (&cancel_default); break; } *parms->rgvarg[0].pboolVal = (cancel_default ? VARIANT_TRUE:VARIANT_FALSE); @@ -94,19 +107,113 @@ STDMETHODIMP GpgolItemEvents::Read (void) { - log_debug ("%s:%s: Called", SRCNAME, __func__); + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); return S_OK; } -/* This is the event sink for a write event. */ +/* This is the event sink for a write event. OL2003 calls this method + before an ECE OnWrite. */ STDMETHODIMP GpgolItemEvents::Write (PBOOL cancel_default) { - (void)cancel_default; - log_debug ("%s:%s: Called", SRCNAME, __func__); + bool sign, encrypt, need_crypto, want_html; + HWND hwnd = NULL; /* Fixme. */ + + log_debug ("%s:%s: Called (this=%p) (send_seen=%d)", + SRCNAME, __func__, this, m_send_seen); + if (!m_send_seen) + return S_OK; /* The user is only saving the message. */ + m_send_seen = 0; + + if (opt.disable_gpgol) + return S_OK; /* GpgOL is not active. */ + + // need_crypto = (!get_crypto_flags (eecb, &sign, &encrypt) + // && (sign || encrypt)); + need_crypto = true; + sign = true; + encrypt = false; + + + /* If we are going to encrypt, check that the BodyFormat is + something we support. This helps avoiding surprise by sending + out unencrypted messages. */ + if (need_crypto) + { + HRESULT hr; + int rc; + LPUNKNOWN unknown; + LPMESSAGE message = NULL; + int bodyfmt; + protocol_t proto = PROTOCOL_UNKNOWN; /* Let the UI server select + the protocol. */ + + bodyfmt = get_oom_int (m_object, "BodyFormat"); + + if (bodyfmt == 1) + want_html = 0; + else if (bodyfmt == 2) + want_html = 1; + else + { + log_debug ("%s:%s: BodyFormat is %d", SRCNAME, __func__, bodyfmt); + MessageBox (hwnd, + _("Sorry, we can only encrypt plain text messages and\n" + "no RTF messages. Please make sure that only the text\n" + "format has been selected."), + "GpgOL", MB_ICONERROR|MB_OK); + + *cancel_default = true; + return S_OK; + } + + /* Unfortunately the Body has not yet been written to the MAPI + object, although the object already exists. Thus we have to + take it from the OOM which requires us to rewrite parts of + the message encryption functions. More work ... */ + unknown = get_oom_iunknown (m_object, "MAPIOBJECT"); + if (!unknown) + log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__); + else + { + hr = unknown->QueryInterface (IID_IMessage, (void**)&message); + if (hr != S_OK || !message) + { + message = NULL; + log_error ("%s:%s: error getting IMESSAGE: hr=%#lx", + SRCNAME, __func__, hr); + } + unknown->Release (); + } + + if (!message) + rc = -1; + else if (encrypt && sign) + rc = message_sign_encrypt (message, proto, hwnd); + else if (encrypt && !sign) + rc = message_encrypt (message, proto, hwnd); + else if (!encrypt && sign) + rc = message_sign (message, proto, hwnd); + else + { + /* In case this is a forward message which is not to be + signed or encrypted we need to remove a possible body + attachment. */ + if (mapi_delete_gpgol_body_attachment (message)) + mapi_save_changes (message, KEEP_OPEN_READWRITE); + rc = 0; + } + + if (rc) + { + *cancel_default = true; + return S_OK; + } + } + return S_OK; } @@ -116,18 +223,35 @@ GpgolItemEvents::Open (PBOOL cancel_default) { (void)cancel_default; - log_debug ("%s:%s: Called", SRCNAME, __func__); + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); return S_OK; } + /* This is the event sink for a close event. */ STDMETHODIMP GpgolItemEvents::Close (PBOOL cancel_default) { (void)cancel_default; - log_debug ("%s:%s: Called", SRCNAME, __func__); + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); + /* Remove ourself. */ + detach_GpgolItemEvents_sink (this); return S_OK; } + +/* This is the event Sink for a send event. OL2003 calls this method + before an ECE OnSubmit. */ +STDMETHODIMP +GpgolItemEvents::Send (PBOOL cancel_default) +{ + (void)cancel_default; + log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); + + m_send_seen = true; + + return S_OK; +} + Modified: trunk/src/mailitem.h =================================================================== --- trunk/src/mailitem.h 2009-11-20 12:09:28 UTC (rev 319) +++ trunk/src/mailitem.h 2009-11-20 12:10:25 UTC (rev 320) @@ -57,14 +57,19 @@ via the IDispatch interface. */ /* dispid=0xf001 */ STDMETHOD(Read)(THIS_ ); + /* dispid=0xf002 */ STDMETHOD(Write)(THIS_ PBOOL cancel); + /* dispid=0xf003 */ STDMETHOD(Open)(THIS_ PBOOL cancel); + /* dispid=0xf004 */ STDMETHOD(Close)(THIS_ PBOOL cancel); + /* dispid=0xf005 */ - //STDMETHOD(Send)(THIS_ PBOOL cancel); + STDMETHOD(Send)(THIS_ PBOOL cancel); + /* dispid=0xf006 */ //STDMETHOD(CustomAction)(THIS_ LPDISPATCH action, LPDISPATCH response, // PBOOL cancel); @@ -72,8 +77,11 @@ //STDMETHOD(CustomPropertyChange)(THIS_ VARIANT name); /* dispid=0xf009 */ //STDMETHOD(PropertyChange)(THIS_ VARIANT name); - /* dispid=0xf00a */ + + /* dispid=0xf00a + OL2003: Called between the ECE OnCheckNames and OnCheckNamesComplete. */ //STDMETHOD(BeforeCheckName)(THIS_ PBOOL cancel); + /* dispid=0xf00b */ //STDMETHOD(AttachmentAdd)(THIS_ LPDISPATCH att); /* dispid=0xf00c */ Modified: trunk/src/message-events.cpp =================================================================== --- trunk/src/message-events.cpp 2009-11-20 12:09:28 UTC (rev 319) +++ trunk/src/message-events.cpp 2009-11-20 12:10:25 UTC (rev 320) @@ -252,42 +252,42 @@ log_debug ("%s:%s: received\n", SRCNAME, __func__); - need_crypto = (!get_crypto_flags (eecb, &sign, &encrypt) - && (sign || encrypt)); + // need_crypto = (!get_crypto_flags (eecb, &sign, &encrypt) + // && (sign || encrypt)); - /* If we are going to encrypt, check that the BodyFormat is - something we support. This helps avoiding surprise by sending - out unencrypted messages. */ - if (need_crypto && !opt.disable_gpgol) - { - obj = get_eecb_object (eecb); - if (!obj) - bodyfmt = -1; - else - { - bodyfmt = get_oom_int (obj, "BodyFormat"); - obj->Release (); - } + // /* If we are going to encrypt, check that the BodyFormat is + // something we support. This helps avoiding surprise by sending + // out unencrypted messages. */ + // if (need_crypto && !opt.disable_gpgol) + // { + // obj = get_eecb_object (eecb); + // if (!obj) + // bodyfmt = -1; + // else + // { + // bodyfmt = get_oom_int (obj, "BodyFormat"); + // obj->Release (); + // } - if (bodyfmt == 1) - m_want_html = 0; - else if (bodyfmt == 2) - m_want_html = 1; - else - { - log_debug ("%s:%s: BodyFormat is %d", SRCNAME, __func__, bodyfmt); - if (FAILED(eecb->GetWindow (&hWnd))) - hWnd = NULL; - MessageBox (hWnd, - _("Sorry, we can only encrypt plain text messages and\n" - "no RTF messages. Please make sure that only the text\n" - "format has been selected."), - "GpgOL", MB_ICONERROR|MB_OK); + // if (bodyfmt == 1) + // m_want_html = 0; + // else if (bodyfmt == 2) + // m_want_html = 1; + // else + // { + // log_debug ("%s:%s: BodyFormat is %d", SRCNAME, __func__, bodyfmt); + // if (FAILED(eecb->GetWindow (&hWnd))) + // hWnd = NULL; + // MessageBox (hWnd, + // _("Sorry, we can only encrypt plain text messages and\n" + // "no RTF messages. Please make sure that only the text\n" + // "format has been selected."), + // "GpgOL", MB_ICONERROR|MB_OK); - m_bWriteFailed = TRUE; - return E_FAIL; - } - } + // m_bWriteFailed = TRUE; + // return E_FAIL; + // } + // } return S_FALSE; @@ -316,58 +316,58 @@ log_debug ("%s:%s: received\n", SRCNAME, __func__); - if (flags & (EEME_FAILED|EEME_COMPLETE_FAILED)) - return S_FALSE; /* We don't need to rollback anything in case - other extensions flagged a failure. */ + // if (flags & (EEME_FAILED|EEME_COMPLETE_FAILED)) + // return S_FALSE; /* We don't need to rollback anything in case + // other extensions flagged a failure. */ - if (opt.disable_gpgol) - return S_FALSE; + // if (opt.disable_gpgol) + // return S_FALSE; - if (!m_bOnSubmitActive) /* The user is just saving the message. */ - return S_FALSE; + // if (!m_bOnSubmitActive) /* The user is just saving the message. */ + // return S_FALSE; - if (m_bWriteFailed) /* Operation failed already. */ - return S_FALSE; + // if (m_bWriteFailed) /* Operation failed already. */ + // return S_FALSE; - /* Try to get the current window. */ - if (FAILED(eecb->GetWindow (&hWnd))) - hWnd = NULL; + // /* Try to get the current window. */ + // if (FAILED(eecb->GetWindow (&hWnd))) + // hWnd = NULL; - /* Get the object and call the encryption or signing function. */ - HRESULT hr = eecb->GetObject (&pMDB, (LPMAPIPROP *)&msg); - if (SUCCEEDED (hr)) - { - protocol_t proto = PROTOCOL_UNKNOWN; /* Let the UI server select - the protocol. */ - bool sign, encrypt; + // /* Get the object and call the encryption or signing function. */ + // HRESULT hr = eecb->GetObject (&pMDB, (LPMAPIPROP *)&msg); + // if (SUCCEEDED (hr)) + // { + // protocol_t proto = PROTOCOL_UNKNOWN; /* Let the UI server select + // the protocol. */ + // bool sign, encrypt; - if (get_crypto_flags (eecb, &sign, &encrypt)) - rc = -1; - else if (encrypt && sign) - rc = message_sign_encrypt (msg, proto, hWnd); - else if (encrypt && !sign) - rc = message_encrypt (msg, proto, hWnd); - else if (!encrypt && sign) - rc = message_sign (msg, proto, hWnd); - else - { - /* In case this is a forward message which is not to be - signed or encrypted we need to remove a possible body - attachment. */ - if (mapi_delete_gpgol_body_attachment (msg)) - mapi_save_changes (msg, KEEP_OPEN_READWRITE); - rc = 0; - } + // if (get_crypto_flags (eecb, &sign, &encrypt)) + // rc = -1; + // else if (encrypt && sign) + // rc = message_sign_encrypt (msg, proto, hWnd); + // else if (encrypt && !sign) + // rc = message_encrypt (msg, proto, hWnd); + // else if (!encrypt && sign) + // rc = message_sign (msg, proto, hWnd); + // else + // { + // /* In case this is a forward message which is not to be + // signed or encrypted we need to remove a possible body + // attachment. */ + // if (mapi_delete_gpgol_body_attachment (msg)) + // mapi_save_changes (msg, KEEP_OPEN_READWRITE); + // rc = 0; + // } - if (rc) - { - hrReturn = E_FAIL; - m_bWriteFailed = TRUE; - } - } + // if (rc) + // { + // hrReturn = E_FAIL; + // m_bWriteFailed = TRUE; + // } + // } - ul_release (msg, __func__, __LINE__); - ul_release (pMDB, __func__, __LINE__); + // ul_release (msg, __func__, __LINE__); + // ul_release (pMDB, __func__, __LINE__); return hrReturn; } From cvs at cvs.gnupg.org Fri Nov 20 13:10:42 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 20 Nov 2009 13:10:42 +0100 Subject: [svn] GpgOL - r321 - branches/more-oom-based-with-OL2007-probs Message-ID: Author: wk Date: 2009-11-20 13:10:42 +0100 (Fri, 20 Nov 2009) New Revision: 321 Added: branches/more-oom-based-with-OL2007-probs/trunk/ Log: oops ,was 319 From cvs at cvs.gnupg.org Mon Nov 23 20:18:05 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 23 Nov 2009 20:18:05 +0100 Subject: [svn] GnuPG - r5199 - in trunk: doc g10 sm tools Message-ID: Author: wk Date: 2009-11-23 20:18:04 +0100 (Mon, 23 Nov 2009) New Revision: 5199 Modified: trunk/doc/ChangeLog trunk/doc/gpg.texi trunk/g10/ChangeLog trunk/g10/gpg.c trunk/g10/keygen.c trunk/g10/options.h trunk/g10/pubkey-enc.c trunk/sm/ChangeLog trunk/sm/certreqgen.c trunk/sm/gpgsm.c trunk/tools/ChangeLog trunk/tools/gpgconf-comp.c Log: Add gpgconf related dummy options default_pubkey_algo. Add option --skip-hidden-recipients Comment updates. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/doc/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) @@ -1,3 +1,8 @@ +2009-11-18 Werner Koch + + * gpg.texi (GPG Key related Options): Describe + --skip-hidden-recipients. + 2009-10-19 David Shaw * gpg.texi (GPG Configuration Options): Clarify that ca-cert-file Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/g10/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) @@ -1,3 +1,13 @@ +2009-11-23 Werner Koch + + * gpg.c (gpgconf_list): Add key "default_pubkey_algo". + +2009-11-18 Werner Koch + + * gpg.c: Add option --skip-hidden-recipients and no- variant. + * options.h (struct opt): Add field SKIP_HIDDEN_RECIPIENTS. + * pubkey-enc.c (get_session_key): Implement that option. + 2009-11-04 Werner Koch * server.c (register_commands): Add NULL arg to Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/sm/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) @@ -1,3 +1,7 @@ +2009-11-23 Werner Koch + + * gpgsm.c (main) : Add key "default_pubkey_algo". + 2009-11-10 Marcus Brinkmann * server.c (cmd_getauditlog): Don't dup FD for es_fdopen_nc as Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/tools/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) @@ -1,3 +1,7 @@ +2009-11-23 Werner Koch + + * gpgconf-comp.c (gc_options_gpg): Add default_pubkey_algo. + 2009-11-05 Marcus Brinkmann * gpg-connect-agent.c (start_agent): Update use of Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/doc/gpg.texi 2009-11-23 19:18:04 UTC (rev 5199) @@ -1761,16 +1761,26 @@ @option{--default-key}. @item --try-all-secrets + at opindex try-all-secrets Don't look at the key ID as stored in the message but try all secret keys in turn to find the right decryption key. This option forces the behaviour as used by anonymous recipients (created by using @option{--throw-keyids}) and might come handy in case where an encrypted message contains a bogus key ID. + at item --skip-hidden-recipients + at itemx --no-skip-hidden-recipients + at opindex skip-hidden-recipients + at opindex no-skip-hidden-recipients +During decryption skip all anonymous recipients. This option helps in +the case that people use the hidden recipients feature to hide there +own encrypt-to key from others. If oneself has many secret keys this +may lead to a major annoyance because all keys are tried in turn to +decrypt soemthing which was not really intended for it. The drawback +of this option is that it is currently not possible to decrypt a +message which includes real anonymous recipients. - - @end table @c ******************************************* Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/g10/gpg.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -233,6 +233,8 @@ oWithSigList, oWithSigCheck, oSkipVerify, + oSkipHiddenRecipients, + oNoSkipHiddenRecipients, oCompressKeys, oCompressSigs, oAlwaysTrust, @@ -626,6 +628,8 @@ ARGPARSE_s_n (aListSigs, "list-sig", "@"), /* alias */ ARGPARSE_s_n (aCheckKeys, "check-sig", "@"), /* alias */ ARGPARSE_s_n (oSkipVerify, "skip-verify", "@"), + ARGPARSE_s_n (oSkipHiddenRecipients, "skip-hidden-recipients", "@"), + ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"), ARGPARSE_s_n (oCompressKeys, "compress-keys", "@"), ARGPARSE_s_n (oCompressSigs, "compress-sigs", "@"), ARGPARSE_s_i (oDefCertLevel, "default-cert-check-level", "@"), /* old */ @@ -1586,6 +1590,11 @@ printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT); printf ("group:%lu:\n", GC_OPT_FLAG_NONE); + /* The next one is an info only item and should match what + keygen:ask_keysize actually implements. */ + printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT, + "RSA-2048"); + xfree (configfile_esc); } @@ -2315,6 +2324,10 @@ case oWithSigList: opt.list_sigs = 1; break; case oSkipVerify: opt.skip_verify=1; break; + + case oSkipHiddenRecipients: opt.skip_hidden_recipients = 1; break; + case oNoSkipHiddenRecipients: opt.skip_hidden_recipients = 0; break; + case oCompressKeys: opt.compress_keys = 1; break; case aListSecretKeys: set_cmd( &cmd, aListSecretKeys); break; /* There are many programs (like mutt) that call gpg with Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/g10/keygen.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -1765,6 +1765,8 @@ static unsigned ask_keysize (int algo, unsigned int primary_keysize) { + /* NOTE: If you change the default key size/algo, remember to change + it also in gpgconf.c:gpgconf_list. */ unsigned int nbits, min, def=2048, max=4096; int for_subkey = !!primary_keysize; int autocomp = 0; Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/g10/options.h 2009-11-23 19:18:04 UTC (rev 5199) @@ -94,6 +94,7 @@ char *lc_messages; int skip_verify; + int skip_hidden_recipients; int compress_keys; int compress_sigs; /* TM_CLASSIC must be zero to accomodate trustdbs generated before Modified: trunk/g10/pubkey-enc.c =================================================================== --- trunk/g10/pubkey-enc.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/g10/pubkey-enc.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -85,6 +85,8 @@ if( !(rc = get_seckey( sk, k->keyid )) ) rc = get_it( k, dek, sk, k->keyid ); } + else if (opt.skip_hidden_recipients) + rc = gpg_error (GPG_ERR_NO_SECKEY); else { /* anonymous receiver: Try all available secret keys */ void *enum_context = NULL; u32 keyid[2]; Modified: trunk/sm/certreqgen.c =================================================================== --- trunk/sm/certreqgen.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/sm/certreqgen.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -475,7 +475,8 @@ return gpg_error (GPG_ERR_INV_PARAMETER); } - /* Check the keylength. */ + /* Check the keylength. NOTE: If you change this make sure that it + macthes the gpgconflist item in gpgsm.c */ if (!get_parameter (para, pKEYLENGTH, 0)) nbits = 2048; else Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/sm/gpgsm.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -1634,6 +1634,11 @@ printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT); printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE); + /* The next one is an info only item and should match what + proc_parameters actually implements. */ + printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT, + "RSA-2048"); + } break; case aGPGConfTest: Modified: trunk/tools/gpgconf-comp.c =================================================================== --- trunk/tools/gpgconf-comp.c 2009-11-10 16:35:59 UTC (rev 5198) +++ trunk/tools/gpgconf-comp.c 2009-11-23 19:18:04 UTC (rev 5199) @@ -667,6 +667,11 @@ { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT, "gnupg", "|FILE|read options from FILE", GC_ARG_TYPE_FILENAME, GC_BACKEND_GPG }, + { "default_pubkey_algo", + (GC_OPT_FLAG_ARG_OPT|GC_OPT_FLAG_NO_CHANGE), GC_LEVEL_INVISIBLE, + NULL, NULL, + GC_ARG_TYPE_STRING, GC_BACKEND_GPG }, + { "Debug", GC_OPT_FLAG_GROUP, GC_LEVEL_ADVANCED, @@ -695,6 +700,8 @@ GC_ARG_TYPE_STRING, GC_BACKEND_GPG }, + + GC_OPTION_NULL }; @@ -744,6 +751,10 @@ { "keyserver", GC_OPT_FLAG_LIST, GC_LEVEL_BASIC, "gnupg", N_("|SPEC|use this keyserver to lookup keys"), GC_ARG_TYPE_LDAP_SERVER, GC_BACKEND_GPGSM }, + { "default_pubkey_algo", + (GC_OPT_FLAG_ARG_OPT|GC_OPT_FLAG_NO_CHANGE), GC_LEVEL_INVISIBLE, + NULL, NULL, + GC_ARG_TYPE_STRING, GC_BACKEND_GPGSM }, { "Debug", GC_OPT_FLAG_GROUP, GC_LEVEL_ADVANCED, From cvs at cvs.gnupg.org Tue Nov 24 18:46:57 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 24 Nov 2009 18:46:57 +0100 Subject: [svn] assuan - r321 - in trunk: doc src Message-ID: Author: marcus Date: 2009-11-24 18:46:57 +0100 (Tue, 24 Nov 2009) New Revision: 321 Modified: trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-pipe-server.c trunk/src/assuan-socket.c trunk/src/assuan.h Log: doc/ 2009-11-24 Marcus Brinkmann * assuan.texi: Remove assuan_disconnect, assuan_deinit_server. Many smaller API fixes. src/ 2009-11-24 Marcus Brinkmann * assuan.h (struct _assuan_peercred) [_WIN32]: Define dummy member so struct is not empty. * assuan-socket.c (assuan_sock_deinit): Set sock_ctx to NULL. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/doc/ChangeLog 2009-11-24 17:46:57 UTC (rev 321) @@ -1,3 +1,8 @@ +2009-11-24 Marcus Brinkmann + + * assuan.texi: Remove assuan_disconnect, assuan_deinit_server. + Many smaller API fixes. + 2009-11-10 Marcus Brinkmann * assuan.texi: Various fixes and updates for the new interface. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/src/ChangeLog 2009-11-24 17:46:57 UTC (rev 321) @@ -1,3 +1,9 @@ +2009-11-24 Marcus Brinkmann + + * assuan.h (struct _assuan_peercred) [_WIN32]: Define dummy member + so struct is not empty. + * assuan-socket.c (assuan_sock_deinit): Set sock_ctx to NULL. + 2009-11-19 Marcus Brinkmann * Makefile.am (common_sources): Remove assuan-connect.c and add Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/doc/assuan.texi 2009-11-24 17:46:57 UTC (rev 321) @@ -594,9 +594,6 @@ This is a pointer to a @code{struct assuan_malloc_hooks}. @end deftp -/* Get the default malloc hooks. */ -assuan_malloc_hooks_t assuan_get_malloc_hooks (void); - @deftypefun void assuan_set_malloc_hooks (@w{assuan_malloc_hooks_t @var{malloc_hooks}}) This function sets the default allocation hooks for new contexts allocated with @code{assuan_new}. You need to provide all three @@ -808,7 +805,7 @@ @table @code @item ASSUAN_NO_WAITPID When using a pipe server, by default Libassuan will wait for the forked -process to die in @code{assuan_disconnect}. In certain cases this is +process to die in @code{assuan_release}. In certain cases this is not desirable. By setting this flag, a call to @code{waitpid} will be suppressed and the caller is responsible to cleanup the child process. @item ASSUAN_CONFIDENTIAL @@ -937,6 +934,10 @@ @table @code @item ASSUAN_SYSTEM_PTH System hooks suitable for use with the GNU Pth library. + at item ASSUAN_SYSTEM_PTH_IMPL +The implementation of system hooks for use with the GNU Pth library. +This must be invoked once somewhere in the application, and defines +the structure that is referenced by @code{ASSUAN_SYSTEM_PTH}. @end table @@ -1058,17 +1059,16 @@ @table @code @item ASSUAN_PIPE_CONNECT_FDPASSING -If cleared a simple pipe based server is expected and the function -behaves similar to @code{assuan_pipe_connect}. - -If set a server based on full-duplex pipes is expected. Such pipes are -usually created using the @code{socketpair} function. It also enables +If cleared a simple pipe based server is expected. If set a server +based on full-duplex pipes is expected. Such pipes are usually +created using the @code{socketpair} function. It also enables features only available with such servers. @item ASSUAN_PIPE_CONNECT_DETACHED If set and there is a need to start the server it will be started as a background process. This flag is useful under W32 systems, so that no -new console is created and pops up a console window when starting the server +new console is created and pops up a console window when starting the +server. @end table @end deftypefun @@ -1081,26 +1081,15 @@ Make a connection to the Unix domain socket @var{name} and return a new Assuan context at @var{ctx}. @var{server_pid} is currently not used but may become handy in the future; if you don't know the -server's process ID (PID), pass @code{-1}. With @var{flags} set to - at code{ASSUAN_SOCKET_CONNECT_FDPASSIN}, @code{sendmsg} and - at code{recvmesg} are used for input and output and thereby enable the -use of descriptor passing. +server's process ID (PID), pass @code{ASSUAN_INVALID_PID}. With + at var{flags} set to @code{ASSUAN_SOCKET_CONNECT_FDPASSIN}, + at code{sendmsg} and @code{recvmesg} are used for input and output and +thereby enable the use of descriptor passing. Connecting to a TCP server is not yet implemented. Standard URL schemes are reserved for @var{name} specifying a TCP server. @end deftypefun -Eventually, after using the Assuan connection, the resources should be -deallocated: - - at deftypefun void assuan_disconnect (@w{assuan_context_t @var{ctx}}) - -Close the connection described by the Assuan context @var{ctx} and -release all resources. This function also tries to send the BYE command -to the server but won't fail on error. It is explicitly allowed to pass - at code{NULL} for @var{ctx}, in which case the function does nothing. - at end deftypefun - Now that we have a connection to the server, all work may be conveniently done using a couple of callbacks and the transact function: @@ -1247,7 +1236,7 @@ If a file descriptor has been passed, the assuan context gets initialized by the function: - at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{fd}}, @w{unsigned int @var{flags}}) + at deftypefun gpg_error_t assuan_init_socket_server (@w{assuan_context_t *@var{r_ctx}}, @w{assuan_fd_t @var{fd}}, @w{unsigned int @var{flags}}) The function takes the file descriptor @var{fd} which is expected to be associated with a socket and returns a new Assuan context at @@ -1292,11 +1281,11 @@ @{ rc = assuan_register_command (ctx, command_table[i].name, - command_table[i].handler); + command_table[i].handler, NULL); if (rc) @{ fprintf (stderr, "register failed: %s\n", gpg_strerror (rc)); - assuan_deinit_server (ctx); + assuan_release (ctx); return; @} @} @@ -1419,7 +1408,7 @@ continue; @} @} - assuan_deinit_server (ctx); + assuan_release (ctx); @} @end example @@ -1449,18 +1438,7 @@ individual command handlers, i.e. operational error, are not seen here. @end deftypefun - @noindent -After the loop has terminated, the Assuan context needs to be released: - - at deftypefun void assuan_deinit_server (@w{assuan_context_t @var{ctx}}) - -Releases the resources described by the Assuan context @var{ctx} It is -explicitly allowed to pass @code{NULL} for @var{ctx}, in which case the -function does nothing. - at end deftypefun - - at noindent That is all needed for the server code. You only need to come up with the code for the individual command handlers. Take care that the line passed to the command handlers is allocated statically within the @@ -1558,8 +1536,7 @@ You should close and unregister the bulk data FDs when you wrote all data (for outbound FDs) or receive an EOF (for inbound FDs). When you receive an ERR from the server, or an OK for the final operation, you -can unregister the inbound status FD and call @code{assuan_disconnect} -to close it. +can unregister the inbound status FD and call @code{assuan_release}. @item As noted above, all send operations on the outbound status FD are done @@ -1733,7 +1710,7 @@ @end deftypefun - at deftypefun gpg_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{int *@var{rfd}}) + at deftypefun gpg_error_t assuan_command_parse_fd (@w{assuan_context_t @var{ctx}}, @w{char *@var{line}}, @w{assuan_fd_t *@var{rfd}}) This is the core of the default @code{INPUT} and @code{OUTPUT} handler. It may be used in custom commands as well to negotiate a @@ -1888,23 +1865,29 @@ and fully transparent for the client. Server code needs to utilize two extra functions to check the permissions. + at deftypefun gpg_error_t assuan_sock_init (void) +Initialize the socket wrappers. Must be called once at startup if any +of the socket wrapper functions are used. + at end deftypefun - at deftypefun int assuan_sock_close (@w{assuan_fd_t @var{fd}}) + at deftypefun gpg_error_t assuan_sock_init (void) +Deinitialize the socket wrappers. + at end deftypefun + at deftypefun int assuan_sock_close (@w{assuan_fd_t @var{fd}}) Wrapper for close which does a closesocket on Windows if needed. @end deftypefun @deftypefun assuan_fd_t assuan_sock_new (@w{int @var{domain}}, @w{int @var{type}}, @w{int @var{proto}}); - Wrapper around socket. @end deftypefun @deftypefun int assuan_sock_connect (@w{assuan_fd_t @var{sockfd}}, @ - @w{struct sockaddr *@var{addr}}, @ + @w{struct sockaddr *@var{addr}}, @ @w{int @var{addrlen}}) Wrapper around connect. For Unix domain sockets under Windows this -function also does a write immediatley after the the connect to send the +function also does a write immediately after the the connect to send the nonce as read from the socket's file. @end deftypefun Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/src/assuan-pipe-server.c 2009-11-24 17:46:57 UTC (rev 321) @@ -48,6 +48,8 @@ #endif /*!HAVE_W32_SYSTEM*/ +/* This actually is a int file descriptor (and not assuan_fd_t) as + _get_osfhandle is called on W32 systems. */ gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, int filedes[2]) { Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/src/assuan-socket.c 2009-11-24 17:46:57 UTC (rev 321) @@ -426,6 +426,7 @@ #endif assuan_release (sock_ctx); + sock_ctx = NULL; } Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-19 23:57:35 UTC (rev 320) +++ trunk/src/assuan.h 2009-11-24 17:46:57 UTC (rev 321) @@ -337,7 +337,7 @@ FILE *assuan_get_data_fp (assuan_context_t ctx); gpg_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line); gpg_error_t assuan_write_status (assuan_context_t ctx, - const char *keyword, const char *text); + const char *keyword, const char *text); /* Negotiate a file descriptor. If LINE contains "FD=N", returns N assuming a local file descriptor. If LINE contains "FD" reads a @@ -388,7 +388,10 @@ pid_t assuan_get_pid (assuan_context_t ctx); struct _assuan_peercred { -#ifndef _WIN32 +#ifdef _WIN32 + /* Empty struct not allowed on some compilers. */ + unsigned int _dummy; +#else pid_t pid; uid_t uid; gid_t gid; @@ -416,17 +419,17 @@ unsigned char **r_buffer, size_t *r_length, size_t maxlen); gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword, - size_t maxlen, - gpg_error_t (*cb) (void *cb_data, - gpg_error_t rc, - unsigned char *buf, - size_t buf_len), - void *cb_data); + size_t maxlen, + gpg_error_t (*cb) (void *cb_data, + gpg_error_t rc, + unsigned char *buf, + size_t buf_len), + void *cb_data); /*-- assuan-buffer.c --*/ gpg_error_t assuan_read_line (assuan_context_t ctx, char **line, size_t *linelen); int assuan_pending_line (assuan_context_t ctx); -gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line ); +gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line); gpg_error_t assuan_send_data (assuan_context_t ctx, const void *buffer, size_t length); @@ -438,7 +441,8 @@ /*-- assuan-util.c --*/ -gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text); +gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, + const char *text); From cvs at cvs.gnupg.org Wed Nov 25 18:55:27 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 25 Nov 2009 18:55:27 +0100 Subject: [svn] assuan - r322 - in trunk: . doc src Message-ID: Author: marcus Date: 2009-11-25 18:55:26 +0100 (Wed, 25 Nov 2009) New Revision: 322 Modified: trunk/NEWS trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-pipe-server.c trunk/src/assuan.h trunk/src/libassuan.def trunk/src/libassuan.vers trunk/src/system.c Log: doc/ 2009-11-25 Marcus Brinkmann * assuan.texi (Data Types): Document assuan_fdopen. src/ 2009-11-25 Marcus Brinkmann * assuan.h (assuan_init_pipe_server): Change type of filedes to assuan_fd_t. (assuan_fdopen): New prototype. * libassuan.vers, libassuan.def: Add assuan_fdopen. * system.c (assuan_fdopen): New function. * assuan-pipe-server.c (assuan_init_pipe_server): Change type of filedes to assuan_fd_t. No longer translate fd to handle. Don't set to binary either (that doesn't do anything for handles, it only affects the libc fd). Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/doc/ChangeLog 2009-11-25 17:55:26 UTC (rev 322) @@ -1,3 +1,7 @@ +2009-11-25 Marcus Brinkmann + + * assuan.texi (Data Types): Document assuan_fdopen. + 2009-11-24 Marcus Brinkmann * assuan.texi: Remove assuan_disconnect, assuan_deinit_server. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/ChangeLog 2009-11-25 17:55:26 UTC (rev 322) @@ -1,3 +1,15 @@ +2009-11-25 Marcus Brinkmann + + * assuan.h (assuan_init_pipe_server): Change type of filedes to + assuan_fd_t. + (assuan_fdopen): New prototype. + * libassuan.vers, libassuan.def: Add assuan_fdopen. + * system.c (assuan_fdopen): New function. + * assuan-pipe-server.c (assuan_init_pipe_server): Change type of + filedes to assuan_fd_t. No longer translate fd to handle. Don't + set to binary either (that doesn't do anything for handles, it + only affects the libc fd). + 2009-11-24 Marcus Brinkmann * assuan.h (struct _assuan_peercred) [_WIN32]: Define dummy member Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/NEWS 2009-11-25 17:55:26 UTC (rev 322) @@ -55,6 +55,8 @@ assuan_pipe_connect_ext REMOVED assuan_init_pipe_server CHANGED: Take ctx arg instead of pointer to ctx. CHANGED: Swallows fds (are closed at end). + CHANGED: Take assuan_fd_t. +assuan_fdopen NEW assuan_set_io_hooks REMOVED: Will come back in expanded form. assuan_io_hooks_t REMOVED: Will come back in expanded form. assuan_io_monitor_t CHANGED: Add a hook data argument. Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/doc/assuan.texi 2009-11-25 17:55:26 UTC (rev 322) @@ -556,13 +556,21 @@ @end deftp + at deftypefun assuan_fd_t assuan_fdopen (@w{int @var{fd}}) +Create an assuan file descriptor from a POSIX (libc) file descriptor + at var{fd}. On Unix, this is equivalent to @code{dup}, while on Windows +this will retrieve the underlying system handle with + at code{_get_osfhandle} and duplicate that. + at end deftypefun + + @node Initializing the library @section Initializing the library In general the library requires no initialization. There are however some initialization hooks provided which are often useful. These should be called as early as possible and in a multi-threaded -application before a second thread is created. +application before a second thread is created. These functions initialize default values that are used at context creation with @code{assuan_new}. As there can only be one default, @@ -1194,10 +1202,10 @@ if (fd == -1) @{ - int filedes[2]; + assuan_fd_t filedes[2]; - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fd_from_posix (0); + filedes[1] = assuan_fd_from_posix (1); rc = assuan_init_pipe_server (&ctx, filedes); @} else @@ -1216,7 +1224,7 @@ handles are connected to a pipe. The initialization is thus done using the function: - at deftypefun gpg_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{int @var{filedes}[2]}) + at deftypefun gpg_error_t assuan_init_pipe_server (@w{assuan_context_t *@var{r_ctx}}, @w{assuan_fd_t @var{filedes}[2]}) The function takes the two file descriptors from @var{filedes} and returns a new Assuan context at @var{r_ctx}. As usual, a return value Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/assuan-pipe-server.c 2009-11-25 17:55:26 UTC (rev 322) @@ -51,7 +51,7 @@ /* This actually is a int file descriptor (and not assuan_fd_t) as _get_osfhandle is called on W32 systems. */ gpg_error_t -assuan_init_pipe_server (assuan_context_t ctx, int filedes[2]) +assuan_init_pipe_server (assuan_context_t ctx, assuan_fd_t filedes[2]) { const char *s; unsigned long ul; @@ -65,13 +65,8 @@ return rc; #ifdef HAVE_W32_SYSTEM - /* MS Windows has so many different types of handle that one needs - to tranlsate them at many place forth and back. Also make sure - that the file descriptors are in binary mode. */ - setmode (filedes[0], O_BINARY); - setmode (filedes[1], O_BINARY); - infd = (void*)_get_osfhandle (filedes[0]); - outfd = (void*)_get_osfhandle (filedes[1]); + infd = filedes[0]; + outfd = filedes[1]; #else s = getenv ("_assuan_connection_fd"); if (s && *s && is_valid_socket (s)) Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/assuan.h 2009-11-25 17:55:26 UTC (rev 322) @@ -91,7 +91,9 @@ #define ASSUAN_INVALID_PID ((pid_t) -1) #endif +assuan_fd_t assuan_fdopen (int fd); + /* Assuan features an emulation of Unix domain sockets based on a local TCP connections. To implement access permissions based on file permissions a nonce is used which is expected by th server as @@ -358,7 +360,8 @@ /*-- assuan-pipe-server.c --*/ -gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, int filedes[2]); +gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, + assuan_fd_t filedes[2]); /*-- assuan-socket-server.c --*/ #define ASSUAN_SOCKET_SERVER_FDPASSING 1 Modified: trunk/src/libassuan.def =================================================================== --- trunk/src/libassuan.def 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/libassuan.def 2009-11-25 17:55:26 UTC (rev 322) @@ -92,6 +92,7 @@ __assuan_socketpair @71 __assuan_spawn @72 __assuan_usleep @73 + assuan_fdopen @74 ; END Modified: trunk/src/libassuan.vers =================================================================== --- trunk/src/libassuan.vers 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/libassuan.vers 2009-11-25 17:55:26 UTC (rev 322) @@ -29,6 +29,7 @@ assuan_command_parse_fd; assuan_ctx_set_system_hooks; assuan_end_confidential; + assuan_fdopen; assuan_get_active_fds; assuan_get_assuan_log_prefix; assuan_get_command_name; Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2009-11-24 17:46:57 UTC (rev 321) +++ trunk/src/system.c 2009-11-25 17:55:26 UTC (rev 322) @@ -44,6 +44,27 @@ #endif +assuan_fd_t +assuan_fdopen (int fd) +{ +#ifdef HAVE_W32_SYSTEM + assuan_fd_t ifd = (assuan_fd_t) _get_osfhandle (fd); + assuan_fd_t ofd; + + if (! DuplicateHandle(GetCurrentProcess(), hfd, + GetCurrentProcess(), &ofd, 0, + TRUE, DUPLICATE_SAME_ACCESS)) + { + errno = EIO; + return ASSUAN_INVALID_FD: + } + return ofd; +#else + return dup (fd); +#endif +} + + /* Manage memory specific to a context. */ void * From cvs at cvs.gnupg.org Wed Nov 25 18:56:32 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 25 Nov 2009 18:56:32 +0100 Subject: [svn] dirmngr - r332 - trunk/src Message-ID: Author: marcus Date: 2009-11-25 18:56:31 +0100 (Wed, 25 Nov 2009) New Revision: 332 Modified: trunk/src/ChangeLog trunk/src/server.c Log: 2009-11-25 Marcus Brinkmann * server.c (start_command_handler): Use assuan_fd_t and assuan_fdopen on fds. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-17 13:46:52 UTC (rev 331) +++ trunk/src/ChangeLog 2009-11-25 17:56:31 UTC (rev 332) @@ -1,3 +1,8 @@ +2009-11-25 Marcus Brinkmann + + * server.c (start_command_handler): Use assuan_fd_t and + assuan_fdopen on fds. + 2009-11-05 Marcus Brinkmann * server.c (start_command_handler): Update use of Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2009-11-17 13:46:52 UTC (rev 331) +++ trunk/src/server.c 2009-11-25 17:56:31 UTC (rev 332) @@ -1361,10 +1361,10 @@ if (fd == ASSUAN_INVALID_FD) { - int filedes[2]; + assuan_fd_t filedes[2]; - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); rc = assuan_init_pipe_server (ctx, filedes); } else From cvs at cvs.gnupg.org Wed Nov 25 18:57:06 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 25 Nov 2009 18:57:06 +0100 Subject: [svn] gpgme - r1432 - trunk/src Message-ID: Author: marcus Date: 2009-11-25 18:57:05 +0100 (Wed, 25 Nov 2009) New Revision: 1432 Modified: trunk/src/ChangeLog trunk/src/gpgme-tool.c Log: 2009-11-25 Marcus Brinkmann * gpgme-tool.c (gpgme_server): Use assuan_fd_t and assuan_fdopen on fds. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-17 13:06:05 UTC (rev 1431) +++ trunk/src/ChangeLog 2009-11-25 17:57:05 UTC (rev 1432) @@ -1,3 +1,8 @@ +2009-11-25 Marcus Brinkmann + + * gpgme-tool.c (gpgme_server): Use assuan_fd_t and assuan_fdopen + on fds. + 2009-11-13 * sign.c (_gpgme_sign_status_handler): Handle SIG_CREATED_SEEN. Modified: trunk/src/gpgme-tool.c =================================================================== --- trunk/src/gpgme-tool.c 2009-11-17 13:06:05 UTC (rev 1431) +++ trunk/src/gpgme-tool.c 2009-11-25 17:57:05 UTC (rev 1432) @@ -2060,7 +2060,7 @@ gpgme_server (gpgme_tool_t gt) { gpg_error_t err; - int filedes[2]; + assuan_fd_t filedes[2]; struct server server; static const char hello[] = ("GPGME-Tool " VERSION " ready"); @@ -2079,8 +2079,8 @@ /* We use a pipe based server so that we can work from scripts. assuan_init_pipe_server will automagically detect when we are called with a socketpair and ignore FIELDES in this case. */ - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); err = assuan_new (&server.assuan_ctx); if (err) log_error (1, err, "can't create assuan context"); From cvs at cvs.gnupg.org Wed Nov 25 18:58:27 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 25 Nov 2009 18:58:27 +0100 Subject: [svn] GnuPG - r5200 - in trunk: agent g10 g13 scd sm Message-ID: Author: marcus Date: 2009-11-25 18:58:26 +0100 (Wed, 25 Nov 2009) New Revision: 5200 Modified: trunk/agent/ChangeLog trunk/agent/command.c trunk/g10/ChangeLog trunk/g10/server.c trunk/g13/server.c trunk/scd/ChangeLog trunk/scd/command.c trunk/sm/ChangeLog trunk/sm/server.c Log: agent/ 2009-11-25 Marcus Brinkmann * command.c (start_command_handler): Use assuan_fd_t and assuan_fdopen on fds. scd/ 2009-11-25 Marcus Brinkmann * command.c (scd_command_handler): Use assuan_fd_t and assuan_fdopen on fds. sm/ 2009-11-25 Marcus Brinkmann * server.c (gpgsm_server): Use assuan_fd_t and assuan_fdopen on fds. g10/ 2009-11-25 Marcus Brinkmann * server.c (gpg_server): Use assuan_fd_t and assuan_fdopen on fds. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/agent/ChangeLog 2009-11-25 17:58:26 UTC (rev 5200) @@ -1,3 +1,8 @@ +2009-11-25 Marcus Brinkmann + + * command.c (start_command_handler): Use assuan_fd_t and + assuan_fdopen on fds. + 2009-11-05 Marcus Brinkmann * call-pinentry.c (start_pinentry): Call assuan_pipe_connect, not Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/g10/ChangeLog 2009-11-25 17:58:26 UTC (rev 5200) @@ -1,3 +1,7 @@ +2009-11-25 Marcus Brinkmann + + * server.c (gpg_server): Use assuan_fd_t and assuan_fdopen on fds. + 2009-11-23 Werner Koch * gpg.c (gpgconf_list): Add key "default_pubkey_algo". Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/scd/ChangeLog 2009-11-25 17:58:26 UTC (rev 5200) @@ -1,3 +1,8 @@ +2009-11-25 Marcus Brinkmann + + * command.c (scd_command_handler): Use assuan_fd_t and + assuan_fdopen on fds. + 2009-11-05 Marcus Brinkmann * command.c (scd_command_handler): Call assuan_init_socket_server, Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/sm/ChangeLog 2009-11-25 17:58:26 UTC (rev 5200) @@ -1,3 +1,8 @@ +2009-11-25 Marcus Brinkmann + + * server.c (gpgsm_server): Use assuan_fd_t and assuan_fdopen on + fds. + 2009-11-23 Werner Koch * gpgsm.c (main) : Add key "default_pubkey_algo". Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/agent/command.c 2009-11-25 17:58:26 UTC (rev 5200) @@ -1916,10 +1916,10 @@ if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD) { - int filedes[2]; + assuan_fd_t filedes[2]; - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); rc = assuan_init_pipe_server (ctx, filedes); } else if (listen_fd != GNUPG_INVALID_FD) Modified: trunk/g10/server.c =================================================================== --- trunk/g10/server.c 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/g10/server.c 2009-11-25 17:58:26 UTC (rev 5200) @@ -658,8 +658,8 @@ /* We use a pipe based server so that we can work from scripts. assuan_init_pipe_server will automagically detect when we are called with a socketpair and ignore FILEDES in this case. */ - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); rc = assuan_new (&ctx); if (rc) { Modified: trunk/g13/server.c =================================================================== --- trunk/g13/server.c 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/g13/server.c 2009-11-25 17:58:26 UTC (rev 5200) @@ -574,7 +574,7 @@ g13_server (ctrl_t ctrl) { gpg_error_t err; - int filedes[2]; + assuan_fd_t filedes[2]; assuan_context_t ctx = NULL; static const char hello[] = ("GNU Privacy Guard's G13 server " PACKAGE_VERSION " ready"); @@ -582,8 +582,8 @@ /* We use a pipe based server so that we can work from scripts. assuan_init_pipe_server will automagically detect when we are called with a socketpair and ignore FIELDES in this case. */ - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); err = assuan_new (&ctx); if (err) { Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/scd/command.c 2009-11-25 17:58:26 UTC (rev 5200) @@ -1913,10 +1913,10 @@ if (fd == -1) { - int filedes[2]; + assuan_fd_t filedes[2]; - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); rc = assuan_init_pipe_server (ctx, filedes); } else Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2009-11-23 19:18:04 UTC (rev 5199) +++ trunk/sm/server.c 2009-11-25 17:58:26 UTC (rev 5200) @@ -1205,7 +1205,7 @@ gpgsm_server (certlist_t default_recplist) { int rc; - int filedes[2]; + assuan_fd_t filedes[2]; assuan_context_t ctx; struct server_control_s ctrl; static const char hello[] = ("GNU Privacy Guard's S/M server " @@ -1217,8 +1217,8 @@ /* We use a pipe based server so that we can work from scripts. assuan_init_pipe_server will automagically detect when we are called with a socketpair and ignore FIELDES in this case. */ - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = assuan_fdopen (0); + filedes[1] = assuan_fdopen (1); rc = assuan_new (&ctx); if (rc) { From cvs at cvs.gnupg.org Thu Nov 26 18:53:06 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Nov 2009 18:53:06 +0100 Subject: [svn] gpgme - r1433 - trunk/src Message-ID: Author: marcus Date: 2009-11-26 18:53:06 +0100 (Thu, 26 Nov 2009) New Revision: 1433 Modified: trunk/src/ChangeLog trunk/src/opassuan.c Log: 2009-11-26 Marcus Brinkmann * opassuan.c (opassuan_start): Allocate result structure before beginning operation. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-25 17:57:05 UTC (rev 1432) +++ trunk/src/ChangeLog 2009-11-26 17:53:06 UTC (rev 1433) @@ -1,3 +1,8 @@ +2009-11-26 Marcus Brinkmann + + * opassuan.c (opassuan_start): Allocate result structure before + beginning operation. + 2009-11-25 Marcus Brinkmann * gpgme-tool.c (gpgme_server): Use assuan_fd_t and assuan_fdopen Modified: trunk/src/opassuan.c =================================================================== --- trunk/src/opassuan.c 2009-11-25 17:57:05 UTC (rev 1432) +++ trunk/src/opassuan.c 2009-11-26 17:53:06 UTC (rev 1433) @@ -29,6 +29,14 @@ #include "util.h" #include "debug.h" +/* LEGACY: Remove this when removing the deprecated result + structure. */ +typedef struct +{ + struct _gpgme_op_assuan_result result; +} *op_data_t; + + static gpgme_error_t opassuan_start (gpgme_ctx_t ctx, int synchronous, const char *command, @@ -50,6 +58,17 @@ if (err) return err; + { + /* LEGACY: Remove this when removing the deprecated result + structure. */ + void *hook; + op_data_t opd; + err = _gpgme_op_data_lookup (ctx, OPDATA_ASSUAN, &hook, + sizeof (*opd), NULL); + if (err) + return err; + } + return _gpgme_engine_op_assuan_transact (ctx->engine, command, data_cb, data_cb_value, inq_cb, inq_cb_value, @@ -138,11 +157,6 @@ void *engine; }; -typedef struct -{ - struct _gpgme_op_assuan_result result; -} *op_data_t; - gpg_error_t _gpgme_engine_assuan_last_op_err (void *engine); gpgme_assuan_result_t From cvs at cvs.gnupg.org Fri Nov 27 18:06:07 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 27 Nov 2009 18:06:07 +0100 Subject: [svn] GpgOL - r322 - in trunk: doc src Message-ID: Author: wk Date: 2009-11-27 18:06:07 +0100 (Fri, 27 Nov 2009) New Revision: 322 Modified: trunk/doc/gpgol.texi trunk/src/ChangeLog trunk/src/common.h trunk/src/eventsink.h trunk/src/ext-commands.cpp trunk/src/inspectors.cpp trunk/src/inspectors.h trunk/src/main.c trunk/src/message-events.cpp trunk/src/oomhelp.h Log: It seems that I solved the probelm with sending message in OL2007. The solution was to find the corresponding inspector via the window handles. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/ChangeLog 2009-11-27 17:06:07 UTC (rev 322) @@ -1,3 +1,20 @@ +2009-11-27 Werner Koch + + * message-events.cpp (get_crypto_flags): Replace EECB arg by HWND. + (OnRead): Pass HWND to get_crypto_flags. Change all callers. + (get_inspector): Remove. + (get_crypto_flags, OnReadComplete): Use get_inspector_from_hwnd. + + * oomhelp.h (IID_IOleWindow): Define. + * inspectors.cpp (find_ole_window): New. + (struct inspector_info_s): Add field HWND. + (register_inspector): Store it.. + (get_inspector_from_hwnd): New. + + * common.h (DBG_OOM_EXTRA): New. + * main.c (read_options): Read new debug flag. + * eventsink.h (debug_oom_extra): Use it. + 2009-11-03 Werner Koch * inspectors.cpp (deregister_inspector): Delete the buttons. Modified: trunk/doc/gpgol.texi =================================================================== --- trunk/doc/gpgol.texi 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/doc/gpgol.texi 2009-11-27 17:06:07 UTC (rev 322) @@ -310,7 +310,9 @@ @item 256 (0x0100) (mime-data) Print data lines while parsing MIME. @item 512 (0x0200) (oom) -Verbose object allocation reporting. +Outlook Object Model reporting. + at item 1024 (0x0400) (oom-extra) +Verbose OOM allocation and advising reporting. @end table You may use the regular C-syntax for entering the value. As an alternative you may use the names of the flags, separated by space or Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/common.h 2009-11-27 17:06:07 UTC (rev 322) @@ -170,6 +170,7 @@ #define DBG_MIME_PARSER (1<<7) #define DBG_MIME_DATA (1<<8) #define DBG_OOM (1<<9) +#define DBG_OOM_EXTRA (1<<10) /* Macros to used in conditionals to enable debug output. */ #define debug_commands (opt.enable_debug & DBG_COMMANDS) Modified: trunk/src/eventsink.h =================================================================== --- trunk/src/eventsink.h 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/eventsink.h 2009-11-27 17:06:07 UTC (rev 322) @@ -25,6 +25,7 @@ #define EVENTSINK_H #define debug_oom (opt.enable_debug & DBG_OOM) +#define debug_oom_extra (opt.enable_debug & DBG_OOM_EXTRA) #define BEGIN_EVENT_SINK(subcls,parentcls) \ @@ -43,7 +44,7 @@ inline STDMETHODIMP_(ULONG) AddRef (void) \ { \ ++m_ref; \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:" #subcls ":%s: m_ref now %lu", \ SRCNAME,__func__, m_ref); \ return m_ref; \ @@ -51,7 +52,7 @@ inline STDMETHODIMP_(ULONG) Release (void) \ { \ ULONG count = --m_ref; \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:" #subcls ":%s: mref now %lu", \ SRCNAME,__func__,count); \ if (!count) \ @@ -200,7 +201,7 @@ HRESULT hr; \ subcls *sink; \ \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:%s:%s: Called", SRCNAME, #subcls, __func__); \ hr = obj->QueryInterface (iidcls, (void**)&sink); \ if (hr != S_OK || !sink) \ @@ -211,13 +212,13 @@ } \ if (sink->m_pCP) \ { \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:%s:%s: Unadvising", SRCNAME, #subcls, __func__); \ hr = sink->m_pCP->Unadvise (sink->m_cookie); \ if (hr != S_OK) \ log_error ("%s:%s:%s: Unadvice failed: hr=%#lx", \ SRCNAME, #subcls, __func__, hr); \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:%s:%s: Releasing connt point", \ SRCNAME, #subcls, __func__); \ sink->m_pCP->Release (); \ @@ -225,7 +226,7 @@ } \ if (sink->m_object) \ { \ - if (debug_oom) \ + if (debug_oom_extra) \ log_debug ("%s:%s:%s: Releasing actual object", \ SRCNAME, #subcls, __func__); \ sink->m_object->Release (); \ Modified: trunk/src/ext-commands.cpp =================================================================== --- trunk/src/ext-commands.cpp 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/ext-commands.cpp 2009-11-27 17:06:07 UTC (rev 322) @@ -116,7 +116,13 @@ if (obj) { /* This should be MailItem; use the getInspector method. */ - inspector = get_oom_object (obj, "GetInspector"); + //inspector = get_oom_object (obj, "GetInspector"); + char *tmp = get_object_name (obj); + + log_debug ("%s:%s: object is at %p (%s)", + SRCNAME, __func__, obj, tmp? tmp:""); + xfree (tmp); + obj->Release (); } return inspector; Modified: trunk/src/inspectors.cpp =================================================================== --- trunk/src/inspectors.cpp 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/inspectors.cpp 2009-11-27 17:06:07 UTC (rev 322) @@ -134,6 +134,9 @@ /* The inspector object. */ LPOOMINSPECTOR inspector; + /* The Window handle of the inspector. */ + HWND hwnd; + /* A list of all the buttons. */ button_list_t buttons; @@ -223,14 +226,45 @@ } +static HWND +find_ole_window (LPOOMINSPECTOR inspector) +{ + HRESULT hr; + LPOLEWINDOW olewndw = NULL; + HWND hwnd = NULL; + + hr = inspector->QueryInterface (IID_IOleWindow, (void**)&olewndw); + if (hr != S_OK || !olewndw) + { + log_error ("%s:%s: IOleWindow not found: hr=%#lx", SRCNAME, __func__, hr); + return NULL; + } + + hr = olewndw->GetWindow (&hwnd); + if (hr != S_OK || !hwnd) + { + log_error ("%s:%s: IOleWindow->GetWindow failed: hr=%#lx", + SRCNAME, __func__, hr); + hwnd = NULL; + } + olewndw->Release (); + log_debug ("%s:%s: inspector %p has hwnd=%p", + SRCNAME, __func__, inspector, hwnd); + return hwnd; +} + + + /* Register the inspector object INSPECTOR with its event SINK. */ static void register_inspector (LPGPGOLINSPECTOREVENTS sink, LPOOMINSPECTOR inspector) { inspector_info_t item; + HWND hwnd; log_debug ("%s:%s: Called (sink=%p, inspector=%p)", SRCNAME, __func__, sink, inspector); + hwnd = find_ole_window (inspector); item = (inspector_info_t)xcalloc (1, sizeof *item); lock_all_inspectors (); @@ -240,6 +274,8 @@ inspector->AddRef (); item->inspector = inspector; + item->hwnd = hwnd; + item->next = all_inspectors; all_inspectors = item; @@ -379,6 +415,30 @@ } +/* Search through all objects and find the inspector which has a + the window handle HWND. Returns NULL if not found. */ +LPDISPATCH +get_inspector_from_hwnd (HWND hwnd) +{ + LPDISPATCH result = NULL; + inspector_info_t iinfo; + + lock_all_inspectors (); + + for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next) + if (iinfo->hwnd == hwnd) + { + result = iinfo->inspector; + if (result) + result->AddRef (); + break; + } + + unlock_all_inspectors (); + return result; +} + + /* The method called by outlook for each new inspector. Note that Outlook sometimes reuses Inspectro objects thus this event is not an indication for a newly opened Inspector. */ @@ -424,9 +484,10 @@ GpgolInspectorEvents::Activate (void) { LPOOMINSPECTOR inspector; - LPDISPATCH obj, obj2; + LPDISPATCH obj; - log_debug ("%s:%s: Called (this=%p)", SRCNAME, __func__, this); + log_debug ("%s:%s: Called (this=%p, inspector=%p)", + SRCNAME, __func__, this, m_object); /* Note: It is easier to use the registered inspector object than to find the inspector object in the ALL_INSPECTORS list. The @@ -451,9 +512,9 @@ obj = get_oom_object (inspector, "get_CurrentItem"); if (obj) { - obj2 = install_GpgolItemEvents_sink (obj); - if (obj2) - obj2->Release (); + // LPDISPATCH obj2 = install_GpgolItemEvents_sink (obj); + // if (obj2) + // obj2->Release (); obj->Release (); } } Modified: trunk/src/inspectors.h =================================================================== --- trunk/src/inspectors.h 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/inspectors.h 2009-11-27 17:06:07 UTC (rev 322) @@ -134,6 +134,7 @@ bool sign, bool encrypt); +LPDISPATCH get_inspector_from_hwnd (HWND hwnd); #endif /*INSPECTORS_H*/ Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/main.c 2009-11-27 17:06:07 UTC (rev 322) @@ -561,6 +561,8 @@ opt.enable_debug |= DBG_MIME_DATA; else if (!strcmp (p, "oom")) opt.enable_debug |= DBG_OOM; + else if (!strcmp (p, "oom-extra")) + opt.enable_debug |= DBG_OOM_EXTRA; else log_debug ("invalid debug flag `%s' ignored", p); } @@ -574,7 +576,7 @@ } xfree (val); val = NULL; if (opt.enable_debug) - log_debug ("enabled debug flags:%s%s%s%s%s%s%s%s%s\n", + log_debug ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s\n", (opt.enable_debug & DBG_IOWORKER)? " ioworker":"", (opt.enable_debug & DBG_IOWORKER_EXTRA)? " ioworker-extra":"", (opt.enable_debug & DBG_FILTER)? " filter":"", @@ -583,7 +585,8 @@ (opt.enable_debug & DBG_COMMANDS)? " commands":"", (opt.enable_debug & DBG_MIME_PARSER)? " mime-parser":"", (opt.enable_debug & DBG_MIME_DATA)? " mime-data":"", - (opt.enable_debug & DBG_OOM)? " oom":"" + (opt.enable_debug & DBG_OOM)? " oom":"", + (opt.enable_debug & DBG_OOM_EXTRA)? " oom-extra":"" ); Modified: trunk/src/message-events.cpp =================================================================== --- trunk/src/message-events.cpp 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/message-events.cpp 2009-11-27 17:06:07 UTC (rev 322) @@ -99,33 +99,13 @@ } -/* Return the inspector the the current Mailitem. If the inspector - does not exists, an inspector object is created (but not - immediatley shown). */ -static LPDISPATCH -get_inspector (LPEXCHEXTCALLBACK eecb) -{ - LPDISPATCH obj; - LPDISPATCH inspector = NULL; - - obj = get_eecb_object (eecb); - if (obj) - { - /* This should be MailItem; use the getInspector method. */ - inspector = get_oom_object (obj, "GetInspector"); - obj->Release (); - } - return inspector; -} - - static int -get_crypto_flags (LPEXCHEXTCALLBACK eecb, bool *r_sign, bool *r_encrypt) +get_crypto_flags (HWND hwnd, bool *r_sign, bool *r_encrypt) { LPDISPATCH inspector; int rc; - inspector = get_inspector (eecb); + inspector = get_inspector_from_hwnd (hwnd); if (!inspector) { log_error ("%s:%s: inspector not found", SRCNAME, __func__); @@ -223,7 +203,7 @@ SRCNAME, __func__, hr); else { - LPDISPATCH inspector = get_inspector (eecb); + LPDISPATCH inspector = get_inspector_from_hwnd (hwnd); message_display_handler (message, inspector, hwnd); if (inspector) inspector->Release (); @@ -246,48 +226,48 @@ GpgolMessageEvents::OnWrite (LPEXCHEXTCALLBACK eecb) { LPDISPATCH obj; - HWND hWnd = NULL; + HWND hwnd = NULL; bool sign, encrypt, need_crypto; int bodyfmt; - log_debug ("%s:%s: received\n", SRCNAME, __func__); + if (FAILED (eecb->GetWindow (&hwnd))) + hwnd = NULL; + log_debug ("%s:%s: received (hwnd=%p)", SRCNAME, __func__, hwnd); - // need_crypto = (!get_crypto_flags (eecb, &sign, &encrypt) - // && (sign || encrypt)); + need_crypto = (!get_crypto_flags (hwnd, &sign, &encrypt) + && (sign || encrypt)); - // /* If we are going to encrypt, check that the BodyFormat is - // something we support. This helps avoiding surprise by sending - // out unencrypted messages. */ - // if (need_crypto && !opt.disable_gpgol) - // { - // obj = get_eecb_object (eecb); - // if (!obj) - // bodyfmt = -1; - // else - // { - // bodyfmt = get_oom_int (obj, "BodyFormat"); - // obj->Release (); - // } + /* If we are going to encrypt, check that the BodyFormat is + something we support. This helps avoiding surprise by sending + out unencrypted messages. */ + if (need_crypto && !opt.disable_gpgol) + { + obj = get_eecb_object (eecb); + if (!obj) + bodyfmt = -1; + else + { + bodyfmt = get_oom_int (obj, "BodyFormat"); + obj->Release (); + } - // if (bodyfmt == 1) - // m_want_html = 0; - // else if (bodyfmt == 2) - // m_want_html = 1; - // else - // { - // log_debug ("%s:%s: BodyFormat is %d", SRCNAME, __func__, bodyfmt); - // if (FAILED(eecb->GetWindow (&hWnd))) - // hWnd = NULL; - // MessageBox (hWnd, - // _("Sorry, we can only encrypt plain text messages and\n" - // "no RTF messages. Please make sure that only the text\n" - // "format has been selected."), - // "GpgOL", MB_ICONERROR|MB_OK); + if (bodyfmt == 1) + m_want_html = 0; + else if (bodyfmt == 2) + m_want_html = 1; + else + { + log_debug ("%s:%s: BodyFormat is %d", SRCNAME, __func__, bodyfmt); + MessageBox (hwnd, + _("Sorry, we can only encrypt plain text messages and\n" + "no RTF messages. Please make sure that only the text\n" + "format has been selected."), + "GpgOL", MB_ICONERROR|MB_OK); - // m_bWriteFailed = TRUE; - // return E_FAIL; - // } - // } + m_bWriteFailed = TRUE; + return E_FAIL; + } + } return S_FALSE; @@ -310,64 +290,63 @@ HRESULT hrReturn = S_FALSE; LPMESSAGE msg = NULL; LPMDB pMDB = NULL; - HWND hWnd = NULL; + HWND hwnd = NULL; int rc; - log_debug ("%s:%s: received\n", SRCNAME, __func__); + if (FAILED(eecb->GetWindow (&hwnd))) + hwnd = NULL; + log_debug ("%s:%s: received (hwnd=%p)", SRCNAME, __func__, hwnd); - // if (flags & (EEME_FAILED|EEME_COMPLETE_FAILED)) - // return S_FALSE; /* We don't need to rollback anything in case - // other extensions flagged a failure. */ + if (flags & (EEME_FAILED|EEME_COMPLETE_FAILED)) + return S_FALSE; /* We don't need to rollback anything in case + other extensions flagged a failure. */ - // if (opt.disable_gpgol) - // return S_FALSE; + if (opt.disable_gpgol) + return S_FALSE; - // if (!m_bOnSubmitActive) /* The user is just saving the message. */ - // return S_FALSE; + if (!m_bOnSubmitActive) /* The user is just saving the message. */ + return S_FALSE; - // if (m_bWriteFailed) /* Operation failed already. */ - // return S_FALSE; + if (m_bWriteFailed) /* Operation failed already. */ + return S_FALSE; - // /* Try to get the current window. */ - // if (FAILED(eecb->GetWindow (&hWnd))) - // hWnd = NULL; - // /* Get the object and call the encryption or signing function. */ - // HRESULT hr = eecb->GetObject (&pMDB, (LPMAPIPROP *)&msg); - // if (SUCCEEDED (hr)) - // { - // protocol_t proto = PROTOCOL_UNKNOWN; /* Let the UI server select - // the protocol. */ - // bool sign, encrypt; + /* Get the object and call the encryption or signing function. */ + HRESULT hr = eecb->GetObject (&pMDB, (LPMAPIPROP *)&msg); + if (SUCCEEDED (hr)) + { + protocol_t proto = PROTOCOL_UNKNOWN; /* Let the UI server select + the protocol. */ + bool sign, encrypt; - // if (get_crypto_flags (eecb, &sign, &encrypt)) - // rc = -1; - // else if (encrypt && sign) - // rc = message_sign_encrypt (msg, proto, hWnd); - // else if (encrypt && !sign) - // rc = message_encrypt (msg, proto, hWnd); - // else if (!encrypt && sign) - // rc = message_sign (msg, proto, hWnd); - // else - // { - // /* In case this is a forward message which is not to be - // signed or encrypted we need to remove a possible body - // attachment. */ - // if (mapi_delete_gpgol_body_attachment (msg)) - // mapi_save_changes (msg, KEEP_OPEN_READWRITE); - // rc = 0; - // } + if (get_crypto_flags (hwnd, &sign, &encrypt)) + rc = -1; + else if (encrypt && sign) + rc = message_sign_encrypt (msg, proto, hwnd); + else if (encrypt && !sign) + rc = message_encrypt (msg, proto, hwnd); + else if (!encrypt && sign) + rc = message_sign (msg, proto, hwnd); + else + { + /* In case this is a forward message which is not to be + signed or encrypted we need to remove a possible body + attachment. */ + if (mapi_delete_gpgol_body_attachment (msg)) + mapi_save_changes (msg, KEEP_OPEN_READWRITE); + rc = 0; + } - // if (rc) - // { - // hrReturn = E_FAIL; - // m_bWriteFailed = TRUE; - // } - // } + if (rc) + { + hrReturn = E_FAIL; + m_bWriteFailed = TRUE; + } + } - // ul_release (msg, __func__, __LINE__); - // ul_release (pMDB, __func__, __LINE__); + ul_release (msg, __func__, __LINE__); + ul_release (pMDB, __func__, __LINE__); return hrReturn; } Modified: trunk/src/oomhelp.h =================================================================== --- trunk/src/oomhelp.h 2009-11-20 12:10:42 UTC (rev 321) +++ trunk/src/oomhelp.h 2009-11-27 17:06:07 UTC (rev 322) @@ -63,6 +63,7 @@ DEFINE_OLEGUID(IID_IUnknown, 0x00000000, 0, 0); DEFINE_OLEGUID(IID_IDispatch, 0x00020400, 0, 0); +DEFINE_OLEGUID(IID_IOleWindow, 0x00000114, 0, 0); #ifdef __cplusplus From cvs at cvs.gnupg.org Fri Nov 27 20:12:01 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 27 Nov 2009 20:12:01 +0100 Subject: [svn] assuan - r323 - trunk/src Message-ID: Author: marcus Date: 2009-11-27 20:12:01 +0100 (Fri, 27 Nov 2009) New Revision: 323 Modified: trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-listen.c trunk/src/assuan-logging.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan.h trunk/src/context.c trunk/src/libassuan.def trunk/src/libassuan.vers trunk/src/system.c Log: 2009-11-27 Marcus Brinkmann * assuan.h (assuan_set_assuan_log_stream): Add prototype. * libassuan.def, libassuan.vers: Add back assuan_set_assuan_log_stream. * assuan-logging.c (assuan_set_assuan_log_stream): Add back. * context.c (assuan_get_pointer): Don't output debug info here. (assuan_get_peercred, assuan_get_pid): But do here. * system.c: Improve debug output. * assuan-defs.h (struct assuan_context_s): Rename pipe_mode to max_accepts. * assuan-listen.c (assuan_accept): Rework max accepts logic. * assuan-socket-server.c (assuan_init_socket_server), assuan-socket-connect.c (assuan_socket_connect), assuan-pipe-server.c (assuan_init_pipe_server), assuan-pipe-connect.c (socketpair_connect): Add debug output, set max_accepts instead of pipe_mode. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/ChangeLog 2009-11-27 19:12:01 UTC (rev 323) @@ -1,3 +1,21 @@ +2009-11-27 Marcus Brinkmann + + * assuan.h (assuan_set_assuan_log_stream): Add prototype. + * libassuan.def, libassuan.vers: Add back + assuan_set_assuan_log_stream. + * assuan-logging.c (assuan_set_assuan_log_stream): Add back. + * context.c (assuan_get_pointer): Don't output debug info here. + (assuan_get_peercred, assuan_get_pid): But do here. + * system.c: Improve debug output. + * assuan-defs.h (struct assuan_context_s): Rename pipe_mode to + max_accepts. + * assuan-listen.c (assuan_accept): Rework max accepts logic. + * assuan-socket-server.c (assuan_init_socket_server), + assuan-socket-connect.c (assuan_socket_connect), + assuan-pipe-server.c (assuan_init_pipe_server), + assuan-pipe-connect.c (socketpair_connect): Add debug output, set + max_accepts instead of pipe_mode. + 2009-11-25 Marcus Brinkmann * assuan.h (assuan_init_pipe_server): Change type of filedes to Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-defs.h 2009-11-27 19:12:01 UTC (rev 323) @@ -164,8 +164,8 @@ } data; } outbound; - int pipe_mode; /* We are in pipe mode, i.e. we can handle just one - connection and must terminate then. */ + int max_accepts; /* If we can not handle more than one connection, + set this to 1, otherwise to -1. */ pid_t pid; /* The pid of the peer. */ assuan_fd_t listen_fd; /* The fd we are listening on (used by socket servers) */ Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-listen.c 2009-11-27 19:12:01 UTC (rev 323) @@ -78,12 +78,16 @@ if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); - if (ctx->pipe_mode > 1) - return -1; /* second invocation for pipemode -> terminate */ - if (! ctx->pipe_mode) + if (ctx->max_accepts != -1) { + if (ctx->max_accepts-- == 0) + return -1; /* second invocation for pipemode -> terminate */ + } + if (ctx->accept_handler) + { + /* FIXME: This should be superfluous, if everything else is + correct. */ ctx->finish_handler (ctx); - rc = ctx->accept_handler (ctx); if (rc) return rc; @@ -111,10 +115,7 @@ rc = assuan_write_line (ctx, "OK Pleased to meet you"); if (rc) return rc; - - if (ctx->pipe_mode) - ctx->pipe_mode = 2; - + return 0; } Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-logging.c 2009-11-27 19:12:01 UTC (rev 323) @@ -45,6 +45,16 @@ static int full_logging; +static FILE *_assuan_log; + +void +assuan_set_assuan_log_stream (FILE *fp) +{ + _assuan_log = fp; + full_logging = !!getenv ("ASSUAN_FULL_LOGGING"); +} + + /* Set the per context log stream. Also enable the default log stream if it has not been set. */ void @@ -96,7 +106,7 @@ if (msg == NULL) return 1; - fp = ctx->log_fp; + fp = ctx->log_fp ? ctx->log_fp : _assuan_log; if (!fp) return 0; Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-pipe-connect.c 2009-11-27 19:12:01 UTC (rev 323) @@ -196,7 +196,8 @@ ctx->engine.sendfd = NULL; ctx->engine.receivefd = NULL; ctx->finish_handler = _assuan_client_finish; - ctx->pipe_mode = 1; + ctx->max_accepts = 1; + ctx->accept_handler = NULL; ctx->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ ctx->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ ctx->pid = pid; @@ -341,7 +342,7 @@ ctx->engine.release = _assuan_client_release; ctx->finish_handler = _assuan_client_finish; - ctx->pipe_mode = 1; + ctx->max_accepts = 1; ctx->inbound.fd = fds[0]; ctx->outbound.fd = fds[0]; _assuan_init_uds_io (ctx); @@ -390,8 +391,8 @@ void (*atfork) (void *opaque, int reserved), void *atforkvalue, unsigned int flags) { - TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect_ext", ctx, - "name=%s,flags=0x%x", name ? name : "(null)", flags); + TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_pipe_connect", ctx, + "name=%s, flags=0x%x", name ? name : "(null)", flags); if (flags & ASSUAN_PIPE_CONNECT_FDPASSING) { Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-pipe-server.c 2009-11-27 19:12:01 UTC (rev 323) @@ -32,8 +32,8 @@ #endif #include "assuan-defs.h" +#include "debug.h" - /* Returns true if atoi(S) denotes a valid socket. */ #ifndef HAVE_W32_SYSTEM static int @@ -59,10 +59,12 @@ assuan_fd_t infd = ASSUAN_INVALID_FD; assuan_fd_t outfd = ASSUAN_INVALID_FD; int is_usd = 0; + TRACE_BEG2 (ctx, ASSUAN_LOG_CTX, "assuan_init_pipe_server", ctx, + "fd[0]=0x%x, fd[1]=0x%x", filedes[0], filedes[1]); rc = _assuan_register_std_commands (ctx); if (rc) - return rc; + return TRACE_ERR (rc); #ifdef HAVE_W32_SYSTEM infd = filedes[0]; @@ -87,7 +89,10 @@ outfd = filedes[1]; } else - return _assuan_error (ctx, GPG_ERR_ASS_SERVER_START); + { + rc = _assuan_error (ctx, GPG_ERR_ASS_SERVER_START); + return TRACE_ERR (rc); + } #endif ctx->is_server = 1; @@ -96,7 +101,7 @@ ctx->engine.writefnc = _assuan_simple_write; ctx->engine.sendfd = NULL; ctx->engine.receivefd = NULL; - ctx->pipe_mode = 1; + ctx->max_accepts = 1; s = getenv ("_assuan_pipe_connect_pid"); if (s && (ul=strtoul (s, NULL, 10)) && ul) @@ -111,5 +116,5 @@ if (is_usd) _assuan_init_uds_io (ctx); - return 0; + return TRACE_SUC(); } Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-socket-connect.c 2009-11-27 19:12:01 UTC (rev 323) @@ -67,6 +67,8 @@ size_t len; const char *s; + TRACE2 (ctx, ASSUAN_LOG_CTX, "assuan_socket_connect", ctx, + "name=%s, flags=0x%x", name ? name : "(null)", flags); if (!ctx || !name) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); @@ -115,6 +117,7 @@ ctx->finish_handler = _assuan_client_finish; ctx->inbound.fd = fd; ctx->outbound.fd = fd; + ctx->max_accepts = -1; if (flags & ASSUAN_SOCKET_CONNECT_FDPASSING) _assuan_init_uds_io (ctx); Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan-socket-server.c 2009-11-27 19:12:01 UTC (rev 323) @@ -38,7 +38,7 @@ # include #endif - +#include "debug.h" #include "assuan-defs.h" static gpg_error_t @@ -116,10 +116,12 @@ unsigned int flags) { gpg_error_t rc; - + TRACE_BEG2 (ctx, ASSUAN_LOG_CTX, "assuan_init_socket_server", ctx, + "fd=0x%x, flags=0x%x", fd, flags); + rc = _assuan_register_std_commands (ctx); if (rc) - return rc; + return TRACE_ERR (rc); ctx->engine.release = _assuan_server_release; ctx->engine.readfnc = _assuan_simple_read; @@ -128,7 +130,10 @@ ctx->engine.receivefd = NULL; ctx->is_server = 1; if (flags & ASSUAN_SOCKET_SERVER_ACCEPTED) - ctx->pipe_mode = 1; /* We want a second accept to indicate EOF. */ + /* We want a second accept to indicate EOF. */ + ctx->max_accepts = 1; + else + ctx->max_accepts = -1; ctx->input_fd = ASSUAN_INVALID_FD; ctx->output_fd = ASSUAN_INVALID_FD; @@ -156,7 +161,7 @@ rc = _assuan_register_std_commands (ctx); if (rc) _assuan_reset (ctx); - return rc; + return TRACE_ERR (rc); } Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/assuan.h 2009-11-27 19:12:01 UTC (rev 323) @@ -298,6 +298,9 @@ string, i.e. "" */ const char *assuan_get_assuan_log_prefix (void); +/* Global default log stream. */ +void assuan_set_assuan_log_stream (FILE *fp); + /* Set the per context log stream for the default log handler. */ void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); Modified: trunk/src/context.c =================================================================== --- trunk/src/context.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/context.c 2009-11-27 19:12:01 UTC (rev 323) @@ -42,8 +42,11 @@ void * assuan_get_pointer (assuan_context_t ctx) { +#if 0 + /* This is called often. */ TRACE1 (ctx, ASSUAN_LOG_CTX, "assuan_get_pointer", ctx, "ctx->user_pointer=%p", ctx ? ctx->user_pointer : NULL); +#endif if (! ctx) return NULL; @@ -177,6 +180,9 @@ pid_t assuan_get_pid (assuan_context_t ctx) { + TRACE1 (ctx, ASSUAN_LOG_CTX, "assuan_get_pid", ctx, + "pid=%i", ctx ? ctx->pid : -1); + return (ctx && ctx->pid) ? ctx->pid : ASSUAN_INVALID_PID; } @@ -186,6 +192,8 @@ gpg_error_t assuan_get_peercred (assuan_context_t ctx, assuan_peercred_t *peercred) { + TRACE (ctx, ASSUAN_LOG_CTX, "assuan_get_peercred", ctx); + if (!ctx) return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); if (!ctx->peercred_valid) Modified: trunk/src/libassuan.def =================================================================== --- trunk/src/libassuan.def 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/libassuan.def 2009-11-27 19:12:01 UTC (rev 323) @@ -64,35 +64,36 @@ assuan_send_data @43 assuan_sendfd @44 assuan_set_assuan_log_prefix @45 - assuan_set_error @46 - assuan_set_flag @47 - assuan_set_gpg_err_source @48 - assuan_set_hello_line @49 - assuan_set_io_monitor @50 - assuan_set_log_cb @51 - assuan_set_log_stream @52 - assuan_set_malloc_hooks @53 - assuan_set_okay_line @54 - assuan_set_pointer @55 - assuan_set_system_hooks @56 - assuan_sock_bind @57 - assuan_sock_check_nonce @58 - assuan_sock_close @59 - assuan_sock_connect @60 - assuan_sock_deinit @61 - assuan_sock_get_nonce @62 - assuan_sock_init @63 - assuan_sock_new @64 - assuan_socket_connect @65 - assuan_transact @66 - assuan_write_line @67 - assuan_write_status @68 - __assuan_close @69 - __assuan_pipe @70 - __assuan_socketpair @71 - __assuan_spawn @72 - __assuan_usleep @73 - assuan_fdopen @74 + assuan_set_assuan_log_stream @46 + assuan_set_error @47 + assuan_set_flag @48 + assuan_set_gpg_err_source @49 + assuan_set_hello_line @50 + assuan_set_io_monitor @51 + assuan_set_log_cb @52 + assuan_set_log_stream @53 + assuan_set_malloc_hooks @54 + assuan_set_okay_line @55 + assuan_set_pointer @56 + assuan_set_system_hooks @57 + assuan_sock_bind @58 + assuan_sock_check_nonce @59 + assuan_sock_close @60 + assuan_sock_connect @61 + assuan_sock_deinit @62 + assuan_sock_get_nonce @63 + assuan_sock_init @64 + assuan_sock_new @65 + assuan_socket_connect @66 + assuan_transact @67 + assuan_write_line @68 + assuan_write_status @69 + __assuan_close @70 + __assuan_pipe @71 + __assuan_socketpair @72 + __assuan_spawn @73 + __assuan_usleep @74 + assuan_fdopen @75 ; END Modified: trunk/src/libassuan.vers =================================================================== --- trunk/src/libassuan.vers 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/libassuan.vers 2009-11-27 19:12:01 UTC (rev 323) @@ -70,6 +70,7 @@ assuan_send_data; assuan_sendfd; assuan_set_assuan_log_prefix; + assuan_set_assuan_log_stream; assuan_set_error; assuan_set_flag; assuan_set_gpg_err_source; Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2009-11-25 17:55:26 UTC (rev 322) +++ trunk/src/system.c 2009-11-27 19:12:01 UTC (rev 323) @@ -192,9 +192,6 @@ HANDLE wh; HANDLE th; SECURITY_ATTRIBUTES sec_attr; - TRACE_BEG2 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx, - "inherit_idx=%i (Assuan uses it for %s)", - inherit_idx, inherit_idx ? "reading" : "writing"); memset (&sec_attr, 0, sizeof (sec_attr)); sec_attr.nLength = sizeof (sec_attr); @@ -202,20 +199,22 @@ if (! CreatePipe (&rh, &wh, &sec_attr, 0)) { - TRACE_LOG1 ("CreatePipe failed: %s", _assuan_w32_strerror (ctx, -1)); + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx, + "CreatePipe failed: %s", _assuan_w32_strerror (ctx, -1)); errno = EIO; - return TRACE_SYSRES (-1); + return -1; } if (! DuplicateHandle (GetCurrentProcess(), (inherit_idx == 0) ? rh : wh, GetCurrentProcess(), &th, 0, TRUE, DUPLICATE_SAME_ACCESS )) { - TRACE_LOG1 ("DuplicateHandle failed: %s", _assuan_w32_strerror (ctx, -1)); + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "__assuan_pipe", ctx, + "DuplicateHandle failed: %s", _assuan_w32_strerror (ctx, -1)); CloseHandle (rh); CloseHandle (wh); errno = EIO; - return TRACE_SYSRES (-1); + return -1; } if (inherit_idx == 0) { @@ -231,7 +230,7 @@ fd[0] = rh; fd[1] = wh; - return TRACE_SUC (); + return 0; #else return pipe (fd); #endif @@ -242,7 +241,16 @@ int _assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx) { - return (ctx->system.pipe) (ctx, fd, inherit_idx); + int err; + TRACE_BEG2 (ctx, ASSUAN_LOG_SYSIO, "_assuan_pipe", ctx, + "inherit_idx=%i (Assuan uses it for %s)", + inherit_idx, inherit_idx ? "reading" : "writing"); + + err = (ctx->system.pipe) (ctx, fd, inherit_idx); + if (err) + return TRACE_SYSRES (err); + + return TRACE_SUC2 ("read=0x%x, write=0x%x", fd[0], fd[1]); } @@ -341,7 +349,15 @@ ssize_t _assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) { +#if 0 + ssize_t res; + TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_read", ctx, + "fd=0x%x, buffer=%p, size=%i", fd, buffer, size); + res = (ctx->system.read) (ctx, fd, buffer, size); + return TRACE_SYSRES (res); +#else return (ctx->system.read) (ctx, fd, buffer, size); +#endif } @@ -390,7 +406,15 @@ _assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) { +#if 0 + ssize_t res; + TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_write", ctx, + "fd=0x%x, buffer=%p, size=%i", fd, buffer, size); + res = (ctx->system.write) (ctx, fd, buffer, size); + return TRACE_SYSRES (res); +#else return (ctx->system.write) (ctx, fd, buffer, size); +#endif } From cvs at cvs.gnupg.org Fri Nov 27 20:13:02 2009 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 27 Nov 2009 20:13:02 +0100 Subject: [svn] GnuPG - r5201 - trunk/agent Message-ID: Author: marcus Date: 2009-11-27 20:13:02 +0100 (Fri, 27 Nov 2009) New Revision: 5201 Modified: trunk/agent/ChangeLog trunk/agent/command.c trunk/agent/gpg-agent.c Log: 2009-11-27 Marcus Brinkmann * command.c (start_command_handler): Do not call assuan_set_log_stream anymore. * gpg-agent.c (main): But call assuan_set_assuan_log_stream here. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2009-11-25 17:58:26 UTC (rev 5200) +++ trunk/agent/ChangeLog 2009-11-27 19:13:02 UTC (rev 5201) @@ -1,3 +1,9 @@ +2009-11-27 Marcus Brinkmann + + * command.c (start_command_handler): Do not call + assuan_set_log_stream anymore. + * gpg-agent.c (main): But call assuan_set_assuan_log_stream here. + 2009-11-25 Marcus Brinkmann * command.c (start_command_handler): Use assuan_fd_t and Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2009-11-25 17:58:26 UTC (rev 5200) +++ trunk/agent/command.c 2009-11-27 19:13:02 UTC (rev 5201) @@ -1953,9 +1953,6 @@ ctrl->server_local->use_cache_for_signing = 1; ctrl->digest.raw_value = 0; - if (DBG_ASSUAN) - assuan_set_log_stream (ctx, log_get_stream ()); - assuan_set_io_monitor (ctx, io_monitor, NULL); for (;;) Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2009-11-25 17:58:26 UTC (rev 5200) +++ trunk/agent/gpg-agent.c 2009-11-27 19:13:02 UTC (rev 5201) @@ -472,6 +472,8 @@ || strcmp (current_logfile, pargs->r.ret_str)) { log_set_file (pargs->r.ret_str); + if (DBG_ASSUAN) + assuan_set_assuan_log_stream (log_get_stream ()); xfree (current_logfile); current_logfile = xtrystrdup (pargs->r.ret_str); } @@ -922,6 +924,8 @@ |JNLIB_LOG_WITH_PID)); current_logfile = xstrdup (logfile); } + if (DBG_ASSUAN) + assuan_set_assuan_log_stream (log_get_stream ()); /* Make sure that we have a default ttyname. */ if (!default_ttyname && ttyname (1)) From cvs at cvs.gnupg.org Sun Nov 29 13:30:21 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 29 Nov 2009 13:30:21 +0100 Subject: [svn] gcry - r1407 - in trunk: . cipher src Message-ID: Author: wk Date: 2009-11-29 13:30:21 +0100 (Sun, 29 Nov 2009) New Revision: 1407 Modified: trunk/README trunk/THANKS trunk/cipher/cipher.c trunk/src/ChangeLog trunk/src/hwfeatures.c Log: Fix detection of cpuid statement. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-10-28 15:11:40 UTC (rev 1406) +++ trunk/src/ChangeLog 2009-11-29 12:30:21 UTC (rev 1407) @@ -1,3 +1,9 @@ +2009-11-29 Werner Koch + + * hwfeatures.c (detect_ia32_gnuc): Repalce "=r" by "+r" so that + HAS-CPUDID is always initialized. Thanks to Ben Hutchings for + pointing out this problem. + 2009-08-05 Werner Koch * ath.h: Include sys/msg.h. Modified: trunk/README =================================================================== --- trunk/README 2009-10-28 15:11:40 UTC (rev 1406) +++ trunk/README 2009-11-29 12:30:21 UTC (rev 1407) @@ -192,13 +192,6 @@ make. Try gmake or grab the sources from a GNU archive and install them. - If you are cross-compiling and you get an error either building a - tool called "yat2m" or running that tool, the problem is most - likely a bad or missing native compiler. We require a standard - C-89 compiler to produce an executable to be run on the build - platform. You can explicitly set such a compiler with configure - arguments. On HP/UX you might want to try: "CC_FOR_BUILD=c89". - Specific problems on some machines: * IBM RS/6000 running AIX @@ -216,8 +209,13 @@ ./configure ac_cv_sys_symbol_underscore=yes + * Sparc64 CPUs + We have reports about failures in the AES module when + compiling using gcc (e.g. version 4.1.2) and the option -O3; + using -O2 solves the problem. + License ------- Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2009-10-28 15:11:40 UTC (rev 1406) +++ trunk/THANKS 2009-11-29 12:30:21 UTC (rev 1407) @@ -7,6 +7,7 @@ Anand Kumria wildfire at progsoc.uts.edu.au Andreas Metzler ametzler at downhill.at.eu.org Ariel T Glenn ariel at columbia.edu +Ben Hutchings ben decadent org uk Bodo Moeller Bodo_Moeller at public.uni-hamburg.de Brenno de Winter brenno at dewinter.com Brian Moore bem at cmc.net Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2009-10-28 15:11:40 UTC (rev 1406) +++ trunk/cipher/cipher.c 2009-11-29 12:30:21 UTC (rev 1407) @@ -1394,7 +1394,7 @@ /**************** * Encrypt INBUF to OUTBUF with the mode selected at open. * inbuf and outbuf may overlap or be the same. - * Depending on the mode some contraints apply to NBYTES. + * Depending on the mode some constraints apply to NBYTES. */ static gcry_err_code_t cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, Modified: trunk/src/hwfeatures.c =================================================================== --- trunk/src/hwfeatures.c 2009-10-28 15:11:40 UTC (rev 1406) +++ trunk/src/hwfeatures.c 2009-11-29 12:30:21 UTC (rev 1407) @@ -67,7 +67,7 @@ "jz .Lno_cpuid%=\n\t" /* Toggling did not work, thus no CPUID. */ "movl $1, %0\n" /* Worked. true -> HAS_CPUID. */ ".Lno_cpuid%=:\n\t" - : "=r" (has_cpuid) + : "+r" (has_cpuid) : : "%eax", "%ecx", "cc" ); From cvs at cvs.gnupg.org Sun Nov 29 14:10:17 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 29 Nov 2009 14:10:17 +0100 Subject: [svn] gcry - r1408 - branches/LIBGCRYPT-1-4-BRANCH/src Message-ID: Author: wk Date: 2009-11-29 14:10:17 +0100 (Sun, 29 Nov 2009) New Revision: 1408 Modified: branches/LIBGCRYPT-1-4-BRANCH/src/ChangeLog branches/LIBGCRYPT-1-4-BRANCH/src/hwfeatures.c Log: Fix ia32 cpuid detection. Modified: branches/LIBGCRYPT-1-4-BRANCH/src/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-4-BRANCH/src/ChangeLog 2009-11-29 12:30:21 UTC (rev 1407) +++ branches/LIBGCRYPT-1-4-BRANCH/src/ChangeLog 2009-11-29 13:10:17 UTC (rev 1408) @@ -1,3 +1,9 @@ +2009-11-29 Werner Koch + + * hwfeatures.c (detect_ia32_gnuc): Replace "=r" by "+r" so that + HAS_CPUDID is always initialized. Thanks to Ben Hutchings for + pointing out this problem. + 2009-06-24 Werner Koch * fips.c (_gcry_initialize_fips_mode): No FIPS mode if Modified: branches/LIBGCRYPT-1-4-BRANCH/src/hwfeatures.c =================================================================== --- branches/LIBGCRYPT-1-4-BRANCH/src/hwfeatures.c 2009-11-29 12:30:21 UTC (rev 1407) +++ branches/LIBGCRYPT-1-4-BRANCH/src/hwfeatures.c 2009-11-29 13:10:17 UTC (rev 1408) @@ -67,7 +67,7 @@ "jz .Lno_cpuid%=\n\t" /* Toggling did not work, thus no CPUID. */ "movl $1, %0\n" /* Worked. true -> HAS_CPUID. */ ".Lno_cpuid%=:\n\t" - : "=r" (has_cpuid) + : "+r" (has_cpuid) : : "%eax", "%ecx", "cc" ); From cvs at cvs.gnupg.org Mon Nov 30 18:42:00 2009 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 30 Nov 2009 18:42:00 +0100 Subject: [svn] GpgOL - r323 - in trunk: po src Message-ID: Author: wk Date: 2009-11-30 18:42:00 +0100 (Mon, 30 Nov 2009) New Revision: 323 Modified: trunk/po/de.po trunk/po/sv.po trunk/src/ChangeLog trunk/src/display.cpp trunk/src/ext-commands.cpp trunk/src/message-events.cpp Log: Plaintext of encrypted message is now shown again. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2009-11-27 17:06:07 UTC (rev 322) +++ trunk/src/ChangeLog 2009-11-30 17:42:00 UTC (rev 323) @@ -1,3 +1,14 @@ +2009-11-30 Werner Koch + + * message-events.cpp (OnReadComplete): Use GetInspector if none was + found. + * display.cpp (update_display): Print the window hierarchy in case + of an error. + * ext-commands.cpp (get_inspector): Add arg HWND. First try + get_inspector_from_hwnd. + (get_crypto_flags, set_crypto_flags): Add arg HWND. + (InstallCommands, DoCommand): Pass HWND to crypt_flags functions. + 2009-11-27 Werner Koch * message-events.cpp (get_crypto_flags): Replace EECB arg by HWND. Modified: trunk/po/de.po [not shown] Modified: trunk/po/sv.po [not shown] Modified: trunk/src/display.cpp =================================================================== --- trunk/src/display.cpp 2009-11-27 17:06:07 UTC (rev 322) +++ trunk/src/display.cpp 2009-11-30 17:42:00 UTC (rev 323) @@ -272,6 +272,7 @@ { log_error ("%s:%s: window handle not found for parent %p\n", SRCNAME, __func__, hwnd); + log_window_hierarchy (hwnd, "this is the window hierachy:"); return -1; } } Modified: trunk/src/ext-commands.cpp =================================================================== --- trunk/src/ext-commands.cpp 2009-11-27 17:06:07 UTC (rev 322) +++ trunk/src/ext-commands.cpp 2009-11-30 17:42:00 UTC (rev 323) @@ -107,23 +107,21 @@ /* Note: Duplicated from message-events.cpp. Eventually we should get rid of this module. */ static LPDISPATCH -get_inspector (LPEXCHEXTCALLBACK eecb) +get_inspector (LPEXCHEXTCALLBACK eecb, HWND hwnd) { LPDISPATCH obj; - LPDISPATCH inspector = NULL; + LPDISPATCH inspector; - obj = get_eecb_object (eecb); - if (obj) + inspector = get_inspector_from_hwnd (hwnd); + if (!inspector) { - /* This should be MailItem; use the getInspector method. */ - //inspector = get_oom_object (obj, "GetInspector"); - char *tmp = get_object_name (obj); - - log_debug ("%s:%s: object is at %p (%s)", - SRCNAME, __func__, obj, tmp? tmp:""); - xfree (tmp); - - obj->Release (); + obj = get_eecb_object (eecb); + if (obj) + { + /* This should be MailItem; use the getInspector method. */ + inspector = get_oom_object (obj, "GetInspector"); + obj->Release (); + } } return inspector; } @@ -132,12 +130,13 @@ /* Note: Duplicated from message-events.cpp. Eventually we should get rid of this module. */ static int -get_crypto_flags (LPEXCHEXTCALLBACK eecb, bool *r_sign, bool *r_encrypt) +get_crypto_flags (LPEXCHEXTCALLBACK eecb, HWND hwnd, + bool *r_sign, bool *r_encrypt) { LPDISPATCH inspector; int rc; - inspector = get_inspector (eecb); + inspector = get_inspector (eecb, hwnd); if (!inspector) { log_error ("%s:%s: inspector not found", SRCNAME, __func__); @@ -153,11 +152,11 @@ static void -set_crypto_flags (LPEXCHEXTCALLBACK eecb, bool sign, bool encrypt) +set_crypto_flags (LPEXCHEXTCALLBACK eecb, HWND hwnd, bool sign, bool encrypt) { LPDISPATCH inspector; - inspector = get_inspector (eecb); + inspector = get_inspector (eecb, hwnd); if (!inspector) log_error ("%s:%s: inspector not found", SRCNAME, __func__); else @@ -173,7 +172,7 @@ STDMETHODIMP GpgolExtCommands::InstallCommands ( LPEXCHEXTCALLBACK eecb, // The Exchange Callback Interface. - HWND hWnd, // The window handle to the main window + HWND hwnd, // The window handle to the main window // of context. HMENU hMenu, // The menu handle to main menu of context. UINT FAR *pnCommandIDBase, // The base command id. @@ -182,11 +181,14 @@ ULONG lFlags) // reserved { HRESULT hr; - m_hWnd = hWnd; + m_hWnd = hwnd; LPDISPATCH obj; (void)hMenu; - + (void)pnCommandIDBase; + (void)pTBEArray; + (void)nTBECnt; + if (debug_commands) log_debug ("%s:%s: context=%s flags=0x%lx\n", SRCNAME, __func__, ext_context_name (m_lContext), lFlags); @@ -288,7 +290,7 @@ if (force_encrypt) encrypt = true; - set_crypto_flags (eecb, sign, encrypt); + set_crypto_flags (eecb, hwnd,sign, encrypt); } xfree (draft_info); } @@ -398,7 +400,7 @@ log_debug ("%s:%s: command SaveMessage called\n", SRCNAME, __func__); - if (get_crypto_flags (eecb, &sign, &encrypt)) + if (get_crypto_flags (eecb, hwnd, &sign, &encrypt)) buf[0] = buf[1] = '?'; else { @@ -412,7 +414,7 @@ if (SUCCEEDED (hr)) mapi_set_gpgol_draft_info (message, buf); else - log_debug ("%s:%s: getObject failed: hr=%#lx\n",SRCNAME, __func__, hr); + log_error ("%s:%s: getObject failed: hr=%#lx\n",SRCNAME, __func__, hr); ul_release (message, __func__, __LINE__); ul_release (mdb, __func__, __LINE__); return S_FALSE; /* Pass on to next handler. */ @@ -466,6 +468,10 @@ GpgolExtCommands::QueryHelpText(UINT nCommandID, ULONG lFlags, LPTSTR pszText, UINT nCharCnt) { + (void)nCommandID; + (void)lFlags; + (void)pszText; + (void)nCharCnt; return S_FALSE; } @@ -486,6 +492,10 @@ LPTSTR description, UINT description_size, ULONG flags) { + (void)toolbarid; + (void)buttonid; + (void)pTBB; + (void)description; (void)description_size; (void)flags; Modified: trunk/src/message-events.cpp =================================================================== --- trunk/src/message-events.cpp 2009-11-27 17:06:07 UTC (rev 322) +++ trunk/src/message-events.cpp 2009-11-30 17:42:00 UTC (rev 323) @@ -203,7 +203,29 @@ SRCNAME, __func__, hr); else { - LPDISPATCH inspector = get_inspector_from_hwnd (hwnd); + LPDISPATCH inspector; + LPDISPATCH obj; + + inspector = get_inspector_from_hwnd (hwnd); + if (!inspector) + { + /* No inspector available. We now force the creation of + a new inspector by using the GetInspector method for + the current MailItem. In theory we could do this + always but we better try the *from_hwnd method first + as this will not create a new inspector in OL2007 if + one already exists. Not a real problem for OnRead + but we had this problem in OnWrite. */ + obj = get_eecb_object (eecb); + if (obj) + { + inspector = get_oom_object (obj, "GetInspector"); + if (opt.enable_debug & DBG_OOM) + log_debug ("%s:%s: %p->GetInspector returned %p", + SRCNAME, __func__, obj, inspector); + obj->Release (); + } + } message_display_handler (message, inspector, hwnd); if (inspector) inspector->Release ();