From: Lennart Poettering Date: Mon, 19 May 2025 15:57:08 +0000 (+0200) Subject: logind,machined: expose bus properties for leader PID fd ids, too X-Git-Tag: v258-rc1~481^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98fc46f2a61c4ba9b07547aec983cf8365c17d8f;p=thirdparty%2Fsystemd.git logind,machined: expose bus properties for leader PID fd ids, too --- diff --git a/man/org.freedesktop.login1.xml b/man/org.freedesktop.login1.xml index 32734b01c0b..c344cb3014c 100644 --- a/man/org.freedesktop.login1.xml +++ b/man/org.freedesktop.login1.xml @@ -1251,6 +1251,8 @@ node /org/freedesktop/login1/session/1 { @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly u Leader = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly t LeaderPIDFDId = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly u Audit = ...; readonly s Type = '...'; readonly s Class = '...'; @@ -1351,6 +1353,8 @@ node /org/freedesktop/login1/session/1 { + + @@ -1539,6 +1543,9 @@ node /org/freedesktop/login1/session/1 { Leader encodes the PID of the process that registered the session. + LeaderPIDFDId encodes the Linux pidfd inode ID of the process that registered + the session. + Audit encodes the Kernel Audit session ID of the session if auditing is available. @@ -1660,6 +1667,7 @@ node /org/freedesktop/login1/session/1 { SetDisplay() was added in version 252. SetTTY() was added in version 254. SetClass() was added in version 256. + LeaderPIDFDId was added in version 258. diff --git a/man/org.freedesktop.machine1.xml b/man/org.freedesktop.machine1.xml index 77923205466..936f2ad7f27 100644 --- a/man/org.freedesktop.machine1.xml +++ b/man/org.freedesktop.machine1.xml @@ -513,6 +513,8 @@ node /org/freedesktop/machine1/machine/rawhide { @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly u Leader = ...; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") + readonly t LeaderPIDFDId = ...; + @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly s Class = '...'; @org.freedesktop.DBus.Property.EmitsChangedSignal("const") readonly s RootDirectory = '...'; @@ -603,6 +605,8 @@ node /org/freedesktop/machine1/machine/rawhide { + + @@ -650,6 +654,9 @@ node /org/freedesktop/machine1/machine/rawhide { Leader is the PID of the leader process of the machine. + LeaderPIDFDId encodes the Linux pidfd inode ID of the leader process of the + machine. + Class is the class of the machine and is either the string "vm" (for real VMs based on virtualized hardware) or "container" (for lightweight userspace virtualization sharing the same kernel as the host). @@ -717,6 +724,7 @@ $ gdbus introspect --system \ CopyToWithFlags() were added in version 252. GetSSHInfo(), VSockCID, SSHAddress and SSHPrivateKeyPath were added in version 256. + LeaderPIDFDId was added in version 258. diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c index 0277f26fe58..70e7fa63c42 100644 --- a/src/login/logind-session-dbus.c +++ b/src/login/logind-session-dbus.c @@ -993,6 +993,7 @@ static const sd_bus_vtable session_vtable[] = { SD_BUS_PROPERTY("Desktop", "s", NULL, offsetof(Session, desktop), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Scope", "s", NULL, offsetof(Session, scope), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Leader", "u", bus_property_get_pid, offsetof(Session, leader.pid), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("LeaderPIDFDId", "t", bus_property_get_pidfdid, offsetof(Session, leader), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Audit", "u", NULL, offsetof(Session, audit_id), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Type", "s", property_get_type, offsetof(Session, type), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Class", "s", property_get_class, offsetof(Session, class), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c index c19b1a5beb0..c299bf71fa3 100644 --- a/src/machine/machine-dbus.c +++ b/src/machine/machine-dbus.c @@ -717,7 +717,8 @@ static const sd_bus_vtable machine_vtable[] = { SD_BUS_PROPERTY("Service", "s", NULL, offsetof(Machine, service), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Unit", "s", NULL, offsetof(Machine, unit), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Scope", "s", NULL, offsetof(Machine, unit), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN), - SD_BUS_PROPERTY("Leader", "u", NULL, offsetof(Machine, leader.pid), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("Leader", "u", bus_property_get_pid, offsetof(Machine, leader.pid), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("LeaderPIDFDId", "t", bus_property_get_pidfdid, offsetof(Machine, leader), SD_BUS_VTABLE_PROPERTY_CONST), 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), diff --git a/src/shared/bus-get-properties.c b/src/shared/bus-get-properties.c index e21eafc4baf..099cfa77f73 100644 --- a/src/shared/bus-get-properties.c +++ b/src/shared/bus-get-properties.c @@ -4,6 +4,7 @@ #include "bus-get-properties.h" #include "bus-message-util.h" +#include "pidref.h" #include "rlimit-util.h" #include "string-util.h" @@ -188,3 +189,23 @@ int bus_property_get_string_set( return bus_message_append_string_set(reply, *s); } + +int bus_property_get_pidfdid( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + PidRef *pidref = ASSERT_PTR(userdata); + + assert(bus); + assert(property); + assert(reply); + + (void) pidref_acquire_pidfd_id(pidref); + + return sd_bus_message_append(reply, "t", pidref->fd_id); +} diff --git a/src/shared/bus-get-properties.h b/src/shared/bus-get-properties.h index a77d3653bea..3f445f0acdd 100644 --- a/src/shared/bus-get-properties.h +++ b/src/shared/bus-get-properties.h @@ -54,6 +54,8 @@ int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface int bus_property_get_string_set(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); +int bus_property_get_pidfdid(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); + #define BUS_DEFINE_PROPERTY_GET_GLOBAL(function, bus_type, val) \ int function(sd_bus *bus, \ const char *path, \