From 67a391f8d0a82aa6436ab21972f4f98d51e4d2e6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Sep 2023 15:06:26 +0930 Subject: [PATCH] lightningd: pass --developer down to plugins, subdaemons when it set. They might need to know this before they do anything, so cmdline seems most natural. Signed-off-by: Rusty Russell --- lightningd/plugin.c | 7 +++++-- lightningd/subd.c | 6 +++++- tests/plugins/badopeningd.sh | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 578d42366..d7dee75d1 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -1823,10 +1823,13 @@ const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id) && strends(p->cmd, p->plugins->ld->dev_debug_subprocess)) debug = true; #endif - cmd = tal_arrz(tmpctx, char *, 2 + debug); + cmd = tal_arr(tmpctx, char *, 1); cmd[0] = p->cmd; if (debug) - cmd[1] = "--debugger"; + tal_arr_expand(&cmd, "--debugger"); + if (p->plugins->ld->developer) + tal_arr_expand(&cmd, "--developer"); + tal_arr_expand(&cmd, NULL); p->pid = pipecmdarr(&stdinfd, &stdoutfd, &pipecmd_preserve, cmd); if (p->pid == -1) return tal_fmt(p, "opening pipe: %s", strerror(errno)); diff --git a/lightningd/subd.c b/lightningd/subd.c index 3f1aa3411..cd08de0bc 100644 --- a/lightningd/subd.c +++ b/lightningd/subd.c @@ -203,6 +203,7 @@ static int subd(const char *path, const char *name, const char *debug_subdaemon, int *msgfd, bool io_logging, + bool developer, va_list *ap) { int childmsg[2], execfail[2]; @@ -225,7 +226,7 @@ static int subd(const char *path, const char *name, if (childpid == 0) { size_t num_args; - char *args[] = { NULL, NULL, NULL, NULL }; + char *args[] = { NULL, NULL, NULL, NULL, NULL }; int **fds = tal_arr(tmpctx, int *, 3); int stdoutfd = STDOUT_FILENO, stderrfd = STDERR_FILENO; @@ -260,6 +261,8 @@ static int subd(const char *path, const char *name, if (debug_subdaemon && strends(name, debug_subdaemon)) args[num_args++] = "--debugger"; #endif + if (developer) + args[num_args++] = "--developer"; execv(args[0], args); child_errno_fail: @@ -743,6 +746,7 @@ static struct subd *new_subd(const tal_t *ctx, /* We only turn on subdaemon io logging if we're going * to print it: too stressful otherwise! */ log_has_io_logging(sd->log), + ld->developer, ap); if (sd->pid == (pid_t)-1) { log_unusual(ld->log, "subd %s failed: %s", diff --git a/tests/plugins/badopeningd.sh b/tests/plugins/badopeningd.sh index b674ca2a4..1c358d720 100755 --- a/tests/plugins/badopeningd.sh +++ b/tests/plugins/badopeningd.sh @@ -1,7 +1,7 @@ #! /bin/sh # If this file exists, we send that message back, then sleep. -if [ $# = 0 ] && [ -f openingd-version ]; then +if [ "$1" != "--version" ] && [ -f openingd-version ]; then # lightningd expects us to write to stdin! cat openingd-version >&0 sleep 10