sys: Use run_command() to print messages to the journal

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2019-04-10 16:13:54 -07:00
parent 9525c93265
commit 7ef0809882
3 changed files with 15 additions and 8 deletions
+9
View File
@@ -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);
}
+5
View File
@@ -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
+1 -8
View File
@@ -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) {