in i signal);
GetMachineAddresses(in s name,
out a(iay) addresses);
+ GetMachineSSHInfo(in s name,
+ out s ssh_address,
+ out s ssh_private_key_path);
GetMachineOSRelease(in s name,
out a{ss} fields);
@org.freedesktop.systemd1.Privileged("true")
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineAddresses()"/>
+ <variablelist class="dbus-method" generated="True" extra-ref="GetMachineSSHInfo()"/>
+
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineOSRelease()"/>
<variablelist class="dbus-method" generated="True" extra-ref="OpenMachinePTY()"/>
<constant>AF_INET6</constant>) and a byte array containing the addresses. This is only supported for
containers that make use of network namespacing.</para>
+ <para><function>GetMachineSSHInfo()</function> retrieves the SSH information of a machine. This method
+ returns two strings, the SSH address which can be used to tell SSH where to connect, and the path
+ to the SSH private key required for the connection to succeed.</para>
+
<para><function>GetMachineOSRelease()</function> retrieves the OS release information of a
container. This method returns an array of key value pairs read from the
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file in
Kill(in s who,
in i signal);
GetAddresses(out a(iay) addresses);
+ GetSSHInfo(out s ssh_address,
+ out s ssh_private_key_path);
GetOSRelease(out a{ss} fields);
GetUIDShift(out u shift);
OpenPTY(out h pty,
readonly s RootDirectory = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly ai NetworkInterfaces = [...];
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly u VSockCID = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly s SSHAddress = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
+ readonly s SSHPrivateKeyPath = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("false")
readonly s State = '...';
};
<variablelist class="dbus-method" generated="True" extra-ref="GetAddresses()"/>
+ <variablelist class="dbus-method" generated="True" extra-ref="GetSSHInfo()"/>
+
<variablelist class="dbus-method" generated="True" extra-ref="GetOSRelease()"/>
<variablelist class="dbus-method" generated="True" extra-ref="GetUIDShift()"/>
<variablelist class="dbus-property" generated="True" extra-ref="NetworkInterfaces"/>
+ <variablelist class="dbus-property" generated="True" extra-ref="VSockCID"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="SSHAddress"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="SSHPrivateKeyPath"/>
+
<variablelist class="dbus-property" generated="True" extra-ref="State"/>
<!--End of Autogenerated section-->
take the same arguments as <function>TerminateMachine()</function> and
<function>KillMachine()</function> on the Manager interface, respectively.</para>
- <para><function>GetAddresses()</function> and <function>GetOSRelease()</function> get the IP address and OS
- release information from the machine. These methods take the same arguments as
- <function>GetMachineAddresses()</function> and <function>GetMachineOSRelease()</function> of the
+ <para><function>GetAddresses()</function>, <function>GetSSHInfo()</function> and <function>GetOSRelease()</function> get the IP address,
+ SSH connection and OS release information from the machine. These methods take the same arguments as
+ <function>GetMachineAddresses()</function>, <function>GetMachineSSHInfo()</function> and <function>GetMachineOSRelease()</function> of the
Manager interface, respectively.</para>
</refsect2>
towards the container, the VM or the host. For details about this information see the description of
<function>CreateMachineWithNetwork()</function> above.</para>
+ <para><varname>VSockCID</varname> is the VSOCK CID of the VM if it is known, or
+ <constant>VMADDR_CID_ANY</constant> otherwise.</para>
+
+ <para><varname>SSHAddress</varname> is the address of the VM in a format <command>ssh</command> can understand
+ if it is known or the empty string.</para>
+
+ <para><varname>SSHPrivateKeyPath</varname> is the path to the SSH private key of the VM if it is known
+ or the empty string.</para>
+
<para><varname>State</varname> is the state of the machine and is one of <literal>opening</literal>,
<literal>running</literal>, or <literal>closing</literal>. Note that the state machine is not considered
part of the API and states might be removed or added without this being considered API breakage.
<title>The Manager Object</title>
<para><function>CopyFromMachineWithFlags()</function> and
<function>CopyToMachineWithFlags()</function> were added in version 252.</para>
+ <para><function>GetMachineSSHInfo()</function> was added in version 256.</para>
</refsect2>
<refsect2>
<title>Machine Objects</title>
<para><function>CopyFromWithFlags()</function> and
<function>CopyToWithFlags()</function> were added in version 252.</para>
+ <para><function>GetSSHInfo()</function>, <varname>VSockCID</varname>, <varname>SSHAddress</varname>
+ and <varname>SSHPrivateKeyPath</varname> were added in version 256.</para>
</refsect2>
</refsect1>
</refentry>
return sd_bus_send(NULL, reply, NULL);
}
+int bus_machine_method_get_ssh_info(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
+ Machine *m = ASSERT_PTR(userdata);
+ int r;
+
+ assert(message);
+
+ r = sd_bus_message_new_method_return(message, &reply);
+ if (r < 0)
+ return r;
+
+ if (!m->ssh_address || !m->ssh_private_key_path)
+ return -ENOENT;
+
+ r = sd_bus_message_append(reply, "ss", m->ssh_address, m->ssh_private_key_path);
+ if (r < 0)
+ return r;
+
+ return sd_bus_send(NULL, reply, NULL);
+}
+
#define EXIT_NOT_FOUND 2
int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) {
SD_BUS_PROPERTY("Class", "s", property_get_class, offsetof(Machine, class), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("RootDirectory", "s", NULL, offsetof(Machine, root_directory), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("NetworkInterfaces", "ai", property_get_netif, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("VSockCID", "u", NULL, offsetof(Machine, vsock_cid), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("SSHAddress", "s", NULL, offsetof(Machine, ssh_address), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("SSHPrivateKeyPath", "s", NULL, offsetof(Machine, ssh_private_key_path), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("State", "s", property_get_state, 0, 0),
SD_BUS_METHOD("Terminate",
SD_BUS_RESULT("a(iay)", addresses),
bus_machine_method_get_addresses,
SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetSSHInfo",
+ SD_BUS_NO_ARGS,
+ SD_BUS_RESULT("s", ssh_address, "s", ssh_private_key_path),
+ bus_machine_method_get_ssh_info,
+ SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_ARGS("GetOSRelease",
SD_BUS_NO_ARGS,
SD_BUS_RESULT("a{ss}", fields),
int bus_machine_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd_bus_error *error);
+int bus_machine_method_get_ssh_info(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_error *error);
int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bus_error *error);
#include "path-util.h"
#include "process-util.h"
#include "serialize.h"
+#include "socket-util.h"
#include "special.h"
#include "stdio-util.h"
#include "string-table.h"
*m = (Machine) {
.leader = PIDREF_NULL,
+ .vsock_cid = VMADDR_CID_ANY,
};
if (name) {
free(m->service);
free(m->root_directory);
free(m->netif);
+ free(m->ssh_address);
+ free(m->ssh_private_key_path);
return mfree(m);
}
int *netif;
size_t n_netif;
+ unsigned vsock_cid;
+ char *ssh_address;
+ char *ssh_private_key_path;
+
LIST_HEAD(Operation, operations);
LIST_FIELDS(Machine, gc_queue);
return redirect_method_to_machine(message, userdata, error, bus_machine_method_get_addresses);
}
+static int method_get_machine_ssh_info(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+ return redirect_method_to_machine(message, userdata, error, bus_machine_method_get_ssh_info);
+}
+
static int method_get_machine_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) {
return redirect_method_to_machine(message, userdata, error, bus_machine_method_get_os_release);
}
SD_BUS_RESULT("a(iay)", addresses),
method_get_machine_addresses,
SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetMachineSSHInfo",
+ SD_BUS_ARGS("s", name),
+ SD_BUS_RESULT("s", ssh_address, "s", ssh_private_key_path),
+ method_get_machine_ssh_info,
+ SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD_WITH_ARGS("GetMachineOSRelease",
SD_BUS_ARGS("s", name),
SD_BUS_RESULT("a{ss}", fields),