File wireshark-0010-dumpcap-permission-denied.patch of Package wireshark

From 4eea0eafa31274294832821d7adb13f13be30564 Mon Sep 17 00:00:00 2001
From: Robert Frohl <rfrohl@suse.com>
Date: Fri, 30 Aug 2024 20:03:20 +0200
Subject: [PATCH] Warn if user can't access dumpcap.

---
 capture/capture_sync.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/capture/capture_sync.c b/capture/capture_sync.c
index 2a5db8bc73..f75e82e2e2 100644
--- a/capture/capture_sync.c
+++ b/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 *data_read_fd,
         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
-- 
2.46.0

openSUSE Build Service is sponsored by