]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: add DumpUnitsMatchingPatternsByFileDescriptor()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Oct 2022 12:23:04 +0000 (14:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Oct 2022 13:00:53 +0000 (15:00 +0200)
man/org.freedesktop.systemd1.xml
src/core/dbus-manager.c
src/core/org.freedesktop.systemd1.conf

index 6986ee8b037615fcaaa3af88159b117f04afb22d..2c9fa81e181f9df9497cf39c6b40404b9d2677ed 100644 (file)
@@ -165,6 +165,8 @@ node /org/freedesktop/systemd1 {
       DumpUnitsMatchingPatterns(in  as patterns,
                                 out s output);
       DumpByFileDescriptor(out h fd);
+      DumpUnitsMatchingPatternsByFileDescriptor(in  as patterns,
+                                                out h fd);
       Reload();
       @org.freedesktop.DBus.Method.NoReply("true")
       Reexecute();
@@ -874,6 +876,8 @@ node /org/freedesktop/systemd1 {
 
     <variablelist class="dbus-method" generated="True" extra-ref="DumpByFileDescriptor()"/>
 
+    <variablelist class="dbus-method" generated="True" extra-ref="DumpUnitsMatchingPatternsByFileDescriptor()"/>
+
     <variablelist class="dbus-method" generated="True" extra-ref="Reload()"/>
 
     <variablelist class="dbus-method" generated="True" extra-ref="Reexecute()"/>
@@ -1342,15 +1346,18 @@ node /org/freedesktop/systemd1 {
       string guaranteed, and new fields may be added any time, and old fields removed. The general structure
       may be rearranged drastically between releases. This is exposed by
       <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
-      <command>dump</command> command. Similarly, <function>DumpUnitsMatchingPatterns()</function> returns the internal
-      state of units whose names match the glob expressions specified in the <varname>patterns</varname>
-      argument. The <function>DumpByFileDescriptor()</function> method is identical to
-      <function>Dump()</function> but returns the data serialized into a file descriptor (the client should
-      read the text data from it until hitting EOF). Given the size limits on D-Bus messages and the possibly
-      large size of the returned string, <function>DumpByFileDescriptor()</function> is usually the
-      preferable interface, since it ensures the data can be passed reliably from the service manager to the
-      client. (Note though that <function>DumpByFileDescriptor()</function> cannot work when communicating
-      with the service manager remotely, as file descriptors are strictly local to a system.)</para>
+      <command>dump</command> command. Similarly, <function>DumpUnitsMatchingPatterns()</function> returns
+      the internal state of units whose names match the glob expressions specified in the
+      <varname>patterns</varname> argument. The
+      <function>DumpByFileDescriptor()</function>/<function>DumpUnitsMatchingPatternsByFileDescriptor()</function>
+      methods are identical to <function>Dump()</function>/<function>DumpUnitsMatchingPatterns()</function>,
+      but return data serialized into a file descriptor (the client should read the text data from it until
+      hitting EOF). Given the size limits on D-Bus messages and the possibly large size of the returned
+      strings,
+      <function>DumpByFileDescriptor()</function>/<function>DumpUnitsMatchingPatternsByFileDescriptor()</function>
+      are usually the preferred interface, since it ensures the data can be passed reliably from the service
+      manager to the client. Note though that they cannot work when communicating with the service manager
+      remotely, as file descriptors are strictly local to a system.</para>
 
       <para><function>Reload()</function> may be invoked to reload all unit files.</para>
 
index 26d19e8ba00ed4c5105d09abc18eb96bb2345587..e8c407c300c54e51a82cca725f4750e8da1a836a 100644 (file)
@@ -1392,7 +1392,11 @@ static int method_dump_by_fd(sd_bus_message *message, void *userdata, sd_bus_err
         return dump_impl(message, userdata, error, NULL, reply_dump_by_fd);
 }
 
-static int method_dump_units_matching_patterns(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+static int dump_units_matching_patterns(
+                sd_bus_message *message,
+                void *userdata,
+                sd_bus_error *error,
+                int (*reply)(sd_bus_message *, char *)) {
         _cleanup_strv_free_ char **patterns = NULL;
         int r;
 
@@ -1400,7 +1404,15 @@ static int method_dump_units_matching_patterns(sd_bus_message *message, void *us
         if (r < 0)
                 return r;
 
-        return dump_impl(message, userdata, error, patterns, reply_dump);
+        return dump_impl(message, userdata, error, patterns, reply);
+}
+
+static int method_dump_units_matching_patterns(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        return dump_units_matching_patterns(message, userdata, error, reply_dump);
+}
+
+static int method_dump_units_matching_patterns_by_fd(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+        return dump_units_matching_patterns(message, userdata, error, reply_dump_by_fd);
 }
 
 static int method_refuse_snapshot(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -3037,6 +3049,11 @@ const sd_bus_vtable bus_manager_vtable[] = {
                                 SD_BUS_RESULT("h", fd),
                                 method_dump_by_fd,
                                 SD_BUS_VTABLE_UNPRIVILEGED),
+        SD_BUS_METHOD_WITH_ARGS("DumpUnitsMatchingPatternsByFileDescriptor",
+                                SD_BUS_ARGS("as", patterns),
+                                SD_BUS_RESULT("h", fd),
+                                method_dump_units_matching_patterns_by_fd,
+                                SD_BUS_VTABLE_UNPRIVILEGED),
         SD_BUS_METHOD_WITH_ARGS("CreateSnapshot",
                                 SD_BUS_ARGS("s", name, "b", cleanup),
                                 SD_BUS_RESULT("o", unit),
index 66dd961c4473ac54854ebf36b9b69ac657460db7..fe9de012b647c4ea8fb240f9c92236f6205c6738 100644 (file)
                        send_interface="org.freedesktop.systemd1.Manager"
                        send_member="DumpUnitsMatchingPatterns"/>
 
+                <allow send_destination="org.freedesktop.systemd1"
+                       send_interface="org.freedesktop.systemd1.Manager"
+                       send_member="DumpUnitsMatchingPatternsByFileDescriptor"/>
+
                 <allow send_destination="org.freedesktop.systemd1"
                        send_interface="org.freedesktop.systemd1.Manager"
                        send_member="ListUnitFiles"/>