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:
parent
d9b8d86bcd
commit
ddbfc4d17e
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user