if (r != 0)
return r;
+ if (!IN_SET(machine->class, MACHINE_CONTAINER, MACHINE_VM))
+ return sd_varlink_error_invalid_parameter_name(link, "class");
+
if (manager->runtime_scope != RUNTIME_SCOPE_USER) {
r = varlink_verify_polkit_async(
link,
c = _MACHINE_CLASS_INVALID;
else {
c = machine_class_from_string(class);
- if (c < 0)
+ if (c < 0 || !IN_SET(c, MACHINE_CONTAINER, MACHINE_VM))
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter");
}
c = _MACHINE_CLASS_INVALID;
else {
c = machine_class_from_string(class);
- if (c < 0)
+ if (c < 0 || !IN_SET(c, MACHINE_CONTAINER, MACHINE_VM))
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter");
}
/run/systemd/machine/io.systemd.Machine \
io.systemd.Machine.Open \
'{"name":"shouldnotwork3", "mode": "shell", "user":"root","path":"/usr/bin/bash","args":["bash","-c","''touch /shouldnotwork; sleep 20''"]}')
+(! varlinkctl \
+ call \
+ /run/systemd/machine/io.systemd.Machine \
+ io.systemd.Machine.Register \
+ "{\"name\":\"shouldnotwork4\", \"class\":\"host\", \"leader\": $sleep_pid}")
+(! machinectl list | grep shouldnotwork4)
+(! run0 -u testuser \
+ varlinkctl \
+ call \
+ /run/systemd/machine/io.systemd.Machine \
+ io.systemd.Machine.Register \
+ "{\"name\":\"shouldnotwork5\", \"class\":\"host\", \"leader\": $sleep_pid}")
+(! machinectl list | grep shouldnotwork5)
+(! busctl call \
+ org.freedesktop.machine1 \
+ /org/freedesktop/machine1 \
+ org.freedesktop.machine1.Manager \
+ RegisterMachine \
+ 'sayssus' \
+ shouldnotwork6 \
+ 0 \
+ "" \
+ host \
+ 0 \
+ "")
+(! machinectl list | grep shouldnotwork6)
+(! run0 -u testuser \
+ busctl call \
+ org.freedesktop.machine1 \
+ /org/freedesktop/machine1 \
+ org.freedesktop.machine1.Manager \
+ RegisterMachine \
+ 'sayssus' \
+ shouldnotwork7 \
+ 0 \
+ "" \
+ host \
+ 0 \
+ "")
+(! machinectl list | grep shouldnotwork7)
systemctl --user --machine testuser@ stop sleep.service
test ! -f /shouldnotwork