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