From 7ef08098826ef737d7ff132229b28bb1cb4fdd65 Mon Sep 17 00:00:00 2001 From: Otavio Pontes Date: Thu, 4 Apr 2019 15:05:18 -0700 Subject: [PATCH] sys: Use run_command() to print messages to the journal Signed-off-by: Otavio Pontes --- src/lib/sys.c | 9 +++++++++ src/lib/sys.h | 5 +++++ src/manifest.c | 9 +-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/sys.c b/src/lib/sys.c index 7d3b85b6..40785d54 100644 --- a/src/lib/sys.c +++ b/src/lib/sys.c @@ -221,3 +221,12 @@ bool file_is_executable(const char *filename) return false; } + +void journal_log_error(const char *message) +{ + if (!message) { + return; + } + + run_command_quiet("/usr/bin/systemd-cat", "--identifier=swupd", "--priority=err", "/bin/echo", message, NULL); +} diff --git a/src/lib/sys.h b/src/lib/sys.h index d2969de8..797010fc 100644 --- a/src/lib/sys.h +++ b/src/lib/sys.h @@ -60,6 +60,11 @@ bool file_exits(const char *filename); */ bool file_is_executable(const char *filename); +/* + * Print error 'message' to system journal. + */ +void journal_log_error(const char *message); + #ifdef __cplusplus } #endif diff --git a/src/manifest.c b/src/manifest.c index f0788259..cfcdcbe7 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -315,7 +315,6 @@ struct manifest *load_mom(int version, bool latest, bool mix_exists, int *err) int ret = 0; char *filename; char *url; - char *log_cmd = NULL; bool retried = false; bool perform_sig_verify = !(migrate && mix_exists); bool invalid_sig = false; @@ -376,13 +375,7 @@ retry_load: } warn("FAILED TO VERIFY SIGNATURE OF Manifest.MoM. Operation proceeding due to\n" " --nosigcheck, but system security may be compromised\n"); - string_or_die(&log_cmd, "echo \"swupd security notice:" - " --nosigcheck used to bypass MoM signature verification failure\" | /usr/bin/systemd-cat --priority=\"err\" --identifier=\"swupd\""); - if (system(log_cmd)) { - /* useless noise to suppress gcc & glibc conspiring - * to make us check the result of system */ - } - free_string(&log_cmd); + journal_log_error("swupd security notice: --nosigcheck used to bypass MoM signature verification failure"); } /* Make a copy of the Manifest for the completion code */ if (latest) {