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

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