From 0c8fdb0223815fa9734216ea29a53ab791d74b3cec6b36d728920d48f59168a3 Mon Sep 17 00:00:00 2001 From: Robert Frohl Date: Wed, 13 Jan 2021 16:20:05 +0000 Subject: [PATCH] Accepting request 862916 from home:rfrohl:branches:network:utilities add dumpcap error message patch OBS-URL: https://build.opensuse.org/request/show/862916 OBS-URL: https://build.opensuse.org/package/show/network:utilities/wireshark?expand=0&rev=328 --- ...shark-0001-dumpcap-permission-denied.patch | 75 +++++++++++++++++++ wireshark.changes | 6 ++ wireshark.spec | 4 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 wireshark-0001-dumpcap-permission-denied.patch diff --git a/wireshark-0001-dumpcap-permission-denied.patch b/wireshark-0001-dumpcap-permission-denied.patch new file mode 100644 index 0000000..928ea73 --- /dev/null +++ b/wireshark-0001-dumpcap-permission-denied.patch @@ -0,0 +1,75 @@ +commit 1865e02e6c22ee55b0bb11b8c78330d4e65a1132 +Author: Robert Frohl +Date: Wed Jan 13 14:18:36 2021 +0100 + + Warn if user can't access dumpcap. + +diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c +index f31914886a..d3baab6c50 100644 +--- a/capchild/capture_sync.c ++++ b/capchild/capture_sync.c +@@ -21,6 +21,10 @@ + + #include + ++#include ++#include ++#include ++ + #ifdef _WIN32 + #include + #include +@@ -570,11 +574,22 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, inf + * Child process - run dumpcap with the right arguments to make + * it just capture with the specified capture parameters + */ ++ char * grp_warning = calloc(1, 256); + dup2(sync_pipe[PIPE_WRITE], 2); + ws_close(sync_pipe[PIPE_READ]); + execv(argv[0], argv); +- g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", +- argv[0], g_strerror(errno)); ++ if (errno == EPERM || errno == EACCES) { ++ struct stat statbuf; ++ struct group *grp; ++ if(stat("/usr/bin/dumpcap", &statbuf) == 0) { ++ if ((grp = getgrgid(statbuf.st_gid)) != NULL) { ++ snprintf(grp_warning , 256, "\nYou need to be a member of the '%s' group. Try running\n'usermod -a -G %s ' as root.", grp->gr_name, grp->gr_name); ++ } ++ } ++ } ++ g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s", ++ argv[0], g_strerror(errno), grp_warning); ++ free(grp_warning); + sync_pipe_errmsg_to_parent(2, errmsg, ""); + + /* Exit with "_exit()", so that we don't close the connection +@@ -805,6 +820,7 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd, + * Child process - run dumpcap with the right arguments to make + * it just capture with the specified capture parameters + */ ++ char * grp_warning = calloc(1, 256); + dup2(data_pipe[PIPE_WRITE], 1); + ws_close(data_pipe[PIPE_READ]); + ws_close(data_pipe[PIPE_WRITE]); +@@ -812,8 +828,18 @@ sync_pipe_open_command(char* const argv[], int *data_read_fd, + ws_close(sync_pipe[PIPE_READ]); + ws_close(sync_pipe[PIPE_WRITE]); + execv(argv[0], argv); +- g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s", +- argv[0], g_strerror(errno)); ++ if (errno == EPERM || errno == EACCES) { ++ struct stat statbuf; ++ struct group *grp; ++ if(stat("/usr/bin/dumpcap", &statbuf) == 0) { ++ if ((grp = getgrgid(statbuf.st_gid)) != NULL) { ++ snprintf(grp_warning , 256, "\nYou need to be a member of the '%s' group. Try running\n'usermod -a -G %s ' as root.", grp->gr_name, grp->gr_name); ++ } ++ } ++ } ++ g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s", ++ argv[0], g_strerror(errno), grp_warning); ++ free(grp_warning); + sync_pipe_errmsg_to_parent(2, errmsg, ""); + + /* Exit with "_exit()", so that we don't close the connection diff --git a/wireshark.changes b/wireshark.changes index 9b0862d..dfe5bf1 100644 --- a/wireshark.changes +++ b/wireshark.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Jan 13 09:32:30 UTC 2021 - Robert Frohl + +- provide helpful error message if user doesn't have permissions to run dumpcap (bsc#1180102) + add wireshark-0001-dumpcap-permission-denied.patch + ------------------------------------------------------------------- Sat Dec 19 04:24:30 UTC 2020 - Andreas Stieger diff --git a/wireshark.spec b/wireshark.spec index c882f45..b98bce7 100644 --- a/wireshark.spec +++ b/wireshark.spec @@ -1,7 +1,7 @@ # # spec file for package wireshark # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -36,6 +36,7 @@ URL: https://www.wireshark.org/ Source: https://www.wireshark.org/download/src/%{name}-%{version}.tar.xz Source2: https://www.wireshark.org/download/SIGNATURES-%{version}.txt#/%{name}-%{version}.tar.xz.asc Source3: https://www.wireshark.org/download/gerald_at_wireshark_dot_org.gpg#/wireshark.keyring +Patch10: wireshark-0001-dumpcap-permission-denied.patch BuildRequires: bison BuildRequires: flex BuildRequires: glib2-devel >= 2.32 @@ -169,6 +170,7 @@ echo "`grep %{name}-%{version}.tar.xz %{SOURCE2} | grep SHA256 | head -n1 | cut %setup -q sed -i 's/^Icon=wireshark.png$/Icon=wireshark/' wireshark*.desktop +%patch10 -p1 %build %cmake -DCMAKE_INSTALL_LIBDIR='%{_lib}/'