commit 1368bc38840eddc9eb3718b6253b830109c86907
parent 10d8e79e54ecbba07f9f9f9cb0f119ab6817ee74
Author: Florian Dold <dold@taler.net>
Date: Thu, 27 Aug 2026 23:45:34 +0200
challenger: allow arguments in TAN helper commands
Diffstat:
5 files changed, 77 insertions(+), 7 deletions(-)
diff --git a/src/challenger/cat-with-args.sh b/src/challenger/cat-with-args.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+# This file is in the public domain.
+if [ "$1" != "--test-command-argument" ]
+then
+ exit 40
+fi
+cat - > "$(printf '%s\n' "$2" | jq -r ".filename")"
+exit 0
diff --git a/src/challenger/challenger-httpd_challenge.c b/src/challenger/challenger-httpd_challenge.c
@@ -415,6 +415,51 @@ child_done_cb (void *cls,
/**
+ * Resolve a binary name via PATH.
+ *
+ * Needed because the GNUnet process helpers do not support
+ * an execp equivalent at present.
+ *
+ * @param binary_name name to search for
+ * @return resolved path, NULL if the binary was not found
+ */
+static char *
+resolve_path (const char *binary_name)
+{
+ char *path_env;
+ char full_path[2048];
+ char *dir;
+ char *path_copy;
+
+ if (NULL != strchr (binary_name,
+ '/'))
+ return GNUNET_strdup (binary_name);
+ path_env = getenv ("PATH");
+ if (NULL == path_env)
+ return NULL;
+ path_copy = GNUNET_strdup (path_env);
+ dir = strtok (path_copy, ":");
+ while (NULL != dir)
+ {
+ snprintf (full_path,
+ sizeof(full_path),
+ "%s/%s",
+ dir,
+ binary_name);
+ if (0 == access (full_path,
+ X_OK))
+ {
+ GNUNET_free (path_copy);
+ return GNUNET_strdup (full_path);
+ }
+ dir = strtok (NULL, ":");
+ }
+ GNUNET_free (path_copy);
+ return NULL;
+}
+
+
+/**
* Transmit the TAN to the given address.
*
* @param[in,out] bc context to submit TAN for
@@ -445,9 +490,16 @@ send_tan (struct ChallengeContext *bc)
}
{
char *address;
+ char *binary_path = NULL;
+ char **cmd_argv;
+ const char *extra_args[2];
address = json_dumps (bc->address,
JSON_COMPACT);
+ extra_args[0] = address;
+ extra_args[1] = NULL;
+ cmd_argv = TALER_words_split (CH_auth_command,
+ extra_args);
#if DEBUG
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Running auth command `%s' on address `%s'\n",
@@ -460,18 +512,21 @@ send_tan (struct ChallengeContext *bc)
bc->child,
GNUNET_process_option_inherit_rpipe (p,
STDIN_FILENO)));
- if (GNUNET_OK !=
- GNUNET_process_run_command_va (bc->child,
- CH_auth_command,
- CH_auth_command,
- address,
- NULL))
+ if (NULL != cmd_argv[0])
+ binary_path = resolve_path (cmd_argv[0]);
+ if ( (NULL == binary_path) ||
+ (GNUNET_OK !=
+ GNUNET_process_run_command_argv (bc->child,
+ binary_path,
+ (const char **) cmd_argv)) )
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
"exec");
GNUNET_process_destroy (bc->child);
bc->child = NULL;
}
+ GNUNET_free (binary_path);
+ TALER_words_destroy (cmd_argv);
free (address);
}
if (NULL == bc->child)
diff --git a/src/challenger/challenger.conf b/src/challenger/challenger.conf
@@ -44,6 +44,7 @@ BASE_URL = http://localhost:9967/
MESSAGE_TEMPLATE_FILE = ${DATADIR}templates/default-challenge-message.txt
# Which external command should be used to transmit challenges?
+# The command may include arguments separated by spaces.
# Example commands are challenger-send-{sms,email,post}.sh
# AUTH_COMMAND =
AUTH_COMMAND = /usr/bin/true
diff --git a/src/challenger/meson.build b/src/challenger/meson.build
@@ -28,6 +28,12 @@ check_SCRIPTS = [
test_helper_cat = configure_file(input: 'cat.sh', output: 'cat.sh', copy: true)
+test_helper_cat_with_args = configure_file(
+ input: 'cat-with-args.sh',
+ output: 'cat-with-args.sh',
+ copy: true,
+)
+
test_conf = configure_file(
input: 'test-challenger.conf',
output: 'test-challenger.conf',
diff --git a/src/challenger/test-challenger.conf b/src/challenger/test-challenger.conf
@@ -1,7 +1,7 @@
[challenger]
# Which external command should be used to transmit challenges?
-AUTH_COMMAND = cat.sh
+AUTH_COMMAND = cat-with-args.sh --test-command-argument
# What address type are we validating? (SMS, e-mail, etc.)
ADDRESS_TYPE = file-access