1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-31 21:18:09 +03:00

machined: return recognizable error when we try to register the same machine name twice

This commit is contained in:
Lennart Poettering 2024-05-11 19:54:54 +02:00
parent d9b8d86bcd
commit ddbfc4d17e
3 changed files with 6 additions and 2 deletions

View File

@ -153,6 +153,8 @@ int vl_method_register(Varlink *link, JsonVariant *parameters, VarlinkMethodFlag
}
r = machine_link(manager, machine);
if (r == -EEXIST)
return varlink_error(link, "io.systemd.Machine.MachineExists", NULL);
if (r < 0)
return r;

View File

@ -16,7 +16,10 @@ static VARLINK_DEFINE_METHOD(
VARLINK_DEFINE_INPUT(sshAddress, VARLINK_STRING, VARLINK_NULLABLE),
VARLINK_DEFINE_INPUT(sshPrivateKeyPath, VARLINK_STRING, VARLINK_NULLABLE));
static VARLINK_DEFINE_ERROR(MachineExists);
VARLINK_DEFINE_INTERFACE(
io_systemd_Machine,
"io.systemd.Machine",
&vl_method_Register);
&vl_method_Register,
&vl_error_MachineExists);

View File

@ -58,7 +58,6 @@ int register_machine(
if (r < 0)
return log_error_errno(r, "Failed to connect to machined on /run/systemd/machine/io.systemd.Machine: %m");
return varlink_callb_and_log(vl,
"io.systemd.Machine.Register",
NULL,