Verified Commit 57714b3f authored by Karel Koci's avatar Karel Koci 🤘

Add new subprocess logging type USIGN

usign is command we have to run as there is no attached library
implementation of given algorithm (at least to my knowledge). But its
output should be mostly ignored because of that there is exception
created for LST_USIGN for output printing level.
parent d79bdc7f
......@@ -949,6 +949,7 @@ struct {
{ LS_FAIL, "LS_FAIL"},
{ LST_PKG_SCRIPT, "LST_PKG_SCRIPT"},
{ LST_HOOK, "LST_HOOK"},
{ LST_USIGN, "LST_USIGN"},
};
// Various enum values that we want to inject
......
......@@ -163,7 +163,7 @@ struct c_log_subproc {
static ssize_t c_log_subproc_write(void *cookie, const char *buf, size_t size) {
struct c_log_subproc *cls = (struct c_log_subproc*)cookie;
size_t len = size;
if (would_log(LL_INFO))
if (would_log(cls->lsp->type == LST_USIGN ? LL_DBG : LL_INFO))
len = fwrite(buf, sizeof(char), size, cls->err ? stderr : stdout);
// This is memory buffer so there should be no problem to match system output
ASSERT(fwrite(buf, sizeof(char), len, cls->lsp->buffer.f) == len);
......@@ -198,7 +198,10 @@ void log_subproc_open(struct log_subproc *lsp, enum log_subproc_type type, const
cls->lsp = lsp;
lsp->err = fopencookie(cls, "w", fncs);
// Print info
INFO("%s", message);
if (type == LST_USIGN)
DBG("%s", message);
else
INFO("%s", message);
}
void log_subproc_close(struct log_subproc *lsp, char **output) {
......
......@@ -109,7 +109,8 @@ void setup_logging(enum log_level tty, enum log_level syslog);
// afterward.
enum log_subproc_type {
LST_PKG_SCRIPT, // This is post/pre install/rm script
LST_HOOK // This is updater's hook
LST_HOOK, // This is updater's hook
LST_USIGN // This is usign executable (this has explicitly lower logging level set to DBG)
};
struct log_subproc {
......
......@@ -99,17 +99,18 @@ Function `subprocess` is defined as follows:
predefined constants are as follows:
- `LST_PKG_SCRIPT` Any script provided by package (pre/post inst/rm)
- `LST_HOOK` Hook script executed on some updater state
- `LST_USIGN` usign binary used for signature validation
* `message` is string describing what this subprocess is to user. It's human
readable description of executed command.
* `timeout` is time in seconds after which subprocess will be automatically
* `timeout` is time in milliseconds after which subprocess will be automatically
killed.
* `callback` is optional function that would be called in subprocess just before
It executes given command. If you don't want to specify it then you can pass nil
Or you can just drop it out (in that case command is expeted on this argument
Place). This functions should has no arguments and shouldn't return anything.
Place). This functions should have no arguments and shouldn't return anything.
* `command` is any arbitrary number of string arguments that are passed as command
and its additional arguments.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment