core: add two new unit file settings: StandardInputData= + StandardInputText=

Both permit configuring data to pass through STDIN to an invoked
process. StandardInputText= accepts a line of text (possibly with
embedded C-style escapes as well as unit specifiers), which is appended
to the buffer to pass as stdin, followed by a single newline.
StandardInputData= is similar, but accepts arbitrary base64 encoded
data, and will not resolve specifiers or C-style escapes, nor append
newlines.

This may be used to pass input/configuration data to services, directly
in-line from unit files, either in a cooked or in a more raw format.
This commit is contained in:
Lennart Poettering
2017-11-17 11:13:44 +01:00
parent 11f5d82507
commit 08f3be7a38
9 changed files with 311 additions and 10 deletions
+19
View File
@@ -55,6 +55,7 @@
#include "fs-util.h"
#include "glob-util.h"
#include "hostname-util.h"
#include "hexdecoct.h"
#include "initreq.h"
#include "install.h"
#include "io-util.h"
@@ -4977,6 +4978,24 @@ static int print_property(const char *name, sd_bus_message *m, const char *conte
return bus_log_parse_error(r);
return 0;
} else if (contents[1] == SD_BUS_TYPE_BYTE && streq(name, "StandardInputData")) {
_cleanup_free_ char *h = NULL;
const void *p;
size_t sz;
ssize_t n;
r = sd_bus_message_read_array(m, 'y', &p, &sz);
if (r < 0)
return bus_log_parse_error(r);
n = base64mem(p, sz, &h);
if (n < 0)
return log_oom();
print_prop(name, "%s", h);
return 0;
}
break;