aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2003-05-27 01:31:06 +0000
committerMarcus Brinkmann <[email protected]>2003-05-27 01:31:06 +0000
commit03bcb7f4c14e771392ccf04d1d5cd38c5baf47b2 (patch)
tree03f00ce78b2feec8187145b102edb6cdd8c30c7f /tests
parentUpdate Miguel's email address. (diff)
downloadgpgme-03bcb7f4c14e771392ccf04d1d5cd38c5baf47b2.tar.gz
gpgme-03bcb7f4c14e771392ccf04d1d5cd38c5baf47b2.zip
doc/
2003-05-27 Marcus Brinkmann <[email protected]> * gpgme.texi (Passphrase Callback): Document new prototype. gpgme/ 2003-05-26 Marcus Brinkmann <[email protected]> * engine.h (EngineCommandHandler): Change last argument to int fd. * gpgme.h (gpgme_passphrase_cb_t): Rewritten to take parts of the description and fd. (gpgme_edit_cb_t): Change last argument to int fd. * ops.h (_gpgme_passphrase_command_handler_internal): New prototype. * passphrase.c: Include <assert.h>. (op_data_t): Rename userid_hint to uid_hint, remove last_pw_handle. (release_op_data): Check values before calling free. (_gpgme_passphrase_status_handler): Likewise. (_gpgme_passphrase_command_handler_internal): New function. (_gpgme_passphrase_command_handler): Rewritten. * edit.c (edit_status_handler): Pass -1 as fd argument. (command_handler): Update prototype. New variable processed. Use it to store return value of _gpgme_passphrase_command_handler_internal which is now used instead _gpgme_passphrase_command_handler. Use it also to check if we should call the user's edit function. Pass fd to user's edit function. * rungpg.c (struct gpg_object_s): Change type of cmd.cb_data to void *. (gpg_release): Check value before calling free. Do not release cmd.cb_data. (command_cb): Function removed. (command_handler): New function. Thus we don't use a data object for command handler stuff anymore, but handle it directly. This allows proper error reporting (cancel of passphrase requests, for example). Also all callbacks work via direct writes to the file descriptor (so that passphrases are not kept in insecure memory). (gpg_set_command_handler): Rewritten to use even more ugly hacks. (read_status): Check cmd.keyword before calling free. Install command_handler as the I/O callback handler with GPG as private data. tests/ 2003-05-27 Marcus Brinkmann <[email protected]> * (t-decrypt-verify.c, t-decrypt.c, t-edit.c, t-encrypt-sign.c, t-encrypt-sym.c, t-sign.c, t-signers.c): Include <unistd.h>. (passphrase_cb): Rewritten. * t-edit.c (edit_fnc): Rewritten.
Diffstat (limited to '')
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/gpg/t-decrypt-verify.c10
-rw-r--r--tests/gpg/t-decrypt.c10
-rw-r--r--tests/gpg/t-edit.c65
-rw-r--r--tests/gpg/t-encrypt-sign.c10
-rw-r--r--tests/gpg/t-encrypt-sym.c15
-rw-r--r--tests/gpg/t-sign.c10
-rw-r--r--tests/gpg/t-signers.c10
8 files changed, 61 insertions, 76 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0374e1df..9848d36f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2003-05-27 Marcus Brinkmann <[email protected]>
+
+ * (t-decrypt-verify.c, t-decrypt.c, t-edit.c, t-encrypt-sign.c,
+ t-encrypt-sym.c, t-sign.c, t-signers.c): Include <unistd.h>.
+ (passphrase_cb): Rewritten.
+ * t-edit.c (edit_fnc): Rewritten.
+
2003-05-04 Marcus Brinkmann <[email protected]>
* gpg/t-keylist-sig.c (main): Remove timestamp check.
diff --git a/tests/gpg/t-decrypt-verify.c b/tests/gpg/t-decrypt-verify.c
index fb8a079f..c89f7f47 100644
--- a/tests/gpg/t-decrypt-verify.c
+++ b/tests/gpg/t-decrypt-verify.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -57,13 +58,10 @@ print_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- /* Cleanup by looking at *hd. */
- if (!desc)
- return 0;
-
- *result = "abc";
+ write (fd, "abc\n", 4);
return 0;
}
diff --git a/tests/gpg/t-decrypt.c b/tests/gpg/t-decrypt.c
index b674653a..7b406a76 100644
--- a/tests/gpg/t-decrypt.c
+++ b/tests/gpg/t-decrypt.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -56,13 +57,10 @@ print_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- /* Cleanup by looking at *hd. */
- if (!desc)
- return 0;
-
- *result = "abc";
+ write (fd, "abc\n", 4);
return 0;
}
diff --git a/tests/gpg/t-edit.c b/tests/gpg/t-edit.c
index a90ebff6..d66933f0 100644
--- a/tests/gpg/t-edit.c
+++ b/tests/gpg/t-edit.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -58,24 +59,18 @@ flush_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc,
- void **r_hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- if (!desc)
- /* Cleanup by looking at *r_hd. */
- return 0;
-
- *result = "abc";
- fprintf (stderr, "%% requesting passphrase for `%s': ", desc);
- fprintf (stderr, "sending `%s'\n", *result);
-
+ write (fd, "abc\n", 4);
return 0;
}
gpgme_error_t
-edit_fnc (void *opaque, gpgme_status_code_t status, const char *args, const char **result)
+edit_fnc (void *opaque, gpgme_status_code_t status, const char *args, int fd)
{
+ char *result = NULL;
gpgme_data_t out = (gpgme_data_t) opaque;
fputs ("[-- Response --]\n", stdout);
@@ -83,36 +78,34 @@ edit_fnc (void *opaque, gpgme_status_code_t status, const char *args, const char
fprintf (stdout, "[-- Code: %i, %s --]\n", status, args);
- if (result)
+ if (!strcmp (args, "keyedit.prompt"))
{
- if (!strcmp (args, "keyedit.prompt"))
- {
- static int step = 0;
-
- switch (step)
- {
- case 0:
- *result = "fpr";
- break;
- case 1:
- *result = "expire";
- break;
- default:
- *result = "quit";
- break;
- }
- step++;
- }
- else if (!strcmp (args, "keyedit.save.okay"))
- {
- *result = "Y";
- }
- else if (!strcmp (args, "keygen.valid"))
+ static int step = 0;
+
+ switch (step)
{
- *result = "0";
+ case 0:
+ result = "fpr";
+ break;
+ case 1:
+ result = "expire";
+ break;
+ default:
+ result = "quit";
+ break;
}
+ step++;
}
+ else if (!strcmp (args, "keyedit.save.okay"))
+ result = "Y";
+ else if (!strcmp (args, "keygen.valid"))
+ result = "0";
+ if (result)
+ {
+ write (fd, result, strlen (result));
+ write (fd, "\n", 1);
+ }
return 0;
}
diff --git a/tests/gpg/t-encrypt-sign.c b/tests/gpg/t-encrypt-sign.c
index d92d6ff8..7e8fc3f9 100644
--- a/tests/gpg/t-encrypt-sign.c
+++ b/tests/gpg/t-encrypt-sign.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -55,13 +56,10 @@ print_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- /* Cleanup by looking at *hd. */
- if (!desc)
- return 0;
-
- *result = "abc";
+ write (fd, "abc\n", 4);
return 0;
}
diff --git a/tests/gpg/t-encrypt-sym.c b/tests/gpg/t-encrypt-sym.c
index 7ebd397d..5adc31c4 100644
--- a/tests/gpg/t-encrypt-sym.c
+++ b/tests/gpg/t-encrypt-sym.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -47,18 +48,12 @@ print_data (gpgme_data_t dh)
fail_if_err (GPGME_File_Error);
}
+
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc,
- void **r_hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- if (!desc)
- /* Cleanup by looking at *r_hd. */
- return 0;
-
- *result = "abc";
- fprintf (stderr, "%% requesting passphrase for `%s': ", desc);
- fprintf (stderr, "sending `%s'\n", *result);
-
+ write (fd, "abc\n", 4);
return 0;
}
diff --git a/tests/gpg/t-sign.c b/tests/gpg/t-sign.c
index e2252150..cb32246d 100644
--- a/tests/gpg/t-sign.c
+++ b/tests/gpg/t-sign.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -55,13 +56,10 @@ print_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- /* Cleanup by looking at *hd. */
- if (!desc)
- return 0;
-
- *result = "abc";
+ write (fd, "abc\n", 4);
return 0;
}
diff --git a/tests/gpg/t-signers.c b/tests/gpg/t-signers.c
index 512da59f..3c97a735 100644
--- a/tests/gpg/t-signers.c
+++ b/tests/gpg/t-signers.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <gpgme.h>
@@ -55,13 +56,10 @@ print_data (gpgme_data_t dh)
static gpgme_error_t
-passphrase_cb (void *opaque, const char *desc, void **hd, const char **result)
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
{
- /* Cleanup by looking at *hd. */
- if (!desc)
- return 0;
-
- *result = "abc";
+ write (fd, "abc\n", 4);
return 0;
}