Blame wireshark-1.6.1-group-msg.patch

Jan Safranek 155755
Customize 'permission denied' error.
Jan Safranek 155755
Jan Safranek 155755
From: Jan Safranek <jsafrane@redhat.com>
Jan Safranek 155755
Jan Safranek 155755
Add Fedora-specific message to error output when dumpcap cannot be started
Jan Safranek 155755
because of permissions.
Jan Safranek 155755
Jan Safranek 155755
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Jan Safranek 155755
Jan Safranek 16d607
diff -up wireshark-1.6.1/capture_sync.c.group-msg wireshark-1.6.1/capture_sync.c
Jan Safranek 16d607
--- wireshark-1.6.1/capture_sync.c.group-msg	2011-07-18 22:18:53.000000000 +0200
Jan Safranek 16d607
+++ wireshark-1.6.1/capture_sync.c	2011-07-21 10:52:28.962144991 +0200
Jan Safranek 16d607
@@ -351,6 +351,7 @@ sync_pipe_start(capture_options *capture
Jan Safranek 155755
     gchar *signal_pipe_name;
Jan Safranek 155755
 #else
Jan Safranek 155755
     char errmsg[1024+1];
Jan Safranek 155755
+    const char *securitymsg = "";
Jan Safranek 155755
     int sync_pipe[2];                       /* pipe used to send messages from child to parent */
Jan Safranek 155755
     enum PIPES { PIPE_READ, PIPE_WRITE };   /* Constants 0 and 1 for PIPE_READ and PIPE_WRITE */
Jan Safranek 155755
 #endif
Jan Safranek 16d607
@@ -596,8 +597,10 @@ sync_pipe_start(capture_options *capture
Jan Safranek 155755
       dup2(sync_pipe[PIPE_WRITE], 2);
Jan Safranek 155755
       ws_close(sync_pipe[PIPE_READ]);
Jan Safranek 155755
       execv(argv[0], (gpointer)argv);
Jan Safranek 155755
-      g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
Jan Safranek 16d607
-                argv[0], g_strerror(errno));
Jan Safranek 155755
+      if (errno == EPERM || errno == EACCES)
Jan Safranek eb5f38
+	      securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
Jan Safranek 155755
+      g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
Jan Safranek 16d607
+                argv[0], g_strerror(errno), securitymsg);
Jan Safranek 155755
       sync_pipe_errmsg_to_parent(2, errmsg, "");
Jan Safranek 155755
 
Jan Safranek 155755
       /* Exit with "_exit()", so that we don't close the connection
Jan Safranek 16d607
@@ -687,6 +690,7 @@ sync_pipe_open_command(const char** argv
Jan Safranek 155755
     int i;
Jan Safranek 155755
 #else
Jan Safranek 155755
     char errmsg[1024+1];
Jan Safranek 155755
+    const char *securitymsg = "";
Jan Safranek 155755
     int sync_pipe[2];                       /* pipe used to send messages from child to parent */
Jan Safranek 155755
     int data_pipe[2];                       /* pipe used to send data from child to parent */
Jan Safranek 155755
 #endif
Jan Safranek 16d607
@@ -811,8 +815,10 @@ sync_pipe_open_command(const char** argv
Jan Safranek 155755
         ws_close(sync_pipe[PIPE_READ]);
Jan Safranek 155755
         ws_close(sync_pipe[PIPE_WRITE]);
Jan Safranek 155755
         execv(argv[0], (gpointer)argv);
Jan Safranek 155755
-        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
Jan Safranek 16d607
-                   argv[0], g_strerror(errno));
Jan Safranek 16d607
+	if (errno == EPERM || errno == EACCES)
Jan Safranek eb5f38
+		securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
Jan Safranek 155755
+        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
Jan Safranek 16d607
+                   argv[0], g_strerror(errno), securitymsg);
Jan Safranek 155755
         sync_pipe_errmsg_to_parent(2, errmsg, "");
Jan Safranek 155755
 
Jan Safranek 155755
         /* Exit with "_exit()", so that we don't close the connection