From 41a172cc953382e4c830481dea14d895c622754e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Fri, 5 Mar 2021 04:09:47 +0000 Subject: 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. --- dumpcap.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'dumpcap.c') 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); } -- cgit v1.2.3