File wireshark-0010-dumpcap-permission-denied.patch of Package wireshark-next
From 116374f6d0ab610212ac9111e32773b341145c0a Mon Sep 17 00:00:00 2001
From: Robert Frohl <rfrohl@suse.com>
Date: Fri, 19 Jul 2024 11:32:04 +0200
Subject: [PATCH] Warn if user can't access dumpcap.
---
capture/capture_sync.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: wireshark-4.4.0/capture/capture_sync.c
===================================================================
--- wireshark-4.4.0.orig/capture/capture_sync.c
+++ wireshark-4.4.0/capture/capture_sync.c
@@ -26,6 +26,10 @@
#include <wsutil/strtoi.h>
#include <wsutil/ws_assert.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <grp.h>
+
#ifdef _WIN32
#include <wsutil/unicode-utils.h>
#include <wsutil/win32-utils.h>
@@ -597,6 +601,17 @@ sync_pipe_open_command(char **argv, int
argv = sync_pipe_add_arg(argv, &argc, sync_id);
#endif
execv(argv[0], argv);
+ char * grp_warning = calloc(1, 256);
+ 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 <YOUR_USERNAME>' as root.", grp->gr_name, grp->gr_name);
+ }
+ }
+ }
+ free(grp_warning);
sync_pipe_write_int_msg(sync_pipe[PIPE_WRITE], SP_EXEC_FAILED, errno);
/* Exit with "_exit()", so that we don't close the connection