2015-07-19 22:17:28 +01:00
|
|
|
From 5bef9deeff8a2e4401de0f45c9701cd6f98f29d8 Mon Sep 17 00:00:00 2001
|
2014-04-13 16:06:00 +01:00
|
|
|
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
|
2015-07-19 22:17:28 +01:00
|
|
|
Date: Thu, 26 Nov 2015 21:03:35 +0100
|
2014-04-13 16:06:00 +01:00
|
|
|
Subject: [PATCH] Lookup dumpcap in PATH
|
|
|
|
|
|
|
|
NixOS patch: Look for dumpcap in PATH first, because there may be a
|
2017-01-29 07:08:36 +00:00
|
|
|
dumpcap wrapper that we want to use instead of the default
|
2014-04-13 16:06:00 +01:00
|
|
|
non-setuid dumpcap binary.
|
|
|
|
|
|
|
|
Also change execv() to execvp() because we've set argv[0] to "dumpcap"
|
|
|
|
and have to enable PATH lookup. Wireshark is not a setuid program, so
|
|
|
|
looking in PATH is not a security issue.
|
2015-07-19 22:17:28 +01:00
|
|
|
|
2021-12-28 22:53:10 +00:00
|
|
|
EDITED by teto for wireshark 3.6
|
|
|
|
|
2015-07-19 22:17:28 +01:00
|
|
|
Signed-off-by: Franz Pletz <fpletz@fnordicwalking.de>
|
2014-04-13 16:06:00 +01:00
|
|
|
---
|
2015-07-19 22:17:28 +01:00
|
|
|
capchild/capture_sync.c | 17 ++++++++++++++---
|
|
|
|
1 file changed, 14 insertions(+), 3 deletions(-)
|
2014-04-13 16:06:00 +01:00
|
|
|
|
2015-07-19 22:17:28 +01:00
|
|
|
diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
|
2021-12-28 22:53:10 +00:00
|
|
|
index f31914886a..df29b6f0ab 100644
|
|
|
|
--- a/capture/capture_sync.c
|
|
|
|
+++ b/capture/capture_sync.c
|
|
|
|
@@ -187,7 +187,18 @@ init_pipe_args(int *argc) {
|
2015-07-19 22:17:28 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
exename = g_strdup_printf("%s\\dumpcap.exe", progfile_dir);
|
|
|
|
#else
|
|
|
|
- exename = g_strdup_printf("%s/dumpcap", progfile_dir);
|
2014-04-13 16:06:00 +01:00
|
|
|
+ /*
|
|
|
|
+ * NixOS patch: Look for dumpcap in PATH first, because there may be a
|
2017-01-29 07:08:36 +00:00
|
|
|
+ * dumpcap wrapper that we want to use instead of the default
|
2014-04-13 16:06:00 +01:00
|
|
|
+ * non-setuid dumpcap binary.
|
|
|
|
+ */
|
|
|
|
+ if (system("command -v dumpcap >/dev/null") == 0) {
|
|
|
|
+ /* Found working dumpcap */
|
|
|
|
+ exename = g_strdup_printf("dumpcap");
|
|
|
|
+ } else {
|
|
|
|
+ /* take Wireshark's absolute program path and replace "Wireshark" with "dumpcap" */
|
2015-07-19 22:17:28 +01:00
|
|
|
+ exename = g_strdup_printf("%s/dumpcap", progfile_dir);
|
2014-04-13 16:06:00 +01:00
|
|
|
+ }
|
2015-07-19 22:17:28 +01:00
|
|
|
#endif
|
2014-04-13 16:06:00 +01:00
|
|
|
|
|
|
|
/* Make that the first argument in the argument list (argv[0]). */
|
2021-12-28 22:53:10 +00:00
|
|
|
@@ -572,7 +583,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, inf
|
2014-04-13 16:06:00 +01:00
|
|
|
*/
|
|
|
|
dup2(sync_pipe[PIPE_WRITE], 2);
|
|
|
|
ws_close(sync_pipe[PIPE_READ]);
|
|
|
|
- execv(argv[0], argv);
|
|
|
|
+ execvp(argv[0], argv);
|
|
|
|
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
|
|
|
argv[0], g_strerror(errno));
|
|
|
|
sync_pipe_errmsg_to_parent(2, errmsg, "");
|
2021-12-28 22:53:10 +00:00
|
|
|
@@ -811,7 +822,7 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd,
|
2014-04-13 16:06:00 +01:00
|
|
|
dup2(sync_pipe[PIPE_WRITE], 2);
|
|
|
|
ws_close(sync_pipe[PIPE_READ]);
|
|
|
|
ws_close(sync_pipe[PIPE_WRITE]);
|
|
|
|
- execv(argv[0], argv);
|
|
|
|
+ execvp(argv[0], argv);
|
|
|
|
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
|
|
|
argv[0], g_strerror(errno));
|
|
|
|
sync_pipe_errmsg_to_parent(2, errmsg, "");
|