+static int register_machine(void) {
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_bus_unref_ sd_bus *bus = NULL;
+ int r;
+
+ r = sd_bus_open_system(&bus);
+ if (r < 0) {
+ log_error("Failed to open system bus: %s", strerror(-r));
+ return r;
+ }
+
+ r = sd_bus_call_method(
+ bus,
+ "org.freedesktop.machine1",
+ "/org/freedesktop/machine1",
+ "org.freedesktop.machine1.Manager",
+ "CreateMachine",
+ &error,
+ NULL,
+ "sayssusa(sv)",
+ arg_machine,
+ SD_BUS_APPEND_ID128(arg_uuid),
+ "nspawn",
+ "container",
+ (uint32_t) 0,
+ strempty(arg_directory),
+ 1, "Slice", "s", strempty(arg_slice));
+ if (r < 0) {
+ log_error("Failed to register machine: %s", error.message ? error.message : strerror(-r));
+ return r;
+ }
+
+ return 0;
+}
+
+static bool audit_enabled(void) {
+ int fd;
+
+ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+ if (fd >= 0) {
+ close_nointr_nofail(fd);
+ return true;
+ }
+ return false;
+}
+