]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind,machined: expose bus properties for leader PID fd ids, too
authorLennart Poettering <lennart@poettering.net>
Mon, 19 May 2025 15:57:08 +0000 (17:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 May 2025 08:23:36 +0000 (10:23 +0200)
man/org.freedesktop.login1.xml
man/org.freedesktop.machine1.xml
src/login/logind-session-dbus.c
src/machine/machine-dbus.c
src/shared/bus-get-properties.c
src/shared/bus-get-properties.h

index 32734b01c0b59cecc69e2f42e25ce88e640882ee..c344cb3014c62d7eb79968fc6e9830c1a67ddd8b 100644 (file)
@@ -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 {
 
     <variablelist class="dbus-property" generated="True" extra-ref="Leader"/>
 
+    <variablelist class="dbus-property" generated="True" extra-ref="LeaderPIDFDId"/>
+
     <variablelist class="dbus-property" generated="True" extra-ref="Audit"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="Type"/>
@@ -1539,6 +1543,9 @@ node /org/freedesktop/login1/session/1 {
 
       <para><varname>Leader</varname> encodes the PID of the process that registered the session.</para>
 
+      <para><varname>LeaderPIDFDId</varname> encodes the Linux pidfd inode ID of the process that registered
+      the session.</para>
+
       <para><varname>Audit</varname> encodes the Kernel Audit session ID of the session if auditing is
       available.</para>
 
@@ -1660,6 +1667,7 @@ node /org/freedesktop/login1/session/1 {
       <para><function>SetDisplay()</function> was added in version 252.</para>
       <para><function>SetTTY()</function> was added in version 254.</para>
       <para><function>SetClass()</function> was added in version 256.</para>
+      <para><varname>LeaderPIDFDId</varname> was added in version 258.</para>
     </refsect2>
   </refsect1>
 
index 779232054662a0310398226a33d2b3093c26e46d..936f2ad7f27c419ad3785c9640ab2068743e59ff 100644 (file)
@@ -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 {
 
     <variablelist class="dbus-property" generated="True" extra-ref="Leader"/>
 
+    <variablelist class="dbus-property" generated="True" extra-ref="LeaderPIDFDId"/>
+
     <variablelist class="dbus-property" generated="True" extra-ref="Class"/>
 
     <variablelist class="dbus-property" generated="True" extra-ref="RootDirectory"/>
@@ -650,6 +654,9 @@ node /org/freedesktop/machine1/machine/rawhide {
 
       <para><varname>Leader</varname> is the PID of the leader process of the machine.</para>
 
+      <para><varname>LeaderPIDFDId</varname> encodes the Linux pidfd inode ID of the leader process of the
+      machine.</para>
+
       <para><varname>Class</varname> 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).</para>
@@ -717,6 +724,7 @@ $ gdbus introspect --system \
       <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>
+      <para><varname>LeaderPIDFDId</varname> was added in version 258.</para>
     </refsect2>
   </refsect1>
 
index 0277f26fe58e3209fc3ec70ceb3412fab8eb010c..70e7fa63c423605217eb409349de30ad964bcaf8 100644 (file)
@@ -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),
index c19b1a5beb0d5813553e9f48ac4fb7073fe1b98a..c299bf71fa3f12a9131bcd8990f9b05262781844 100644 (file)
@@ -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),
index e21eafc4bafbb5e46c254f25aa9ba0dbb1cc5962..099cfa77f7390df6f30153a4225709d9980cfd45 100644 (file)
@@ -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);
+}
index a77d3653bea4c56514591a46b8611f51400bb897..3f445f0acddef056d30a9957a5b1bc56a065f137 100644 (file)
@@ -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,                                  \