mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
plugin_control: spawn plugin processes with a non-0 umask
Changelog-Added: JSONRPC: 'plugin start' now restores initial umask before spawning the plugin process
This commit is contained in:
committed by
Christian Decker
parent
1cfb8425f5
commit
841fbf54ea
@@ -1,6 +1,8 @@
|
||||
#include <lightningd/options.h>
|
||||
#include <lightningd/plugin_control.h>
|
||||
#include <lightningd/plugin_hook.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* A dummy structure used to give multiple arguments to callbacks. */
|
||||
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)
|
||||
{
|
||||
int stdin, stdout;
|
||||
mode_t prev_mask;
|
||||
char **p_cmd;
|
||||
struct jsonrpc_request *req;
|
||||
struct plugin *p = dp->plugin;
|
||||
@@ -115,7 +118,10 @@ static struct command_result *plugin_start(struct dynamic_plugin *dp)
|
||||
p->dynamic = true;
|
||||
p_cmd = tal_arrz(NULL, char *, 2);
|
||||
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);
|
||||
umask(prev_mask);
|
||||
if (p->pid == -1)
|
||||
return plugin_dynamic_error(dp, "Error running command");
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user