anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 9c02a3d38090f4b01a5f7e7af13dbf24240632b2
parent c74d84c38b6c242559b0861a772c2ffced9f077b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 16 Mar 2026 23:38:25 +0100

adapt to revised GNUNET_process() API one more time

Diffstat:
Msrc/authorization/anastasis_authorization_plugin_email.c | 16+++++++---------
Msrc/authorization/anastasis_authorization_plugin_post.c | 24+++++++++++-------------
Msrc/authorization/anastasis_authorization_plugin_sms.c | 16+++++++---------
Msrc/include/anastasis_testing_lib.h | 156++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/include/anastasis_util_lib.h | 43-------------------------------------------
Msrc/reducer/anastasis_api_redux.c | 62++++++++++++++++++++++++++++++++++++--------------------------
Msrc/testing/testing_api_helpers.c | 68++++++++++++++++++++++++++++++++++++++------------------------------
7 files changed, 177 insertions(+), 208 deletions(-)

diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c @@ -352,20 +352,18 @@ email_challenge (struct ANASTASIS_AUTHORIZATION_State *as, return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED; return ANASTASIS_AUTHORIZATION_CRES_FAILED; } - as->child = GNUNET_process_create (); + as->child = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ERR); GNUNET_assert (GNUNET_OK == GNUNET_process_set_options ( as->child, GNUNET_process_option_inherit_rpipe (p, STDIN_FILENO))); - if ( (GNUNET_OK != - GNUNET_process_set_command_va (as->child, - as->ctx->auth_command, - as->ctx->auth_command, - as->email, - NULL)) || - (GNUNET_OK != - GNUNET_process_start (as->child)) ) + if (GNUNET_OK != + GNUNET_process_run_command_va (as->child, + as->ctx->auth_command, + as->ctx->auth_command, + as->email, + NULL)) { GNUNET_process_destroy (as->child); as->child = NULL; diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c @@ -422,24 +422,22 @@ post_challenge (struct ANASTASIS_AUTHORIZATION_State *as, return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED; return ANASTASIS_AUTHORIZATION_CRES_FAILED; } - as->child = GNUNET_process_create (); + as->child = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ERR); GNUNET_assert (GNUNET_OK == GNUNET_process_set_options ( as->child, GNUNET_process_option_inherit_rpipe (p, STDIN_FILENO))); - if ( (GNUNET_OK != - GNUNET_process_set_command_va (as->child, - as->ctx->auth_command, - as->ctx->auth_command, - name, - street, - city, - zip, - country, - NULL)) || - (GNUNET_OK != - GNUNET_process_start (as->child)) ) + if (GNUNET_OK != + GNUNET_process_run_command_va (as->child, + as->ctx->auth_command, + as->ctx->auth_command, + name, + street, + city, + zip, + country, + NULL)) { GNUNET_process_destroy (as->child); as->child = NULL; diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c @@ -351,20 +351,18 @@ sms_challenge (struct ANASTASIS_AUTHORIZATION_State *as, return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED; return ANASTASIS_AUTHORIZATION_CRES_FAILED; } - as->child = GNUNET_process_create (); + as->child = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ERR); GNUNET_assert (GNUNET_OK == GNUNET_process_set_options ( as->child, GNUNET_process_option_inherit_rpipe (p, STDIN_FILENO))); - if ( (GNUNET_OK != - GNUNET_process_set_command_va (as->child, - as->ctx->auth_command, - as->ctx->auth_command, - as->phone_number, - NULL)) || - (GNUNET_OK != - GNUNET_process_start (as->child)) ) + if (GNUNET_OK != + GNUNET_process_run_command_va (as->child, + as->ctx->auth_command, + as->ctx->auth_command, + as->phone_number, + NULL)) { GNUNET_process_destroy (as->child); as->child = NULL; diff --git a/src/include/anastasis_testing_lib.h b/src/include/anastasis_testing_lib.h @@ -30,7 +30,7 @@ /* ********************* Helper functions ********************* */ #define ANASTASIS_FAIL() \ - do {GNUNET_break (0); return NULL; } while (0) + do {GNUNET_break (0); return NULL; } while (0) /** @@ -38,13 +38,13 @@ * statically allocated data of type @a type. */ #define ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - ANASTASIS_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - type **ret); \ - struct TALER_TESTING_Trait \ - ANASTASIS_TESTING_make_trait_ ## name ( \ - type * value); + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret); \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + type * value); /** @@ -52,27 +52,27 @@ * allocated data of type @a type. */ #define ANASTASIS_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - ANASTASIS_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - type **ret) \ - { \ - if (NULL == cmd->traits) return GNUNET_SYSERR; \ - return cmd->traits (cmd->cls, \ - (const void **) ret, \ - TALER_S (name), \ - 0); \ - } \ - struct TALER_TESTING_Trait \ - ANASTASIS_TESTING_make_trait_ ## name ( \ - type * value) \ - { \ - struct TALER_TESTING_Trait ret = { \ - .trait_name = TALER_S (name), \ - .ptr = (const void *) value \ - }; \ - return ret; \ - } + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type * *ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + 0); \ + } \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } /** @@ -80,15 +80,15 @@ * statically allocated data of type @a type. */ #define ANASTASIS_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - ANASTASIS_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - unsigned int index, \ - type **ret); \ - struct TALER_TESTING_Trait \ - ANASTASIS_TESTING_make_trait_ ## name ( \ - unsigned int index, \ - type * value); + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret); \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type *value); /** @@ -96,56 +96,56 @@ * allocated data of type @a type. */ #define ANASTASIS_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ - enum GNUNET_GenericReturnValue \ - ANASTASIS_TESTING_get_trait_ ## name ( \ - const struct TALER_TESTING_Command *cmd, \ - unsigned int index, \ - type **ret) \ - { \ - if (NULL == cmd->traits) return GNUNET_SYSERR; \ - return cmd->traits (cmd->cls, \ - (const void **) ret, \ - TALER_S (name), \ - index); \ - } \ - struct TALER_TESTING_Trait \ - ANASTASIS_TESTING_make_trait_ ## name ( \ - unsigned int index, \ - type * value) \ - { \ - struct TALER_TESTING_Trait ret = { \ - .index = index, \ - .trait_name = TALER_S (name), \ - .ptr = (const void *) value \ - }; \ - return ret; \ - } + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type * *ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + index); \ + } \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .index = index, \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } /** * Call #op on all simple traits. */ #define ANASTASIS_TESTING_SIMPLE_TRAITS(op) \ - op (hash, const struct GNUNET_HashCode) \ - op (truth, const struct ANASTASIS_Truth *) \ - op (policy, const struct ANASTASIS_Policy *) \ - op (provider_salt, const struct ANASTASIS_CRYPTO_ProviderSaltP) \ - op (core_secret, const void) \ - op (truth_key, const struct ANASTASIS_CRYPTO_TruthKeyP) \ - op (account_pub, const struct ANASTASIS_CRYPTO_AccountPublicKeyP) \ - op (account_priv, const struct ANASTASIS_CRYPTO_AccountPrivateKeyP) \ - op (payment_secret, const struct ANASTASIS_PaymentSecretP) \ - op (truth_uuid, const struct ANASTASIS_CRYPTO_TruthUUIDP) \ - op (eks, const struct ANASTASIS_CRYPTO_EncryptedKeyShareP) \ - op (code, const char) \ - op (filename, const char) + op (hash, const struct GNUNET_HashCode) \ + op (truth, const struct ANASTASIS_Truth *) \ + op (policy, const struct ANASTASIS_Policy *) \ + op (provider_salt, const struct ANASTASIS_CRYPTO_ProviderSaltP) \ + op (core_secret, const void) \ + op (truth_key, const struct ANASTASIS_CRYPTO_TruthKeyP) \ + op (account_pub, const struct ANASTASIS_CRYPTO_AccountPublicKeyP) \ + op (account_priv, const struct ANASTASIS_CRYPTO_AccountPrivateKeyP) \ + op (payment_secret, const struct ANASTASIS_PaymentSecretP) \ + op (truth_uuid, const struct ANASTASIS_CRYPTO_TruthUUIDP) \ + op (eks, const struct ANASTASIS_CRYPTO_EncryptedKeyShareP) \ + op (code, const char) \ + op (filename, const char) /** * Call #op on all indexed traits. */ #define ANASTASIS_TESTING_INDEXED_TRAITS(op) \ - op (challenges, const struct ANASTASIS_Challenge *) + op (challenges, const struct ANASTASIS_Challenge *) ANASTASIS_TESTING_SIMPLE_TRAITS (ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT) @@ -176,7 +176,7 @@ TALER_TESTING_prepare_merchant (const char *config_filename); * @return the process, or NULL if the process could not * be started. */ -struct GNUNET_OS_Process * +struct GNUNET_Process * TALER_TESTING_run_merchant (const char *config_filename, const char *merchant_url); @@ -191,7 +191,7 @@ TALER_TESTING_run_merchant (const char *config_filename, * @return the process, or NULL if the process could not * be started. */ -struct GNUNET_OS_Process * +struct GNUNET_Process * ANASTASIS_TESTING_run_anastasis (const char *config_filename, const char *anastasis_url); diff --git a/src/include/anastasis_util_lib.h b/src/include/anastasis_util_lib.h @@ -48,49 +48,6 @@ ANASTASIS_project_data (void); /** - * Handle for the child management - */ -struct ANASTASIS_ChildWaitHandle; - -/** - * Defines a ANASTASIS_ChildCompletedCallback which is sent back - * upon death or completion of a child process. Used to trigger - * authentication commands. - * - * @param cls handle for the callback - * @param type type of the process - * @param exit_code status code of the process - * -*/ -typedef void -(*ANASTASIS_ChildCompletedCallback)(void *cls, - enum GNUNET_OS_ProcessStatusType type, - long unsigned int exit_code); - - -/** - * Starts the handling of the child processes. - * Function checks the status of the child process and sends back a - * ANASTASIS_ChildCompletedCallback upon completion/death of the child. - * - * @param proc child process which is monitored - * @param cb reference to the callback which is called after completion - * @param cb_cls closure for the callback - * @return ANASTASIS_ChildWaitHandle is returned - */ -struct ANASTASIS_ChildWaitHandle * -ANASTASIS_wait_child (struct GNUNET_OS_Process *proc, - ANASTASIS_ChildCompletedCallback cb, - void *cb_cls); - -/** - * Stop waiting on this child. - */ -void -ANASTASIS_wait_child_cancel (struct ANASTASIS_ChildWaitHandle *cwh); - - -/** * Convert input string @a as into @a pin. * * @param as input of the form 42355-256-2262-265 diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c @@ -1616,7 +1616,7 @@ struct ExternalReducerCls struct GNUNET_SCHEDULER_Task *read_task; struct GNUNET_DISK_PipeHandle *reducer_stdin; struct GNUNET_DISK_PipeHandle *reducer_stdout; - struct GNUNET_OS_Process *reducer_process; + struct GNUNET_Process *reducer_process; ANASTASIS_ActionCallback action_cb; void *action_cb_cls; }; @@ -1655,21 +1655,24 @@ cleanup_external_reducer (void *cls) unsigned long code; enum GNUNET_GenericReturnValue pwret; - pwret = GNUNET_OS_process_wait_status (red_cls->reducer_process, - &type, - &code); - + pwret = GNUNET_process_wait (red_cls->reducer_process, + false, + &type, + &code); GNUNET_assert (GNUNET_SYSERR != pwret); if (GNUNET_NO == pwret) { - GNUNET_assert (0 == - GNUNET_OS_process_kill (red_cls->reducer_process, - SIGTERM)); + GNUNET_assert (GNUNET_OK == + GNUNET_process_kill (red_cls->reducer_process, + SIGTERM)); GNUNET_assert (GNUNET_SYSERR != - GNUNET_OS_process_wait (red_cls->reducer_process)); + GNUNET_process_wait (red_cls->reducer_process, + true, + NULL, + NULL)); } - GNUNET_OS_process_destroy (red_cls->reducer_process); + GNUNET_process_destroy (red_cls->reducer_process); red_cls->reducer_process = NULL; } @@ -1794,26 +1797,33 @@ redux_action_external (const char *ext_reducer, action, arg_str); - red_cls->reducer_process = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR, - red_cls->reducer_stdin, - red_cls->reducer_stdout, - NULL, - ext_reducer, - ext_reducer, - "-a", - arg_str, - action, - NULL); - - GNUNET_free (arg_str); - - if (NULL == red_cls->reducer_process) + red_cls->reducer_process + = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ERR); + GNUNET_assert (GNUNET_OK == + GNUNET_process_set_options ( + red_cls->reducer_process, + GNUNET_process_option_inherit_rpipe (red_cls->reducer_stdin, + STDIN_FILENO), + GNUNET_process_option_inherit_rpipe (red_cls->reducer_stdout, + STDOUT_FILENO))); + if (GNUNET_OK != + GNUNET_process_run_command_va (red_cls->reducer_process, + ext_reducer, + ext_reducer, + "-a", + arg_str, + action, + NULL)) { GNUNET_break (0); + GNUNET_process_destroy (red_cls->reducer_process); + red_cls->reducer_process = NULL; + GNUNET_free (arg_str); GNUNET_free (state_str); cleanup_external_reducer (red_cls); return NULL; } + GNUNET_free (arg_str); /* Close pipe ends we don't use. */ GNUNET_assert (GNUNET_OK == @@ -1849,8 +1859,8 @@ redux_action_external (const char *ext_reducer, red_cls); { - struct ANASTASIS_ReduxAction *ra = GNUNET_new (struct - ANASTASIS_ReduxAction); + struct ANASTASIS_ReduxAction *ra + = GNUNET_new (struct ANASTASIS_ReduxAction); ra->cleanup_cls = red_cls; ra->cleanup = cleanup_external_reducer; return ra; diff --git a/src/testing/testing_api_helpers.c b/src/testing/testing_api_helpers.c @@ -29,24 +29,26 @@ #include <gnunet/gnunet_curl_lib.h> -struct GNUNET_OS_Process * +struct GNUNET_Process * ANASTASIS_TESTING_run_anastasis (const char *config_filename, const char *anastasis_url) { - struct GNUNET_OS_Process *anastasis_proc; + struct GNUNET_Process *anastasis_proc; unsigned int iter; char *wget_cmd; - anastasis_proc - = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "anastasis-httpd", - "anastasis-httpd", - "--log=INFO", - "-c", config_filename, - NULL); - if (NULL == anastasis_proc) + anastasis_proc = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ALL); + if (GNUNET_OK != + GNUNET_process_run_command_va (anastasis_proc, + "anastasis-httpd", + "anastasis-httpd", + "--log=INFO", + "-c", config_filename, + NULL)) + { + GNUNET_process_destroy (anastasis_proc); ANASTASIS_FAIL (); + } GNUNET_asprintf (&wget_cmd, "wget -q -t 1 -T 1" @@ -64,11 +66,15 @@ ANASTASIS_TESTING_run_anastasis (const char *config_filename, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to launch `anastasis-httpd' (or `wget')\n"); - GNUNET_break (0 == - GNUNET_OS_process_kill (anastasis_proc, - SIGTERM)); - GNUNET_OS_process_wait (anastasis_proc); - GNUNET_OS_process_destroy (anastasis_proc); + GNUNET_break (GNUNET_OK == + GNUNET_process_kill (anastasis_proc, + SIGTERM)); + GNUNET_break (GNUNET_OK == + GNUNET_process_wait (anastasis_proc, + true, + NULL, + NULL)); + GNUNET_process_destroy (anastasis_proc); ANASTASIS_FAIL (); } { @@ -94,7 +100,7 @@ ANASTASIS_TESTING_prepare_anastasis (const char *config_filename) { struct GNUNET_CONFIGURATION_Handle *cfg; unsigned long long port; - struct GNUNET_OS_Process *dbinit_proc; + struct GNUNET_Process *dbinit_proc; enum GNUNET_OS_ProcessStatusType type; unsigned long code; char *base_url; @@ -130,28 +136,31 @@ ANASTASIS_TESTING_prepare_anastasis (const char *config_filename) } /* DB preparation */ - if (NULL == (dbinit_proc = GNUNET_OS_start_process - (GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "anastasis-dbinit", - "anastasis-dbinit", - "-c", config_filename, - "-r", - NULL))) + dbinit_proc = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ALL); + if (GNUNET_OK != + GNUNET_process_run_command_va (dbinit_proc, + "anastasis-dbinit", + "anastasis-dbinit", + "-c", config_filename, + "-r", + NULL)) { + GNUNET_process_destroy (dbinit_proc); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to run anastasis-dbinit. Check your PATH.\n"); return NULL; } if (GNUNET_SYSERR == - GNUNET_OS_process_wait_status (dbinit_proc, - &type, - &code)) + GNUNET_process_wait (dbinit_proc, + true, + &type, + &code)) { - GNUNET_OS_process_destroy (dbinit_proc); + GNUNET_process_destroy (dbinit_proc); ANASTASIS_FAIL (); } + GNUNET_process_destroy (dbinit_proc); if ( (type == GNUNET_OS_PROCESS_EXITED) && (0 != code) ) { @@ -166,7 +175,6 @@ ANASTASIS_TESTING_prepare_anastasis (const char *config_filename) "Unexpected error running `anastasis-dbinit'!\n"); return NULL; } - GNUNET_OS_process_destroy (dbinit_proc); GNUNET_asprintf (&base_url, "http://localhost:%llu/", port);