|
@ -1,6 +1,8 @@ |
|
|
#include <lightningd/options.h> |
|
|
#include <lightningd/options.h> |
|
|
#include <lightningd/plugin_control.h> |
|
|
#include <lightningd/plugin_control.h> |
|
|
#include <lightningd/plugin_hook.h> |
|
|
#include <lightningd/plugin_hook.h> |
|
|
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
#include <sys/types.h> |
|
|
|
|
|
|
|
|
/* A dummy structure used to give multiple arguments to callbacks. */ |
|
|
/* A dummy structure used to give multiple arguments to callbacks. */ |
|
|
struct dynamic_plugin { |
|
|
struct dynamic_plugin { |
|
@ -108,6 +110,7 @@ static void plugin_dynamic_manifest_callback(const char *buffer, |
|
|
static struct command_result *plugin_start(struct dynamic_plugin *dp) |
|
|
static struct command_result *plugin_start(struct dynamic_plugin *dp) |
|
|
{ |
|
|
{ |
|
|
int stdin, stdout; |
|
|
int stdin, stdout; |
|
|
|
|
|
mode_t prev_mask; |
|
|
char **p_cmd; |
|
|
char **p_cmd; |
|
|
struct jsonrpc_request *req; |
|
|
struct jsonrpc_request *req; |
|
|
struct plugin *p = dp->plugin; |
|
|
struct plugin *p = dp->plugin; |
|
@ -115,7 +118,10 @@ static struct command_result *plugin_start(struct dynamic_plugin *dp) |
|
|
p->dynamic = true; |
|
|
p->dynamic = true; |
|
|
p_cmd = tal_arrz(NULL, char *, 2); |
|
|
p_cmd = tal_arrz(NULL, char *, 2); |
|
|
p_cmd[0] = p->cmd; |
|
|
p_cmd[0] = p->cmd; |
|
|
|
|
|
/* In case the plugin create files, this is a better default. */ |
|
|
|
|
|
prev_mask = umask(dp->cmd->ld->initial_umask); |
|
|
p->pid = pipecmdarr(&stdin, &stdout, &pipecmd_preserve, p_cmd); |
|
|
p->pid = pipecmdarr(&stdin, &stdout, &pipecmd_preserve, p_cmd); |
|
|
|
|
|
umask(prev_mask); |
|
|
if (p->pid == -1) |
|
|
if (p->pid == -1) |
|
|
return plugin_dynamic_error(dp, "Error running command"); |
|
|
return plugin_dynamic_error(dp, "Error running command"); |
|
|
else |
|
|
else |
|
|