let's make sure the specified hostname is really valid before we build
an fs path from it. Just as a safety future, so that people can't trick
us with hostnames including "/../" or so.
#include "env-file.h"
#include "fd-util.h"
#include "format-util.h"
+#include "hostname-util.h"
#include "locale-util.h"
#include "macro.h"
#include "output-mode.h"
const char *prefix,
char **ret) {
- int r;
_cleanup_free_ char *root = NULL;
+ int r;
if (machine) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_free_ char *unit = NULL;
const char *m;
+ if (!hostname_is_valid(machine, 0))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Machine name is not valid: %s", machine);
+
m = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, m, "SCOPE", &unit);
if (r < 0)