aboutsummaryrefslogtreecommitdiff
path: root/ports-mgmt/pkg-devel
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2019-05-23 17:00:09 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2019-05-23 17:00:09 +0000
commit68f4e42bd9428273f65e64f1c7faadc9445d04b2 (patch)
treea915c8b3413c2b33a620f20e2593d2cb832c5a52 /ports-mgmt/pkg-devel
parentfe757f18464f837322a738967a1d9eb71090340d (diff)
downloadports-68f4e42bd9428273f65e64f1c7faadc9445d04b2.tar.gz
ports-68f4e42bd9428273f65e64f1c7faadc9445d04b2.zip
Add a patch to not close stding but actually use /dev/null
When running scripts
Notes
Notes: svn path=/head/; revision=502342
Diffstat (limited to 'ports-mgmt/pkg-devel')
-rw-r--r--ports-mgmt/pkg-devel/files/patch-better-stdin-handling47
1 files changed, 47 insertions, 0 deletions
diff --git a/ports-mgmt/pkg-devel/files/patch-better-stdin-handling b/ports-mgmt/pkg-devel/files/patch-better-stdin-handling
new file mode 100644
index 000000000000..045a088440f2
--- /dev/null
+++ b/ports-mgmt/pkg-devel/files/patch-better-stdin-handling
@@ -0,0 +1,47 @@
+diff --git libpkg/scripts.c libpkg/scripts.c
+index 04667af1..489b46d7 100644
+--- libpkg/scripts.c
++++ libpkg/scripts.c
+@@ -35,6 +35,7 @@
+
+ #include <assert.h>
+ #include <errno.h>
++#include <fcntl.h>
+ #include <paths.h>
+ #include <spawn.h>
+ #include <stdlib.h>
+@@ -59,6 +60,7 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
+ const char *argv[4];
+ char **ep;
+ int ret = EPKG_OK;
++ int fd = -1;
+ int stdin_pipe[2] = {-1, -1};
+ posix_spawn_file_actions_t action;
+ bool use_pipe = 0;
+@@ -157,8 +159,15 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
+
+ use_pipe = 1;
+ } else {
+- posix_spawn_file_actions_addclose(&action,
+- STDIN_FILENO);
++ fd = open("/dev/null", O_RDWR);
++ if (fd < 0) {
++ pkg_errno("Cannot open %s", "/dev/null");
++ ret = EPKG_FATAL;
++ posix_spawn_file_actions_destroy(&action);
++ goto cleanup;
++ }
++ posix_spawn_file_actions_adddup2(&action,
++ fd, STDIN_FILENO);
+
+ argv[0] = _PATH_BSHELL;
+ argv[1] = "-c";
+@@ -178,6 +187,8 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
+ }
+ posix_spawn_file_actions_destroy(&action);
+
++ if (fd != -1)
++ close(fd);
+ if (use_pipe) {
+ script_cmd_p = utstring_body(script_cmd);
+ script_cmd_len = utstring_len(script_cmd);