2013-09-11 11:08:10 +00:00
|
|
|
From a6168e1f1bdb639c0ffd15a5f4eed864814e0bce Mon Sep 17 00:00:00 2001
|
2013-09-10 10:16:03 +00:00
|
|
|
From: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
Date: Fri, 26 Nov 2010 14:30:45 +0300
|
2013-09-11 11:08:10 +00:00
|
|
|
Subject: [PATCH 2/6] Customize 'permission denied' error.
|
2010-11-26 13:30:45 +00:00
|
|
|
|
|
|
|
Add Fedora-specific message to error output when dumpcap cannot be started
|
|
|
|
because of permissions.
|
|
|
|
|
2013-09-10 10:16:03 +00:00
|
|
|
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
|
|
|
|
---
|
|
|
|
capture_sync.c | 16 ++++++++++++----
|
|
|
|
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
|
|
2013-06-17 13:19:18 +00:00
|
|
|
diff --git a/capture_sync.c b/capture_sync.c
|
2013-09-11 11:08:10 +00:00
|
|
|
index 391aa6a..6dfe1de 100644
|
2013-06-17 13:19:18 +00:00
|
|
|
--- a/capture_sync.c
|
|
|
|
+++ b/capture_sync.c
|
|
|
|
@@ -368,6 +368,7 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session)
|
2010-11-26 13:30:45 +00:00
|
|
|
gchar *signal_pipe_name;
|
|
|
|
#else
|
|
|
|
char errmsg[1024+1];
|
|
|
|
+ const char *securitymsg = "";
|
|
|
|
int sync_pipe[2]; /* pipe used to send messages from child to parent */
|
|
|
|
enum PIPES { PIPE_READ, PIPE_WRITE }; /* Constants 0 and 1 for PIPE_READ and PIPE_WRITE */
|
|
|
|
#endif
|
2013-09-10 10:16:03 +00:00
|
|
|
@@ -638,8 +639,11 @@ sync_pipe_start(capture_options *capture_opts, capture_session *cap_session)
|
2012-06-25 13:46:28 +00:00
|
|
|
dup2(sync_pipe[PIPE_WRITE], 2);
|
|
|
|
ws_close(sync_pipe[PIPE_READ]);
|
2013-06-17 13:19:18 +00:00
|
|
|
execv(argv[0], argv);
|
2012-06-25 13:46:28 +00:00
|
|
|
- g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
|
|
|
- argv[0], g_strerror(errno));
|
|
|
|
+ if (errno == EPERM || errno == EACCES)
|
2013-09-10 10:16:03 +00:00
|
|
|
+ securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
|
2012-06-25 13:46:28 +00:00
|
|
|
+ g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
|
2013-09-10 10:16:03 +00:00
|
|
|
+ argv[0], g_strerror(errno), securitymsg);
|
|
|
|
+
|
2012-06-25 13:46:28 +00:00
|
|
|
sync_pipe_errmsg_to_parent(2, errmsg, "");
|
2010-11-26 13:30:45 +00:00
|
|
|
|
2012-06-25 13:46:28 +00:00
|
|
|
/* Exit with "_exit()", so that we don't close the connection
|
2013-09-10 10:16:03 +00:00
|
|
|
@@ -731,6 +735,7 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
|
2012-06-25 13:46:28 +00:00
|
|
|
PROCESS_INFORMATION pi;
|
2010-11-26 13:30:45 +00:00
|
|
|
#else
|
|
|
|
char errmsg[1024+1];
|
|
|
|
+ const char *securitymsg = "";
|
|
|
|
int sync_pipe[2]; /* pipe used to send messages from child to parent */
|
|
|
|
int data_pipe[2]; /* pipe used to send data from child to parent */
|
|
|
|
#endif
|
2013-09-10 10:16:03 +00:00
|
|
|
@@ -865,8 +870,11 @@ sync_pipe_open_command(char** argv, int *data_read_fd,
|
2010-11-26 13:30:45 +00:00
|
|
|
ws_close(sync_pipe[PIPE_READ]);
|
|
|
|
ws_close(sync_pipe[PIPE_WRITE]);
|
2013-06-17 13:19:18 +00:00
|
|
|
execv(argv[0], argv);
|
2010-11-26 13:30:45 +00:00
|
|
|
- g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
|
2011-07-21 09:20:56 +00:00
|
|
|
- argv[0], g_strerror(errno));
|
2013-09-10 10:16:03 +00:00
|
|
|
+ execv(argv[0], (gpointer)argv);
|
|
|
|
+ if (errno == EPERM || errno == EACCES)
|
|
|
|
+ securitymsg = "\nAre you a member of the 'wireshark' group? Try running\n'usermod -a -G wireshark _your_username_' as root.";
|
2010-11-26 13:30:45 +00:00
|
|
|
+ g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s%s",
|
2013-09-10 10:16:03 +00:00
|
|
|
+ argv[0], g_strerror(errno), securitymsg);
|
2010-11-26 13:30:45 +00:00
|
|
|
sync_pipe_errmsg_to_parent(2, errmsg, "");
|
|
|
|
|
|
|
|
/* Exit with "_exit()", so that we don't close the connection
|
2013-09-10 10:16:03 +00:00
|
|
|
--
|
|
|
|
1.8.3.1
|
|
|
|
|