unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 4c000c23a1230f65f3162bcdc31031d675c9d5bb 2745 bytes (raw)
name: gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
Taken from Nixpkgs:
<https://github.com/NixOS/nixpkgs/blob/aa060ababf1490e8b39a6122d42112ea958f39cf/pkgs/applications/networking/sniffers/wireshark/wireshark-lookup-dumpcap-in-path.patch>

From 5bef9deeff8a2e4401de0f45c9701cd6f98f29d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= <bjorn.forsman@gmail.com>
Date: Thu, 26 Nov 2015 21:03:35 +0100
Subject: [PATCH] Lookup dumpcap in PATH

NixOS patch: Look for dumpcap in PATH first, because there may be a
dumpcap wrapper that we want to use instead of the default
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.

Signed-off-by: Franz Pletz <fpletz@fnordicwalking.de>
---
 capchild/capture_sync.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
index 970688e..49914d5 100644
--- a/capchild/capture_sync.c
+++ b/capchild/capture_sync.c
@@ -332,7 +332,18 @@ init_pipe_args(int *argc) {
 #ifdef _WIN32
     exename = g_strdup_printf("%s\\dumpcap.exe", progfile_dir);
 #else
-    exename = g_strdup_printf("%s/dumpcap", progfile_dir);
+    /*
+     * NixOS patch: Look for dumpcap in PATH first, because there may be a
+     * dumpcap wrapper that we want to use instead of the default
+     * 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" */
+        exename = g_strdup_printf("%s/dumpcap", progfile_dir);
+    }
 #endif
 
     /* Make that the first argument in the argument list (argv[0]). */
@@ -729,7 +740,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
          */
         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, "");
@@ -997,7 +1008,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
         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, "");
-- 
2.6.3


debug log:

solving 4c000c23a1 ...
found 4c000c23a1 in https://yhetil.org/guix-patches/20200615161841.24337-1-brice@waegenei.re/

applying [1/1] https://yhetil.org/guix-patches/20200615161841.24337-1-brice@waegenei.re/
diff --git a/gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch b/gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch
new file mode 100644
index 0000000000..4c000c23a1

1:50: trailing whitespace.
 
1:70: trailing whitespace.
-- 
Checking patch gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch...
1:72: new blank line at EOF.
+
Applied patch gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch cleanly.
warning: 3 lines add whitespace errors.

index at:
100644 4c000c23a1230f65f3162bcdc31031d675c9d5bb	gnu/packages/patches/wireshark-lookup-dumpcap-in-path.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).