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

1444df
From: Jan Safranek <jsafrane@redhat.com>
1444df
Date: Fri, 26 Nov 2010 14:30:45 +0300
173888
Subject: [PATCH] Customize 'permission denied' error.
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
1444df
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
1444df
Peter Hatina f670be
diff --git a/capture_sync.c b/capture_sync.c
d3e571
index 2f9d2cc..b18e47f 100644
Peter Hatina f670be
--- a/capture_sync.c
Peter Hatina f670be
+++ b/capture_sync.c
d3e571
@@ -374,6 +374,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
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
d3e571
@@ -649,8 +650,11 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session, voi
Jan Safranek d08c88
         dup2(sync_pipe[PIPE_WRITE], 2);
Jan Safranek d08c88
         ws_close(sync_pipe[PIPE_READ]);
Peter Hatina f670be
         execv(argv[0], argv);
Jan Safranek d08c88
-        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
Jan Safranek d08c88
-                   argv[0], g_strerror(errno));
Jan Safranek d08c88
+        if (errno == EPERM || errno == EACCES)
1444df
+ 	      securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
Jan Safranek d08c88
+        g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
1444df
+                argv[0], g_strerror(errno), securitymsg);
1444df
+
Jan Safranek d08c88
         sync_pipe_errmsg_to_parent(2, errmsg, "");
Jan Safranek 155755
 
Jan Safranek d08c88
         /* Exit with "_exit()", so that we don't close the connection
d3e571
@@ -745,6 +749,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
Jan Safranek d08c88
     PROCESS_INFORMATION pi;
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
d3e571
@@ -879,8 +884,11 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
Jan Safranek 155755
         ws_close(sync_pipe[PIPE_READ]);
Jan Safranek 155755
         ws_close(sync_pipe[PIPE_WRITE]);
Peter Hatina f670be
         execv(argv[0], 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));
1444df
+        execv(argv[0], (gpointer)argv);
1444df
+	if (errno == EPERM || errno == EACCES)
1444df
+		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",
1444df
+                   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