core: add OpenFile setting

This commit is contained in:
Richard Phibel
2023-01-10 15:16:26 +01:00
committed by Lennart Poettering
parent 81315baa68
commit cd48e23f6a
27 changed files with 914 additions and 6 deletions
+33
View File
@@ -23,6 +23,7 @@
#include "locale-util.h"
#include "memory-util.h"
#include "numa-util.h"
#include "open-file.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
@@ -1857,6 +1858,38 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
if (r < 0)
return bus_log_parse_error(r);
return 1;
} else if (contents[0] == SD_BUS_TYPE_STRUCT_BEGIN && streq(name, "OpenFile")) {
char *path, *fdname;
uint64_t offlags;
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(sst)");
if (r < 0)
return bus_log_parse_error(r);
while ((r = sd_bus_message_read(m, "(sst)", &path, &fdname, &offlags)) > 0) {
_cleanup_free_ char *ofs = NULL;
r = open_file_to_string(
&(OpenFile){
.path = path,
.fdname = fdname,
.flags = offlags,
},
&ofs);
if (r < 0)
return log_error_errno(
r, "Failed to convert OpenFile= value to string: %m");
bus_print_property_value(name, expected_value, flags, ofs);
}
if (r < 0)
return bus_log_parse_error(r);
r = sd_bus_message_exit_container(m);
if (r < 0)
return bus_log_parse_error(r);
return 1;
}