From 517e9fa0f062e286f893f41770d0562c4baf0c51 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 31 Jan 2015 15:22:59 +0100 Subject: [PATCH] ibft: avoid logging multiple lines when ibft fails In case of error, ibft prints an error message to stderr with two trailing newlines. This causes multiple lines in our logfile. Replace newlines in the error message by whitespaces. (cherry picked from commit 205c109741b822e9475994b74232b6bf64d4f16d) --- src/settings/plugins/ibft/reader.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c index ccf84372e6..833818c876 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -136,6 +136,15 @@ read_ibft_blocks (const char *iscsiadm_path, } if (WEXITSTATUS (status) != 0) { + if (err) { + char *nl; + + /* the error message contains newlines. concatenate the lines with whitespace */ + for (nl = err; *nl; nl++) { + if (*nl == '\n') + *nl = ' '; + } + } g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "iBFT: %s exited with error %d. Message: '%s'", iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)");