mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 03:35:41 +02:00
module/script: open comm-pipe + /dev/null with CLOEXEC
This ensures we don’t leak FDs when exec:ing e.g. on-click handlers. Note that the comm-pipe FD is *supposed* to stay open when we execing the script. This is handled by the call to dup2(), which drops the CLOEXEC flag. Since dup2() is called after the fork, the dup:ed FD is never visible in the “parent” yambar process.
This commit is contained in:
parent
2b6f5b1e36
commit
068c25d8f6
1 changed files with 2 additions and 2 deletions
|
@ -396,7 +396,7 @@ execute_script(struct module *mod)
|
||||||
|
|
||||||
/* Stdout redirection pipe */
|
/* Stdout redirection pipe */
|
||||||
int comm_pipe[2];
|
int comm_pipe[2];
|
||||||
if (pipe(comm_pipe) < 0) {
|
if (pipe2(comm_pipe, O_CLOEXEC) < 0) {
|
||||||
LOG_ERRNO("failed to create stdin/stdout redirection pipe");
|
LOG_ERRNO("failed to create stdin/stdout redirection pipe");
|
||||||
close(exec_pipe[0]);
|
close(exec_pipe[0]);
|
||||||
close(exec_pipe[1]);
|
close(exec_pipe[1]);
|
||||||
|
@ -444,7 +444,7 @@ execute_script(struct module *mod)
|
||||||
close(comm_pipe[0]);
|
close(comm_pipe[0]);
|
||||||
|
|
||||||
/* Re-direct stdin/stdout */
|
/* Re-direct stdin/stdout */
|
||||||
int dev_null = open("/dev/null", O_RDONLY);
|
int dev_null = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||||
if (dev_null < 0)
|
if (dev_null < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue