gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: fix misc issues


From: gnunet
Subject: [taler-anastasis] branch master updated: fix misc issues
Date: Sun, 14 Feb 2021 12:32:57 +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 fcac8f5  fix misc issues
fcac8f5 is described below

commit fcac8f5306b3eacd07cc898abb62ce639f83a0a6
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 14 12:32:55 2021 +0100

    fix misc issues
---
 src/authorization/anastasis_authorization_plugin.c |   9 +-
 .../anastasis_authorization_plugin_file.c          |   2 +-
 src/backend/anastasis-httpd_truth.c                |  15 ++-
 src/testing/testing_api_cmd_keyshare_lookup.c      | 112 ++++++++++++++++-----
 src/testing/testing_api_cmd_truth_store.c          |   2 +
 5 files changed, 105 insertions(+), 35 deletions(-)

diff --git a/src/authorization/anastasis_authorization_plugin.c 
b/src/authorization/anastasis_authorization_plugin.c
index fdeda22..7874594 100644
--- a/src/authorization/anastasis_authorization_plugin.c
+++ b/src/authorization/anastasis_authorization_plugin.c
@@ -85,10 +85,6 @@ ANASTASIS_authorization_plugin_load (
   struct AuthPlugin *ap;
   char *currency;
 
-  if (GNUNET_OK !=
-      TALER_config_get_currency (AH_cfg,
-                                 &currency))
-    return NULL;
   for (ap = ap_head; NULL != ap; ap = ap->next)
     if (0 == strcmp (method,
                      ap->name))
@@ -96,7 +92,10 @@ ANASTASIS_authorization_plugin_load (
       *cost = ap->cost;
       return ap->authorization;
     }
-
+  if (GNUNET_OK !=
+      TALER_config_get_currency (AH_cfg,
+                                 &currency))
+    return NULL;
   ap = GNUNET_new (struct AuthPlugin);
   GNUNET_asprintf (&sec_name,
                    "authorization-%s",
diff --git a/src/authorization/anastasis_authorization_plugin_file.c 
b/src/authorization/anastasis_authorization_plugin_file.c
index d2adc54..8c8790b 100644
--- a/src/authorization/anastasis_authorization_plugin_file.c
+++ b/src/authorization/anastasis_authorization_plugin_file.c
@@ -200,7 +200,7 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
                                      "Challenge written to file");
     resp = MHD_create_response_from_buffer (response_size,
                                             response,
-                                            MHD_RESPMEM_MUST_FREE);
+                                            MHD_RESPMEM_MUST_COPY);
     GNUNET_free (response);
     TALER_MHD_add_global_headers (resp);
     mres = MHD_queue_response (connection,
diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 825d527..5cf426b 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -130,6 +130,12 @@ struct GetContext
    */
   bool in_list;
 
+  /**
+   * Did the request include a response?
+   */
+  bool have_response;
+
+
 };
 
 
@@ -157,6 +163,7 @@ AH_truth_shutdown (void)
                                    gc_tail,
                                    gc);
       gc->in_list = false;
+      MHD_resume_connection (gc->connection);
     }
     if (NULL != gc->as)
     {
@@ -164,7 +171,6 @@ AH_truth_shutdown (void)
       gc->as = NULL;
       gc->authorization = NULL;
     }
-    MHD_resume_connection (gc->connection);
   }
   ANASTASIS_authorization_plugin_shutdown ();
 }
@@ -575,7 +581,6 @@ AH_handler_truth_get (
 {
   struct GetContext *gc = hc->ctx;
   struct GNUNET_HashCode challenge_response;
-  bool have_response;
   void *encrypted_truth;
   size_t encrypted_truth_size;
   void *decrypted_truth;
@@ -665,7 +670,7 @@ AH_handler_truth_get (
                                            
TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                            "response");
       }
-      have_response = (NULL != challenge_response_s);
+      gc->have_response = (NULL != challenge_response_s);
     }
 
   } /* end of first-time initialization (if NULL == gc) */
