aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2021-03-05 04:09:47 +0000
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-03-06 12:56:11 +0000
commit41a172cc953382e4c830481dea14d895c622754e (patch)
treec5356ca4a2d622f621aefd5124e9ad3bd4cd6871 /dumpcap.c
parentb5530e7021fa68c1d8e7e454b758cfea64acd6ba (diff)
if_capabilities: Use a structured error msg from dumpcap
Have dumpcap in child mode return an error message with a primary and secondary string, instead of using stderr. When writing to the console log we ignore the second message to prevent flooding the log with tutorial-like info on permissions.
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 8a64a20510..19cf9f3818 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -5447,9 +5447,20 @@ main(int argc, char *argv[])
caps = get_if_capabilities(interface_opts, &err, &err_str);
if (caps == NULL) {
- cmdarg_err("The capabilities of the capture device \"%s\" could not be obtained (%s).\n"
- "%s", interface_opts->name, err_str,
- get_pcap_failure_secondary_error_message(err, err_str));
+ if (capture_child) {
+ char *error_msg = g_strdup_printf("The capabilities of the capture device"
+ " \"%s\" could not be obtained (%s)",
+ interface_opts->name, err_str);
+ sync_pipe_errmsg_to_parent(2, error_msg,
+ get_pcap_failure_secondary_error_message(err, err_str));
+ g_free(error_msg);
+ }
+ else {
+ cmdarg_err("The capabilities of the capture device"
+ "\"%s\" could not be obtained (%s).\n%s",
+ interface_opts->name, err_str,
+ get_pcap_failure_secondary_error_message(err, err_str));
+ }
g_free(err_str);
exit_main(2);
}