Blame SOURCES/wireshark-0002-Customize-permission-denied-error.patch

537ca1
From: Jan Safranek <jsafrane@redhat.com>
537ca1
Date: Fri, 26 Nov 2010 14:30:45 +0300
537ca1
Subject: [PATCH] Customize 'permission denied' error.
537ca1
537ca1
Add Fedora-specific message to error output when dumpcap cannot be started
537ca1
because of permissions.
537ca1
537ca1
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
537ca1
537ca1
diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
537ca1
index 2f9d2cc..b18e47f 100644
537ca1
--- a/capchild/capture_sync.c
537ca1
+++ b/capchild/capture_sync.c
537ca1
@@ -375,6 +375,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
537ca1
     gchar *signal_pipe_name;
537ca1
 #else
537ca1
     char errmsg[1024+1];
537ca1
+    const char *securitymsg = "";
537ca1
     int sync_pipe[2];                       /* pipe used to send messages from child to parent */
537ca1
     enum PIPES { PIPE_READ, PIPE_WRITE };   /* Constants 0 and 1 for PIPE_READ and PIPE_WRITE */
537ca1
 #endif
537ca1
@@ -728,8 +729,11 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
537ca1
         dup2(sync_pipe[PIPE_WRITE], 2);
537ca1
         ws_close(sync_pipe[PIPE_READ]);
537ca1
         execv(argv[0], argv);
537ca1
-        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
537ca1
-                   argv[0], g_strerror(errno));
537ca1
+        if (errno == EPERM || errno == EACCES)
537ca1
+          securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
537ca1
+        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
537ca1
+                argv[0], g_strerror(errno), securitymsg);
537ca1
+
537ca1
         sync_pipe_errmsg_to_parent(2, errmsg, "");
537ca1
 
537ca1
         /* Exit with "_exit()", so that we don't close the connection
537ca1
@@ -826,6 +830,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
537ca1
     int i;
537ca1
 #else
537ca1
     char errmsg[1024+1];
537ca1
+    const char *securitymsg = "";
537ca1
     int sync_pipe[2];                       /* pipe used to send messages from child to parent */
537ca1
     int data_pipe[2];                       /* pipe used to send data from child to parent */
537ca1
 #endif
537ca1
@@ -1003,8 +1008,11 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
537ca1
         ws_close(sync_pipe[PIPE_READ]);
537ca1
         ws_close(sync_pipe[PIPE_WRITE]);
537ca1
         execv(argv[0], argv);
537ca1
-        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
537ca1
-                   argv[0], g_strerror(errno));
537ca1
+        execv(argv[0], (gpointer)argv);
537ca1
+	if (errno == EPERM || errno == EACCES)
537ca1
+		securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
537ca1
+        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
537ca1
+                   argv[0], g_strerror(errno), securitymsg);
537ca1
         sync_pipe_errmsg_to_parent(2, errmsg, "");
537ca1
 
537ca1
         /* Exit with "_exit()", so that we don't close the connection