[systemd-devel] [PATCH v2 ] hostnamectl: correct IDs for remote hosts

Lennart Poettering lennart at poettering.net
Tue Jun 3 11:47:37 PDT 2014


On Sun, 01.06.14 20:53, Rico Sagner (sagner at b1-systems.de) wrote:

>  
> +static int property_get_machineid(
> +                sd_bus *bus,
> +                const char *path,
> +                const char *interface,
> +                const char *property,
> +                sd_bus_message *reply,
> +                void *userdata,
> +                sd_bus_error *error) {
> +
> +        Manager *m = userdata;
> +
> +        assert(bus);
> +        assert(reply);
> +        assert(m);
> +
> +        return sd_bus_message_append_array(reply, 'y', &m->machineid, 16);
> +}

As discussed elsewhere in this thread, we can get rid of this property
as sd_bus_get_owner_machine_id() already can be used from the client
side, and we should just use that... Hence we only need the boot id
property, the machine id property is redundant...

> +static int property_get_bootid(
> +                sd_bus *bus,
> +                const char *path,
> +                const char *interface,
> +                const char *property,
> +                sd_bus_message *reply,
> +                void *userdata,
> +                sd_bus_error *error) {
> +
> +        Manager *m = userdata;
> +
> +        assert(bus);
> +        assert(reply);
> +        assert(m);
> +
> +        return sd_bus_message_append_array(reply, 'y', &m->bootid, 16);
> +}

Please don't cache the boot id. There's no need for that, as
sd_id128_get_boot() already caches internally... Just call it
directly here and return what it returns.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list