@@ -867,7 +872,7 @@ AH_handler_truth_get (
      but check that the hash matches */
   if (is_question)
   {
-    if (! have_response)
+    if (! gc->have_response)
     {
       GNUNET_free (decrypted_truth);
       GNUNET_free (truth_mime);
@@ -913,7 +918,7 @@ AH_handler_truth_get (
   }
 
   /* Not security question, check for answer in DB */
-  if (have_response)
+  if (gc->have_response)
   {
     enum ANASTASIS_DB_CodeStatus cs;
 
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c 
b/src/testing/testing_api_cmd_keyshare_lookup.c
index d8768ca..48ca623 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -89,7 +89,12 @@ struct KeyShareLookupState
   char *redirect_uri;
 
   /**
-   * "instructions" for challenge, if any.
+   * "code" returned by service, if any.
+   */
+  char *code;
+
+  /**
+   * "instructions" for how to solve the challenge as returned by service, if 
any.
    */
   char *instructions;
 
@@ -98,6 +103,11 @@ struct KeyShareLookupState
    */
   int lookup_mode;
 
+  /**
+   * True if the authentication method is 'file'.
+   */
+  bool is_file;
+
 };
 
 
@@ -143,8 +153,40 @@ keyshare_lookup_cb (void *cls,
 
     break;
   case ANASTASIS_KSD_INVALID_ANSWER:
-    ksls->instructions = GNUNET_strdup (
-      dd->details.open_challenge.instructions);
+    if (ksls->is_file)
+    {
+      FILE *file;
+      char code[22];
+
+      file = fopen (dd->details.open_challenge.instructions,
+                    "r");
+      if (NULL == file)
+      {
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+                                  "open",
+                                  dd->details.open_challenge.instructions);
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
+      if (0 == fscanf (file,
+                       "%21s",
+                       code))
+      {
+        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+                                  "fscanf",
+                                  dd->details.open_challenge.instructions);
+        GNUNET_break (0 == fclose (file));
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
+      GNUNET_break (0 == fclose (file));
+      ksls->code = GNUNET_strdup (code);
+    }
+    else
+    {
+      ksls->instructions = GNUNET_strdup (
+        dd->details.open_challenge.instructions);
+    }
     break;
   case ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION:
     ksls->redirect_uri = GNUNET_strdup (dd->details.redirect_url);
@@ -169,6 +211,7 @@ keyshare_lookup_run (void *cls,
   const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
   const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid;
   const struct ANASTASIS_PaymentSecretP *payment_secret;
+  const char *answer;
 
   ksls->is = is;
   if (NULL == ksls->upload_reference)
@@ -189,6 +232,21 @@ keyshare_lookup_run (void *cls,
       TALER_TESTING_interpreter_fail (ksls->is);
       return;
     }
+    {
+      const char *method;
+
+      if (GNUNET_OK !=
+          TALER_TESTING_get_trait_string (upload_cmd,
+                                          0,
+                                          &method))
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (ksls->is);
+        return;
+      }
+      ksls->is_file = (0 == strcasecmp (method,
+                                        "file"));
+    }
     if (GNUNET_OK !=
         ANASTASIS_TESTING_get_trait_truth_uuid (upload_cmd,
                                                 0,
@@ -233,26 +291,29 @@ keyshare_lookup_run (void *cls,
       TALER_TESTING_interpreter_fail (ksls->is);
       return;
     }
+    if (GNUNET_OK !=
+        ANASTASIS_TESTING_get_trait_code (download_cmd,
+                                          0,
+                                          &answer))
     {
-      if (GNUNET_OK !=
-          ANASTASIS_TESTING_get_trait_code (download_cmd,
-                                            0,
-                                            &ksls->answer))
-      {
-        GNUNET_break (0);
-        TALER_TESTING_interpreter_fail (ksls->is);
-        return;
-      }
-      if (NULL == ksls->answer)
-      {
-        GNUNET_break (0);
-        TALER_TESTING_interpreter_fail (ksls->is);
-        return;
-      }
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Answer from trait: %s\n",
-                  ksls->answer);
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (ksls->is);
+      return;
     }
+    if (NULL == ksls->answer)
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (ksls->is);
+      return;
+    }
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Answer from trait: %s\n",
+                answer);
+  }
+  else
+  {
+    /* answer is the answer */
+    answer = ksls->answer;
   }
 
   if (NULL != ksls->payment_reference)
@@ -280,9 +341,9 @@ keyshare_lookup_run (void *cls,
   {
     struct GNUNET_HashCode h_answer;
 
-    if (NULL != ksls->answer)
-      GNUNET_CRYPTO_hash (ksls->answer,
-                          strlen (ksls->answer),
+    if (NULL != answer)
+      GNUNET_CRYPTO_hash (answer,
+                          strlen (answer),
                           &h_answer);
     ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
                                             ksls->anastasis_url,
@@ -320,6 +381,7 @@ keyshare_lookup_cleanup (void *cls,
   }
   GNUNET_free (ksls->pay_uri);
   GNUNET_free (ksls->order_id);
+  GNUNET_free (ksls->code);
   GNUNET_free (ksls->instructions);
   GNUNET_free (ksls->redirect_uri);
   GNUNET_free (ksls);
@@ -349,6 +411,8 @@ keyshare_lookup_traits (void *cls,
                                   ksls->pay_uri),
     TALER_TESTING_make_trait_order_id (0,
                                        ksls->order_id),
+    ANASTASIS_TESTING_make_trait_code (0,
+                                       ksls->code),
     TALER_TESTING_trait_end ()
   };
 
diff --git a/src/testing/testing_api_cmd_truth_store.c 
b/src/testing/testing_api_cmd_truth_store.c
index 8e5a032..6eb3a09 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -365,6 +365,8 @@ truth_store_traits (void *cls,
                                                  
&tss->payment_secret_response),
     TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
                                   tss->pay_uri),
+    TALER_TESTING_make_trait_string (0,
+                                     tss->method),
     TALER_TESTING_trait_end ()
   };
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]