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

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