[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: fix plugin unload
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: fix plugin unload |
Date: |
Sat, 13 Feb 2021 20:12:00 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 1a4803b fix plugin unload
1a4803b is described below
commit 1a4803bcadcb240a5a9e9c29cc38477d9ba100ad
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Feb 13 20:11:58 2021 +0100
fix plugin unload
---
contrib/gana | 2 +-
src/authorization/anastasis_authorization_plugin.c | 2 +-
.../anastasis_authorization_plugin_email.c | 2 +
.../anastasis_authorization_plugin_file.c | 2 +
.../anastasis_authorization_plugin_sms.c | 2 +
src/backend/anastasis-httpd_truth.c | 173 +++++++++++++--------
src/include/anastasis_authorization_plugin.h | 8 +-
src/include/anastasis_testing_lib.h | 29 +++-
src/testing/test_anastasis_api.c | 15 +-
src/testing/test_anastasis_api.conf | 2 +-
src/testing/testing_api_cmd_truth_store.c | 29 ++++
src/util/anastasis_crypto.c | 2 +
12 files changed, 183 insertions(+), 85 deletions(-)
diff --git a/contrib/gana b/contrib/gana
index cb43a26..95a0e41 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit cb43a2642dd75f21c45392667e0877c97474915b
+Subproject commit 95a0e418f0b6801e09f2251a4e777ed8906e0f56
diff --git a/src/authorization/anastasis_authorization_plugin.c
b/src/authorization/anastasis_authorization_plugin.c
index 3a7f15b..fdeda22 100644
--- a/src/authorization/anastasis_authorization_plugin.c
+++ b/src/authorization/anastasis_authorization_plugin.c
@@ -167,7 +167,7 @@ ANASTASIS_authorization_plugin_shutdown (void)
ap_tail,
ap);
GNUNET_PLUGIN_unload (ap->lib_name,
- ap);
+ ap->authorization);
GNUNET_free (ap->lib_name);
GNUNET_free (ap->name);
GNUNET_free (ap);
diff --git a/src/authorization/anastasis_authorization_plugin_email.c
b/src/authorization/anastasis_authorization_plugin_email.c
index f7e00fa..574fd7f 100644
--- a/src/authorization/anastasis_authorization_plugin_email.c
+++ b/src/authorization/anastasis_authorization_plugin_email.c
@@ -68,6 +68,7 @@ struct ANASTASIS_AUTHORIZATION_State
*
* @param cls closure
* @param connection HTTP client request (for queuing response)
+ * @param truth_mime mime type of @e data
* @param data input to validate (i.e. is it a valid phone number, etc.)
* @param data_length number of bytes in @a data
* @return #GNUNET_OK if @a data is valid,
@@ -77,6 +78,7 @@ struct ANASTASIS_AUTHORIZATION_State
static enum GNUNET_GenericReturnValue
email_validate (void *cls,
struct MHD_Connection *connection,
+ const char *mime_type,
const char *data,
size_t data_length)
{
diff --git a/src/authorization/anastasis_authorization_plugin_file.c
b/src/authorization/anastasis_authorization_plugin_file.c
index 29c9459..dd5ad7a 100644
--- a/src/authorization/anastasis_authorization_plugin_file.c
+++ b/src/authorization/anastasis_authorization_plugin_file.c
@@ -60,6 +60,7 @@ struct ANASTASIS_AUTHORIZATION_State
*
* @param cls closure
* @param connection HTTP client request (for queuing response)
+ * @param truth_mime mime type of @e data
* @param data input to validate (i.e. is it a valid phone number, etc.)
* @param data_length number of bytes in @a data
* @return #GNUNET_OK if @a data is valid,
@@ -69,6 +70,7 @@ struct ANASTASIS_AUTHORIZATION_State
static enum GNUNET_GenericReturnValue
file_validate (void *cls,
struct MHD_Connection *connection,
+ const char *truth_mime,
const char *data,
size_t data_length)
{
diff --git a/src/authorization/anastasis_authorization_plugin_sms.c
b/src/authorization/anastasis_authorization_plugin_sms.c
index ba5842d..f65d940 100644
--- a/src/authorization/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -128,6 +128,7 @@ struct ANASTASIS_AUTHORIZATION_State
*
* @param cls closure with a `struct SMS_Context`
* @param connection HTTP client request (for queuing response)
+ * @param truth_mime mime type of @e data
* @param data input to validate (i.e. is it a valid phone number, etc.)
* @param data_length number of bytes in @a data
* @return #GNUNET_OK if @a data is valid,
@@ -137,6 +138,7 @@ struct ANASTASIS_AUTHORIZATION_State
static enum GNUNET_GenericReturnValue
sms_validate (void *cls,
struct MHD_Connection *connection,
+ const char *truth_mime,
const char *data,
size_t data_length)
{
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index a14eb1d..75becfe 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -120,6 +120,11 @@ struct GetContext
*/
bool payment_identifier_provided;
+ /**
+ * True if this entry is in the #gc_head DLL.
+ */
+ bool in_list;
+
};
@@ -141,9 +146,13 @@ AH_truth_shutdown (void)
while (NULL != (gc = gc_head))
{
- GNUNET_CONTAINER_DLL_remove (gc_head,
- gc_tail,
- gc);
+ if (gc->in_list)
+ {
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ }
if (NULL != gc->as)
{
gc->authorization->cleanup (gc->as);
@@ -170,9 +179,13 @@ request_done (struct TM_HandlerContext *hc)
if (NULL == gc)
return;
hc->cc = NULL;
- GNUNET_CONTAINER_DLL_remove (gc_head,
- gc_tail,
- gc);
+ if (gc->in_list)
+ {
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ }
if (NULL != gc->as)
{
gc->authorization->cleanup (gc->as);
@@ -247,9 +260,11 @@ proposal_cb (void *cls,
enum GNUNET_DB_QueryStatus qs;
gc->hc->cc = NULL;
+ GNUNET_assert (gc->in_list);
GNUNET_CONTAINER_DLL_remove (gc_head,
gc_tail,
gc);
+ gc->in_list = false;
MHD_resume_connection (gc->connection);
AH_trigger_daemon (NULL);
if (MHD_HTTP_OK != por->hr.http_status)
@@ -308,9 +323,11 @@ check_payment_cb (void *cls,
gc->cpo = NULL;
gc->hc->cc = NULL;
+ GNUNET_assert (gc->in_list);
GNUNET_CONTAINER_DLL_remove (gc_head,
gc_tail,
gc);
+ gc->in_list = false;
MHD_resume_connection (gc->connection);
AH_trigger_daemon (NULL);
@@ -408,7 +425,7 @@ begin_payment (struct GetContext *gc)
TALER_EC_GENERIC_DB_FETCH_FAILED,
"lookup challenge payment");
}
- gc->hc->cc = &request_done;
+ gc->in_list = true;
GNUNET_CONTAINER_DLL_insert (gc_tail,
gc_head,
gc);
@@ -537,7 +554,7 @@ AH_handler_truth_get (
size_t encrypted_truth_size;
void *decrypted_truth;
size_t decrypted_truth_size;
- char *truth_mime;
+ char *truth_mime = NULL;
bool is_question;
if (NULL != gc)
@@ -611,7 +628,7 @@ AH_handler_truth_get (
hc->ctx = gc;
gc->connection = connection;
gc->truth_uuid = *truth_uuid;
-
+ gc->hc->cc = &request_done;
{
const char *pay_id;
@@ -735,15 +752,16 @@ AH_handler_truth_get (
TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_METHOD_NO_LONGER_SUPPORTED,
method);
GNUNET_free (encrypted_truth);
+ GNUNET_free (truth_mime);
GNUNET_free (method);
return ret;
}
- GNUNET_free (method);
}
else
{
gc->challenge_cost = AH_question_cost;
}
+ GNUNET_free (method);
}
{
@@ -763,6 +781,7 @@ AH_handler_truth_get (
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&gc->payment_identifier,
sizeof (struct ANASTASIS_PaymentSecretP));
+ GNUNET_free (truth_mime);
GNUNET_free (encrypted_truth);
return begin_payment (gc);
}
@@ -774,6 +793,7 @@ AH_handler_truth_get (
case GNUNET_DB_STATUS_HARD_ERROR:
case GNUNET_DB_STATUS_SOFT_ERROR:
GNUNET_break (0);
+ GNUNET_free (truth_mime);
GNUNET_free (encrypted_truth);
return TALER_MHD_reply_with_error (gc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
@@ -781,11 +801,13 @@ AH_handler_truth_get (
"check challenge payment");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* Re-use existing payment identifier */
+ GNUNET_free (truth_mime);
GNUNET_free (encrypted_truth);
return begin_payment (gc);
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
if (! paid)
{
+ GNUNET_free (truth_mime);
GNUNET_free (encrypted_truth);
return begin_payment (gc);
}
@@ -804,6 +826,14 @@ AH_handler_truth_get (
&decrypted_truth_size);
GNUNET_free (encrypted_truth);
}
+ if (NULL == decrypted_truth)
+ {
+ GNUNET_free (truth_mime);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_EXPECTATION_FAILED,
+
TALER_EC_ANASTASIS_TRUTH_DECRYPTION_FAILED,
+ NULL);
+ }
/* Special case for secure question: we do not generate a numeric challenge,
but check that the hash matches */
@@ -812,6 +842,7 @@ AH_handler_truth_get (
if (! have_response)
{
GNUNET_free (decrypted_truth);
+ GNUNET_free (truth_mime);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED,
@@ -828,8 +859,11 @@ AH_handler_truth_get (
decrypted_truth_size)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Wrong answer provided to secure question\n");
+ "Wrong answer provided to secure question had %u bytes,
wanted %u\n",
+ (unsigned int) sizeof (challenge_response),
+ (unsigned int) decrypted_truth_size);
GNUNET_free (decrypted_truth);
+ GNUNET_free (truth_mime);
/* for rate-limiting... */
#if 0
enum GNUNET_DB_QueryStatus qs;
@@ -844,6 +878,8 @@ AH_handler_truth_get (
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_FAILED,
NULL);
}
+ GNUNET_free (decrypted_truth);
+ GNUNET_free (truth_mime);
return return_key_share (&gc->truth_uuid,
connection);
}
@@ -854,6 +890,7 @@ AH_handler_truth_get (
enum ANASTASIS_DB_CodeStatus cs;
GNUNET_free (decrypted_truth);
+ GNUNET_free (truth_mime);
cs = db->verify_challenge_code (db->cls,
&gc->truth_uuid,
&challenge_response);
@@ -891,8 +928,10 @@ AH_handler_truth_get (
ret = gc->authorization->validate (gc->authorization->cls,
connection,
+ truth_mime,
decrypted_truth,
decrypted_truth_size);
+ GNUNET_free (truth_mime);
switch (ret)
{
case GNUNET_OK:
@@ -947,63 +986,65 @@ AH_handler_truth_get (
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_ACTIVE,
NULL);
}
- gc->as = gc->authorization->start (gc->authorization->cls,
- &AH_trigger_daemon,
- NULL,
- &gc->truth_uuid,
- gc->code,
- decrypted_truth,
- decrypted_truth_size);
- GNUNET_free (decrypted_truth);
- if (NULL == gc->as)
- {
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
-
TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
- NULL);
- }
- hc->cc = &request_done;
- GNUNET_CONTAINER_DLL_insert (gc_head,
- gc_tail,
- gc);
- {
- enum ANASTASIS_AUTHORIZATION_Result aret;
+ }
- aret = gc->authorization->process (gc->as,
- connection);
- switch (aret)
- {
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
- /* all good, challenge sent! */
- qs = db->mark_challenge_sent (db->cls,
- &gc->truth_uuid,
- gc->code);
- GNUNET_break (0 < qs);
- break;
- case ANASTASIS_AUTHORIZATION_RES_FAILED:
- /* sending challenge failed */
- // FIXME: give at least a refund!?
- break;
- case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
- /* we have been suspended, see you later */
- return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
- /* Challenge sent successfully, but HTTP reply failed */
- qs = db->mark_challenge_sent (db->cls,
- &gc->truth_uuid,
- gc->code);
- GNUNET_break (0 < qs);
- gc->authorization->cleanup (gc->as);
- return MHD_NO;
- case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
- /* failure to send challenge AND to queue reply, kill connection */
- gc->authorization->cleanup (gc->as);
- return MHD_NO;
- }
- gc->authorization->cleanup (gc->as);
- gc->as = NULL;
+ gc->as = gc->authorization->start (gc->authorization->cls,
+ &AH_trigger_daemon,
+ NULL,
+ &gc->truth_uuid,
+ gc->code,
+ decrypted_truth,
+ decrypted_truth_size);
+ GNUNET_free (decrypted_truth);
+ if (NULL == gc->as)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+
TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ NULL);
+ }
+ gc->in_list = true;
+ GNUNET_CONTAINER_DLL_insert (gc_head,
+ gc_tail,
+ gc);
+ {
+ enum ANASTASIS_AUTHORIZATION_Result aret;
+ enum GNUNET_DB_QueryStatus qs;
+
+ aret = gc->authorization->process (gc->as,
+ connection);
+ switch (aret)
+ {
+ case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
+ /* all good, challenge sent! */
+ qs = db->mark_challenge_sent (db->cls,
+ &gc->truth_uuid,
+ gc->code);
+ GNUNET_break (0 < qs);
+ break;
+ case ANASTASIS_AUTHORIZATION_RES_FAILED:
+ /* sending challenge failed */
+ // FIXME: give at least a refund!?
+ break;
+ case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
+ /* we have been suspended, see you later */
return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
+ /* Challenge sent successfully, but HTTP reply failed */
+ qs = db->mark_challenge_sent (db->cls,
+ &gc->truth_uuid,
+ gc->code);
+ GNUNET_break (0 < qs);
+ gc->authorization->cleanup (gc->as);
+ return MHD_NO;
+ case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
+ /* failure to send challenge AND to queue reply, kill connection */
+ gc->authorization->cleanup (gc->as);
+ return MHD_NO;
}
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ return MHD_YES;
}
}
diff --git a/src/include/anastasis_authorization_plugin.h
b/src/include/anastasis_authorization_plugin.h
index d28658d..5985f52 100644
--- a/src/include/anastasis_authorization_plugin.h
+++ b/src/include/anastasis_authorization_plugin.h
@@ -89,12 +89,6 @@ struct ANASTASIS_AuthorizationPlugin
*/
void *cls;
- /**
- * Name of the library which generated this plugin. Set by the
- * plugin loader.
- */
- char *library_name;
-
/**
* How long should a generated challenge be valid for this type of method.
*/
@@ -120,6 +114,7 @@ struct ANASTASIS_AuthorizationPlugin
*
* @param cls closure
* @param connection HTTP client request (for queuing response)
+ * @param truth_mime mime type of @e data
* @param data input to validate (i.e. is it a valid phone number, etc.)
* @param data_length number of bytes in @a data
* @return #GNUNET_OK if @a data is valid,
@@ -129,6 +124,7 @@ struct ANASTASIS_AuthorizationPlugin
enum GNUNET_GenericReturnValue
(*validate)(void *cls,
struct MHD_Connection *connection,
+ const char *truth_mime,
const char *data,
size_t data_length);
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index 49deddf..d24aa15 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -430,8 +430,13 @@ enum ANASTASIS_TESTING_TruthStoreOption
* @param label command label
* @param anastasis_url base URL of the anastasis serving
* the truth store request.
+ * @param prev_upload reference to a previous upload to get a payment ID from
+ * @param method what authentication method is being used
+ * @param mime_type MIME type of @a truth_data
+ * @param truth_data_size number of bytes in @a truth_data
+ * @param truth_data recovery data to post /truth (in plaintext)
+ * @param tso flags
* @param http_status expected HTTP status.
- * @param truth_data recovery data to post /truth
* @return the command
*/
struct TALER_TESTING_Command
@@ -446,6 +451,28 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
unsigned int http_status);
+/**
+ * Make the "truth store" command for a secure question.
+ *
+ * @param label command label
+ * @param anastasis_url base URL of the anastasis serving
+ * the truth store request.
+ * @param prev_upload reference to a previous upload to get a payment ID from
+ * @param answer the answer to the question
+ * @param tso flags
+ * @param http_status expected HTTP status.
+ * @return the command
+ */
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_question (
+ const char *label,
+ const char *anastasis_url,
+ const char *prev_upload,
+ const char *answer,
+ enum ANASTASIS_TESTING_TruthStoreOption tso,
+ unsigned int http_status);
+
+
/**
* Make the "keyshare lookup" command.
*
diff --git a/src/testing/test_anastasis_api.c b/src/testing/test_anastasis_api.c
index f470c47..a7e649a 100644
--- a/src/testing/test_anastasis_api.c
+++ b/src/testing/test_anastasis_api.c
@@ -197,13 +197,10 @@ run (void *cls,
};
struct TALER_TESTING_Command truth[] = {
- ANASTASIS_TESTING_cmd_truth_store (
+ ANASTASIS_TESTING_cmd_truth_question (
"truth-store-1",
anastasis_url,
NULL,
- "question",
- "Truth mime",
- strlen ("The-Answer"),
"The-Answer",
ANASTASIS_TESTING_TSO_NONE,
MHD_HTTP_NO_CONTENT),
@@ -219,12 +216,12 @@ run (void *cls,
"truth-store-2",
anastasis_url,
NULL,
- "question",
- "Truth mime",
- strlen ("Answer-2"),
- "Answer-2",
+ "file",
+ "text/plain",
+ strlen ("file-secret"),
+ "file-secret",
ANASTASIS_TESTING_TSO_NONE,
- MHD_HTTP_OK),
+ MHD_HTTP_NO_CONTENT),
ANASTASIS_TESTING_cmd_keyshare_lookup (
"challenge-run-1",
anastasis_url,
diff --git a/src/testing/test_anastasis_api.conf
b/src/testing/test_anastasis_api.conf
index 007ffd1..40d5d29 100644
--- a/src/testing/test_anastasis_api.conf
+++ b/src/testing/test_anastasis_api.conf
@@ -61,7 +61,7 @@ PAYMENT_BACKEND_URL = http://localhost:8080/
#ANNUAL_FEE = EUR:4.99
ANNUAL_FEE = EUR:4.99
-TRUTH_UPLOAD_FEE = EUR:0
+TRUTH_UPLOAD_FEE = EUR:0.0
# Authentication costs
[authorization-question]
diff --git a/src/testing/testing_api_cmd_truth_store.c
b/src/testing/testing_api_cmd_truth_store.c
index 8740775..398229d 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -369,6 +369,9 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
{
struct TruthStoreState *tss;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Storing %u bytes of truth\n",
+ (unsigned int) truth_data_size);
tss = GNUNET_new (struct TruthStoreState);
tss->http_status = http_status;
tss->tsopt = tso;
@@ -391,3 +394,29 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
return cmd;
}
}
+
+
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_question (
+ const char *label,
+ const char *anastasis_url,
+ const char *prev_upload,
+ const char *answer,
+ enum ANASTASIS_TESTING_TruthStoreOption tso,
+ unsigned int http_status)
+{
+ struct GNUNET_HashCode h;
+
+ GNUNET_CRYPTO_hash (answer,
+ strlen (answer),
+ &h);
+ return ANASTASIS_TESTING_cmd_truth_store (label,
+ anastasis_url,
+ prev_upload,
+ "question",
+ "binary/sha512",
+ sizeof (h),
+ &h,
+ tso,
+ http_status);
+}
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index d882b5e..6bfd525 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -437,6 +437,7 @@ ANASTASIS_CRYPTO_truth_encrypt (
size_t *ect_size)
{
const char *salt = "ect";
+
anastasis_encrypt (truth_enc_key,
sizeof (struct ANASTASIS_CRYPTO_TruthKeyP),
truth,
@@ -456,6 +457,7 @@ ANASTASIS_CRYPTO_truth_decrypt (
size_t *truth_size)
{
const char *salt = "ect";
+
anastasis_decrypt (truth_enc_key,
sizeof (struct ANASTASIS_CRYPTO_TruthKeyP),
enc_truth,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: fix plugin unload,
gnunet <=