summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-16 08:30:27 +0100
committerGitHub <noreply@github.com>2021-02-16 08:30:27 +0100
commite557c82dd5867a790d37f0a165feb0570712516b (patch)
tree70c273315f4ed2d8f9b8d31a1df37d7381160b3b
parent8f50eb04acb37b8ef50f823a2917bf0a10e9ec8e (diff)
parent23e5c8d2966622f3c5c15ac3c2ac5ed04a72b77d (diff)
downloadsystemd-e557c82dd5867a790d37f0a165feb0570712516b.tar.gz
Merge pull request #18571 from bluca/portable_dbus_doc
portable: use helpers for DBUS registration and document DBUS interface
-rw-r--r--man/org.freedesktop.portable1.xml427
-rw-r--r--man/portablectl.xml1
-rw-r--r--man/rules/meson.build1
-rw-r--r--man/systemd-portabled.service.xml3
-rw-r--r--src/portable/portabled-bus.c95
-rw-r--r--src/portable/portabled-image-bus.c71
-rw-r--r--src/portable/portabled-image-bus.h1
-rw-r--r--src/portable/portabled.c21
-rw-r--r--src/portable/portabled.h3
9 files changed, 591 insertions, 32 deletions
diff --git a/man/org.freedesktop.portable1.xml b/man/org.freedesktop.portable1.xml
new file mode 100644
index 0000000000..e6d2f4f536
--- /dev/null
+++ b/man/org.freedesktop.portable1.xml
@@ -0,0 +1,427 @@
+<?xml version='1.0'?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" >
+<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
+
+<refentry id="org.freedesktop.portable1" conditional='ENABLE_PORTABLED'
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <refentryinfo>
+ <title>org.freedesktop.portable1</title>
+ <productname>systemd</productname>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>org.freedesktop.portable1</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>org.freedesktop.portable1</refname>
+ <refpurpose>The D-Bus interface of systemd-portabled</refpurpose>
+ </refnamediv>
+
+ <refsect1>
+ <title>Introduction</title>
+
+ <para>
+ <citerefentry><refentrytitle>systemd-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ is a system service that may be used to attach, detach and inspect portable services. This page describes the
+ D-Bus interface.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>The Manager Object</title>
+
+ <para>The service exposes the following interfaces on the Manager object on the bus:</para>
+
+ <programlisting executable="systemd-portabled" node="/org/freedesktop/portable1" interface="org.freedesktop.portable1.Manager">
+node /org/freedesktop/portable1 {
+ interface org.freedesktop.portable1.Manager {
+ methods:
+ GetImage(in s image,
+ out o object);
+ ListImages(out a(ssbtttso) UNNAMED);
+ GetImageOSRelease(in s image,
+ out a{ss} os_release);
+ GetImageMetadata(in s image,
+ in as matches,
+ out s image,
+ out ay os_release,
+ out a{say} units);
+ GetImageState(in s image,
+ out s state);
+ AttachImage(in s image,
+ in as matches,
+ in s profile,
+ in b runtime,
+ in s copy_mode,
+ out a(sss) changes);
+ DetachImage(in s image,
+ in b runtime,
+ out a(sss) changes);
+ ReattachImage(in s image,
+ in as matches,
+ in s profile,
+ in b runtime,
+ in s copy_mode,
+ out a(sss) changes_removed,
+ out a(sss) changes_updated);
+ RemoveImage(in s image);
+ MarkImageReadOnly(in s image,
+ in b read_only);
+ SetImageLimit(in s image,
+ in t limit);
+ SetPoolLimit(in t limit);
+ properties:
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly s PoolPath = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t PoolUsage = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t PoolLimit = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly as Profiles = ['...', ...];
+ };
+ interface org.freedesktop.DBus.Peer { ... };
+ interface org.freedesktop.DBus.Introspectable { ... };
+ interface org.freedesktop.DBus.Properties { ... };
+};
+ </programlisting>
+
+ <!--Autogenerated cross-references for systemd.directives, do not edit-->
+
+ <variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.portable1.Manager"/>
+
+ <variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.portable1.Manager"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetImage()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="ListImages()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetImageOSRelease()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetImageMetadata()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetImageState()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="AttachImage()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="DetachImage()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="ReattachImage()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="RemoveImage()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="MarkImageReadOnly()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="SetImageLimit()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="SetPoolLimit()"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="PoolPath"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="PoolUsage"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="PoolLimit"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Profiles"/>
+
+ <!--End of Autogenerated section-->
+
+ <refsect2>
+ <title>Methods</title>
+
+ <para><function>GetImage()</function> may be used to get the image object path of the image with the
+ specified name.</para>
+
+ <para><function>ListImages()</function> returns an array of all currently known images. The
+ structures in the array consist of the following fields: image name, type, read-only flag, creation
+ time, modification time, current disk space, usage and image object path.</para>
+
+ <para><function>GetImageOSRelease()</function> retrieves the OS release information of an image.
+ This method returns an array of key value pairs read from the
+ <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file in
+ the image and is useful to identify the operating system used in a portable service.</para>
+
+ <para><function>GetImageMetadata()</function> retrieves metadata associated with an image.
+ This method returns the image name, the image's <citerefentry><refentrytitle>os-release</refentrytitle>
+ <manvolnum>5</manvolnum></citerefentry> content in the form of a (streamable) array of bytes,
+ and a list of portable units contained in the image, in the form of a string (unit name) and
+ an array of bytes with the content.</para>
+
+ <para><function>GetImageState()</function> retrieves the image state as one of the following
+ strings:
+ <itemizedlist>
+ <listitem><para>detached</para></listitem>
+
+ <listitem><para>attached</para></listitem>
+
+ <listitem><para>attached-runtime</para></listitem>
+
+ <listitem><para>enabled</para></listitem>
+
+ <listitem><para>enabled-runtime</para></listitem>
+
+ <listitem><para>running</para></listitem>
+
+ <listitem><para>running-runtime</para></listitem>
+ </itemizedlist></para>
+
+ <para><function>AttachImage()</function> attaches a portable image to the system.
+ This method takes an image path or name, a list of strings that will be used to search for
+ unit files inside the image (partial or complete matches), a string indicating which
+ portable profile to use for the image (see <varname>Profiles</varname> property for
+ a list of available profiles), a boolean indicating whether to attach the image only
+ for the current boot session, and a string representing the preferred copy mode
+ (whether to copy the image or to just symlink it) with the following possible values:
+ <itemizedlist>
+ <listitem><para>(null)</para></listitem>
+
+ <listitem><para>copy</para></listitem>
+
+ <listitem><para>symlink</para></listitem>
+ </itemizedlist>
+ This method returns the list of changes applied to the system (for example, which unit was
+ added and is now available as a system service). Each change is represented as a triplet of
+ strings: the type of change applied, the path on which it was applied, and the source
+ (if any). The type of change applied will be one of the following possible values:
+ <itemizedlist>
+ <listitem><para>copy</para></listitem>
+
+ <listitem><para>symlink</para></listitem>
+
+ <listitem><para>write</para></listitem>
+
+ <listitem><para>mkdir</para></listitem>
+ </itemizedlist>
+ Note that an image cannot be attached if a unit that it contains is already present
+ on the system.</para>
+
+ <para><function>DetachImage()</function> detaches a portable image from the system.
+ This method takes an image path or name, and a boolean indicating whether the image to
+ detach was attached only for the current boot session or persistently. This method
+ returns the list of changes applied to the system (for example, which unit was removed
+ and is no longer available as a system service). Each change is represented as a triplet of
+ strings: the type of change applied, the path on which it was applied, and the source
+ (if any). The type of change applied will be one of the following possible values:
+ <itemizedlist>
+ <listitem><para>unlink</para></listitem>
+ </itemizedlist>
+ Note that an image cannot be detached if a unit that it contains is running.</para>
+
+ <para><function>ReattachImage()</function> combines the effects of the
+ <function>AttachImage()</function> method and the <function>DetachImage()</function> method.
+ The difference is that it is allowed to reattach an image while one or more of its units
+ are running. The reattach operation will fail if no matching image is attached.
+ The input parameters match the <function>AttachImage()</function> method, and the return
+ parameters are the combination of the return parameters of the
+ <function>DetachImage()</function> method (first array, units that were removed) and the
+ <function>AttachImage()</function> method (second array, units that were updated or added).</para>
+
+ <para><function>RemoveImage()</function> removes the image with the specified name.</para>
+
+ <para><function>MarkImageReadOnly()</function> toggles the read-only flag of an image.</para>
+
+ <para><function>SetPoolLimit()</function> sets an overall quota limit on the pool of images.</para>
+
+ <para><function>SetImageLimit()</function> sets a per-image quota limit.</para>
+ </refsect2>
+
+ <refsect2>
+ <title>Properties</title>
+
+ <para><varname>PoolPath</varname> specifies the file system path where images are written to.</para>
+
+ <para><varname>PoolUsage</varname> specifies the current usage size of the image pool in bytes.</para>
+
+ <para><varname>PoolLimit</varname> specifies the size limit of the image pool in bytes.</para>
+
+ <para><varname>Profiles</varname> specifies the available runtime profiles for portable services.</para>
+ </refsect2>
+ </refsect1>
+
+ <refsect1>
+ <title>The Image Object</title>
+
+ <para>The service exposes the following interfaces on the Image object on the bus:</para>
+
+ <programlisting executable="systemd-portabled" node="/org/freedesktop/portable1" interface="org.freedesktop.portable1.Image">
+node /org/freedesktop/portable1 {
+ interface org.freedesktop.portable1.Image {
+ methods:
+ GetOSRelease(out a{ss} UNNAMED);
+ GetMetadata(in as matches,
+ out s image,
+ out ay os_release,
+ out a{say} units);
+ GetState(out s UNNAMED);
+ Attach(in as matches,
+ in s profile,
+ in b runtime,
+ in s copy_mode,
+ out a(sss) changes);
+ Detach(in b runtime,
+ out a(sss) changes);
+ Reattach(in as matches,
+ in s profile,
+ in b runtime,
+ in s copy_mode,
+ out a(sss) changes_removed,
+ out a(sss) changes_updated);
+ Remove();
+ MarkReadOnly(in b read_only);
+ SetLimit(in t limit);
+ properties:
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly s Name = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly s Path = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly s Type = '...';
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly b ReadOnly = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t CreationTimestamp = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t ModificationTimestamp = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t Usage = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t Limit = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t UsageExclusive = ...;
+ @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
+ readonly t LimitExclusive = ...;
+ };
+ interface org.freedesktop.DBus.Peer { ... };
+ interface org.freedesktop.DBus.Introspectable { ... };
+ interface org.freedesktop.DBus.Properties { ... };
+};
+ </programlisting>
+
+ <!--method GetOSRelease is not documented!-->
+
+ <!--method GetMetadata is not documented!-->
+
+ <!--method GetState is not documented!-->
+
+ <!--method Attach is not documented!-->
+
+ <!--method Detach is not documented!-->
+
+ <!--method Reattach is not documented!-->
+
+ <!--method Remove is not documented!-->
+
+ <!--method MarkReadOnly is not documented!-->
+
+ <!--method SetLimit is not documented!-->
+
+ <!--Autogenerated cross-references for systemd.directives, do not edit-->
+
+ <variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.portable1.Image"/>
+
+ <variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.portable1.Image"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetOSRelease()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetMetadata()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="GetState()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="Attach()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="Detach()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="Reattach()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="Remove()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="MarkReadOnly()"/>
+
+ <variablelist class="dbus-method" generated="True" extra-ref="SetLimit()"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Name"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Path"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Type"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="ReadOnly"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="CreationTimestamp"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="ModificationTimestamp"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Usage"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="Limit"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="UsageExclusive"/>
+
+ <variablelist class="dbus-property" generated="True" extra-ref="LimitExclusive"/>
+
+ <!--End of Autogenerated section-->
+
+ <refsect2>
+ <title>Methods</title>
+
+ <para>The following methods implement the same operation as the respective methods on the
+ <interfacename>Manager</interfacename> object (see above). However, these methods operate on the image
+ object and hence does not take an image name parameter. Invoking the methods directly on the Manager
+ object has the advantage of not requiring a <function>GetImage()</function> call to get the image object
+ for a specific image name. Calling the methods on the Manager object is hence a round trip
+ optimization. List of methods:
+ <itemizedlist>
+ <listitem><para>GetOSRelease()</para></listitem>
+
+ <listitem><para>GetMetadata()</para></listitem>
+
+ <listitem><para>GetState()</para></listitem>
+
+ <listitem><para>Attach()</para></listitem>
+
+ <listitem><para>Detach()</para></listitem>
+
+ <listitem><para>Reattach()</para></listitem>
+
+ <listitem><para>Remove()</para></listitem>
+
+ <listitem><para>MarkReadOnly()</para></listitem>
+
+ <listitem><para>SetLimit()</para></listitem>
+ </itemizedlist></para>
+ </refsect2>
+
+ <refsect2>
+ <title>Properties</title>
+
+ <para><varname>Name</varname> specifies the image name.</para>
+
+ <para><varname>Path</varname> specifies the file system path where image is stored.</para>
+
+ <para><varname>Type</varname> specifies the image type.</para>
+
+ <para><varname>ReadOnly</varname> specifies whether the image is read-only.</para>
+
+ <para><varname>CreationTimestamp</varname> specifies the image creation timestamp.</para>
+
+ <para><varname>ModificationTimestamp</varname> specifies the image modification timestamp.</para>
+
+ <para><varname>Usage</varname> specifies the image disk usage.</para>
+
+ <para><varname>Limit</varname> specifies the image disk usage limit.</para>
+
+ <para><varname>UsageExclusive</varname> specifies the image disk usage (exclusive).</para>
+
+ <para><varname>LimitExclusive</varname> specifies the image disk usage limit (exclusive).</para>
+ </refsect2>
+ </refsect1>
+
+ <refsect1>
+ <title>Versioning</title>
+
+ <para>These D-Bus interfaces follow <ulink url="http://0pointer.de/blog/projects/versioning-dbus.html">
+ the usual interface versioning guidelines</ulink>.</para>
+ </refsect1>
+</refentry>
diff --git a/man/portablectl.xml b/man/portablectl.xml
index bd0c9e0573..3f37ad1164 100644
--- a/man/portablectl.xml
+++ b/man/portablectl.xml
@@ -434,6 +434,7 @@
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>org.freedesktop.portable1</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/man/rules/meson.build b/man/rules/meson.build
index c13c8efc5c..c8e589e0f0 100644
--- a/man/rules/meson.build
+++ b/man/rules/meson.build
@@ -57,6 +57,7 @@ manpages = [
['org.freedesktop.login1', '5', [], 'ENABLE_LOGIND'],
['org.freedesktop.machine1', '5', [], 'ENABLE_MACHINED'],
['org.freedesktop.oom1', '5', [], 'ENABLE_OOMD'],
+ ['org.freedesktop.portable1', '5', [], 'ENABLE_PORTABLED'],
['org.freedesktop.resolve1', '5', [], 'ENABLE_RESOLVE'],
['org.freedesktop.systemd1', '5', [], ''],
['org.freedesktop.timedate1', '5', [], 'ENABLE_TIMEDATED'],
diff --git a/man/systemd-portabled.service.xml b/man/systemd-portabled.service.xml
index ce91b4fcbb..23906f2663 100644
--- a/man/systemd-portabled.service.xml
+++ b/man/systemd-portabled.service.xml
@@ -43,7 +43,8 @@
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>portablectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>portablectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>org.freedesktop.portable1</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/src/portable/portabled-bus.c b/src/portable/portabled-bus.c
index c31ab092b4..fa143b71c0 100644
--- a/src/portable/portabled-bus.c
+++ b/src/portable/portabled-bus.c
@@ -3,6 +3,7 @@
#include "alloc-util.h"
#include "btrfs-util.h"
#include "bus-common-errors.h"
+#include "bus-object.h"
#include "bus-polkit.h"
#include "discover-image.h"
#include "fd-util.h"
@@ -359,21 +360,91 @@ const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("PoolUsage", "t", property_get_pool_usage, 0, 0),
SD_BUS_PROPERTY("PoolLimit", "t", property_get_pool_limit, 0, 0),
SD_BUS_PROPERTY("Profiles", "as", property_get_profiles, 0, 0),
- SD_BUS_METHOD("GetImage", "s", "o", method_get_image, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("ListImages", NULL, "a(ssbtttso)", method_list_images, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("GetImageOSRelease", "s", "a{ss}", method_get_image_os_release, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("GetImageMetadata", "sas", "saya{say}", method_get_image_metadata, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("GetImageState", "s", "s", method_get_image_state, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("AttachImage", "sassbs", "a(sss)", method_attach_image, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("DetachImage", "sb", "a(sss)", method_detach_image, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("ReattachImage", "sassbs", "a(sss)a(sss)", method_reattach_image, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("RemoveImage", "s", NULL, method_remove_image, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("MarkImageReadOnly", "sb", NULL, method_mark_image_read_only, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("SetImageLimit", "st", NULL, method_set_image_limit, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("SetPoolLimit", "t", NULL, method_set_pool_limit, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetImage",
+ SD_BUS_ARGS("s", image),
+ SD_BUS_RESULT("o", object),
+ method_get_image,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("ListImages",
+ SD_BUS_NO_ARGS,
+ SD_BUS_RESULT("a(ssbtttso)", images),
+ method_list_images,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetImageOSRelease",
+ SD_BUS_ARGS("s", image),
+ SD_BUS_RESULT("a{ss}", os_release),
+ method_get_image_os_release,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetImageMetadata",
+ SD_BUS_ARGS("s", image,
+ "as", matches),
+ SD_BUS_RESULT("s", image,
+ "ay", os_release,
+ "a{say}", units),
+ method_get_image_metadata,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetImageState",
+ SD_BUS_ARGS("s", image),
+ SD_BUS_RESULT("s", state),
+ method_get_image_state,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("AttachImage",
+ SD_BUS_ARGS("s", image,
+ "as", matches,
+ "s", profile,
+ "b", runtime,
+ "s", copy_mode),
+ SD_BUS_RESULT("a(sss)", changes),
+ method_attach_image,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("DetachImage",
+ SD_BUS_ARGS("s", image,
+ "b", runtime),
+ SD_BUS_RESULT("a(sss)", changes),
+ method_detach_image,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("ReattachImage",
+ SD_BUS_ARGS("s", image,
+ "as", matches,
+ "s", profile,
+ "b", runtime,
+ "s", copy_mode),
+ SD_BUS_RESULT("a(sss)", changes_removed,
+ "a(sss)", changes_updated),
+ method_reattach_image,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("RemoveImage",
+ SD_BUS_ARGS("s", image),
+ SD_BUS_NO_RESULT,
+ method_remove_image,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("MarkImageReadOnly",
+ SD_BUS_ARGS("s", image,
+ "b", read_only),
+ SD_BUS_NO_RESULT,
+ method_mark_image_read_only,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("SetImageLimit",
+ SD_BUS_ARGS("s", image,
+ "t", limit),
+ SD_BUS_NO_RESULT,
+ method_set_image_limit,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("SetPoolLimit",
+ SD_BUS_ARGS("t", limit),
+ SD_BUS_NO_RESULT,
+ method_set_pool_limit,
+ SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END
};
+const BusObjectImplementation manager_object = {
+ "/org/freedesktop/portable1",
+ "org.freedesktop.portable1.Manager",
+ .vtables = BUS_VTABLES(manager_vtable),
+ .children = BUS_IMPLEMENTATIONS(&image_object),
+};
+
static int reply_portable_compose_message(sd_bus_message *reply, const PortableChange *changes, size_t n_changes) {
size_t i;
int r;
diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c
index 630648ba3c..75bb4d80c1 100644
--- a/src/portable/portabled-image-bus.c
+++ b/src/portable/portabled-image-bus.c
@@ -9,6 +9,7 @@
#include "bus-common-errors.h"
#include "bus-get-properties.h"
#include "bus-label.h"
+#include "bus-object.h"
#include "bus-polkit.h"
#include "bus-util.h"
#include "discover-image.h"
@@ -707,15 +708,60 @@ const sd_bus_vtable image_vtable[] = {
SD_BUS_PROPERTY("Limit", "t", NULL, offsetof(Image, limit), 0),
SD_BUS_PROPERTY("UsageExclusive", "t", NULL, offsetof(Image, usage_exclusive), 0),
SD_BUS_PROPERTY("LimitExclusive", "t", NULL, offsetof(Image, limit_exclusive), 0),
- SD_BUS_METHOD("GetOSRelease", NULL, "a{ss}", bus_image_method_get_os_release, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("GetMetadata", "as", "saya{say}", bus_image_method_get_metadata, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("GetState", NULL, "s", bus_image_method_get_state, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("Attach", "assbs", "a(sss)", bus_image_method_attach, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("Detach", "b", "a(sss)", bus_image_method_detach, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("Reattach", "assbs", "a(sss)a(sss)", bus_image_method_reattach, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("Remove", NULL, NULL, bus_image_method_remove, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("MarkReadOnly", "b", NULL, bus_image_method_mark_read_only, SD_BUS_VTABLE_UNPRIVILEGED),
- SD_BUS_METHOD("SetLimit", "t", NULL, bus_image_method_set_limit, SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetOSRelease",
+ SD_BUS_NO_ARGS,
+ SD_BUS_RESULT("a{ss}", os_release),
+ bus_image_method_get_os_release,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetMetadata",
+ SD_BUS_ARGS("as", matches),
+ SD_BUS_RESULT("s", image,
+ "ay", os_release,
+ "a{say}", units),
+ bus_image_method_get_metadata,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("GetState",
+ SD_BUS_NO_ARGS,
+ SD_BUS_RESULT("s", state),
+ bus_image_method_get_state,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("Attach",
+ SD_BUS_ARGS("as", matches,
+ "s", profile,
+ "b", runtime,
+ "s", copy_mode),
+ SD_BUS_RESULT("a(sss)", changes),
+ bus_image_method_attach,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("Detach",
+ SD_BUS_ARGS("b", runtime),
+ SD_BUS_RESULT("a(sss)", changes),
+ bus_image_method_detach,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("Reattach",
+ SD_BUS_ARGS("as", matches,
+ "s", profile,
+ "b", runtime,
+ "s", copy_mode),
+ SD_BUS_RESULT("a(sss)", changes_removed,
+ "a(sss)", changes_updated),
+ bus_image_method_reattach,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("Remove",
+ SD_BUS_NO_ARGS,
+ SD_BUS_NO_RESULT,
+ bus_image_method_remove,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("MarkReadOnly",
+ SD_BUS_ARGS("b", read_only),
+ SD_BUS_NO_RESULT,
+ bus_image_method_mark_read_only,
+ SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_METHOD_WITH_ARGS("SetLimit",
+ SD_BUS_ARGS("t", limit),
+ SD_BUS_NO_RESULT,
+ bus_image_method_set_limit,
+ SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END
};
@@ -919,3 +965,10 @@ int bus_image_node_enumerator(sd_bus *bus, const char *path, void *userdata, cha
return 1;
}
+
+const BusObjectImplementation image_object = {
+ "/org/freedesktop/portable1/image",
+ "org.freedesktop.portable1.Image",
+ .fallback_vtables = BUS_FALLBACK_VTABLES({image_vtable, bus_image_object_find}),
+ .node_enumerator = bus_image_node_enumerator,
+};
diff --git a/src/portable/portabled-image-bus.h b/src/portable/portabled-image-bus.h
index e5faf43d90..763a0890f9 100644
--- a/src/portable/portabled-image-bus.h
+++ b/src/portable/portabled-image-bus.h
@@ -15,6 +15,7 @@ int bus_image_common_mark_read_only(Manager *m, sd_bus_message *message, const c
int bus_image_common_set_limit(Manager *m, sd_bus_message *message, const char *name_or_path, Image *image, sd_bus_error *error);
extern const sd_bus_vtable image_vtable[];
+extern const BusObjectImplementation image_object;
int bus_image_path(Image *image, char **ret);
diff --git a/src/portable/portabled.c b/src/portable/portabled.c
index 8a17f09365..3c8e20e0f3 100644
--- a/src/portable/portabled.c
+++ b/src/portable/portabled.c
@@ -15,6 +15,7 @@
#include "portabled-image-bus.h"
#include "portabled.h"
#include "process-util.h"
+#include "service-util.h"
#include "signal-util.h"
static Manager* manager_unref(Manager *m);
@@ -73,17 +74,9 @@ static int manager_connect_bus(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to connect to system bus: %m");
- r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/portable1", "org.freedesktop.portable1.Manager", manager_vtable, m);
+ r = bus_add_implementation(m->bus, &manager_object, m);
if (r < 0)
- return log_error_errno(r, "Failed to add manager object vtable: %m");
-
- r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/portable1/image", "org.freedesktop.portable1.Image", image_vtable, bus_image_object_find, m);
- if (r < 0)
- return log_error_errno(r, "Failed to add image object vtable: %m");
-
- r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/portable1/image", bus_image_node_enumerator, m);
- if (r < 0)
- return log_error_errno(r, "Failed to add image enumerator: %m");
+ return r;
r = bus_log_control_api_register(m->bus);
if (r < 0)
@@ -137,6 +130,14 @@ static int run(int argc, char *argv[]) {
log_setup();
+ r = service_parse_argv("systemd-portabled.service",
+ "Manage registrations of portable images.",
+ BUS_IMPLEMENTATIONS(&manager_object,
+ &log_control_object),
+ argc, argv);
+ if (r <= 0)
+ return r;
+
umask(0022);
if (argc != 1)
diff --git a/src/portable/portabled.h b/src/portable/portabled.h
index 03a9996916..71ec41d4f1 100644
--- a/src/portable/portabled.h
+++ b/src/portable/portabled.h
@@ -4,6 +4,7 @@
#include "sd-bus.h"
#include "sd-event.h"
+#include "bus-object.h"
#include "hashmap.h"
#include "list.h"
@@ -23,3 +24,5 @@ struct Manager {
LIST_HEAD(Operation, operations);
unsigned n_operations;
};
+
+extern const BusObjectImplementation manager_object;