Compare commits

..

No commits in common. "d910f4c2b2542544d7b187a09605da7a0f220837" and "6bae4b905ccf512aadb66e357a845079b8b41f53" have entirely different histories.

99 changed files with 2180 additions and 1280 deletions

7
TODO
View File

@ -22,12 +22,6 @@ Janitorial Clean-ups:
Features: Features:
* homed: permit multiple private keys to be used locally, and pick the right
one for signing records automatically depending on a pre-existing signature
* homed: add a way to "adopt" a home directory, i.e. strip foreign signatures
and insert a local signature instead.
* busctl: maybe expose a verb "ping" for pinging a dbus service to see if it * busctl: maybe expose a verb "ping" for pinging a dbus service to see if it
exists and responds. exists and responds.
@ -226,6 +220,7 @@ Features:
- rollback when resize fails mid-operation - rollback when resize fails mid-operation
- GNOME's side for forget key on suspend (requires rework so that lock screen runs outside of uid) - GNOME's side for forget key on suspend (requires rework so that lock screen runs outside of uid)
- resize on login? - resize on login?
- fstrim on logout?
- shrink fs on logout? - shrink fs on logout?
- update LUKS password on login if we find there's a password that unlocks the JSON record but not the LUKS device. - update LUKS password on login if we find there's a password that unlocks the JSON record but not the LUKS device.
- create on activate? - create on activate?

View File

@ -168,10 +168,6 @@ If the UID assigned to a user does not match the owner of the home directory in
the file system, the home directory is automatically and recursively `chown()`ed the file system, the home directory is automatically and recursively `chown()`ed
to the correct UID. to the correct UID.
Depending on the `luksDiscard` setting of the user record either the backing Depending on the `discard` setting of the user record either the backing
loopback file is `fallocate()`ed during activation, or the mounted file system loopback file is `fallocate()`ed during activation, or the mounted file system
is `FITRIM`ed after mounting, to ensure the setting is correctly enforced. is `FITRIM`ed after mounting, to ensure the setting is correctly enforced.
When deactivating a home directory, the file system or block device is trimmed
or extended as configured in the `luksOfflineDiscard` setting of the user
record.

View File

@ -455,10 +455,6 @@ storage. If false and `luks` storage is used turns this behavior off. In
addition, depending on this setting an `FITRIM` or `fallocate()` operation is addition, depending on this setting an `FITRIM` or `fallocate()` operation is
executed to make sure the image matches the selected option. executed to make sure the image matches the selected option.
`luksOfflineDiscard` → A boolean. Similar to `luksDiscard`, it controls whether
to trim/allocate the file system/backing file when deactivating the home
directory.
`luksCipher` → A string, indicating the cipher to use for the LUKS storage mechanism. `luksCipher` → A string, indicating the cipher to use for the LUKS storage mechanism.
`luksCipherMode` → A string, selecting the cipher mode to use for the LUKS storage mechanism. `luksCipherMode` → A string, selecting the cipher mode to use for the LUKS storage mechanism.
@ -652,12 +648,11 @@ that may be used in this section are identical to the equally named ones in the
`mountNoDevices`, `mountNoSuid`, `mountNoExecute`, `cifsDomain`, `mountNoDevices`, `mountNoSuid`, `mountNoExecute`, `cifsDomain`,
`cifsUserName`, `cifsService`, `imagePath`, `uid`, `gid`, `memberOf`, `cifsUserName`, `cifsService`, `imagePath`, `uid`, `gid`, `memberOf`,
`fileSystemType`, `partitionUuid`, `luksUuid`, `fileSystemUuid`, `luksDiscard`, `fileSystemType`, `partitionUuid`, `luksUuid`, `fileSystemUuid`, `luksDiscard`,
`luksOfflineDiscard`, `luksOfflineDiscard`, `luksCipher`, `luksCipherMode`, `luksCipher`, `luksCipherMode`, `luksVolumeKeySize`, `luksPbkdfHashAlgorithm`,
`luksVolumeKeySize`, `luksPbkdfHashAlgorithm`, `luksPbkdfType`, `luksPbkdfType`, `luksPbkdfTimeCostUSec`, `luksPbkdfMemoryCost`,
`luksPbkdfTimeCostUSec`, `luksPbkdfMemoryCost`, `luksPbkdfParallelThreads`, `luksPbkdfParallelThreads`, `rateLimitIntervalUSec`, `rateLimitBurst`,
`rateLimitIntervalUSec`, `rateLimitBurst`, `enforcePasswordPolicy`, `enforcePasswordPolicy`, `autoLogin`, `stopDelayUSec`, `killProcesses`,
`autoLogin`, `stopDelayUSec`, `killProcesses`, `passwordChangeMinUSec`, `passwordChangeMinUSec`, `passwordChangeMaxUSec`, `passwordChangeWarnUSec`,
`passwordChangeMaxUSec`, `passwordChangeWarnUSec`,
`passwordChangeInactiveUSec`, `passwordChangeNow`, `pkcs11TokenUri`. `passwordChangeInactiveUSec`, `passwordChangeNow`, `pkcs11TokenUri`.
## Fields in the `binding` section ## Fields in the `binding` section

View File

@ -1,190 +0,0 @@
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="systemd.directives" conditional="HAVE_PYTHON">
<refentryinfo>
<title>systemd.directives</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>systemd.directives</refentrytitle>
<manvolnum>7</manvolnum>
</refmeta>
<refnamediv>
<refname>systemd.directives</refname>
<refpurpose>Index of configuration directives</refpurpose>
</refnamediv>
<refsect1>
<title>Unit directives</title>
<para>Directives for configuring units, used in unit files.</para>
<variablelist id='unit-directives' />
</refsect1>
<refsect1>
<title>Options on the kernel command line</title>
<para>Kernel boot options for configuring the behaviour of the systemd process.</para>
<variablelist id='kernel-commandline-options' />
</refsect1>
<refsect1>
<title>Environment variables</title>
<para>Environment variables understood by the systemd manager and other programs and environment
variable-compatible settings.</para>
<variablelist id='environment-variables' />
</refsect1>
<refsect1>
<title>EFI variables</title>
<para>EFI variables understood by
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>
and other programs.</para>
<variablelist id='efi-variables' />
</refsect1>
<refsect1>
<title>UDEV directives</title>
<para>Directives for configuring systemd units through the udev database.</para>
<variablelist id='udev-directives' />
</refsect1>
<refsect1>
<title>Network directives</title>
<para>Directives for configuring network links through the net-setup-link udev builtin and networks
through systemd-networkd.</para>
<variablelist id='network-directives' />
</refsect1>
<refsect1>
<title>Journal fields</title>
<para>Fields in the journal events with a well known meaning.</para>
<variablelist id='journal-directives' />
</refsect1>
<refsect1>
<title>PAM configuration directives</title>
<para>Directives for configuring PAM behaviour.</para>
<variablelist id='pam-directives' />
</refsect1>
<refsect1>
<title><filename>/etc/crypttab</filename> and
<filename>/etc/fstab</filename> options</title>
<para>Options which influence mounted filesystems and encrypted volumes.</para>
<variablelist id='fstab-options' />
</refsect1>
<refsect1>
<title><citerefentry><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>
directives</title>
<para>Directives for configuring systemd-nspawn containers.</para>
<variablelist id='nspawn-directives' />
</refsect1>
<refsect1>
<title>Program configuration options</title>
<para>Directives for configuring the behaviour of the systemd process and other tools through
configuration files.</para>
<variablelist id='config-directives' />
</refsect1>
<refsect1>
<title>Command line options</title>
<para>Command-line options accepted by programs in the systemd suite.</para>
<variablelist id='options' />
</refsect1>
<refsect1>
<title>Constants</title>
<para>Various constant used and/or defined by systemd.</para>
<variablelist id='constants' />
</refsect1>
<refsect1>
<title>Miscellaneous options and directives</title>
<para>Other configuration elements which don't fit in any of the above groups.</para>
<variablelist id='miscellaneous' />
</refsect1>
<refsect1>
<title>Specifiers</title>
<para>Short strings which are substituted in configuration directives.</para>
<variablelist id='specifiers' />
</refsect1>
<refsect1>
<title>Files and directories</title>
<para>Paths and file names referred to in the documentation.</para>
<variablelist id='filenames' />
</refsect1>
<refsect1>
<title>D-Bus interfaces</title>
<para>Interfaces exposed over D-Bus.</para>
<variablelist id='dbus-interface' />
</refsect1>
<refsect1>
<title>D-Bus methods</title>
<para>Methods exposed in the D-Bus interface.</para>
<variablelist id='dbus-method' />
</refsect1>
<refsect1>
<title>D-Bus properties</title>
<para>Properties exposed in the D-Bus interface.</para>
<variablelist id='dbus-property' />
</refsect1>
<refsect1>
<title>D-Bus signals</title>
<para>Signals emitted in the D-Bus interface.</para>
<variablelist id='dbus-signal' />
</refsect1>
<refsect1>
<title>Colophon</title>
<para id='colophon' />
</refsect1>
</refentry>

View File

@ -544,16 +544,6 @@
loopback file) the discard logic defaults to on.</para></listitem> loopback file) the discard logic defaults to on.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--luks-offline-discard=</option><replaceable>BOOL</replaceable></term>
<listitem><para>Similar to <option>--luks-discard=</option>, controls the trimming of the file
system. However, while <option>--luks-discard=</option> controls what happens when the home directory
is active, <option>--luks-offline-discard=</option> controls what happens when it becomes inactive,
i.e. whether to trim/allocate the storage when deactivating the home directory. This option defaults
to on, to ensure disk space is minimized while a user is not logged in.</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--luks-cipher=</option><replaceable>CIPHER</replaceable></term> <term><option>--luks-cipher=</option><replaceable>CIPHER</replaceable></term>
<term><option>--luks-cipher-mode=</option><replaceable>MODE</replaceable></term> <term><option>--luks-cipher-mode=</option><replaceable>MODE</replaceable></term>

View File

@ -110,9 +110,9 @@ endif
systemd_directives_xml = custom_target( systemd_directives_xml = custom_target(
'systemd.directives.xml', 'systemd.directives.xml',
input : ['directives-template.xml', source_xml_files], input : source_xml_files,
output : 'systemd.directives.xml', output : 'systemd.directives.xml',
command : [make_directive_index_py, '@OUTPUT@', '@INPUT@']) command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
nonindex_xml_files = source_xml_files + [systemd_directives_xml] nonindex_xml_files = source_xml_files + [systemd_directives_xml]
systemd_index_xml = custom_target( systemd_index_xml = custom_target(
@ -217,7 +217,7 @@ if git.found()
output : 'update-man-rules', output : 'update-man-rules',
command : ['sh', '-c', command : ['sh', '-c',
'cd @0@ && '.format(meson.build_root()) + 'cd @0@ && '.format(meson.build_root()) +
'python3 @0@/tools/update-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) + 'python3 @0@/tools/make-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
'mv t @0@/rules/meson.build'.format(meson.current_source_dir())], 'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
depend_files : custom_entities_ent) depend_files : custom_entities_ent)
endif endif

View File

@ -259,31 +259,31 @@
<variablelist class='pam-directives'> <variablelist class='pam-directives'>
<varlistentry> <varlistentry>
<term><varname>systemd.memory_max=</varname></term> <term><varname>systemd.memory_max</varname></term>
<listitem><para>Sets unit <varname>MemoryMax=</varname>.</para></listitem> <listitem><para>Sets unit <varname>MemoryMax=</varname>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>systemd.tasks_max=</varname></term> <term><varname>systemd.tasks_max</varname></term>
<listitem><para>Sets unit <varname>TasksMax=</varname>.</para></listitem> <listitem><para>Sets unit <varname>TasksMax=</varname>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>systemd.cpu_weight=</varname></term> <term><varname>systemd.cpu_weight</varname></term>
<listitem><para>Sets unit <varname>CPUWeight=</varname>.</para></listitem> <listitem><para>Sets unit <varname>CPUWeight=</varname>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>systemd.io_weight=</varname></term> <term><varname>systemd.io_weight</varname></term>
<listitem><para>Sets unit <varname>IOWeight=</varname>.</para></listitem> <listitem><para>Sets unit <varname>IOWeight=</varname>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><varname>systemd.runtime_max_sec=</varname></term> <term><varname>systemd.runtime_max_sec</varname></term>
<listitem><para>Sets unit <varname>RuntimeMaxSec=</varname>.</para></listitem> <listitem><para>Sets unit <varname>RuntimeMaxSec=</varname>.</para></listitem>
</varlistentry> </varlistentry>

View File

@ -1,4 +1,4 @@
# Do not edit. Generated by update-man-rules.py. # Do not edit. Generated by make-man-rules.py.
# Update with: # Update with:
# ninja -C build man/update-man-rules # ninja -C build man/update-man-rules
manpages = [ manpages = [
@ -720,11 +720,7 @@ manpages = [
['sd_machine_get_class', '3', ['sd_machine_get_ifindices'], ''], ['sd_machine_get_class', '3', ['sd_machine_get_ifindices'], ''],
['sd_notify', ['sd_notify',
'3', '3',
['sd_notify_barrier', ['sd_notifyf', 'sd_pid_notify', 'sd_pid_notify_with_fds', 'sd_pid_notifyf', 'sd_notify_barrier'],
'sd_notifyf',
'sd_pid_notify',
'sd_pid_notify_with_fds',
'sd_pid_notifyf'],
''], ''],
['sd_path_lookup', '3', ['sd_path_lookup_strv'], ''], ['sd_path_lookup', '3', ['sd_path_lookup_strv'], ''],
['sd_pid_get_owner_uid', ['sd_pid_get_owner_uid',

View File

@ -24,11 +24,6 @@
<entry>Host name</entry> <entry>Host name</entry>
<entry>The hostname of the running system.</entry> <entry>The hostname of the running system.</entry>
</row> </row>
<row id='l'>
<entry><literal>%l</literal></entry>
<entry>Short host name</entry>
<entry>The hostname of the running system, truncated at the first dot to remove any domain component.</entry>
</row>
<row id='m'> <row id='m'>
<entry><literal>%m</literal></entry> <entry><literal>%m</literal></entry>
<entry>Machine ID</entry> <entry>Machine ID</entry>

View File

@ -47,55 +47,6 @@
<citerefentry><refentrytitle>userdbctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> <citerefentry><refentrytitle>userdbctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
</refsect1> </refsect1>
<refsect1>
<title>Key Management</title>
<para>User records are cryptographically signed with a public/private key pair (the signature is part of
the JSON record itself). For a user to be permitted to log in locally the public key matching the
signature of their user record must be installed. For a user record to be modified locally the private
key matching the signature must be installed locally, too. The keys are stored in the
<filename>/var/lib/systemd/home/</filename> directory:</para>
<variablelist>
<varlistentry>
<term><filename>/var/lib/systemd/home/local.private</filename></term>
<listitem><para>The private key of the public/private key pair used for local records. Currently,
only a single such key may be installed.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>/var/lib/systemd/home/local.public</filename></term>
<listitem><para>The public key of the public/private key pair used for local records. Currently,
only a single such key may be installed.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>/var/lib/systemd/home/*.public</filename></term>
<listitem><para>Additional public keys. Any users whose user records are signed with any of these keys
are permitted to log in locally. An arbitrary number of keys may be installed this
way.</para></listitem>
</varlistentry>
</variablelist>
<para>All key files listed above are in PEM format.</para>
<para>In order to migrate a home directory from a host <literal>foobar</literal> to another host
<literal>quux</literal> it is hence sufficient to copy
<filename>/var/lib/systemd/home/local.public</filename> from the host <literal>foobar</literal> to
<literal>quux</literal>, maybe calling the file on the destination
<filename>/var/lib/systemd/home/foobar.public</filename>, reflecting the origin of the key. If the user
record should be modifiable on <literal>quux</literal> the pair
<filename>/var/lib/systemd/home/local.public</filename> and
<filename>/var/lib/systemd/home/local.private</filename> need to be copied from <literal>foobar</literal>
to <literal>quux</literal>, and placed under the identical paths there, as currently only a single
private key is supported per host. Note of course that the latter means that user records
generated/signed before the key pair is copied in, lose their validity.</para>
</refsect1>
<refsect1> <refsect1>
<title>See Also</title> <title>See Also</title>
<para> <para>

View File

@ -75,7 +75,7 @@
<para>An instance name of the network service as defined in the section 4.1.1 of <ulink <para>An instance name of the network service as defined in the section 4.1.1 of <ulink
url="https://tools.ietf.org/html/rfc6763">RFC 6763</ulink>, e.g. <literal>webserver</literal>.</para> url="https://tools.ietf.org/html/rfc6763">RFC 6763</ulink>, e.g. <literal>webserver</literal>.</para>
<para>The option supports simple specifier expansion. The following expansions are understood:</para> <para>The option supports simple specifier expansion. The following expansions are understood:</para>
<table class='specifiers'> <table>
<title>Specifiers available</title> <title>Specifiers available</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'> <tgroup cols='3' align='left' colsep='1' rowsep='1'>
<colspec colname="spec" /> <colspec colname="spec" />

View File

@ -444,9 +444,9 @@
created. (See created. (See
<citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry> <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
for more information.) This option is mandatory. Note that the usual specifier expansion is applied for more information.) This option is mandatory. Note that the usual specifier expansion is applied
to this setting, literal percent characters should hence be written as <literal to this setting, literal percent characters should hence be written as <literal>%%</literal>. If this
class='specifiers'>%%</literal>. If this mount is a bind mount and the specified path does not exist mount is a bind mount and the specified path does not exist yet it is created as
yet it is created as directory.</para></listitem> directory.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
@ -469,7 +469,7 @@
<listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting <listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting
is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters
should hence be written as <literal class='specifiers'>%%</literal>.</para></listitem> should hence be written as <literal>%%</literal>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -184,13 +184,11 @@
project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> for project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
details. If this refers to a device node, a dependency on the respective device unit is automatically details. If this refers to a device node, a dependency on the respective device unit is automatically
created. (See created. (See
<citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry> <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
for more information.) If this refers to a file, a dependency on the respective mount unit is information.) If this refers to a file, a dependency on the respective mount unit is automatically
automatically created. (See created. (See <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
<citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> for for more information.) This option is mandatory. Note that the usual specifier expansion is applied to this
more information.) This option is mandatory. Note that the usual specifier expansion is applied to setting, literal percent characters should hence be written as <literal>%%</literal>.</para></listitem>
this setting, literal percent characters should hence be written as
<literal class='specifiers'>%%</literal>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -1695,7 +1695,7 @@
and resolvable for the setting to be valid. The following and resolvable for the setting to be valid. The following
specifiers are understood:</para> specifiers are understood:</para>
<table class='specifiers'> <table>
<title>Specifiers available in unit files</title> <title>Specifiers available in unit files</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'> <tgroup cols='3' align='left' colsep='1' rowsep='1'>
<colspec colname="spec" /> <colspec colname="spec" />
@ -1710,8 +1710,7 @@
</thead> </thead>
<tbody> <tbody>
<row> <row>
<!-- We do not use the common definition from standard-specifiers.xml here since it includes a <!-- We do not use the common definition from standard-specifiers.xml here since it includes a reference onto our own man page, which would make the rendered version self-referential. -->
reference onto our own man page, which would make the rendered version self-referential. -->
<entry><literal>%a</literal></entry> <entry><literal>%a</literal></entry>
<entry>Architecture</entry> <entry>Architecture</entry>
<entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry> <entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry>
@ -1741,17 +1740,11 @@
Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
</row> </row>
<row> <row>
<!-- We do not use the common definition from standard-specifiers.xml here since we want a <!-- We do not use the common definition from standard-specifiers.xml here since we want a slightly more verbose explanation here, referring to the reload cycle. -->
slightly more verbose explanation here, referring to the reload cycle. -->
<entry><literal>%H</literal></entry> <entry><literal>%H</literal></entry>
<entry>Host name</entry> <entry>Host name</entry>
<entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
</row> </row>
<row>
<entry><literal>%l</literal></entry>
<entry>Short host name</entry>
<entry>The hostname of the running system at the point in time the unit configuration is loaded, truncated at the first dot to remove any domain component.</entry>
</row>
<row> <row>
<entry><literal>%i</literal></entry> <entry><literal>%i</literal></entry>
<entry>Instance name</entry> <entry>Instance name</entry>

View File

@ -234,12 +234,10 @@ r - 500-900
<refsect1> <refsect1>
<title>Specifiers</title> <title>Specifiers</title>
<para>Specifiers can be used in the <literal>Name</literal>, <literal>ID</literal>, <para>Specifiers can be used in the "Name", "ID", "GECOS", "Home directory", and "Shell" fields.
<literal>GECOS</literal>, <literal>Home directory</literal>, and <literal>Shell</literal> fields. An An unknown or unresolvable specifier is treated as invalid configuration.
unknown or unresolvable specifier is treated as invalid configuration. The following expansions are The following expansions are understood:</para>
understood:</para> <table>
<table class='specifiers'>
<title>Specifiers available</title> <title>Specifiers available</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'> <tgroup cols='3' align='left' colsep='1' rowsep='1'>
<colspec colname="spec" /> <colspec colname="spec" />
@ -257,7 +255,6 @@ r - 500-900
<xi:include href="standard-specifiers.xml" xpointer="b"/> <xi:include href="standard-specifiers.xml" xpointer="b"/>
<xi:include href="standard-specifiers.xml" xpointer="B"/> <xi:include href="standard-specifiers.xml" xpointer="B"/>
<xi:include href="standard-specifiers.xml" xpointer="H"/> <xi:include href="standard-specifiers.xml" xpointer="H"/>
<xi:include href="standard-specifiers.xml" xpointer="l"/>
<xi:include href="standard-specifiers.xml" xpointer="m"/> <xi:include href="standard-specifiers.xml" xpointer="m"/>
<xi:include href="standard-specifiers.xml" xpointer="o"/> <xi:include href="standard-specifiers.xml" xpointer="o"/>
<row> <row>

View File

@ -618,7 +618,7 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
<para>Specifiers can be used in the "path" and "argument" fields. <para>Specifiers can be used in the "path" and "argument" fields.
An unknown or unresolvable specifier is treated as invalid configuration. An unknown or unresolvable specifier is treated as invalid configuration.
The following expansions are understood:</para> The following expansions are understood:</para>
<table class='specifiers'> <table>
<title>Specifiers available</title> <title>Specifiers available</title>
<tgroup cols='3' align='left' colsep='1' rowsep='1'> <tgroup cols='3' align='left' colsep='1' rowsep='1'>
<colspec colname="spec" /> <colspec colname="spec" />
@ -646,7 +646,6 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
<entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry> <entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="H"/> <xi:include href="standard-specifiers.xml" xpointer="H"/>
<xi:include href="standard-specifiers.xml" xpointer="l"/>
<row> <row>
<entry><literal>%L</literal></entry> <entry><literal>%L</literal></entry>
<entry>System or user log directory</entry> <entry>System or user log directory</entry>

View File

@ -299,7 +299,7 @@ substs.set('BUILD_ROOT', project_build_root
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig') pkgconfig = import('pkgconfig')
check_compilation_sh = find_program('tools/check-compilation.sh') check_compilation_sh = find_program('tools/meson-check-compilation.sh')
meson_build_sh = find_program('tools/meson-build.sh') meson_build_sh = find_program('tools/meson-build.sh')
want_tests = get_option('tests') want_tests = get_option('tests')
@ -639,14 +639,7 @@ endforeach
############################################################ ############################################################
fallback_hostname = get_option('fallback-hostname') conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
if fallback_hostname == '' or fallback_hostname[0] == '.' or fallback_hostname[0] == '-'
error('Invalid fallback-hostname configuration')
# A more extensive test is done in test-hostname-util. Let's catch
# the most obvious errors here so we don't fail with an assert later.
endif
conf.set_quoted('FALLBACK_HOSTNAME', fallback_hostname)
conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname')) conf.set10('ENABLE_COMPAT_GATEWAY_HOSTNAME', get_option('compat-gateway-hostname'))
gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : []) gateway_hostnames = ['_gateway'] + (conf.get('ENABLE_COMPAT_GATEWAY_HOSTNAME') == 1 ? ['gateway'] : [])
@ -3251,8 +3244,8 @@ run_target(
make_directive_index_py = find_program('tools/make-directive-index.py') make_directive_index_py = find_program('tools/make-directive-index.py')
make_man_index_py = find_program('tools/make-man-index.py') make_man_index_py = find_program('tools/make-man-index.py')
xml_helper_py = find_program('tools/xml_helper.py') xml_helper_py = find_program('tools/xml_helper.py')
hwdb_update_sh = find_program('tools/hwdb-update.sh') hwdb_update_sh = find_program('tools/meson-hwdb-update.sh')
autosuspend_update_sh = find_program('tools/autosuspend-update.sh') autosuspend_update_sh = find_program('tools/meson-autosuspend-update.sh')
subdir('sysctl.d') subdir('sysctl.d')
subdir('sysusers.d') subdir('sysusers.d')
@ -3293,13 +3286,13 @@ meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
############################################################ ############################################################
check_help = find_program('tools/check-help.sh') meson_check_help = find_program('tools/meson-check-help.sh')
foreach exec : public_programs foreach exec : public_programs
name = exec.full_path().split('/')[-1] name = exec.full_path().split('/')[-1]
if want_tests != 'false' if want_tests != 'false'
test('check-help-' + name, test('check-help-' + name,
check_help, meson_check_help,
args : exec.full_path()) args : exec.full_path())
endif endif
endforeach endforeach
@ -3378,10 +3371,10 @@ if git.found()
endif endif
if git.found() if git.found()
git_contrib_sh = find_program('tools/git-contrib.sh') meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
run_target( run_target(
'git-contrib', 'git-contrib',
command : [git_contrib_sh]) command : [meson_git_contrib_sh])
endif endif
if git.found() if git.found()
@ -3405,11 +3398,11 @@ endif
############################################################ ############################################################
check_api_docs_sh = find_program('tools/check-api-docs.sh') meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
run_target( run_target(
'check-api-docs', 'check-api-docs',
depends : [man, libsystemd, libudev], depends : [man, libsystemd, libudev],
command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()]) command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
############################################################ ############################################################
watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog

View File

@ -141,7 +141,7 @@ static void security_info_free(struct security_info *i) {
strv_free(i->supplementary_groups); strv_free(i->supplementary_groups);
strv_free(i->system_call_architectures); strv_free(i->system_call_architectures);
set_free(i->system_call_filter); set_free_free(i->system_call_filter);
} }
static bool security_info_runs_privileged(const struct security_info *i) { static bool security_info_runs_privileged(const struct security_info *i) {
@ -1728,7 +1728,11 @@ static int property_read_system_call_filter(
if (r == 0) if (r == 0)
break; break;
r = set_put_strdup(&info->system_call_filter, name); r = set_ensure_allocated(&info->system_call_filter, &string_hash_ops);
if (r < 0)
return r;
r = set_put_strdup(info->system_call_filter, name);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -349,7 +349,14 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnits",
&error, &reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
@ -1277,7 +1284,15 @@ static int dot(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, ""); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnits",
&error,
&reply,
"");
if (r < 0) if (r < 0)
log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r)); log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, r));
@ -1319,7 +1334,15 @@ static int dump_fallback(sd_bus *bus) {
assert(bus); assert(bus);
r = bus_call_method(bus, bus_systemd_mgr, "Dump", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Dump",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to issue method call Dump: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to issue method call Dump: %s", bus_error_message(&error, r));
@ -1347,7 +1370,15 @@ static int dump(int argc, char *argv[], void *userdata) {
if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD)) if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD))
return dump_fallback(bus); return dump_fallback(bus);
r = bus_call_method(bus, bus_systemd_mgr, "DumpByFileDescriptor", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"DumpByFileDescriptor",
&error,
&reply,
NULL);
if (r < 0) { if (r < 0) {
/* fall back to Dump if DumpByFileDescriptor is not supported */ /* fall back to Dump if DumpByFileDescriptor is not supported */
if (!IN_SET(r, -EACCES, -EBADR)) if (!IN_SET(r, -EACCES, -EBADR))
@ -1413,7 +1444,15 @@ static int set_log_level(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create bus connection: %m"); return log_error_errno(r, "Failed to create bus connection: %m");
r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogLevel",
&error,
"s",
argv[1]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
@ -1430,7 +1469,14 @@ static int get_log_level(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create bus connection: %m"); return log_error_errno(r, "Failed to create bus connection: %m");
r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level); r = sd_bus_get_property_string(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogLevel",
&error,
&level);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r));
@ -1454,7 +1500,15 @@ static int set_log_target(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create bus connection: %m"); return log_error_errno(r, "Failed to create bus connection: %m");
r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogTarget",
&error,
"s",
argv[1]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
@ -1471,7 +1525,14 @@ static int get_log_target(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create bus connection: %m"); return log_error_errno(r, "Failed to create bus connection: %m");
r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target); r = sd_bus_get_property_string(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogTarget",
&error,
&target);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r));
@ -1594,7 +1655,7 @@ static int dump_exit_status(int argc, char *argv[], void *userdata) {
#if HAVE_SECCOMP #if HAVE_SECCOMP
static int load_kernel_syscalls(Set **ret) { static int load_kernel_syscalls(Set **ret) {
_cleanup_set_free_ Set *syscalls = NULL; _cleanup_(set_free_freep) Set *syscalls = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
int r; int r;
@ -1630,7 +1691,11 @@ static int load_kernel_syscalls(Set **ret) {
if (STR_IN_SET(e, "newuname", "newfstat", "newstat", "newlstat", "sysctl")) if (STR_IN_SET(e, "newuname", "newfstat", "newstat", "newlstat", "sysctl"))
continue; continue;
r = set_put_strdup(&syscalls, e); r = set_ensure_allocated(&syscalls, &string_hash_ops);
if (r < 0)
return log_oom();
r = set_put_strdup(syscalls, e);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to add system call to list: %m"); return log_error_errno(r, "Failed to add system call to list: %m");
} }
@ -1670,7 +1735,7 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
if (strv_isempty(strv_skip(argv, 1))) { if (strv_isempty(strv_skip(argv, 1))) {
_cleanup_set_free_ Set *kernel = NULL; _cleanup_(set_free_freep) Set *kernel = NULL;
int i, k; int i, k;
k = load_kernel_syscalls(&kernel); k = load_kernel_syscalls(&kernel);
@ -2056,7 +2121,15 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
if (argc == 1) { if (argc == 1) {
/* get ServiceWatchdogs */ /* get ServiceWatchdogs */
r = bus_get_property_trivial(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, 'b', &b); r = sd_bus_get_property_trivial(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ServiceWatchdogs",
&error,
'b',
&b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r));
@ -2068,7 +2141,15 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
if (b < 0) if (b < 0)
return log_error_errno(b, "Failed to parse service-watchdogs argument: %m"); return log_error_errno(b, "Failed to parse service-watchdogs argument: %m");
r = bus_set_property(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, "b", b); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ServiceWatchdogs",
&error,
"b",
b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r));
} }

View File

@ -77,10 +77,8 @@ static int files_add(
/* Is this a masking entry? */ /* Is this a masking entry? */
if ((flags & CONF_FILES_FILTER_MASKED)) if ((flags & CONF_FILES_FILTER_MASKED))
if (null_or_empty(&st)) { if (null_or_empty(&st)) {
assert(masked);
/* Mark this one as masked */ /* Mark this one as masked */
r = set_put_strdup(&masked, de->d_name); r = set_put_strdup(masked, de->d_name);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -10,8 +10,6 @@ void string_hash_func(const char *p, struct siphash *state) {
} }
DEFINE_HASH_OPS(string_hash_ops, char, string_hash_func, string_compare_func); DEFINE_HASH_OPS(string_hash_ops, char, string_hash_func, string_compare_func);
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(string_hash_ops_free,
char, string_hash_func, string_compare_func, free);
DEFINE_HASH_OPS_FULL(string_hash_ops_free_free, DEFINE_HASH_OPS_FULL(string_hash_ops_free_free,
char, string_hash_func, string_compare_func, free, char, string_hash_func, string_compare_func, free,
char, free); char, free);

View File

@ -76,7 +76,6 @@ struct hash_ops {
void string_hash_func(const char *p, struct siphash *state); void string_hash_func(const char *p, struct siphash *state);
#define string_compare_func strcmp #define string_compare_func strcmp
extern const struct hash_ops string_hash_ops; extern const struct hash_ops string_hash_ops;
extern const struct hash_ops string_hash_ops_free;
extern const struct hash_ops string_hash_ops_free_free; extern const struct hash_ops string_hash_ops_free_free;
void path_hash_func(const char *p, struct siphash *state); void path_hash_func(const char *p, struct siphash *state);

View File

@ -1775,54 +1775,41 @@ int hashmap_put_strdup(Hashmap **h, const char *k, const char *v) {
return r; return r;
_cleanup_free_ char *kdup = NULL, *vdup = NULL; _cleanup_free_ char *kdup = NULL, *vdup = NULL;
kdup = strdup(k); kdup = strdup(k);
if (!kdup)
return -ENOMEM;
if (v) {
vdup = strdup(v); vdup = strdup(v);
if (!vdup) if (!kdup || !vdup)
return -ENOMEM; return -ENOMEM;
}
r = hashmap_put(*h, kdup, vdup); r = hashmap_put(*h, kdup, vdup);
if (r < 0) { if (r < 0) {
if (r == -EEXIST && streq_ptr(v, hashmap_get(*h, kdup))) if (r == -EEXIST && streq(v, hashmap_get(*h, kdup)))
return 0; return 0;
return r; return r;
} }
/* 0 with non-null vdup would mean vdup is already in the hashmap, which cannot be */ assert(r > 0); /* 0 would mean vdup is already in the hashmap, which cannot be */
assert(vdup == NULL || r > 0);
if (r > 0)
kdup = vdup = NULL; kdup = vdup = NULL;
return r; return 0;
} }
int set_put_strdup(Set **s, const char *p) { int set_put_strdup(Set *s, const char *p) {
char *c; char *c;
int r;
assert(s); assert(s);
assert(p); assert(p);
r = set_ensure_allocated(s, &string_hash_ops_free); if (set_contains(s, (char*) p))
if (r < 0)
return r;
if (set_contains(*s, (char*) p))
return 0; return 0;
c = strdup(p); c = strdup(p);
if (!c) if (!c)
return -ENOMEM; return -ENOMEM;
return set_consume(*s, c); return set_consume(s, c);
} }
int set_put_strdupv(Set **s, char **l) { int set_put_strdupv(Set *s, char **l) {
int n = 0, r; int n = 0, r;
char **i; char **i;

View File

@ -31,7 +31,6 @@ bool hostname_is_set(void) {
char* gethostname_malloc(void) { char* gethostname_malloc(void) {
struct utsname u; struct utsname u;
const char *s;
/* This call tries to return something useful, either the actual hostname /* This call tries to return something useful, either the actual hostname
* or it makes something up. The only reason it might fail is OOM. * or it makes something up. The only reason it might fail is OOM.
@ -39,28 +38,10 @@ char* gethostname_malloc(void) {
assert_se(uname(&u) >= 0); assert_se(uname(&u) >= 0);
s = u.nodename; if (isempty(u.nodename) || streq(u.nodename, "(none)"))
if (isempty(s) || streq(s, "(none)")) return strdup(FALLBACK_HOSTNAME);
s = FALLBACK_HOSTNAME;
return strdup(s); return strdup(u.nodename);
}
char* gethostname_short_malloc(void) {
struct utsname u;
const char *s;
/* Like above, but kills the FQDN part if present. */
assert_se(uname(&u) >= 0);
s = u.nodename;
if (isempty(s) || streq(s, "(none)") || s[0] == '.') {
s = FALLBACK_HOSTNAME;
assert(s[0] != '.');
}
return strndup(s, strcspn(s, "."));
} }
int gethostname_strict(char **ret) { int gethostname_strict(char **ret) {

View File

@ -9,7 +9,6 @@
bool hostname_is_set(void); bool hostname_is_set(void);
char* gethostname_malloc(void); char* gethostname_malloc(void);
char* gethostname_short_malloc(void);
int gethostname_strict(char **ret); int gethostname_strict(char **ret);
bool valid_ldh_char(char c) _const_; bool valid_ldh_char(char c) _const_;

View File

@ -113,8 +113,8 @@ static inline char **set_get_strv(Set *s) {
} }
int set_consume(Set *s, void *value); int set_consume(Set *s, void *value);
int set_put_strdup(Set **s, const char *p); int set_put_strdup(Set *s, const char *p);
int set_put_strdupv(Set **s, char **l); int set_put_strdupv(Set *s, char **l);
int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags); int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags);
#define SET_FOREACH(e, s, i) \ #define SET_FOREACH(e, s, i) \

View File

@ -458,7 +458,7 @@ static int on_path(const char *path, void *userdata) {
assert(paths); assert(paths);
r = set_put_strdup(&paths, path); r = set_put_strdup(paths, path);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();

View File

@ -3634,7 +3634,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
if (r < 0) if (r < 0)
return r; return r;
return 1; return 0;
} }
static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = { static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = {

View File

@ -1724,7 +1724,7 @@ int bus_unit_queue_job(
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *job_path = NULL, *unit_path = NULL; _cleanup_free_ char *job_path = NULL, *unit_path = NULL;
_cleanup_set_free_ Set *affected = NULL; _cleanup_(set_freep) Set *affected = NULL;
Iterator i; Iterator i;
Job *j, *a; Job *j, *a;
int r; int r;

View File

@ -1878,7 +1878,7 @@ static int mount_process_proc_self_mountinfo(Manager *m) {
/* Remember that this device might just have disappeared */ /* Remember that this device might just have disappeared */
if (set_ensure_allocated(&gone, &path_hash_ops) < 0 || if (set_ensure_allocated(&gone, &path_hash_ops) < 0 ||
set_put_strdup(&gone, mount->parameters_proc_self_mountinfo.what) < 0) set_put_strdup(gone, mount->parameters_proc_self_mountinfo.what) < 0)
log_oom(); /* we don't care too much about OOM here... */ log_oom(); /* we don't care too much about OOM here... */
} }
@ -1933,7 +1933,7 @@ static int mount_process_proc_self_mountinfo(Manager *m) {
/* Track devices currently used */ /* Track devices currently used */
if (set_ensure_allocated(&around, &path_hash_ops) < 0 || if (set_ensure_allocated(&around, &path_hash_ops) < 0 ||
set_put_strdup(&around, mount->parameters_proc_self_mountinfo.what) < 0) set_put_strdup(around, mount->parameters_proc_self_mountinfo.what) < 0)
log_oom(); log_oom();
} }

View File

@ -291,7 +291,6 @@ int unit_full_printf(const Unit *u, const char *format, char **ret) {
{ 'm', specifier_machine_id, NULL }, { 'm', specifier_machine_id, NULL },
{ 'H', specifier_host_name, NULL }, { 'H', specifier_host_name, NULL },
{ 'l', specifier_short_host_name, NULL },
{ 'b', specifier_boot_id, NULL }, { 'b', specifier_boot_id, NULL },
{ 'v', specifier_kernel_release, NULL }, { 'v', specifier_kernel_release, NULL },
{} {}

View File

@ -4709,7 +4709,7 @@ int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const ch
/* Make sure the drop-in dir is registered in our path cache. This way we don't need to stupidly /* Make sure the drop-in dir is registered in our path cache. This way we don't need to stupidly
* recreate the cache after every drop-in we write. */ * recreate the cache after every drop-in we write. */
if (u->manager->unit_path_cache) { if (u->manager->unit_path_cache) {
r = set_put_strdup(&u->manager->unit_path_cache, p); r = set_put_strdup(u->manager->unit_path_cache, p);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -66,6 +66,12 @@ static enum {
EXPORT_FORMAT_MINIMAL, /* also strip signature */ EXPORT_FORMAT_MINIMAL, /* also strip signature */
} arg_export_format = EXPORT_FORMAT_FULL; } arg_export_format = EXPORT_FORMAT_FULL;
static const BusLocator home_mgr = {
.destination = "org.freedesktop.home1",
.path = "/org/freedesktop/home1",
.interface = "org.freedesktop.home1.Manager",
};
STATIC_DESTRUCTOR_REGISTER(arg_identity_extra, json_variant_unrefp); STATIC_DESTRUCTOR_REGISTER(arg_identity_extra, json_variant_unrefp);
STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_this_machine, json_variant_unrefp); STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_this_machine, json_variant_unrefp);
STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_privileged, json_variant_unrefp); STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_privileged, json_variant_unrefp);
@ -116,7 +122,7 @@ static int list_homes(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_home_mgr, "ListHomes", &error, &reply, NULL); r = bus_call_method(bus, &home_mgr, "ListHomes", &error, &reply, NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list homes: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list homes: %s", bus_error_message(&error, r));
@ -379,7 +385,7 @@ static int activate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ActivateHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ActivateHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -421,7 +427,7 @@ static int deactivate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "DeactivateHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "DeactivateHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -528,9 +534,9 @@ static int inspect_home(int argc, char *argv[], void *userdata) {
continue; continue;
} }
r = bus_call_method(bus, bus_home_mgr, "GetUserRecordByName", &error, &reply, "s", *i); r = bus_call_method(bus, &home_mgr, "GetUserRecordByName", &error, &reply, "s", *i);
} else } else
r = bus_call_method(bus, bus_home_mgr, "GetUserRecordByUID", &error, &reply, "u", (uint32_t) uid); r = bus_call_method(bus, &home_mgr, "GetUserRecordByUID", &error, &reply, "u", (uint32_t) uid);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r)); log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r));
@ -604,7 +610,7 @@ static int authenticate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "AuthenticateHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "AuthenticateHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1425,7 +1431,7 @@ static int create_home(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "CreateHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "CreateHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1476,7 +1482,7 @@ static int remove_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "RemoveHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "RemoveHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1539,7 +1545,7 @@ static int acquire_updated_home_record(
if (!identity_properties_specified()) if (!identity_properties_specified())
return log_error_errno(SYNTHETIC_ERRNO(EALREADY), "No field to change specified."); return log_error_errno(SYNTHETIC_ERRNO(EALREADY), "No field to change specified.");
r = bus_call_method(bus, bus_home_mgr, "GetUserRecordByName", &error, &reply, "s", username); r = bus_call_method(bus, &home_mgr, "GetUserRecordByName", &error, &reply, "s", username);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to acquire user home record: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to acquire user home record: %s", bus_error_message(&error, r));
@ -1625,7 +1631,7 @@ static int update_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *formatted = NULL; _cleanup_free_ char *formatted = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "UpdateHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "UpdateHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1662,7 +1668,7 @@ static int update_home(int argc, char *argv[], void *userdata) {
log_debug("Resizing"); log_debug("Resizing");
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ResizeHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ResizeHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1695,7 +1701,7 @@ static int update_home(int argc, char *argv[], void *userdata) {
log_debug("Propagating password"); log_debug("Propagating password");
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ChangePasswordHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1767,7 +1773,7 @@ static int passwd_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ChangePasswordHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1846,7 +1852,7 @@ static int resize_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ResizeHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ResizeHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1883,7 +1889,7 @@ static int lock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "LockHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "LockHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1922,7 +1928,7 @@ static int unlock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "UnlockHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "UnlockHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1985,7 +1991,7 @@ static int with_home(int argc, char *argv[], void *userdata) {
return log_oom(); return log_oom();
for (;;) { for (;;) {
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "AcquireHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "AcquireHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2025,7 +2031,7 @@ static int with_home(int argc, char *argv[], void *userdata) {
} }
} }
r = bus_call_method(bus, bus_home_mgr, "GetHomeByName", &error, &reply, "s", argv[1]); r = bus_call_method(bus, &home_mgr, "GetHomeByName", &error, &reply, "s", argv[1]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to inspect home: %s", bus_error_message(&error, r));
@ -2052,7 +2058,7 @@ static int with_home(int argc, char *argv[], void *userdata) {
/* Close the fd that pings the home now. */ /* Close the fd that pings the home now. */
acquired_fd = safe_close(acquired_fd); acquired_fd = safe_close(acquired_fd);
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ReleaseHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ReleaseHome");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2081,7 +2087,7 @@ static int lock_all_homes(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "LockAllHomes"); r = bus_message_new_method_call(bus, &m, &home_mgr, "LockAllHomes");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2226,9 +2232,6 @@ static int help(int argc, char *argv[], void *userdata) {
" --fs-type=TYPE File system type to use in case of luks\n" " --fs-type=TYPE File system type to use in case of luks\n"
" storage (ext4, xfs, btrfs)\n" " storage (ext4, xfs, btrfs)\n"
" --luks-discard=BOOL Whether to use 'discard' feature of file system\n" " --luks-discard=BOOL Whether to use 'discard' feature of file system\n"
" when activated (mounted)\n"
" --luks-offline-discard=BOOL\n"
" Whether to trim file on logout\n"
" --luks-cipher=CIPHER Cipher to use for LUKS encryption\n" " --luks-cipher=CIPHER Cipher to use for LUKS encryption\n"
" --luks-cipher-mode=MODE Cipher mode to use for LUKS encryption\n" " --luks-cipher-mode=MODE Cipher mode to use for LUKS encryption\n"
" --luks-volume-key-size=BITS\n" " --luks-volume-key-size=BITS\n"
@ -2282,7 +2285,6 @@ static int parse_argv(int argc, char *argv[]) {
ARG_IMAGE_PATH, ARG_IMAGE_PATH,
ARG_UMASK, ARG_UMASK,
ARG_LUKS_DISCARD, ARG_LUKS_DISCARD,
ARG_LUKS_OFFLINE_DISCARD,
ARG_JSON, ARG_JSON,
ARG_SETENV, ARG_SETENV,
ARG_TIMEZONE, ARG_TIMEZONE,
@ -2376,7 +2378,6 @@ static int parse_argv(int argc, char *argv[]) {
{ "image-path", required_argument, NULL, ARG_IMAGE_PATH }, { "image-path", required_argument, NULL, ARG_IMAGE_PATH },
{ "fs-type", required_argument, NULL, ARG_FS_TYPE }, { "fs-type", required_argument, NULL, ARG_FS_TYPE },
{ "luks-discard", required_argument, NULL, ARG_LUKS_DISCARD }, { "luks-discard", required_argument, NULL, ARG_LUKS_DISCARD },
{ "luks-offline-discard", required_argument, NULL, ARG_LUKS_OFFLINE_DISCARD },
{ "luks-cipher", required_argument, NULL, ARG_LUKS_CIPHER }, { "luks-cipher", required_argument, NULL, ARG_LUKS_CIPHER },
{ "luks-cipher-mode", required_argument, NULL, ARG_LUKS_CIPHER_MODE }, { "luks-cipher-mode", required_argument, NULL, ARG_LUKS_CIPHER_MODE },
{ "luks-volume-key-size", required_argument, NULL, ARG_LUKS_VOLUME_KEY_SIZE }, { "luks-volume-key-size", required_argument, NULL, ARG_LUKS_VOLUME_KEY_SIZE },
@ -2946,25 +2947,6 @@ static int parse_argv(int argc, char *argv[]) {
break; break;
case ARG_LUKS_OFFLINE_DISCARD:
if (isempty(optarg)) {
r = drop_from_identity("luksOfflineDiscard");
if (r < 0)
return r;
break;
}
r = parse_boolean(optarg);
if (r < 0)
return log_error_errno(r, "Failed to parse --luks-offline-discard= parameter: %s", optarg);
r = json_variant_set_field_boolean(&arg_identity_extra, "luksOfflineDiscard", r);
if (r < 0)
return log_error_errno(r, "Failed to set offline discard field: %m");
break;
case ARG_LUKS_VOLUME_KEY_SIZE: case ARG_LUKS_VOLUME_KEY_SIZE:
case ARG_LUKS_PBKDF_PARALLEL_THREADS: case ARG_LUKS_PBKDF_PARALLEL_THREADS:
case ARG_RATE_LIMIT_BURST: { case ARG_RATE_LIMIT_BURST: {

View File

@ -1002,8 +1002,6 @@ static int home_start_work(Home *h, const char *verb, UserRecord *hr, UserRecord
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
const char *homework;
/* Child */ /* Child */
if (setenv("NOTIFY_SOCKET", "/run/systemd/home/notify", 1) < 0) { if (setenv("NOTIFY_SOCKET", "/run/systemd/home/notify", 1) < 0) {
@ -1019,11 +1017,7 @@ static int home_start_work(Home *h, const char *verb, UserRecord *hr, UserRecord
stdin_fd = stdout_fd = -1; /* have been invalidated by rearrange_stdio() */ stdin_fd = stdout_fd = -1; /* have been invalidated by rearrange_stdio() */
/* Allow overriding the homework path via an environment variable, to make debugging execl(SYSTEMD_HOMEWORK_PATH, SYSTEMD_HOMEWORK_PATH, verb, NULL);
* easier. */
homework = getenv("SYSTEMD_HOMEWORK_PATH") ?: SYSTEMD_HOMEWORK_PATH;
execl(homework, homework, verb, NULL);
log_error_errno(errno, "Failed to invoke " SYSTEMD_HOMEWORK_PATH ": %m"); log_error_errno(errno, "Failed to invoke " SYSTEMD_HOMEWORK_PATH ": %m");
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@ -893,19 +893,19 @@ int home_store_header_identity_luks(
return 1; return 1;
} }
int run_fitrim(int root_fd) { static int run_fitrim(int root_fd) {
char buf[FORMAT_BYTES_MAX]; char buf[FORMAT_BYTES_MAX];
struct fstrim_range range = { struct fstrim_range range = {
.len = UINT64_MAX, .len = UINT64_MAX,
}; };
/* If discarding is on, discard everything right after mounting, so that the discard setting takes /* If discarding is on, discard everything right after mounting, so that the discard setting takes
* effect on activation. (Also, optionally, trim on logout) */ * effect on activation. */
assert(root_fd >= 0); assert(root_fd >= 0);
if (ioctl(root_fd, FITRIM, &range) < 0) { if (ioctl(root_fd, FITRIM, &range) < 0) {
if (ERRNO_IS_NOT_SUPPORTED(errno) || errno == EBADF) { if (IN_SET(errno, ENOTTY, EOPNOTSUPP, EBADF)) {
log_debug_errno(errno, "File system does not support FITRIM, not trimming."); log_debug_errno(errno, "File system does not support FITRIM, not trimming.");
return 0; return 0;
} }
@ -918,32 +918,15 @@ int run_fitrim(int root_fd) {
return 1; return 1;
} }
int run_fitrim_by_path(const char *root_path) { static int run_fallocate(int backing_fd, const struct stat *st) {
_cleanup_close_ int root_fd = -1;
root_fd = open(root_path, O_RDONLY|O_DIRECTORY|O_CLOEXEC);
if (root_fd < 0)
return log_error_errno(errno, "Failed to open file system '%s' for trimming: %m", root_path);
return run_fitrim(root_fd);
}
int run_fallocate(int backing_fd, const struct stat *st) {
char buf[FORMAT_BYTES_MAX]; char buf[FORMAT_BYTES_MAX];
struct stat stbuf;
assert(backing_fd >= 0); assert(backing_fd >= 0);
assert(st);
/* If discarding is off, let's allocate the whole image before mounting, so that the setting takes /* If discarding is off, let's allocate the whole image before mounting, so that the setting takes
* effect on activation */ * effect on activation */
if (!st) {
if (fstat(backing_fd, &stbuf) < 0)
return log_error_errno(errno, "Failed to fstat(): %m");
st = &stbuf;
}
if (!S_ISREG(st->st_mode)) if (!S_ISREG(st->st_mode))
return 0; return 0;
@ -972,16 +955,6 @@ int run_fallocate(int backing_fd, const struct stat *st) {
return 1; return 1;
} }
int run_fallocate_by_path(const char *backing_path) {
_cleanup_close_ int backing_fd = -1;
backing_fd = open(backing_path, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
if (backing_fd < 0)
return log_error_errno(errno, "Failed to open '%s' for fallocate(): %m", backing_path);
return run_fallocate(backing_fd, NULL);
}
int home_prepare_luks( int home_prepare_luks(
UserRecord *h, UserRecord *h,
bool already_activated, bool already_activated,
@ -1138,7 +1111,7 @@ int home_prepare_luks(
h->luks_volume_key_size, h->luks_volume_key_size,
h->password, h->password,
pkcs11_decrypted_passwords ? *pkcs11_decrypted_passwords : NULL, pkcs11_decrypted_passwords ? *pkcs11_decrypted_passwords : NULL,
user_record_luks_discard(h) || user_record_luks_offline_discard(h), user_record_luks_discard(h),
&cd, &cd,
&found_luks_uuid, &found_luks_uuid,
&volume_key, &volume_key,
@ -1174,9 +1147,6 @@ int home_prepare_luks(
if (user_record_luks_discard(h)) if (user_record_luks_discard(h))
(void) run_fitrim(root_fd); (void) run_fitrim(root_fd);
setup->image_fd = TAKE_FD(fd);
setup->do_offline_fallocate = !(setup->do_offline_fitrim = user_record_luks_offline_discard(h));
} }
setup->loop = TAKE_PTR(loop); setup->loop = TAKE_PTR(loop);
@ -1289,7 +1259,6 @@ int home_activate_luks(
return r; return r;
setup.undo_mount = false; setup.undo_mount = false;
setup.do_offline_fitrim = false;
loop_device_relinquish(setup.loop); loop_device_relinquish(setup.loop);
@ -1298,7 +1267,6 @@ int home_activate_luks(
log_warning_errno(r, "Failed to relinquish DM device, ignoring: %m"); log_warning_errno(r, "Failed to relinquish DM device, ignoring: %m");
setup.undo_dm = false; setup.undo_dm = false;
setup.do_offline_fallocate = false;
log_info("Everything completed."); log_info("Everything completed.");
@ -1311,7 +1279,6 @@ int home_activate_luks(
int home_deactivate_luks(UserRecord *h) { int home_deactivate_luks(UserRecord *h) {
_cleanup_(crypt_freep) struct crypt_device *cd = NULL; _cleanup_(crypt_freep) struct crypt_device *cd = NULL;
_cleanup_free_ char *dm_name = NULL, *dm_node = NULL; _cleanup_free_ char *dm_name = NULL, *dm_node = NULL;
bool we_detached;
int r; int r;
/* Note that the DM device and loopback device are set to auto-detach, hence strictly speaking we /* Note that the DM device and loopback device are set to auto-detach, hence strictly speaking we
@ -1326,45 +1293,23 @@ int home_deactivate_luks(UserRecord *h) {
r = crypt_init_by_name(&cd, dm_name); r = crypt_init_by_name(&cd, dm_name);
if (IN_SET(r, -ENODEV, -EINVAL, -ENOENT)) { if (IN_SET(r, -ENODEV, -EINVAL, -ENOENT)) {
log_debug_errno(r, "LUKS device %s has already been detached.", dm_name); log_debug_errno(r, "LUKS device %s is already detached.", dm_name);
we_detached = false; return false;
} else if (r < 0) } else if (r < 0)
return log_error_errno(r, "Failed to initialize cryptsetup context for %s: %m", dm_name); return log_error_errno(r, "Failed to initialize cryptsetup context for %s: %m", dm_name);
else {
log_info("Discovered used LUKS device %s.", dm_node); log_info("Discovered used LUKS device %s.", dm_node);
crypt_set_log_callback(cd, cryptsetup_log_glue, NULL); crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
r = crypt_deactivate(cd, dm_name); r = crypt_deactivate(cd, dm_name);
if (IN_SET(r, -ENODEV, -EINVAL, -ENOENT)) { if (IN_SET(r, -ENODEV, -EINVAL, -ENOENT))
log_debug_errno(r, "LUKS device %s is already detached.", dm_node); log_debug_errno(r, "LUKS device %s is already detached.", dm_node);
we_detached = false; else if (r < 0)
} else if (r < 0)
return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", dm_node); return log_info_errno(r, "LUKS device %s couldn't be deactivated: %m", dm_node);
else {
log_info("LUKS device detaching completed."); log_info("LUKS device detaching completed.");
we_detached = true; return true;
}
}
if (user_record_luks_offline_discard(h))
log_debug("Not allocating on logout.");
else
(void) run_fallocate_by_path(user_record_image_path(h));
return we_detached;
}
int home_trim_luks(UserRecord *h) {
assert(h);
if (!user_record_luks_offline_discard(h)) {
log_debug("Not trimming on logout.");
return 0;
}
(void) run_fitrim_by_path(user_record_home_directory(h));
return 0;
} }
static int run_mkfs( static int run_mkfs(
@ -1973,9 +1918,7 @@ int home_create_luks(
if (asprintf(&disk_uuid_path, "/dev/disk/by-uuid/" SD_ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(luks_uuid)) < 0) if (asprintf(&disk_uuid_path, "/dev/disk/by-uuid/" SD_ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(luks_uuid)) < 0)
return log_oom(); return log_oom();
if (user_record_luks_discard(h) || user_record_luks_offline_discard(h)) { if (user_record_luks_discard(h)) {
/* If we want online or offline discard, discard once before we start using things. */
if (ioctl(image_fd, BLKDISCARD, (uint64_t[]) { 0, block_device_size }) < 0) if (ioctl(image_fd, BLKDISCARD, (uint64_t[]) { 0, block_device_size }) < 0)
log_full_errno(errno == EOPNOTSUPP ? LOG_DEBUG : LOG_WARNING, errno, log_full_errno(errno == EOPNOTSUPP ? LOG_DEBUG : LOG_WARNING, errno,
"Failed to issue full-device BLKDISCARD on device, ignoring: %m"); "Failed to issue full-device BLKDISCARD on device, ignoring: %m");
@ -2061,7 +2004,7 @@ int home_create_luks(
user_record_user_name_and_realm(h), user_record_user_name_and_realm(h),
pkcs11_decrypted_passwords, pkcs11_decrypted_passwords,
effective_passwords, effective_passwords,
user_record_luks_discard(h) || user_record_luks_offline_discard(h), user_record_luks_discard(h),
h, h,
&cd); &cd);
if (r < 0) if (r < 0)
@ -2141,12 +2084,6 @@ int home_create_luks(
goto fail; goto fail;
} }
if (user_record_luks_offline_discard(h)) {
r = run_fitrim(root_fd);
if (r < 0)
goto fail;
}
root_fd = safe_close(root_fd); root_fd = safe_close(root_fd);
r = umount_verbose("/run/systemd/user-home-mount"); r = umount_verbose("/run/systemd/user-home-mount");
@ -2165,12 +2102,6 @@ int home_create_luks(
loop = loop_device_unref(loop); loop = loop_device_unref(loop);
if (!user_record_luks_offline_discard(h)) {
r = run_fallocate(image_fd, NULL /* refresh stat() data */);
if (r < 0)
goto fail;
}
if (disk_uuid_path) if (disk_uuid_path)
(void) ioctl(image_fd, BLKRRPART, 0); (void) ioctl(image_fd, BLKRRPART, 0);

View File

@ -9,7 +9,6 @@ int home_prepare_luks(UserRecord *h, bool already_activated, const char *force_i
int home_activate_luks(UserRecord *h, char ***pkcs11_decrypted_passwords, UserRecord **ret_home); int home_activate_luks(UserRecord *h, char ***pkcs11_decrypted_passwords, UserRecord **ret_home);
int home_deactivate_luks(UserRecord *h); int home_deactivate_luks(UserRecord *h);
int home_trim_luks(UserRecord *h);
int home_store_header_identity_luks(UserRecord *h, HomeSetup *setup, UserRecord *old_home); int home_store_header_identity_luks(UserRecord *h, HomeSetup *setup, UserRecord *old_home);
@ -37,8 +36,3 @@ static inline uint64_t luks_volume_key_size_convert(struct crypt_device *cd) {
return (uint64_t) k; return (uint64_t) k;
} }
int run_fitrim(int root_fd);
int run_fitrim_by_path(const char *root_path);
int run_fallocate(int backing_fd, const struct stat *st);
int run_fallocate_by_path(const char *backing_path);

View File

@ -163,15 +163,7 @@ int home_setup_undo(HomeSetup *setup) {
assert(setup); assert(setup);
if (setup->root_fd >= 0) {
if (setup->do_offline_fitrim) {
q = run_fitrim(setup->root_fd);
if (q < 0)
r = q;
}
setup->root_fd = safe_close(setup->root_fd); setup->root_fd = safe_close(setup->root_fd);
}
if (setup->undo_mount) { if (setup->undo_mount) {
q = umount_verbose("/run/systemd/user-home-mount"); q = umount_verbose("/run/systemd/user-home-mount");
@ -185,20 +177,8 @@ int home_setup_undo(HomeSetup *setup) {
r = q; r = q;
} }
if (setup->image_fd >= 0) {
if (setup->do_offline_fallocate) {
q = run_fallocate(setup->image_fd, NULL);
if (q < 0)
r = q;
}
setup->image_fd = safe_close(setup->image_fd);
}
setup->undo_mount = false; setup->undo_mount = false;
setup->undo_dm = false; setup->undo_dm = false;
setup->do_offline_fitrim = false;
setup->do_offline_fallocate = false;
setup->dm_name = mfree(setup->dm_name); setup->dm_name = mfree(setup->dm_name);
setup->dm_node = mfree(setup->dm_node); setup->dm_node = mfree(setup->dm_node);
@ -686,12 +666,6 @@ static int home_deactivate(UserRecord *h, bool force) {
if (r < 0) if (r < 0)
return r; return r;
if (r == USER_TEST_MOUNTED) { if (r == USER_TEST_MOUNTED) {
if (user_record_storage(h) == USER_LUKS) {
r = home_trim_luks(h);
if (r < 0)
return r;
}
if (umount2(user_record_home_directory(h), UMOUNT_NOFOLLOW | (force ? MNT_FORCE|MNT_DETACH : 0)) < 0) if (umount2(user_record_home_directory(h), UMOUNT_NOFOLLOW | (force ? MNT_FORCE|MNT_DETACH : 0)) < 0)
return log_error_errno(errno, "Failed to unmount %s: %m", user_record_home_directory(h)); return log_error_errno(errno, "Failed to unmount %s: %m", user_record_home_directory(h));

View File

@ -17,7 +17,6 @@ typedef struct HomeSetup {
LoopDevice *loop; LoopDevice *loop;
struct crypt_device *crypt_device; struct crypt_device *crypt_device;
int root_fd; int root_fd;
int image_fd;
sd_id128_t found_partition_uuid; sd_id128_t found_partition_uuid;
sd_id128_t found_luks_uuid; sd_id128_t found_luks_uuid;
sd_id128_t found_fs_uuid; sd_id128_t found_fs_uuid;
@ -29,8 +28,6 @@ typedef struct HomeSetup {
bool undo_dm; bool undo_dm;
bool undo_mount; bool undo_mount;
bool do_offline_fitrim;
bool do_offline_fallocate;
uint64_t partition_offset; uint64_t partition_offset;
uint64_t partition_size; uint64_t partition_size;
@ -39,7 +36,6 @@ typedef struct HomeSetup {
#define HOME_SETUP_INIT \ #define HOME_SETUP_INIT \
{ \ { \
.root_fd = -1, \ .root_fd = -1, \
.image_fd = -1, \
.partition_offset = UINT64_MAX, \ .partition_offset = UINT64_MAX, \
.partition_size = UINT64_MAX, \ .partition_size = UINT64_MAX, \
} }

View File

@ -23,6 +23,12 @@
#define USER_RECORD_IS_HOMED INT_TO_PTR(1) #define USER_RECORD_IS_HOMED INT_TO_PTR(1)
#define USER_RECORD_IS_OTHER INT_TO_PTR(2) #define USER_RECORD_IS_OTHER INT_TO_PTR(2)
static const BusLocator home_mgr = {
.destination = "org.freedesktop.home1",
.path = "/org/freedesktop/home1",
.interface = "org.freedesktop.home1.Manager",
};
static int parse_argv( static int parse_argv(
pam_handle_t *handle, pam_handle_t *handle,
int argc, const char **argv, int argc, const char **argv,
@ -125,7 +131,7 @@ static int acquire_user_record(
if (r != PAM_SUCCESS) if (r != PAM_SUCCESS)
return r; return r;
r = bus_call_method(bus, bus_home_mgr, "GetUserRecordByName", &error, &reply, "s", username); r = bus_call_method(bus, &home_mgr, "GetUserRecordByName", &error, &reply, "s", username);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, SD_BUS_ERROR_SERVICE_UNKNOWN) || if (sd_bus_error_has_name(&error, SD_BUS_ERROR_SERVICE_UNKNOWN) ||
sd_bus_error_has_name(&error, SD_BUS_ERROR_NAME_HAS_NO_OWNER)) { sd_bus_error_has_name(&error, SD_BUS_ERROR_NAME_HAS_NO_OWNER)) {
@ -451,7 +457,7 @@ static int acquire_home(
} }
} }
r = bus_message_new_method_call(bus, &m, bus_home_mgr, do_auth ? "AcquireHome" : "RefHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, do_auth ? "AcquireHome" : "RefHome");
if (r < 0) if (r < 0)
return pam_bus_log_create_error(handle, r); return pam_bus_log_create_error(handle, r);
@ -660,7 +666,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
if (r != PAM_SUCCESS) if (r != PAM_SUCCESS)
return r; return r;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ReleaseHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ReleaseHome");
if (r < 0) if (r < 0)
return pam_bus_log_create_error(handle, r); return pam_bus_log_create_error(handle, r);
@ -886,7 +892,7 @@ _public_ PAM_EXTERN int pam_sm_chauthtok(
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome"); r = bus_message_new_method_call(bus, &m, &home_mgr, "ChangePasswordHome");
if (r < 0) if (r < 0)
return pam_bus_log_create_error(handle, r); return pam_bus_log_create_error(handle, r);

View File

@ -71,14 +71,14 @@ static sd_device_enumerator *device_enumerator_free(sd_device_enumerator *enumer
sd_device_unref(enumerator->devices[i]); sd_device_unref(enumerator->devices[i]);
free(enumerator->devices); free(enumerator->devices);
set_free(enumerator->match_subsystem); set_free_free(enumerator->match_subsystem);
set_free(enumerator->nomatch_subsystem); set_free_free(enumerator->nomatch_subsystem);
hashmap_free(enumerator->match_sysattr); hashmap_free_free_free(enumerator->match_sysattr);
hashmap_free(enumerator->nomatch_sysattr); hashmap_free_free_free(enumerator->nomatch_sysattr);
hashmap_free(enumerator->match_property); hashmap_free_free_free(enumerator->match_property);
set_free(enumerator->match_sysname); set_free_free(enumerator->match_sysname);
set_free(enumerator->match_tag); set_free_free(enumerator->match_tag);
set_free(enumerator->match_parent); set_free_free(enumerator->match_parent);
return mfree(enumerator); return mfree(enumerator);
} }
@ -97,49 +97,89 @@ _public_ int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enum
else else
set = &enumerator->nomatch_subsystem; set = &enumerator->nomatch_subsystem;
r = set_put_strdup(set, subsystem); r = set_ensure_allocated(set, NULL);
if (r <= 0) if (r < 0)
return r;
r = set_put_strdup(*set, subsystem);
if (r < 0)
return r; return r;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
_public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match) { _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *_sysattr, const char *_value, int match) {
_cleanup_free_ char *sysattr = NULL, *value = NULL;
Hashmap **hashmap; Hashmap **hashmap;
int r; int r;
assert_return(enumerator, -EINVAL); assert_return(enumerator, -EINVAL);
assert_return(sysattr, -EINVAL); assert_return(_sysattr, -EINVAL);
if (match) if (match)
hashmap = &enumerator->match_sysattr; hashmap = &enumerator->match_sysattr;
else else
hashmap = &enumerator->nomatch_sysattr; hashmap = &enumerator->nomatch_sysattr;
r = hashmap_put_strdup(hashmap, sysattr, value); r = hashmap_ensure_allocated(hashmap, NULL);
if (r <= 0) if (r < 0)
return r; return r;
sysattr = strdup(_sysattr);
if (!sysattr)
return -ENOMEM;
if (_value) {
value = strdup(_value);
if (!value)
return -ENOMEM;
}
r = hashmap_put(*hashmap, sysattr, value);
if (r < 0)
return r;
sysattr = NULL;
value = NULL;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
_public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value) { _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *_property, const char *_value) {
_cleanup_free_ char *property = NULL, *value = NULL;
int r; int r;
assert_return(enumerator, -EINVAL); assert_return(enumerator, -EINVAL);
assert_return(property, -EINVAL); assert_return(_property, -EINVAL);
r = hashmap_put_strdup(&enumerator->match_property, property, value); r = hashmap_ensure_allocated(&enumerator->match_property, NULL);
if (r <= 0) if (r < 0)
return r; return r;
property = strdup(_property);
if (!property)
return -ENOMEM;
if (_value) {
value = strdup(_value);
if (!value)
return -ENOMEM;
}
r = hashmap_put(enumerator->match_property, property, value);
if (r < 0)
return r;
property = NULL;
value = NULL;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
_public_ int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname) { _public_ int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname) {
@ -148,13 +188,17 @@ _public_ int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumer
assert_return(enumerator, -EINVAL); assert_return(enumerator, -EINVAL);
assert_return(sysname, -EINVAL); assert_return(sysname, -EINVAL);
r = set_put_strdup(&enumerator->match_sysname, sysname); r = set_ensure_allocated(&enumerator->match_sysname, NULL);
if (r <= 0) if (r < 0)
return r;
r = set_put_strdup(enumerator->match_sysname, sysname);
if (r < 0)
return r; return r;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
_public_ int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag) { _public_ int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag) {
@ -163,41 +207,52 @@ _public_ int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator
assert_return(enumerator, -EINVAL); assert_return(enumerator, -EINVAL);
assert_return(tag, -EINVAL); assert_return(tag, -EINVAL);
r = set_put_strdup(&enumerator->match_tag, tag); r = set_ensure_allocated(&enumerator->match_tag, NULL);
if (r <= 0) if (r < 0)
return r;
r = set_put_strdup(enumerator->match_tag, tag);
if (r < 0)
return r; return r;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
}
static void device_enumerator_clear_match_parent(sd_device_enumerator *enumerator) {
if (!enumerator)
return;
set_clear_free(enumerator->match_parent);
} }
int device_enumerator_add_match_parent_incremental(sd_device_enumerator *enumerator, sd_device *parent) { int device_enumerator_add_match_parent_incremental(sd_device_enumerator *enumerator, sd_device *parent) {
const char *path; const char *path;
int r; int r;
assert(enumerator); assert_return(enumerator, -EINVAL);
assert(parent); assert_return(parent, -EINVAL);
r = sd_device_get_syspath(parent, &path); r = sd_device_get_syspath(parent, &path);
if (r < 0) if (r < 0)
return r; return r;
r = set_put_strdup(&enumerator->match_parent, path); r = set_ensure_allocated(&enumerator->match_parent, NULL);
if (r <= 0) if (r < 0)
return r;
r = set_put_strdup(enumerator->match_parent, path);
if (r < 0)
return r; return r;
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
_public_ int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent) { _public_ int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent) {
assert_return(enumerator, -EINVAL); device_enumerator_clear_match_parent(enumerator);
assert_return(parent, -EINVAL);
set_clear(enumerator->match_parent);
return device_enumerator_add_match_parent_incremental(enumerator, parent); return device_enumerator_add_match_parent_incremental(enumerator, parent);
} }
@ -208,7 +263,7 @@ _public_ int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enum
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) { int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) {
@ -218,7 +273,7 @@ int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator)
enumerator->scan_uptodate = false; enumerator->scan_uptodate = false;
return 1; return 0;
} }
static int device_compare(sd_device * const *_a, sd_device * const *_b) { static int device_compare(sd_device * const *_a, sd_device * const *_b) {

View File

@ -68,9 +68,9 @@ static sd_device *device_free(sd_device *device) {
ordered_hashmap_free_free_free(device->properties); ordered_hashmap_free_free_free(device->properties);
ordered_hashmap_free_free_free(device->properties_db); ordered_hashmap_free_free_free(device->properties_db);
hashmap_free_free_free(device->sysattr_values); hashmap_free_free_free(device->sysattr_values);
set_free(device->sysattrs); set_free_free(device->sysattrs);
set_free(device->tags); set_free_free(device->tags);
set_free(device->devlinks); set_free_free(device->devlinks);
return mfree(device); return mfree(device);
} }
@ -1078,7 +1078,11 @@ int device_add_tag(sd_device *device, const char *tag) {
if (!is_valid_tag(tag)) if (!is_valid_tag(tag))
return -EINVAL; return -EINVAL;
r = set_put_strdup(&device->tags, tag); r = set_ensure_allocated(&device->tags, &string_hash_ops);
if (r < 0)
return r;
r = set_put_strdup(device->tags, tag);
if (r < 0) if (r < 0)
return r; return r;
@ -1094,7 +1098,11 @@ int device_add_devlink(sd_device *device, const char *devlink) {
assert(device); assert(device);
assert(devlink); assert(devlink);
r = set_put_strdup(&device->devlinks, devlink); r = set_ensure_allocated(&device->devlinks, &string_hash_ops);
if (r < 0)
return r;
r = set_put_strdup(device->devlinks, devlink);
if (r < 0) if (r < 0)
return r; return r;
@ -1583,6 +1591,10 @@ static int device_sysattrs_read_all(sd_device *device) {
if (!dir) if (!dir)
return -errno; return -errno;
r = set_ensure_allocated(&device->sysattrs, &string_hash_ops);
if (r < 0)
return r;
FOREACH_DIRENT_ALL(dent, dir, return -errno) { FOREACH_DIRENT_ALL(dent, dir, return -errno) {
_cleanup_free_ char *path = NULL; _cleanup_free_ char *path = NULL;
struct stat statbuf; struct stat statbuf;
@ -1601,7 +1613,7 @@ static int device_sysattrs_read_all(sd_device *device) {
if (!(statbuf.st_mode & S_IRUSR)) if (!(statbuf.st_mode & S_IRUSR))
continue; continue;
r = set_put_strdup(&device->sysattrs, dent->d_name); r = set_put_strdup(device->sysattrs, dent->d_name);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -163,7 +163,13 @@ static int set_locale(int argc, char **argv, void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_locale, "SetLocale"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.locale1",
"/org/freedesktop/locale1",
"org.freedesktop.locale1",
"SetLocale");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -209,9 +215,11 @@ static int set_vconsole_keymap(int argc, char **argv, void *userdata) {
map = argv[1]; map = argv[1];
toggle_map = argc > 2 ? argv[2] : ""; toggle_map = argc > 2 ? argv[2] : "";
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_locale, "org.freedesktop.locale1",
"/org/freedesktop/locale1",
"org.freedesktop.locale1",
"SetVConsoleKeyboard", "SetVConsoleKeyboard",
&error, &error,
NULL, NULL,
@ -250,9 +258,11 @@ static int set_x11_keymap(int argc, char **argv, void *userdata) {
variant = argc > 3 ? argv[3] : ""; variant = argc > 3 ? argv[3] : "";
options = argc > 4 ? argv[4] : ""; options = argc > 4 ? argv[4] : "";
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_locale, "org.freedesktop.locale1",
"/org/freedesktop/locale1",
"org.freedesktop.locale1",
"SetX11Keyboard", "SetX11Keyboard",
&error, &error,
NULL, NULL,

View File

@ -64,7 +64,14 @@ static int get_session_path(sd_bus *bus, const char *session_id, sd_bus_error *e
int r; int r;
char *ans; char *ans;
r = bus_call_method(bus, bus_login_mgr, "GetSession", error, &reply, "s", session_id); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"GetSession",
error, &reply,
"s", session_id);
if (r < 0) if (r < 0)
return r; return r;
@ -123,7 +130,14 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_login_mgr, "ListSessions", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ListSessions",
&error, &reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list sessions: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list sessions: %s", bus_error_message(&error, r));
@ -197,7 +211,14 @@ static int list_users(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_login_mgr, "ListUsers", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ListUsers",
&error, &reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list users: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list users: %s", bus_error_message(&error, r));
@ -247,7 +268,14 @@ static int list_seats(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_login_mgr, "ListSeats", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ListSeats",
&error, &reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list seats: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list seats: %s", bus_error_message(&error, r));
@ -933,7 +961,14 @@ static int show_seat(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message * reply = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message * reply = NULL;
const char *path = NULL; const char *path = NULL;
r = bus_call_method(bus, bus_login_mgr, "GetSeat", &error, &reply, "s", argv[i]); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"GetSeat",
&error, &reply,
"s", argv[i]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get seat: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get seat: %s", bus_error_message(&error, r));
@ -982,9 +1017,11 @@ static int activate(int argc, char *argv[], void *userdata) {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
streq(argv[0], "lock-session") ? "LockSession" : streq(argv[0], "lock-session") ? "LockSession" :
streq(argv[0], "unlock-session") ? "UnlockSession" : streq(argv[0], "unlock-session") ? "UnlockSession" :
streq(argv[0], "terminate-session") ? "TerminateSession" : streq(argv[0], "terminate-session") ? "TerminateSession" :
@ -1013,9 +1050,11 @@ static int kill_session(int argc, char *argv[], void *userdata) {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"KillSession", "KillSession",
&error, NULL, &error, NULL,
"ssi", argv[i], arg_kill_who, arg_signal); "ssi", argv[i], arg_kill_who, arg_signal);
@ -1062,9 +1101,11 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to look up user %s: %m", argv[i]); return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
} }
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"SetUserLinger", "SetUserLinger",
&error, NULL, &error, NULL,
"ubb", (uint32_t) uid, b, true); "ubb", (uint32_t) uid, b, true);
@ -1092,7 +1133,14 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to look up user %s: %m", argv[i]); return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
r = bus_call_method(bus, bus_login_mgr, "TerminateUser", &error, NULL, "u", (uint32_t) uid); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"TerminateUser",
&error, NULL,
"u", (uint32_t) uid);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not terminate user: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate user: %s", bus_error_message(&error, -r));
} }
@ -1120,9 +1168,11 @@ static int kill_user(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to look up user %s: %m", argv[i]); return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"KillUser", "KillUser",
&error, NULL, &error, NULL,
"ui", (uint32_t) uid, arg_signal); "ui", (uint32_t) uid, arg_signal);
@ -1145,12 +1195,15 @@ static int attach(int argc, char *argv[], void *userdata) {
for (i = 2; i < argc; i++) { for (i = 2; i < argc; i++) {
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"AttachDevice", "AttachDevice",
&error, NULL, &error, NULL,
"ssb", argv[1], argv[i], true); "ssb", argv[1], argv[i], true);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not attach device: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not attach device: %s", bus_error_message(&error, -r));
} }
@ -1168,7 +1221,14 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(bus, bus_login_mgr, "FlushDevices", &error, NULL, "b", true); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"FlushDevices",
&error, NULL,
"b", true);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not flush devices: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not flush devices: %s", bus_error_message(&error, -r));
@ -1185,9 +1245,11 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_login_mgr, "org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
streq(argv[0], "lock-sessions") ? "LockSessions" : "UnlockSessions", streq(argv[0], "lock-sessions") ? "LockSessions" : "UnlockSessions",
&error, NULL, &error, NULL,
NULL); NULL);
@ -1209,7 +1271,14 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
r = bus_call_method(bus, bus_login_mgr, "TerminateSeat", &error, NULL, "s", argv[i]); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"TerminateSeat",
&error, NULL,
"s", argv[i]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not terminate seat: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate seat: %s", bus_error_message(&error, -r));
} }

View File

@ -206,7 +206,7 @@ int devnode_acl_all(const char *seat,
continue; continue;
log_device_debug(d, "Found udev node %s for seat %s", node, seat); log_device_debug(d, "Found udev node %s for seat %s", node, seat);
r = set_put_strdup(&nodes, node); r = set_put_strdup(nodes, node);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -1625,9 +1625,11 @@ static int execute_shutdown_or_sleep(
if (w == INHIBIT_SHUTDOWN) if (w == INHIBIT_SHUTDOWN)
bus_manager_log_shutdown(m, unit_name); bus_manager_log_shutdown(m, unit_name);
r = bus_call_method( r = sd_bus_call_method(
m->bus, m->bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartUnit", "StartUnit",
error, error,
&reply, &reply,
@ -3979,7 +3981,13 @@ int manager_start_scope(
assert(pid > 1); assert(pid > 1);
assert(job); assert(job);
r = bus_message_new_method_call(manager->bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
manager->bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return r; return r;
@ -4066,9 +4074,11 @@ int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error,
assert(unit); assert(unit);
assert(job); assert(job);
r = bus_call_method( r = sd_bus_call_method(
manager->bus, manager->bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartUnit", "StartUnit",
error, error,
&reply, &reply,
@ -4087,9 +4097,11 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
assert(unit); assert(unit);
assert(job); assert(job);
r = bus_call_method( r = sd_bus_call_method(
manager->bus, manager->bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StopUnit", "StopUnit",
error, error,
&reply, &reply,
@ -4147,9 +4159,11 @@ int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo
assert(manager); assert(manager);
assert(unit); assert(unit);
return bus_call_method( return sd_bus_call_method(
manager->bus, manager->bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"KillUnit", "KillUnit",
error, error,
NULL, NULL,

View File

@ -11,7 +11,6 @@
#include "bus-error.h" #include "bus-error.h"
#include "bus-log-control-api.h" #include "bus-log-control-api.h"
#include "bus-polkit.h" #include "bus-polkit.h"
#include "bus-util.h"
#include "cgroup-util.h" #include "cgroup-util.h"
#include "def.h" #include "def.h"
#include "device-util.h" #include "device-util.h"
@ -633,11 +632,25 @@ static int manager_connect_bus(Manager *m) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "JobRemoved", match_job_removed, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"JobRemoved",
match_job_removed, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for JobRemoved: %m"); return log_error_errno(r, "Failed to request match for JobRemoved: %m");
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "UnitRemoved", match_unit_removed, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"UnitRemoved",
match_unit_removed, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for UnitRemoved: %m"); return log_error_errno(r, "Failed to request match for UnitRemoved: %m");
@ -652,11 +665,26 @@ static int manager_connect_bus(Manager *m) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for PropertiesChanged: %m"); return log_error_errno(r, "Failed to request match for PropertiesChanged: %m");
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "Reloading", match_reloading, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Reloading",
match_reloading, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for Reloading: %m"); return log_error_errno(r, "Failed to request match for Reloading: %m");
r = bus_call_method_async(m->bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL); r = sd_bus_call_method_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Subscribe",
NULL, NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to enable subscription: %m"); return log_error_errno(r, "Failed to enable subscription: %m");

View File

@ -789,7 +789,13 @@ _public_ PAM_EXTERN int pam_sm_open_session(
strna(memory_max), strna(tasks_max), strna(cpu_weight), strna(io_weight), strna(runtime_max_sec)); strna(memory_max), strna(tasks_max), strna(cpu_weight), strna(io_weight), strna(runtime_max_sec));
} }
r = bus_message_new_method_call(bus, &m, bus_login_mgr, "CreateSession"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"CreateSession");
if (r < 0) if (r < 0)
return pam_bus_log_create_error(handle, r); return pam_bus_log_create_error(handle, r);
@ -978,7 +984,15 @@ _public_ PAM_EXTERN int pam_sm_close_session(
if (r != PAM_SUCCESS) if (r != PAM_SUCCESS)
return r; return r;
r = bus_call_method(bus, bus_login_mgr, "ReleaseSession", &error, NULL, "s", id); r = sd_bus_call_method(bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ReleaseSession",
&error,
NULL,
"s",
id);
if (r < 0) { if (r < 0) {
pam_syslog(handle, LOG_ERR, "Failed to release session: %s", bus_error_message(&error, r)); pam_syslog(handle, LOG_ERR, "Failed to release session: %s", bus_error_message(&error, r));
return PAM_SESSION_ERR; return PAM_SESSION_ERR;

View File

@ -552,7 +552,14 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
getty = strjoina("container-getty@", p, ".service"); getty = strjoina("container-getty@", p, ".service");
r = bus_call_method(container_bus, bus_systemd_mgr, "StartUnit", error, NULL, "ss", getty, "replace"); r = sd_bus_call_method(
container_bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartUnit",
error, NULL,
"ss", getty, "replace");
if (r < 0) if (r < 0)
return r; return r;
@ -661,7 +668,13 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
container_bus = allocated_bus ?: m->manager->bus; container_bus = allocated_bus ?: m->manager->bus;
r = bus_message_new_method_call(container_bus, &tm, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
container_bus,
&tm,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return r; return r;

View File

@ -108,7 +108,14 @@ static int call_get_os_release(sd_bus *bus, const char *method, const char *name
awaited_args++; awaited_args++;
query_res = newa0(const char *, awaited_args); query_res = newa0(const char *, awaited_args);
r = bus_call_method(bus, bus_machine_mgr, method, &error, &reply, "s", name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
method,
&error,
&reply, "s", name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to call '%s()': %s", method, bus_error_message(&error, r)); return log_debug_errno(r, "Failed to call '%s()': %s", method, bus_error_message(&error, r));
@ -172,7 +179,14 @@ static int call_get_addresses(
assert(prefix); assert(prefix);
assert(prefix2); assert(prefix2);
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineAddresses",
NULL,
&reply,
"s", name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Could not get addresses: %s", bus_error_message(&error, r)); return log_debug_errno(r, "Could not get addresses: %s", bus_error_message(&error, r));
@ -269,7 +283,14 @@ static int list_machines(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"ListMachines",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not get machines: %s", bus_error_message(&error, r)); return log_error_errno(r, "Could not get machines: %s", bus_error_message(&error, r));
@ -348,7 +369,14 @@ static int list_images(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"ListImages",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not get images: %s", bus_error_message(&error, r)); return log_error_errno(r, "Could not get images: %s", bus_error_message(&error, r));
@ -465,7 +493,14 @@ static int print_uid_shift(sd_bus *bus, const char *name) {
assert(bus); assert(bus);
assert(name); assert(name);
r = bus_call_method(bus, bus_machine_mgr, "GetMachineUIDShift", &error, &reply, "s", name); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineUIDShift",
&error,
&reply,
"s", name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to query UID/GID shift: %s", bus_error_message(&error, r)); return log_debug_errno(r, "Failed to query UID/GID shift: %s", bus_error_message(&error, r));
@ -716,7 +751,14 @@ static int show_machine(int argc, char *argv[], void *userdata) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
const char *path = NULL; const char *path = NULL;
r = bus_call_method(bus, bus_machine_mgr, "GetMachine", &error, &reply, "s", argv[i]); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachine",
&error,
&reply,
"s", argv[i]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not get path to machine: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get path to machine: %s", bus_error_message(&error, -r));
@ -738,7 +780,13 @@ static int print_image_hostname(sd_bus *bus, const char *name) {
const char *hn; const char *hn;
int r; int r;
r = bus_call_method(bus, bus_machine_mgr, "GetImageHostname", NULL, &reply, "s", name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetImageHostname",
NULL, &reply, "s", name);
if (r < 0) if (r < 0)
return r; return r;
@ -759,7 +807,13 @@ static int print_image_machine_id(sd_bus *bus, const char *name) {
size_t size; size_t size;
int r; int r;
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineID", NULL, &reply, "s", name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetImageMachineID",
NULL, &reply, "s", name);
if (r < 0) if (r < 0)
return r; return r;
@ -780,7 +834,13 @@ static int print_image_machine_info(sd_bus *bus, const char *name) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r; int r;
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineInfo", NULL, &reply, "s", name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetImageMachineInfo",
NULL, &reply, "s", name);
if (r < 0) if (r < 0)
return r; return r;
@ -1033,7 +1093,15 @@ static int show_image(int argc, char *argv[], void *userdata) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
const char *path = NULL; const char *path = NULL;
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, &reply, "s", argv[i]); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetImage",
&error,
&reply,
"s", argv[i]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not get path to image: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get path to image: %s", bus_error_message(&error, -r));
@ -1063,9 +1131,11 @@ static int kill_machine(int argc, char *argv[], void *userdata) {
arg_kill_who = "all"; arg_kill_who = "all";
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_machine_mgr, "org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"KillMachine", "KillMachine",
&error, &error,
NULL, NULL,
@ -1101,7 +1171,15 @@ static int terminate_machine(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
r = bus_call_method(bus, bus_machine_mgr, "TerminateMachine", &error, NULL, "s", argv[i]); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"TerminateMachine",
&error,
NULL,
"s", argv[i]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not terminate machine: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate machine: %s", bus_error_message(&error, -r));
} }
@ -1135,10 +1213,12 @@ static int copy_files(int argc, char *argv[], void *userdata) {
host_path = abs_host_path; host_path = abs_host_path;
} }
r = bus_message_new_method_call( r = sd_bus_message_new_method_call(
bus, bus,
&m, &m,
bus_machine_mgr, "org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
copy_from ? "CopyFromMachine" : "CopyToMachine"); copy_from ? "CopyFromMachine" : "CopyToMachine");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1169,9 +1249,11 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_machine_mgr, "org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"BindMountMachine", "BindMountMachine",
&error, &error,
NULL, NULL,
@ -1343,7 +1425,15 @@ static int login_machine(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request machine removal match: %m"); return log_error_errno(r, "Failed to request machine removal match: %m");
r = bus_call_method(bus, bus_machine_mgr, "OpenMachineLogin", &error, &reply, "s", machine); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"OpenMachineLogin",
&error,
&reply,
"s", machine);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get login PTY: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to get login PTY: %s", bus_error_message(&error, -r));
@ -1408,7 +1498,13 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request machine removal match: %m"); return log_error_errno(r, "Failed to request machine removal match: %m");
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "OpenMachineShell"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"OpenMachineShell");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1449,7 +1545,13 @@ static int remove_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "RemoveImage"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"RemoveImage");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1475,9 +1577,11 @@ static int rename_image(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_machine_mgr, "org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"RenameImage", "RenameImage",
&error, &error,
NULL, NULL,
@ -1498,7 +1602,13 @@ static int clone_image(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CloneImage"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"CloneImage");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1531,7 +1641,15 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(bus, bus_machine_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MarkImageReadOnly",
&error,
NULL,
"sb", argv[1], b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, -r));
@ -1545,7 +1663,15 @@ static int image_exists(sd_bus *bus, const char *name) {
assert(bus); assert(bus);
assert(name); assert(name);
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, NULL, "s", name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetImage",
&error,
NULL,
"s", name);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_IMAGE)) if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_IMAGE))
return 0; return 0;
@ -1807,10 +1933,12 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to attach bus to event loop: %m"); return log_error_errno(r, "Failed to attach bus to event loop: %m");
r = bus_match_signal_async( r = sd_bus_match_signal_async(
bus, bus,
&slot_job_removed, &slot_job_removed,
bus_import_mgr, "org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"TransferRemoved", "TransferRemoved",
match_transfer_removed, NULL, &path); match_transfer_removed, NULL, &path);
if (r < 0) if (r < 0)
@ -1894,7 +2022,13 @@ static int import_tar(int argc, char *argv[], void *userdata) {
return log_error_errno(errno, "Failed to open %s: %m", path); return log_error_errno(errno, "Failed to open %s: %m", path);
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportTar"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ImportTar");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1955,7 +2089,13 @@ static int import_raw(int argc, char *argv[], void *userdata) {
return log_error_errno(errno, "Failed to open %s: %m", path); return log_error_errno(errno, "Failed to open %s: %m", path);
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportRaw"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ImportRaw");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2010,7 +2150,13 @@ static int import_fs(int argc, char *argv[], void *userdata) {
return log_error_errno(errno, "Failed to open directory '%s': %m", path); return log_error_errno(errno, "Failed to open directory '%s': %m", path);
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportFileSystem"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ImportFileSystem");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2069,7 +2215,13 @@ static int export_tar(int argc, char *argv[], void *userdata) {
return log_error_errno(errno, "Failed to open %s: %m", path); return log_error_errno(errno, "Failed to open %s: %m", path);
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportTar"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ExportTar");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2112,7 +2264,13 @@ static int export_raw(int argc, char *argv[], void *userdata) {
return log_error_errno(errno, "Failed to open %s: %m", path); return log_error_errno(errno, "Failed to open %s: %m", path);
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportRaw"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ExportRaw");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2168,7 +2326,13 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
} }
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullTar"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"PullTar");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2225,7 +2389,13 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
} }
} }
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullRaw"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"PullRaw");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2268,7 +2438,14 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_import_mgr, "ListTransfers", &error, &reply, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"ListTransfers",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not get transfers: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get transfers: %s", bus_error_message(&error, -r));
@ -2365,7 +2542,15 @@ static int cancel_transfer(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to parse transfer id: %s", argv[i]); return log_error_errno(r, "Failed to parse transfer id: %s", argv[i]);
r = bus_call_method(bus, bus_import_mgr, "CancelTransfer", &error, NULL, "u", id); r = sd_bus_call_method(
bus,
"org.freedesktop.import1",
"/org/freedesktop/import1",
"org.freedesktop.import1.Manager",
"CancelTransfer",
&error,
NULL,
"u", id);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not cancel transfer: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not cancel transfer: %s", bus_error_message(&error, -r));
} }
@ -2392,10 +2577,26 @@ static int set_limit(int argc, char *argv[], void *userdata) {
if (argc > 2) if (argc > 2)
/* With two arguments changes the quota limit of the /* With two arguments changes the quota limit of the
* specified image */ * specified image */
r = bus_call_method(bus, bus_machine_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"SetImageLimit",
&error,
NULL,
"st", argv[1], limit);
else else
/* With one argument changes the pool quota limit */ /* With one argument changes the pool quota limit */
r = bus_call_method(bus, bus_machine_mgr, "SetPoolLimit", &error, NULL, "t", limit); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"SetPoolLimit",
&error,
NULL,
"t", limit);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r)); return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r));
@ -2415,7 +2616,13 @@ static int clean_images(int argc, char *argv[], void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CleanPool"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"CleanPool");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);

View File

@ -1577,7 +1577,16 @@ int manager_unref_unit(
assert(m); assert(m);
assert(unit); assert(unit);
return bus_call_method(m->bus, bus_systemd_mgr, "UnrefUnit", error, NULL, "s", unit); return sd_bus_call_method(
m->bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"UnrefUnit",
error,
NULL,
"s",
unit);
} }
int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job) { int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job) {
@ -1587,7 +1596,15 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
assert(manager); assert(manager);
assert(unit); assert(unit);
r = bus_call_method(manager->bus, bus_systemd_mgr, "StopUnit", error, &reply, "ss", unit, "fail"); r = sd_bus_call_method(
manager->bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StopUnit",
error,
&reply,
"ss", unit, "fail");
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) || if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) ||
sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) { sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) {
@ -1624,7 +1641,15 @@ int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_erro
assert(manager); assert(manager);
assert(unit); assert(unit);
return bus_call_method(manager->bus, bus_systemd_mgr, "KillUnit", error, NULL, "ssi", unit, "all", signo); return sd_bus_call_method(
manager->bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"KillUnit",
error,
NULL,
"ssi", unit, "all", signo);
} }
int manager_unit_is_active(Manager *manager, const char *unit) { int manager_unit_is_active(Manager *manager, const char *unit) {

View File

@ -12,7 +12,6 @@
#include "bus-error.h" #include "bus-error.h"
#include "bus-log-control-api.h" #include "bus-log-control-api.h"
#include "bus-polkit.h" #include "bus-polkit.h"
#include "bus-util.h"
#include "cgroup-util.h" #include "cgroup-util.h"
#include "dirent-util.h" #include "dirent-util.h"
#include "fd-util.h" #include "fd-util.h"
@ -194,11 +193,25 @@ static int manager_connect_bus(Manager *m) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "JobRemoved", match_job_removed, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"JobRemoved",
match_job_removed, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to add match for JobRemoved: %m"); return log_error_errno(r, "Failed to add match for JobRemoved: %m");
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "UnitRemoved", match_unit_removed, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"UnitRemoved",
match_unit_removed, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for UnitRemoved: %m"); return log_error_errno(r, "Failed to request match for UnitRemoved: %m");
@ -213,11 +226,26 @@ static int manager_connect_bus(Manager *m) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for PropertiesChanged: %m"); return log_error_errno(r, "Failed to request match for PropertiesChanged: %m");
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "Reloading", match_reloading, NULL, m); r = sd_bus_match_signal_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Reloading",
match_reloading, NULL, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request match for Reloading: %m"); return log_error_errno(r, "Failed to request match for Reloading: %m");
r = bus_call_method_async(m->bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL); r = sd_bus_call_method_async(
m->bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Subscribe",
NULL, NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to enable subscription: %m"); return log_error_errno(r, "Failed to enable subscription: %m");

View File

@ -551,7 +551,13 @@ static int start_transient_mount(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to make mount unit name: %m"); return log_error_errno(r, "Failed to make mount unit name: %m");
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -632,7 +638,13 @@ static int start_transient_automount(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to make mount unit name: %m"); return log_error_errno(r, "Failed to make mount unit name: %m");
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -842,7 +854,13 @@ static int stop_mount(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to make %s unit name from path %s: %m", suffix + 1, where); return log_error_errno(r, "Failed to make %s unit name from path %s: %m", suffix + 1, where);
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StopUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StopUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);

View File

@ -2302,7 +2302,15 @@ static int link_renew_one(sd_bus *bus, int index, const char *name) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r; int r;
r = bus_call_method(bus, bus_network_mgr, "RenewLink", &error, NULL, "i", index); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"RenewLink",
&error,
NULL,
"i", index);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to renew dynamic configuration of interface %s: %s", return log_error_errno(r, "Failed to renew dynamic configuration of interface %s: %s",
name, bus_error_message(&error, r)); name, bus_error_message(&error, r));
@ -2336,7 +2344,15 @@ static int link_force_renew_one(sd_bus *bus, int index, const char *name) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r; int r;
r = bus_call_method(bus, bus_network_mgr, "ForceRenewLink", &error, NULL, "i", index); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"ForceRenewLink",
&error,
NULL,
"i", index);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to force renew dynamic configuration of interface %s: %s", return log_error_errno(r, "Failed to force renew dynamic configuration of interface %s: %s",
name, bus_error_message(&error, r)); name, bus_error_message(&error, r));
@ -2375,7 +2391,13 @@ static int verb_reload(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to connect system bus: %m"); return log_error_errno(r, "Failed to connect system bus: %m");
r = bus_call_method(bus, bus_network_mgr, "Reload", &error, NULL, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"Reload",
&error, NULL, NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to reload network settings: %m"); return log_error_errno(r, "Failed to reload network settings: %m");
@ -2411,7 +2433,13 @@ static int verb_reconfigure(int argc, char *argv[], void *userdata) {
SET_FOREACH(p, indexes, j) { SET_FOREACH(p, indexes, j) {
index = PTR_TO_INT(p); index = PTR_TO_INT(p);
r = bus_call_method(bus, bus_network_mgr, "ReconfigureLink", &error, NULL, "i", index); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"ReconfigureLink",
&error, NULL, "i", index);
if (r < 0) { if (r < 0) {
char ifname[IF_NAMESIZE + 1]; char ifname[IF_NAMESIZE + 1];

View File

@ -498,7 +498,7 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
return -ENOMEM; return -ENOMEM;
STRV_FOREACH(i, ntas) { STRV_FOREACH(i, ntas) {
r = set_put_strdup(&ns, *i); r = set_put_strdup(ns, *i);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -199,12 +199,16 @@ int create_subcgroup(pid_t pid, bool keep_unit, CGroupUnified unified_requested)
* namespace. * namespace.
*/ */
static int get_process_controllers(Set **ret) { static int get_process_controllers(Set **ret) {
_cleanup_set_free_ Set *controllers = NULL; _cleanup_set_free_free_ Set *controllers = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
int r; int r;
assert(ret); assert(ret);
controllers = set_new(&string_hash_ops);
if (!controllers)
return -ENOMEM;
f = fopen("/proc/self/cgroup", "re"); f = fopen("/proc/self/cgroup", "re");
if (!f) if (!f)
return errno == ENOENT ? -ESRCH : -errno; return errno == ENOENT ? -ESRCH : -errno;
@ -233,7 +237,7 @@ static int get_process_controllers(Set **ret) {
if (STR_IN_SET(l, "", "name=systemd", "name=unified")) if (STR_IN_SET(l, "", "name=systemd", "name=unified"))
continue; continue;
r = set_put_strdup(&controllers, l); r = set_put_strdup(controllers, l);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -299,7 +303,7 @@ static int mount_legacy_cgns_supported(
uid_t uid_range, uid_t uid_range,
const char *selinux_apifs_context) { const char *selinux_apifs_context) {
_cleanup_set_free_ Set *controllers = NULL; _cleanup_set_free_free_ Set *controllers = NULL;
const char *cgroup_root = "/sys/fs/cgroup", *c; const char *cgroup_root = "/sys/fs/cgroup", *c;
int r; int r;

View File

@ -122,9 +122,11 @@ int register_machine(
assert(bus); assert(bus);
if (keep_unit) { if (keep_unit) {
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_machine_mgr, "org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"RegisterMachineWithNetwork", "RegisterMachineWithNetwork",
&error, &error,
NULL, NULL,
@ -139,7 +141,13 @@ int register_machine(
} else { } else {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CreateMachineWithNetwork"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"CreateMachineWithNetwork");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -210,7 +218,16 @@ int unregister_machine(
assert(bus); assert(bus);
r = bus_call_method(bus, bus_machine_mgr, "UnregisterMachine", &error, NULL, "s", machine_name); r = sd_bus_call_method(
bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"UnregisterMachine",
&error,
NULL,
"s",
machine_name);
if (r < 0) if (r < 0)
log_debug("Failed to unregister machine: %s", bus_error_message(&error, r)); log_debug("Failed to unregister machine: %s", bus_error_message(&error, r));
@ -245,7 +262,13 @@ int allocate_scope(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to mangle scope name: %m"); return log_error_errno(r, "Failed to mangle scope name: %m");
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -331,15 +354,26 @@ int terminate_scope(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to mangle scope name: %m"); return log_error_errno(r, "Failed to mangle scope name: %m");
r = bus_call_method(bus, bus_systemd_mgr, "AbandonScope", &error, NULL, "s", scope); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"AbandonScope",
&error,
NULL,
"s",
scope);
if (r < 0) { if (r < 0) {
log_debug_errno(r, "Failed to abandon scope '%s', ignoring: %s", scope, bus_error_message(&error, r)); log_debug_errno(r, "Failed to abandon scope '%s', ignoring: %s", scope, bus_error_message(&error, r));
sd_bus_error_free(&error); sd_bus_error_free(&error);
} }
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"KillUnit", "KillUnit",
&error, &error,
NULL, NULL,
@ -352,7 +386,16 @@ int terminate_scope(
sd_bus_error_free(&error); sd_bus_error_free(&error);
} }
r = bus_call_method(bus, bus_systemd_mgr, "UnrefUnit", &error, NULL, "s", scope); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"UnrefUnit",
&error,
NULL,
"s",
scope);
if (r < 0) if (r < 0)
log_debug_errno(r, "Failed to drop reference to scope '%s', ignoring: %s", scope, bus_error_message(&error, r)); log_debug_errno(r, "Failed to drop reference to scope '%s', ignoring: %s", scope, bus_error_message(&error, r));

View File

@ -8,7 +8,6 @@
#include "alloc-util.h" #include "alloc-util.h"
#include "bus-common-errors.h" #include "bus-common-errors.h"
#include "bus-util.h"
#include "env-util.h" #include "env-util.h"
#include "errno-util.h" #include "errno-util.h"
#include "format-util.h" #include "format-util.h"
@ -129,7 +128,14 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineAddresses",
NULL,
&reply,
"s", name);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -281,7 +287,14 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineAddresses",
NULL,
&reply,
"s", name);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -451,7 +464,15 @@ enum nss_status _nss_mymachines_getpwnam_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "MapFromMachineUser", &error, &reply, "su", machine, (uint32_t) uid); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MapFromMachineUser",
&error,
&reply,
"su",
machine, (uint32_t) uid);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_USER_MAPPING)) if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_USER_MAPPING))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
@ -527,7 +548,15 @@ enum nss_status _nss_mymachines_getpwuid_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "MapToMachineUser", &error, &reply, "u", (uint32_t) uid); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MapToMachineUser",
&error,
&reply,
"u",
(uint32_t) uid);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_USER_MAPPING)) if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_USER_MAPPING))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
@ -618,7 +647,15 @@ enum nss_status _nss_mymachines_getgrnam_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "MapFromMachineGroup", &error, &reply, "su", machine, (uint32_t) gid); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MapFromMachineGroup",
&error,
&reply,
"su",
machine, (uint32_t) gid);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_GROUP_MAPPING)) if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_GROUP_MAPPING))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;
@ -691,7 +728,15 @@ enum nss_status _nss_mymachines_getgrgid_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_call_method(bus, bus_machine_mgr, "MapToMachineGroup", &error, &reply, "u", (uint32_t) gid); r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MapToMachineGroup",
&error,
&reply,
"u",
(uint32_t) gid);
if (r < 0) { if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_GROUP_MAPPING)) if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_GROUP_MAPPING))
return NSS_STATUS_NOTFOUND; return NSS_STATUS_NOTFOUND;

View File

@ -10,7 +10,6 @@
#include "sd-bus.h" #include "sd-bus.h"
#include "bus-common-errors.h" #include "bus-common-errors.h"
#include "bus-util.h"
#include "errno-util.h" #include "errno-util.h"
#include "in-addr-util.h" #include "in-addr-util.h"
#include "macro.h" #include "macro.h"
@ -143,7 +142,13 @@ enum nss_status _nss_resolve_gethostbyname4_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveHostname");
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -317,7 +322,13 @@ enum nss_status _nss_resolve_gethostbyname3_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveHostname");
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -503,7 +514,13 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
if (r < 0) if (r < 0)
goto fail; goto fail;
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveAddress"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveAddress");
if (r < 0) if (r < 0)
goto fail; goto fail;

View File

@ -1156,6 +1156,10 @@ int portable_detach(
return log_debug_errno(errno, "Failed to open '%s' directory: %m", where); return log_debug_errno(errno, "Failed to open '%s' directory: %m", where);
} }
unit_files = set_new(&string_hash_ops);
if (!unit_files)
return -ENOMEM;
markers = set_new(&path_hash_ops); markers = set_new(&path_hash_ops);
if (!markers) if (!markers)
return -ENOMEM; return -ENOMEM;
@ -1168,7 +1172,7 @@ int portable_detach(
continue; continue;
/* Filter out duplicates */ /* Filter out duplicates */
if (set_contains(unit_files, de->d_name)) if (set_get(unit_files, de->d_name))
continue; continue;
dirent_ensure_type(d, de); dirent_ensure_type(d, de);
@ -1193,7 +1197,7 @@ int portable_detach(
if (r > 0) if (r > 0)
return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit file '%s' is active, can't detach.", de->d_name); return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit file '%s' is active, can't detach.", de->d_name);
r = set_put_strdup(&unit_files, de->d_name); r = set_put_strdup(unit_files, de->d_name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name); return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name);
@ -1306,7 +1310,7 @@ static int portable_get_state_internal(
_cleanup_(lookup_paths_free) LookupPaths paths = {}; _cleanup_(lookup_paths_free) LookupPaths paths = {};
bool found_enabled = false, found_running = false; bool found_enabled = false, found_running = false;
_cleanup_set_free_ Set *unit_files = NULL; _cleanup_set_free_free_ Set *unit_files = NULL;
_cleanup_closedir_ DIR *d = NULL; _cleanup_closedir_ DIR *d = NULL;
const char *where; const char *where;
struct dirent *de; struct dirent *de;
@ -1332,6 +1336,10 @@ static int portable_get_state_internal(
return log_debug_errno(errno, "Failed to open '%s' directory: %m", where); return log_debug_errno(errno, "Failed to open '%s' directory: %m", where);
} }
unit_files = set_new(&string_hash_ops);
if (!unit_files)
return -ENOMEM;
FOREACH_DIRENT(de, d, return log_debug_errno(errno, "Failed to enumerate '%s' directory: %m", where)) { FOREACH_DIRENT(de, d, return log_debug_errno(errno, "Failed to enumerate '%s' directory: %m", where)) {
UnitFileState state; UnitFileState state;
@ -1339,7 +1347,7 @@ static int portable_get_state_internal(
continue; continue;
/* Filter out duplicates */ /* Filter out duplicates */
if (set_contains(unit_files, de->d_name)) if (set_get(unit_files, de->d_name))
continue; continue;
dirent_ensure_type(d, de); dirent_ensure_type(d, de);
@ -1364,7 +1372,7 @@ static int portable_get_state_internal(
if (r > 0) if (r > 0)
found_running = true; found_running = true;
r = set_put_strdup(&unit_files, de->d_name); r = set_put_strdup(unit_files, de->d_name);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name); return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name);
} }

View File

@ -239,7 +239,13 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "GetImageMetadata"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"GetImageMetadata");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -548,7 +554,13 @@ static int maybe_stop_disable(sd_bus *bus, char *image, char *argv[]) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not watch jobs: %m"); return log_error_errno(r, "Could not watch jobs: %m");
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "GetImageMetadata"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"GetImageMetadata");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -631,7 +643,13 @@ static int attach_image(int argc, char *argv[], void *userdata) {
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password); (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "AttachImage"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"AttachImage");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -679,7 +697,15 @@ static int detach_image(int argc, char *argv[], void *userdata) {
(void) maybe_stop_disable(bus, image, argv); (void) maybe_stop_disable(bus, image, argv);
r = bus_call_method(bus, bus_portable_mgr, "DetachImage", &error, &reply, "sb", image, arg_runtime); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"DetachImage",
&error,
&reply,
"sb", image, arg_runtime);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to detach image: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to detach image: %s", bus_error_message(&error, r));
@ -700,7 +726,15 @@ static int list_images(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_portable_mgr, "ListImages", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"ListImages",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list images: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list images: %s", bus_error_message(&error, r));
@ -777,7 +811,13 @@ static int remove_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "RemoveImage"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"RemoveImage");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -811,7 +851,15 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password); (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(bus, bus_portable_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"MarkImageReadOnly",
&error,
NULL,
"sb", argv[1], b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, r)); return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, r));
@ -840,10 +888,26 @@ static int set_limit(int argc, char *argv[], void *userdata) {
if (argc > 2) if (argc > 2)
/* With two arguments changes the quota limit of the specified image */ /* With two arguments changes the quota limit of the specified image */
r = bus_call_method(bus, bus_portable_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"SetImageLimit",
&error,
NULL,
"st", argv[1], limit);
else else
/* With one argument changes the pool quota limit */ /* With one argument changes the pool quota limit */
r = bus_call_method(bus, bus_portable_mgr, "SetPoolLimit", &error, NULL, "t", limit); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"SetPoolLimit",
&error,
NULL,
"t", limit);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r)); return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r));
@ -867,7 +931,15 @@ static int is_image_attached(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_portable_mgr, "GetImageState", &error, &reply, "s", image); r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"GetImageState",
&error,
&reply,
"s", image);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get image state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get image state: %s", bus_error_message(&error, r));
@ -892,7 +964,14 @@ static int dump_profiles(void) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_get_property_strv(bus, bus_portable_mgr, "Profiles", &error, &l); r = sd_bus_get_property_strv(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"Profiles",
&error,
&l);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to acquire list of profiles: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to acquire list of profiles: %s", bus_error_message(&error, r));

View File

@ -169,7 +169,13 @@ static int resolve_host(sd_bus *bus, const char *name) {
log_debug("Resolving %s (family %s, interface %s).", name, af_to_name(arg_family) ?: "*", isempty(arg_ifname) ? "*" : arg_ifname); log_debug("Resolving %s (family %s, interface %s).", name, af_to_name(arg_family) ?: "*", isempty(arg_ifname) ? "*" : arg_ifname);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveHostname");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -280,7 +286,13 @@ static int resolve_address(sd_bus *bus, int family, const union in_addr_union *a
log_debug("Resolving %s.", pretty); log_debug("Resolving %s.", pretty);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveAddress"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveAddress");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -409,7 +421,13 @@ static int resolve_record(sd_bus *bus, const char *name, uint16_t class, uint16_
log_debug("Resolving %s %s %s (interface %s).", name, dns_class_to_string(class), dns_type_to_string(type), isempty(arg_ifname) ? "*" : arg_ifname); log_debug("Resolving %s %s %s (interface %s).", name, dns_class_to_string(class), dns_type_to_string(type), isempty(arg_ifname) ? "*" : arg_ifname);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveRecord"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveRecord");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -671,7 +689,13 @@ static int resolve_service(sd_bus *bus, const char *name, const char *type, cons
else else
log_debug("Resolving service type %s (family %s, interface %s).", domain, af_to_name(arg_family) ?: "*", isempty(arg_ifname) ? "*" : arg_ifname); log_debug("Resolving service type %s (family %s, interface %s).", domain, af_to_name(arg_family) ?: "*", isempty(arg_ifname) ? "*" : arg_ifname);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveService"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResolveService");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -970,7 +994,14 @@ static int show_statistics(int argc, char **argv, void *userdata) {
assert(bus); assert(bus);
r = bus_get_property_trivial(bus, bus_resolve_mgr, "DNSSECSupported", &error, 'b', &dnssec_supported); r = sd_bus_get_property_trivial(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"DNSSECSupported",
&error,
'b',
&dnssec_supported);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get DNSSEC supported state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get DNSSEC supported state: %s", bus_error_message(&error, r));
@ -979,7 +1010,14 @@ static int show_statistics(int argc, char **argv, void *userdata) {
yes_no(dnssec_supported), yes_no(dnssec_supported),
ansi_normal()); ansi_normal());
r = bus_get_property(bus, bus_resolve_mgr, "TransactionStatistics", &error, &reply, "(tt)"); r = sd_bus_get_property(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"TransactionStatistics",
&error,
&reply,
"(tt)");
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get transaction statistics: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get transaction statistics: %s", bus_error_message(&error, r));
@ -991,7 +1029,14 @@ static int show_statistics(int argc, char **argv, void *userdata) {
reply = sd_bus_message_unref(reply); reply = sd_bus_message_unref(reply);
r = bus_get_property(bus, bus_resolve_mgr, "CacheStatistics", &error, &reply, "(ttt)"); r = sd_bus_get_property(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"CacheStatistics",
&error,
&reply,
"(ttt)");
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get cache statistics: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get cache statistics: %s", bus_error_message(&error, r));
@ -1004,7 +1049,14 @@ static int show_statistics(int argc, char **argv, void *userdata) {
reply = sd_bus_message_unref(reply); reply = sd_bus_message_unref(reply);
r = bus_get_property(bus, bus_resolve_mgr, "DNSSECStatistics", &error, &reply, "(tttt)"); r = sd_bus_get_property(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"DNSSECStatistics",
&error,
&reply,
"(tttt)");
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get DNSSEC statistics: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get DNSSEC statistics: %s", bus_error_message(&error, r));
@ -1072,7 +1124,14 @@ static int reset_statistics(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata; sd_bus *bus = userdata;
int r; int r;
r = bus_call_method(bus, bus_resolve_mgr, "ResetStatistics", &error, NULL, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResetStatistics",
&error,
NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to reset statistics: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to reset statistics: %s", bus_error_message(&error, r));
@ -1084,7 +1143,14 @@ static int flush_caches(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata; sd_bus *bus = userdata;
int r; int r;
r = bus_call_method(bus, bus_resolve_mgr, "FlushCaches", &error, NULL, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"FlushCaches",
&error,
NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to flush caches: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to flush caches: %s", bus_error_message(&error, r));
@ -1096,7 +1162,14 @@ static int reset_server_features(int argc, char **argv, void *userdata) {
sd_bus *bus = userdata; sd_bus *bus = userdata;
int r; int r;
r = bus_call_method(bus, bus_resolve_mgr, "ResetServerFeatures", &error, NULL, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"ResetServerFeatures",
&error,
NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to reset server features: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to reset server features: %s", bus_error_message(&error, r));
@ -1848,12 +1921,18 @@ static int verb_status(int argc, char **argv, void *userdata) {
return r; return r;
} }
static int call_dns(sd_bus *bus, char **dns, const BusLocator *locator, sd_bus_error *error) { static int call_dns(sd_bus *bus, char **dns, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL;
char **p; char **p;
int r; int r;
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDNS"); r = sd_bus_message_new_method_call(
bus,
&req,
destination,
path,
interface,
"SetLinkDNS");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1918,11 +1997,19 @@ static int verb_dns(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_DNS, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_DNS, NULL);
r = call_dns(bus, argv + 2, bus_resolve_mgr, &error); r = call_dns(bus, argv + 2,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
&error);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = call_dns(bus, argv + 2, bus_network_mgr, &error); r = call_dns(bus, argv + 2,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
&error);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -1935,12 +2022,18 @@ static int verb_dns(int argc, char **argv, void *userdata) {
return 0; return 0;
} }
static int call_domain(sd_bus *bus, char **domain, const BusLocator *locator, sd_bus_error *error) { static int call_domain(sd_bus *bus, char **domain, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL;
char **p; char **p;
int r; int r;
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDomains"); r = sd_bus_message_new_method_call(
bus,
&req,
destination,
path,
interface,
"SetLinkDomains");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1999,11 +2092,19 @@ static int verb_domain(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_DOMAIN, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_DOMAIN, NULL);
r = call_domain(bus, argv + 2, bus_resolve_mgr, &error); r = call_domain(bus, argv + 2,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
&error);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = call_domain(bus, argv + 2, bus_network_mgr, &error); r = call_domain(bus, argv + 2,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
&error);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -2039,11 +2140,27 @@ static int verb_default_route(int argc, char **argv, void *userdata) {
if (b < 0) if (b < 0)
return log_error_errno(b, "Failed to parse boolean argument: %s", argv[2]); return log_error_errno(b, "Failed to parse boolean argument: %s", argv[2]);
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDefaultRoute", &error, NULL, "ib", arg_ifindex, b); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"SetLinkDefaultRoute",
&error,
NULL,
"ib", arg_ifindex, b);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method(bus, bus_network_mgr, "SetLinkDefaultRoute", &error, NULL, "ib", arg_ifindex, b); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkDefaultRoute",
&error,
NULL,
"ib", arg_ifindex, b);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -2075,11 +2192,27 @@ static int verb_llmnr(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_LLMNR, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_LLMNR, NULL);
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkLLMNR", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"SetLinkLLMNR",
&error,
NULL,
"is", arg_ifindex, argv[2]);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method(bus, bus_network_mgr, "SetLinkLLMNR", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkLLMNR",
&error,
NULL,
"is", arg_ifindex, argv[2]);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -2111,13 +2244,23 @@ static int verb_mdns(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_MDNS, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_MDNS, NULL);
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkMulticastDNS", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"SetLinkMulticastDNS",
&error,
NULL,
"is", arg_ifindex, argv[2]);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_network_mgr, "org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkMulticastDNS", "SetLinkMulticastDNS",
&error, &error,
NULL, NULL,
@ -2153,13 +2296,23 @@ static int verb_dns_over_tls(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_PRIVATE, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_PRIVATE, NULL);
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDNSOverTLS", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"SetLinkDNSOverTLS",
&error,
NULL,
"is", arg_ifindex, argv[2]);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_network_mgr, "org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkDNSOverTLS", "SetLinkDNSOverTLS",
&error, &error,
NULL, NULL,
@ -2195,11 +2348,27 @@ static int verb_dnssec(int argc, char **argv, void *userdata) {
if (argc < 3) if (argc < 3)
return status_ifindex(bus, arg_ifindex, NULL, STATUS_DNSSEC, NULL); return status_ifindex(bus, arg_ifindex, NULL, STATUS_DNSSEC, NULL);
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDNSSEC", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"SetLinkDNSSEC",
&error,
NULL,
"is", arg_ifindex, argv[2]);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method(bus, bus_network_mgr, "SetLinkDNSSEC", &error, NULL, "is", arg_ifindex, argv[2]); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkDNSSEC",
&error,
NULL,
"is", arg_ifindex, argv[2]);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -2212,11 +2381,17 @@ static int verb_dnssec(int argc, char **argv, void *userdata) {
return 0; return 0;
} }
static int call_nta(sd_bus *bus, char **nta, const BusLocator *locator, sd_bus_error *error) { static int call_nta(sd_bus *bus, char **nta, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL;
int r; int r;
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDNSSECNegativeTrustAnchors"); r = sd_bus_message_new_method_call(
bus,
&req,
destination,
path,
interface,
"SetLinkDNSSECNegativeTrustAnchors");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2267,11 +2442,19 @@ static int verb_nta(int argc, char **argv, void *userdata) {
} }
} }
r = call_nta(bus, clear ? NULL : argv + 2, bus_resolve_mgr, &error); r = call_nta(bus, clear ? NULL : argv + 2,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
&error);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = call_nta(bus, clear ? NULL : argv + 2, bus_network_mgr, &error); r = call_nta(bus, clear ? NULL : argv + 2,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
&error);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&
@ -2300,11 +2483,27 @@ static int verb_revert_link(int argc, char **argv, void *userdata) {
if (arg_ifindex <= 0) if (arg_ifindex <= 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Interface argument required."); return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Interface argument required.");
r = bus_call_method(bus, bus_resolve_mgr, "RevertLink", &error, NULL, "i", arg_ifindex); r = sd_bus_call_method(
bus,
"org.freedesktop.resolve1",
"/org/freedesktop/resolve1",
"org.freedesktop.resolve1.Manager",
"RevertLink",
&error,
NULL,
"i", arg_ifindex);
if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) { if (r < 0 && sd_bus_error_has_name(&error, BUS_ERROR_LINK_BUSY)) {
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_call_method(bus, bus_network_mgr, "RevertLinkDNS", &error, NULL, "i", arg_ifindex); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"RevertLinkDNS",
&error,
NULL,
"i", arg_ifindex);
} }
if (r < 0) { if (r < 0) {
if (arg_ifindex_permissive && if (arg_ifindex_permissive &&

View File

@ -184,10 +184,11 @@ static int dns_trust_anchor_add_builtin_negative(DnsTrustAnchor *d) {
* unsigned. */ * unsigned. */
NULSTR_FOREACH(name, private_domains) { NULSTR_FOREACH(name, private_domains) {
if (dns_trust_anchor_knows_domain_positive(d, name)) if (dns_trust_anchor_knows_domain_positive(d, name))
continue; continue;
r = set_put_strdup(&d->negative_by_name, name); r = set_put_strdup(d->negative_by_name, name);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -629,7 +629,7 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Invalid negative trust anchor domain: %s", *i); "Invalid negative trust anchor domain: %s", *i);
r = set_put_strdup(&ns, *i); r = set_put_strdup(ns, *i);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -493,7 +493,7 @@ static int link_update_dnssec_negative_trust_anchors(Link *l) {
if (!ns) if (!ns)
return -ENOMEM; return -ENOMEM;
r = set_put_strdupv(&ns, ntas); r = set_put_strdupv(ns, ntas);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -1166,7 +1166,13 @@ static int start_transient_service(
return r; return r;
} }
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1414,7 +1420,13 @@ static int start_transient_scope(sd_bus *bus) {
return r; return r;
} }
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1598,7 +1610,13 @@ static int start_transient_trigger(
return log_error_errno(r, "Failed to change unit suffix: %m"); return log_error_errno(r, "Failed to change unit suffix: %m");
} }
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartTransientUnit");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);

View File

@ -1,63 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "bus-locator.h"
const BusLocator* const bus_home_mgr = &(BusLocator){
.destination = "org.freedesktop.home1",
.path = "/org/freedesktop/home1",
.interface = "org.freedesktop.home1.Manager",
};
const BusLocator* const bus_import_mgr = &(BusLocator){
.destination ="org.freedesktop.import1",
.path = "/org/freedesktop/import1",
.interface = "org.freedesktop.import1.Manager"
};
const BusLocator* const bus_locale = &(BusLocator){
.destination = "org.freedesktop.locale1",
.path = "/org/freedesktop/locale1",
.interface = "org.freedesktop.locale1"
};
const BusLocator* const bus_login_mgr = &(BusLocator){
.destination = "org.freedesktop.login1",
.path = "/org/freedesktop/login1",
.interface = "org.freedesktop.login1.Manager"
};
const BusLocator* const bus_machine_mgr = &(BusLocator){
.destination ="org.freedesktop.machine1",
.path = "/org/freedesktop/machine1",
.interface = "org.freedesktop.machine1.Manager"
};
const BusLocator* const bus_network_mgr = &(BusLocator){
.destination = "org.freedesktop.network1",
.path = "/org/freedesktop/network1",
.interface = "org.freedesktop.network1.Manager"
};
const BusLocator* const bus_portable_mgr = &(BusLocator){
.destination = "org.freedesktop.portable1",
.path = "/org/freedesktop/portable1",
.interface = "org.freedesktop.portable1.Manager"
};
const BusLocator* const bus_resolve_mgr = &(BusLocator){
.destination = "org.freedesktop.resolve1",
.path = "/org/freedesktop/resolve1",
.interface = "org.freedesktop.resolve1.Manager"
};
const BusLocator* const bus_systemd_mgr = &(BusLocator){
.destination = "org.freedesktop.systemd1",
.path = "/org/freedesktop/systemd1",
.interface = "org.freedesktop.systemd1.Manager"
};
const BusLocator* const bus_timedate = &(BusLocator){
.destination = "org.freedesktop.timedate1",
.path = "/org/freedesktop/timedate1",
.interface = "org.freedesktop.timedate1"
};

View File

@ -1,19 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
typedef struct BusLocator {
const char *destination;
const char *path;
const char *interface;
} BusLocator;
extern const BusLocator* const bus_home_mgr;
extern const BusLocator* const bus_import_mgr;
extern const BusLocator* const bus_locale;
extern const BusLocator* const bus_login_mgr;
extern const BusLocator* const bus_machine_mgr;
extern const BusLocator* const bus_network_mgr;
extern const BusLocator* const bus_portable_mgr;
extern const BusLocator* const bus_resolve_mgr;
extern const BusLocator* const bus_systemd_mgr;
extern const BusLocator* const bus_timedate;

View File

@ -1695,10 +1695,14 @@ int bus_introspect_implementations(
if (impl != main_impl) if (impl != main_impl)
bus_introspect_implementation(&intro, impl); bus_introspect_implementation(&intro, impl);
_cleanup_set_free_ Set *nodes = NULL; _cleanup_set_free_free_ Set *nodes = NULL;
for (size_t i = 0; impl->children && impl->children[i]; i++) { for (size_t i = 0; impl->children && impl->children[i]; i++) {
r = set_put_strdup(&nodes, impl->children[i]->path); r = set_ensure_allocated(&nodes, &string_hash_ops);
if (r < 0)
return log_oom();
r = set_put_strdup(nodes, impl->children[i]->path);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }

View File

@ -9,7 +9,6 @@
#include "sd-bus.h" #include "sd-bus.h"
#include "sd-event.h" #include "sd-event.h"
#include "bus-locator.h"
#include "macro.h" #include "macro.h"
#include "set.h" #include "set.h"
#include "string-util.h" #include "string-util.h"
@ -23,6 +22,12 @@ typedef enum BusTransport {
_BUS_TRANSPORT_INVALID = -1 _BUS_TRANSPORT_INVALID = -1
} BusTransport; } BusTransport;
typedef struct BusLocator {
const char *destination;
const char *path;
const char *interface;
} BusLocator;
typedef struct BusObjectImplementation BusObjectImplementation; typedef struct BusObjectImplementation BusObjectImplementation;
typedef struct BusObjectVtablePair { typedef struct BusObjectVtablePair {

View File

@ -65,7 +65,7 @@ void bus_wait_for_jobs_free(BusWaitForJobs *d) {
if (!d) if (!d)
return; return;
set_free(d->jobs); set_free_free(d->jobs);
sd_bus_slot_unref(d->slot_disconnected); sd_bus_slot_unref(d->slot_disconnected);
sd_bus_slot_unref(d->slot_job_removed); sd_bus_slot_unref(d->slot_job_removed);
@ -315,9 +315,15 @@ int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_ar
} }
int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) { int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path) {
int r;
assert(d); assert(d);
return set_put_strdup(&d->jobs, path); r = set_ensure_allocated(&d->jobs, &string_hash_ops);
if (r < 0)
return r;
return set_put_strdup(d->jobs, path);
} }
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet) { int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet) {

View File

@ -121,8 +121,8 @@ static int parse_fieldv(const void *data, size_t length, const ParseFieldVec *fi
return 0; return 0;
} }
static int field_set_test(const Set *fields, const char *name, size_t n) { static int field_set_test(Set *fields, const char *name, size_t n) {
char *s; char *s = NULL;
if (!fields) if (!fields)
return 1; return 1;
@ -369,7 +369,7 @@ static int output_short(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
int r; int r;
@ -533,7 +533,7 @@ static int output_verbose(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
const void *data; const void *data;
@ -652,7 +652,7 @@ static int output_export(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
sd_id128_t boot_id; sd_id128_t boot_id;
@ -849,7 +849,7 @@ static int update_json_data(
static int update_json_data_split( static int update_json_data_split(
Hashmap *h, Hashmap *h,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const void *data, const void *data,
size_t size) { size_t size) {
@ -870,7 +870,7 @@ static int update_json_data_split(
return 0; return 0;
name = strndupa(data, eq - (const char*) data); name = strndupa(data, eq - (const char*) data);
if (output_fields && !set_contains(output_fields, name)) if (output_fields && !set_get(output_fields, name))
return 0; return 0;
return update_json_data(h, flags, name, eq + 1, size - (eq - (const char*) data) - 1); return update_json_data(h, flags, name, eq + 1, size - (eq - (const char*) data) - 1);
@ -882,7 +882,7 @@ static int output_json(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
char sid[SD_ID128_STRING_MAX], usecbuf[DECIMAL_STR_MAX(usec_t)]; char sid[SD_ID128_STRING_MAX], usecbuf[DECIMAL_STR_MAX(usec_t)];
@ -1073,7 +1073,7 @@ static int output_cat(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
const char *field; const char *field;
@ -1103,7 +1103,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
OutputMode mode, OutputMode mode,
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
const Set *output_fields, Set *output_fields,
const size_t highlight[2]) = { const size_t highlight[2]) = {
[OUTPUT_SHORT] = output_short, [OUTPUT_SHORT] = output_short,
@ -1133,25 +1133,30 @@ int show_journal_entry(
const size_t highlight[2], const size_t highlight[2],
bool *ellipsized) { bool *ellipsized) {
_cleanup_set_free_ Set *fields = NULL; int ret;
int r; _cleanup_set_free_free_ Set *fields = NULL;
assert(mode >= 0); assert(mode >= 0);
assert(mode < _OUTPUT_MODE_MAX); assert(mode < _OUTPUT_MODE_MAX);
if (n_columns <= 0) if (n_columns <= 0)
n_columns = columns(); n_columns = columns();
r = set_put_strdupv(&fields, output_fields); if (output_fields) {
if (r < 0) fields = set_new(&string_hash_ops);
return r; if (!fields)
return log_oom();
r = output_funcs[mode](f, j, mode, n_columns, flags, fields, highlight); ret = set_put_strdupv(fields, output_fields);
if (ret < 0)
return ret;
}
if (ellipsized && r > 0) ret = output_funcs[mode](f, j, mode, n_columns, flags, fields, highlight);
if (ellipsized && ret > 0)
*ellipsized = true; *ellipsized = true;
return r; return ret;
} }
static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) { static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) {

View File

@ -25,8 +25,6 @@ shared_sources = files('''
bpf-program.h bpf-program.h
bridge-util.c bridge-util.c
bridge-util.h bridge-util.h
bus-locator.c
bus-locator.h
bus-log-control-api.c bus-log-control-api.c
bus-log-control-api.h bus-log-control-api.h
bus-polkit.c bus-polkit.c

View File

@ -239,7 +239,7 @@ int bind_remount_recursive_with_mountinfo(
} }
if (!set_contains(done, path)) { if (!set_contains(done, path)) {
r = set_put_strdup(&todo, path); r = set_put_strdup(todo, path);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -266,7 +266,7 @@ int bind_remount_recursive_with_mountinfo(
log_debug("Made top-level directory %s a mount point.", prefix); log_debug("Made top-level directory %s a mount point.", prefix);
r = set_put_strdup(&done, simplified); r = set_put_strdup(done, simplified);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -160,17 +160,6 @@ int specifier_host_name(char specifier, const void *data, const void *userdata,
return 0; return 0;
} }
int specifier_short_host_name(char specifier, const void *data, const void *userdata, char **ret) {
char *n;
n = gethostname_short_malloc();
if (!n)
return -ENOMEM;
*ret = n;
return 0;
}
int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret) { int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret) {
struct utsname uts; struct utsname uts;
char *n; char *n;

View File

@ -18,7 +18,6 @@ int specifier_string(char specifier, const void *data, const void *userdata, cha
int specifier_machine_id(char specifier, const void *data, const void *userdata, char **ret); int specifier_machine_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_boot_id(char specifier, const void *data, const void *userdata, char **ret); int specifier_boot_id(char specifier, const void *data, const void *userdata, char **ret);
int specifier_host_name(char specifier, const void *data, const void *userdata, char **ret); int specifier_host_name(char specifier, const void *data, const void *userdata, char **ret);
int specifier_short_host_name(char specifier, const void *data, const void *userdata, char **ret);
int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret); int specifier_kernel_release(char specifier, const void *data, const void *userdata, char **ret);
int specifier_architecture(char specifier, const void *data, const void *userdata, char **ret); int specifier_architecture(char specifier, const void *data, const void *userdata, char **ret);
int specifier_os_id(char specifier, const void *data, const void *userdata, char **ret); int specifier_os_id(char specifier, const void *data, const void *userdata, char **ret);

View File

@ -463,7 +463,7 @@ int unit_file_find_fragment(
/* The unit always has its own name if it's not a template. */ /* The unit always has its own name if it's not a template. */
if (IN_SET(name_type, UNIT_NAME_PLAIN, UNIT_NAME_INSTANCE)) { if (IN_SET(name_type, UNIT_NAME_PLAIN, UNIT_NAME_INSTANCE)) {
r = set_put_strdup(&names, unit_name); r = set_put_strdup(names, unit_name);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -493,7 +493,7 @@ int unit_file_find_fragment(
if (!streq(unit_name, *t)) if (!streq(unit_name, *t))
log_debug("%s: %s has alias %s", __func__, unit_name, *t); log_debug("%s: %s has alias %s", __func__, unit_name, *t);
r = set_put_strdup(&names, *t); r = set_put_strdup(names, *t);
} }
if (r < 0) if (r < 0)
return r; return r;

View File

@ -279,7 +279,7 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
printf(" Access Mode: 0%03oo\n", user_record_access_mode(hr)); printf(" Access Mode: 0%03oo\n", user_record_access_mode(hr));
if (storage == USER_LUKS) { if (storage == USER_LUKS) {
printf("LUKS Discard: online=%s offline=%s\n", yes_no(user_record_luks_discard(hr)), yes_no(user_record_luks_offline_discard(hr))); printf("LUKS Discard: %s\n", yes_no(user_record_luks_discard(hr)));
if (!sd_id128_is_null(hr->luks_uuid)) if (!sd_id128_is_null(hr->luks_uuid))
printf(" LUKS UUID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(hr->luks_uuid)); printf(" LUKS UUID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(hr->luks_uuid));

View File

@ -52,7 +52,6 @@ UserRecord* user_record_new(void) {
.nodev = true, .nodev = true,
.nosuid = true, .nosuid = true,
.luks_discard = -1, .luks_discard = -1,
.luks_offline_discard = -1,
.luks_volume_key_size = UINT64_MAX, .luks_volume_key_size = UINT64_MAX,
.luks_pbkdf_time_cost_usec = UINT64_MAX, .luks_pbkdf_time_cost_usec = UINT64_MAX,
.luks_pbkdf_memory_cost = UINT64_MAX, .luks_pbkdf_memory_cost = UINT64_MAX,
@ -945,7 +944,6 @@ static int dispatch_per_machine(const char *name, JsonVariant *variant, JsonDisp
{ "luksUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, luks_uuid), 0 }, { "luksUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, luks_uuid), 0 },
{ "fileSystemUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, file_system_uuid), 0 }, { "fileSystemUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, file_system_uuid), 0 },
{ "luksDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_discard), 0, }, { "luksDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_discard), 0, },
{ "luksOfflineDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_offline_discard), 0, },
{ "luksCipher", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher), JSON_SAFE }, { "luksCipher", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher), JSON_SAFE },
{ "luksCipherMode", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher_mode), JSON_SAFE }, { "luksCipherMode", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher_mode), JSON_SAFE },
{ "luksVolumeKeySize", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(UserRecord, luks_volume_key_size), 0 }, { "luksVolumeKeySize", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(UserRecord, luks_volume_key_size), 0 },
@ -1278,7 +1276,6 @@ int user_record_load(UserRecord *h, JsonVariant *v, UserRecordLoadFlags load_fla
{ "luksUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, luks_uuid), 0 }, { "luksUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, luks_uuid), 0 },
{ "fileSystemUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, file_system_uuid), 0 }, { "fileSystemUuid", JSON_VARIANT_STRING, json_dispatch_id128, offsetof(UserRecord, file_system_uuid), 0 },
{ "luksDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_discard), 0 }, { "luksDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_discard), 0 },
{ "luksOfflineDiscard", _JSON_VARIANT_TYPE_INVALID, json_dispatch_tristate, offsetof(UserRecord, luks_offline_discard), 0 },
{ "luksCipher", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher), JSON_SAFE }, { "luksCipher", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher), JSON_SAFE },
{ "luksCipherMode", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher_mode), JSON_SAFE }, { "luksCipherMode", JSON_VARIANT_STRING, json_dispatch_string, offsetof(UserRecord, luks_cipher_mode), JSON_SAFE },
{ "luksVolumeKeySize", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(UserRecord, luks_volume_key_size), 0 }, { "luksVolumeKeySize", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, offsetof(UserRecord, luks_volume_key_size), 0 },
@ -1503,27 +1500,6 @@ bool user_record_luks_discard(UserRecord *h) {
return path_startswith(ip, "/dev/"); return path_startswith(ip, "/dev/");
} }
bool user_record_luks_offline_discard(UserRecord *h) {
const char *ip;
assert(h);
if (h->luks_offline_discard >= 0)
return h->luks_offline_discard;
/* Discard while we are logged out should generally be a good idea, except when operating directly on
* physical media, where we should just bind it to the online discard mode. */
ip = user_record_image_path(h);
if (!ip)
return false;
if (path_startswith(ip, "/dev/"))
return user_record_luks_discard(h);
return true;
}
const char *user_record_luks_cipher(UserRecord *h) { const char *user_record_luks_cipher(UserRecord *h) {
assert(h); assert(h);

View File

@ -261,7 +261,6 @@ typedef struct UserRecord {
sd_id128_t file_system_uuid; sd_id128_t file_system_uuid;
int luks_discard; int luks_discard;
int luks_offline_discard;
char *luks_cipher; char *luks_cipher;
char *luks_cipher_mode; char *luks_cipher_mode;
uint64_t luks_volume_key_size; uint64_t luks_volume_key_size;
@ -333,7 +332,6 @@ const char *user_record_cifs_user_name(UserRecord *h);
const char *user_record_shell(UserRecord *h); const char *user_record_shell(UserRecord *h);
const char *user_record_real_name(UserRecord *h); const char *user_record_real_name(UserRecord *h);
bool user_record_luks_discard(UserRecord *h); bool user_record_luks_discard(UserRecord *h);
bool user_record_luks_offline_discard(UserRecord *h);
const char *user_record_luks_cipher(UserRecord *h); const char *user_record_luks_cipher(UserRecord *h);
const char *user_record_luks_cipher_mode(UserRecord *h); const char *user_record_luks_cipher_mode(UserRecord *h);
uint64_t user_record_luks_volume_key_size(UserRecord *h); uint64_t user_record_luks_volume_key_size(UserRecord *h);

View File

@ -547,7 +547,13 @@ static int get_unit_list(
assert(unit_infos); assert(unit_infos);
assert(_reply); assert(_reply);
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitsByPatterns"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnitsByPatterns");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -568,7 +574,13 @@ static int get_unit_list(
m = sd_bus_message_unref(m); m = sd_bus_message_unref(m);
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitsFiltered"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnitsFiltered");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1608,7 +1620,13 @@ static int list_unit_files(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitFilesByPatterns"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnitFilesByPatterns");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -1640,7 +1658,13 @@ static int list_unit_files(int argc, char *argv[], void *userdata) {
m = sd_bus_message_unref(m); m = sd_bus_message_unref(m);
sd_bus_error_free(&error); sd_bus_error_free(&error);
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitFiles"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListUnitFiles");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -2154,7 +2178,15 @@ static int determine_default(char **ret_name) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "GetDefaultTarget", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetDefaultTarget",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get default target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get default target: %s", bus_error_message(&error, r));
@ -2213,7 +2245,15 @@ static int set_default(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "SetDefaultTarget", &error, &reply, "sb", unit, 1); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetDefaultTarget",
&error,
&reply,
"sb", unit, 1);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set default target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set default target: %s", bus_error_message(&error, r));
@ -2256,7 +2296,15 @@ static int output_waiting_jobs(sd_bus *bus, Table *table, uint32_t id, const cha
assert(bus); assert(bus);
r = bus_call_method(bus, bus_systemd_mgr, method, &error, &reply, "u", id); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method,
&error,
&reply,
"u", id);
if (r < 0) if (r < 0)
return log_debug_errno(r, "Failed to get waiting jobs for job %" PRIu32, id); return log_debug_errno(r, "Failed to get waiting jobs for job %" PRIu32, id);
@ -2381,7 +2429,15 @@ static int list_jobs(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "ListJobs", &error, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ListJobs",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to list jobs: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to list jobs: %s", bus_error_message(&error, r));
@ -2437,7 +2493,15 @@ static int cancel_job(int argc, char *argv[], void *userdata) {
if (q < 0) if (q < 0)
return log_error_errno(q, "Failed to parse job id \"%s\": %m", *name); return log_error_errno(q, "Failed to parse job id \"%s\": %m", *name);
q = bus_call_method(bus, bus_systemd_mgr, "CancelJob", &error, NULL, "u", id); q = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"CancelJob",
&error,
NULL,
"u", id);
if (q < 0) { if (q < 0) {
log_error_errno(q, "Failed to cancel job %"PRIu32": %s", id, bus_error_message(&error, q)); log_error_errno(q, "Failed to cancel job %"PRIu32": %s", id, bus_error_message(&error, q));
if (r == 0) if (r == 0)
@ -2459,7 +2523,15 @@ static int need_daemon_reload(sd_bus *bus, const char *unit) {
/* We don't use unit_dbus_path_from_name() directly since we /* We don't use unit_dbus_path_from_name() directly since we
* don't want to load the unit if it isn't loaded. */ * don't want to load the unit if it isn't loaded. */
r = bus_call_method(bus, bus_systemd_mgr, "GetUnit", NULL, &reply, "s", unit); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnit",
NULL,
&reply,
"s", unit);
if (r < 0) if (r < 0)
return r; return r;
@ -2883,9 +2955,11 @@ static int start_unit_one(
_cleanup_(sd_bus_error_free) sd_bus_error enqueue_error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error enqueue_error = SD_BUS_ERROR_NULL;
/* Use the new, fancy EnqueueUnitJob() API if the user wants us to print the transaction */ /* Use the new, fancy EnqueueUnitJob() API if the user wants us to print the transaction */
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"EnqueueUnitJob", "EnqueueUnitJob",
&enqueue_error, &enqueue_error,
&reply, &reply,
@ -2931,7 +3005,15 @@ static int start_unit_one(
} }
if (!done) { if (!done) {
r = bus_call_method(bus, bus_systemd_mgr, method, error, &reply, "ss", name, mode); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method,
error,
&reply,
"ss", name, mode);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -3120,7 +3202,15 @@ static int start_unit(int argc, char *argv[], void *userdata) {
} }
if (arg_wait) { if (arg_wait) {
r = bus_call_method_async(bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL); r = sd_bus_call_method_async(
bus,
NULL,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Subscribe",
NULL, NULL,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to enable subscription: %m"); return log_error_errno(r, "Failed to enable subscription: %m");
@ -3187,7 +3277,18 @@ static int logind_set_wall_message(void) {
if (arg_dry_run) if (arg_dry_run)
return 0; return 0;
r = bus_call_method(bus, bus_login_mgr, "SetWallMessage", &error, NULL, "sb", m, !arg_no_wall); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"SetWallMessage",
&error,
NULL,
"sb",
m,
!arg_no_wall);
if (r < 0) if (r < 0)
return log_warning_errno(r, "Failed to set wall message, ignoring: %s", bus_error_message(&error, r)); return log_warning_errno(r, "Failed to set wall message, ignoring: %s", bus_error_message(&error, r));
return 0; return 0;
@ -3229,7 +3330,15 @@ static int logind_reboot(enum action a) {
if (arg_dry_run) if (arg_dry_run)
return 0; return 0;
r = bus_call_method(bus, bus_login_mgr, actions[a].method, &error, NULL, "b", arg_ask_password); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
actions[a].method,
&error,
NULL,
"b", arg_ask_password);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to %s via logind: %s", actions[a].description, bus_error_message(&error, r)); return log_error_errno(r, "Failed to %s via logind: %s", actions[a].description, bus_error_message(&error, r));
@ -3269,7 +3378,15 @@ static int logind_check_inhibitors(enum action a) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_login_mgr, "ListInhibitors", NULL, &reply, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ListInhibitors",
NULL,
&reply,
NULL);
if (r < 0) if (r < 0)
/* If logind is not around, then there are no inhibitors... */ /* If logind is not around, then there are no inhibitors... */
return 0; return 0;
@ -3364,7 +3481,15 @@ static int prepare_firmware_setup(void) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_login_mgr, "SetRebootToFirmwareSetup", &error, NULL, "b", true); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"SetRebootToFirmwareSetup",
&error,
NULL,
"b", true);
if (r < 0) if (r < 0)
return log_error_errno(r, "Cannot indicate to EFI to boot into setup mode: %s", bus_error_message(&error, r)); return log_error_errno(r, "Cannot indicate to EFI to boot into setup mode: %s", bus_error_message(&error, r));
@ -3389,7 +3514,15 @@ static int prepare_boot_loader_menu(void) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_login_mgr, "SetRebootToBootLoaderMenu", &error, NULL, "t", arg_boot_loader_menu); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"SetRebootToBootLoaderMenu",
&error,
NULL,
"t", arg_boot_loader_menu);
if (r < 0) if (r < 0)
return log_error_errno(r, "Cannot indicate to boot loader to enter boot loader entry menu: %s", bus_error_message(&error, r)); return log_error_errno(r, "Cannot indicate to boot loader to enter boot loader entry menu: %s", bus_error_message(&error, r));
@ -3414,7 +3547,15 @@ static int prepare_boot_loader_entry(void) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_login_mgr, "SetRebootToBootLoaderEntry", &error, NULL, "s", arg_boot_loader_entry); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"SetRebootToBootLoaderEntry",
&error,
NULL,
"s", arg_boot_loader_entry);
if (r < 0) if (r < 0)
return log_error_errno(r, "Cannot set boot into loader entry '%s': %s", arg_boot_loader_entry, bus_error_message(&error, r)); return log_error_errno(r, "Cannot set boot into loader entry '%s': %s", arg_boot_loader_entry, bus_error_message(&error, r));
@ -3517,7 +3658,15 @@ static int set_exit_code(uint8_t code) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "SetExitCode", &error, NULL, "y", code); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetExitCode",
&error,
NULL,
"y", code);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set exit code: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set exit code: %s", bus_error_message(&error, r));
@ -3722,9 +3871,11 @@ static int kill_unit(int argc, char *argv[], void *userdata) {
STRV_FOREACH(name, names) { STRV_FOREACH(name, names) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
q = bus_call_method( q = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"KillUnit", "KillUnit",
&error, &error,
NULL, NULL,
@ -3782,7 +3933,15 @@ static int clean_or_freeze_unit(int argc, char *argv[], void *userdata) {
if (w) { if (w) {
/* If we shall wait for the cleaning to complete, let's add a ref on the unit first */ /* If we shall wait for the cleaning to complete, let's add a ref on the unit first */
r = bus_call_method(bus, bus_systemd_mgr, "RefUnit", &error, NULL, "s", *name); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"RefUnit",
&error,
NULL,
"s", *name);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to add reference to unit %s: %s", *name, bus_error_message(&error, r)); log_error_errno(r, "Failed to add reference to unit %s: %s", *name, bus_error_message(&error, r));
if (ret == EXIT_SUCCESS) if (ret == EXIT_SUCCESS)
@ -3791,7 +3950,13 @@ static int clean_or_freeze_unit(int argc, char *argv[], void *userdata) {
} }
} }
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method);
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -5629,7 +5794,15 @@ static int get_unit_dbus_path_by_pid(
char *u; char *u;
int r; int r;
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitByPID", &error, &reply, "u", pid); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnitByPID",
&error,
&reply,
"u", pid);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get unit for PID %"PRIu32": %s", pid, bus_error_message(&error, r)); return log_error_errno(r, "Failed to get unit for PID %"PRIu32": %s", pid, bus_error_message(&error, r));
@ -5958,7 +6131,13 @@ static int set_property(int argc, char *argv[], void *userdata) {
polkit_agent_open_maybe(); polkit_agent_open_maybe();
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetUnitProperties"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetUnitProperties");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -6025,7 +6204,13 @@ static int daemon_reload(int argc, char *argv[], void *userdata) {
assert_not_reached("Unexpected action"); assert_not_reached("Unexpected action");
} }
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method);
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -6073,7 +6258,15 @@ static int trivial_method(int argc, char *argv[], void *userdata) {
streq(argv[0], "exit") ? "Exit" : streq(argv[0], "exit") ? "Exit" :
/* poweroff */ "PowerOff"; /* poweroff */ "PowerOff";
r = bus_call_method(bus, bus_systemd_mgr, method, &error, NULL, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method,
&error,
NULL,
NULL);
if (r < 0 && arg_action == ACTION_SYSTEMCTL) if (r < 0 && arg_action == ACTION_SYSTEMCTL)
return log_error_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r));
@ -6105,7 +6298,15 @@ static int reset_failed(int argc, char *argv[], void *userdata) {
STRV_FOREACH(name, names) { STRV_FOREACH(name, names) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
q = bus_call_method(bus, bus_systemd_mgr, "ResetFailedUnit", &error, NULL, "s", *name); q = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ResetFailedUnit",
&error,
NULL,
"s", *name);
if (q < 0) { if (q < 0) {
log_error_errno(q, "Failed to reset failed state of unit %s: %s", *name, bus_error_message(&error, q)); log_error_errno(q, "Failed to reset failed state of unit %s: %s", *name, bus_error_message(&error, q));
if (r == 0) if (r == 0)
@ -6146,7 +6347,15 @@ static int show_environment(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags); (void) pager_open(arg_pager_flags);
r = bus_get_property(bus, bus_systemd_mgr, "Environment", &error, &reply, "as"); r = sd_bus_get_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Environment",
&error,
&reply,
"as");
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get environment: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get environment: %s", bus_error_message(&error, r));
@ -6227,7 +6436,15 @@ static int switch_root(int argc, char *argv[], void *userdata) {
log_debug("Switching root - root: %s; init: %s", root, strna(init)); log_debug("Switching root - root: %s; init: %s", root, strna(init));
r = bus_call_method(bus, bus_systemd_mgr, "SwitchRoot", &error, NULL, "ss", root, init); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SwitchRoot",
&error,
NULL,
"ss", root, init);
if (r < 0) { if (r < 0) {
(void) default_signals(SIGTERM, -1); (void) default_signals(SIGTERM, -1);
@ -6249,7 +6466,14 @@ static int log_level(int argc, char *argv[], void *userdata) {
if (argc == 1) { if (argc == 1) {
_cleanup_free_ char *level = NULL; _cleanup_free_ char *level = NULL;
r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level); r = sd_bus_get_property_string(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogLevel",
&error,
&level);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get log level: %s", bus_error_message(&error, r));
@ -6258,7 +6482,15 @@ static int log_level(int argc, char *argv[], void *userdata) {
} else { } else {
assert(argc == 2); assert(argc == 2);
r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogLevel",
&error,
"s",
argv[1]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set log level: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set log level: %s", bus_error_message(&error, r));
} }
@ -6278,7 +6510,14 @@ static int log_target(int argc, char *argv[], void *userdata) {
if (argc == 1) { if (argc == 1) {
_cleanup_free_ char *target = NULL; _cleanup_free_ char *target = NULL;
r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target); r = sd_bus_get_property_string(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogTarget",
&error,
&target);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get log target: %s", bus_error_message(&error, r));
@ -6287,7 +6526,15 @@ static int log_target(int argc, char *argv[], void *userdata) {
} else { } else {
assert(argc == 2); assert(argc == 2);
r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"LogTarget",
&error,
"s",
argv[1]);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set log target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set log target: %s", bus_error_message(&error, r));
} }
@ -6308,7 +6555,15 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
if (argc == 1) { if (argc == 1) {
/* get ServiceWatchdogs */ /* get ServiceWatchdogs */
r = bus_get_property_trivial(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, 'b', &b); r = sd_bus_get_property_trivial(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ServiceWatchdogs",
&error,
'b',
&b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get service-watchdog state: %s", bus_error_message(&error, r));
@ -6322,7 +6577,15 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
if (b < 0) if (b < 0)
return log_error_errno(b, "Failed to parse service-watchdogs argument: %m"); return log_error_errno(b, "Failed to parse service-watchdogs argument: %m");
r = bus_set_property(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, "b", b); r = sd_bus_set_property(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"ServiceWatchdogs",
&error,
"b",
b);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set service-watchdog state: %s", bus_error_message(&error, r));
} }
@ -6350,7 +6613,13 @@ static int set_environment(int argc, char *argv[], void *userdata) {
? "SetEnvironment" ? "SetEnvironment"
: "UnsetEnvironment"; : "UnsetEnvironment";
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method);
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -6377,7 +6646,13 @@ static int import_environment(int argc, char *argv[], void *userdata) {
polkit_agent_open_maybe(); polkit_agent_open_maybe();
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetEnvironment"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetEnvironment");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -6816,7 +7091,13 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
} else } else
assert_not_reached("Unknown verb"); assert_not_reached("Unknown verb");
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method);
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -6952,7 +7233,13 @@ static int add_dependency(int argc, char *argv[], void *userdata) {
polkit_agent_open_maybe(); polkit_agent_open_maybe();
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "AddDependencyUnitFiles"); r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"AddDependencyUnitFiles");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -7008,9 +7295,11 @@ static int preset_all(int argc, char *argv[], void *userdata) {
polkit_agent_open_maybe(); polkit_agent_open_maybe();
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"PresetAllUnitFiles", "PresetAllUnitFiles",
&error, &error,
&reply, &reply,
@ -7067,7 +7356,15 @@ static int show_installation_targets(sd_bus *bus, const char *name) {
const char *link; const char *link;
int r; int r;
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitFileLinks", &error, &reply, "sb", name, arg_runtime); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnitFileLinks",
&error,
&reply,
"sb", name, arg_runtime);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get unit file links for %s: %s", name, bus_error_message(&error, r)); return log_error_errno(r, "Failed to get unit file links for %s: %s", name, bus_error_message(&error, r));
@ -7144,7 +7441,15 @@ static int unit_is_enabled(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
const char *s; const char *s;
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitFileState", &error, &reply, "s", *name); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnitFileState",
&error,
&reply,
"s", *name);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get unit file state for %s: %s", *name, bus_error_message(&error, r)); return log_error_errno(r, "Failed to get unit file state for %s: %s", *name, bus_error_message(&error, r));
@ -7175,7 +7480,14 @@ static int match_startup_finished(sd_bus_message *m, void *userdata, sd_bus_erro
assert(state); assert(state);
r = bus_get_property_string(sd_bus_message_get_bus(m), bus_systemd_mgr, "SystemState", NULL, state); r = sd_bus_get_property_string(
sd_bus_message_get_bus(m),
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SystemState",
NULL,
state);
sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), r); sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), r);
return 0; return 0;
@ -7204,10 +7516,12 @@ static int is_system_running(int argc, char *argv[], void *userdata) {
if (r >= 0) if (r >= 0)
r = sd_bus_attach_event(bus, event, 0); r = sd_bus_attach_event(bus, event, 0);
if (r >= 0) if (r >= 0)
r = bus_match_signal_async( r = sd_bus_match_signal_async(
bus, bus,
&slot_startup_finished, &slot_startup_finished,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"StartupFinished", "StartupFinished",
match_startup_finished, NULL, &state); match_startup_finished, NULL, &state);
if (r < 0) { if (r < 0) {
@ -7216,7 +7530,14 @@ static int is_system_running(int argc, char *argv[], void *userdata) {
} }
} }
r = bus_get_property_string(bus, bus_systemd_mgr, "SystemState", &error, &state); r = sd_bus_get_property_string(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SystemState",
&error,
&state);
if (r < 0) { if (r < 0) {
log_warning_errno(r, "Failed to query system state: %s", bus_error_message(&error, r)); log_warning_errno(r, "Failed to query system state: %s", bus_error_message(&error, r));
@ -7974,7 +8295,14 @@ static int help_boot_loader_entry(void) {
if (r < 0) if (r < 0)
return r; return r;
r = bus_get_property_strv(bus, bus_login_mgr, "BootLoaderEntries", &error, &l); r = sd_bus_get_property_strv(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"BootLoaderEntries",
&error,
&l);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to enumerate boot loader entries: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to enumerate boot loader entries: %s", bus_error_message(&error, r));
@ -9086,7 +9414,17 @@ static int logind_schedule_shutdown(void) {
(void) logind_set_wall_message(); (void) logind_set_wall_message();
r = bus_call_method(bus, bus_login_mgr, "ScheduleShutdown", &error, NULL, "st", action, arg_when); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"ScheduleShutdown",
&error,
NULL,
"st",
action,
arg_when);
if (r < 0) if (r < 0)
return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r)); return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r));
@ -9188,7 +9526,14 @@ static int logind_cancel_shutdown(void) {
(void) logind_set_wall_message(); (void) logind_set_wall_message();
r = bus_call_method(bus, bus_login_mgr, "CancelScheduledShutdown", &error, NULL, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"CancelScheduledShutdown",
&error,
NULL, NULL);
if (r < 0) if (r < 0)
return log_warning_errno(r, "Failed to talk to logind, shutdown hasn't been cancelled: %s", bus_error_message(&error, r)); return log_warning_errno(r, "Failed to talk to logind, shutdown hasn't been cancelled: %s", bus_error_message(&error, r));

View File

@ -1392,7 +1392,6 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
{ 'm', specifier_machine_id, NULL }, { 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL }, { 'b', specifier_boot_id, NULL },
{ 'H', specifier_host_name, NULL }, { 'H', specifier_host_name, NULL },
{ 'l', specifier_short_host_name, NULL },
{ 'v', specifier_kernel_release, NULL }, { 'v', specifier_kernel_release, NULL },
{ 'a', specifier_architecture, NULL }, { 'a', specifier_architecture, NULL },
{ 'o', specifier_os_id, NULL }, { 'o', specifier_os_id, NULL },

View File

@ -470,7 +470,7 @@ tests += [
'', 'timeout=90'], '', 'timeout=90'],
[['src/test/test-set.c'], [['src/test/test-set.c'],
[libbasic], [],
[]], []],
[['src/test/test-ordered-set.c'], [['src/test/test-ordered-set.c'],

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */ /* SPDX-License-Identifier: LGPL-2.1+ */
#include "hashmap.h" #include "hashmap.h"
#include "string-util.h"
#include "util.h" #include "util.h"
unsigned custom_counter = 0; unsigned custom_counter = 0;
@ -110,58 +109,6 @@ static void test_iterated_cache(void) {
assert_se(iterated_cache_free(c) == NULL); assert_se(iterated_cache_free(c) == NULL);
} }
static void test_hashmap_put_strdup(void) {
_cleanup_hashmap_free_ Hashmap *m = NULL;
char *s;
/* We don't have ordered_hashmap_put_strdup() yet. If it is added,
* these tests should be moved to test-hashmap-plain.c. */
log_info("/* %s */", __func__);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 1);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 0);
assert_se(hashmap_put_strdup(&m, "foo", "BAR") == -EEXIST);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 0);
assert_se(hashmap_contains(m, "foo"));
s = hashmap_get(m, "foo");
assert_se(streq(s, "bar"));
assert_se(hashmap_put_strdup(&m, "xxx", "bar") == 1);
assert_se(hashmap_put_strdup(&m, "xxx", "bar") == 0);
assert_se(hashmap_put_strdup(&m, "xxx", "BAR") == -EEXIST);
assert_se(hashmap_put_strdup(&m, "xxx", "bar") == 0);
assert_se(hashmap_contains(m, "xxx"));
s = hashmap_get(m, "xxx");
assert_se(streq(s, "bar"));
}
static void test_hashmap_put_strdup_null(void) {
_cleanup_hashmap_free_ Hashmap *m = NULL;
char *s;
log_info("/* %s */", __func__);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 1);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 0);
assert_se(hashmap_put_strdup(&m, "foo", NULL) == -EEXIST);
assert_se(hashmap_put_strdup(&m, "foo", "bar") == 0);
assert_se(hashmap_contains(m, "foo"));
s = hashmap_get(m, "foo");
assert_se(streq(s, "bar"));
assert_se(hashmap_put_strdup(&m, "xxx", NULL) == 1);
assert_se(hashmap_put_strdup(&m, "xxx", "bar") == -EEXIST);
assert_se(hashmap_put_strdup(&m, "xxx", NULL) == 0);
assert_se(hashmap_contains(m, "xxx"));
s = hashmap_get(m, "xxx");
assert_se(s == NULL);
}
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
/* This file tests in test-hashmap-plain.c, and tests in test-hashmap-ordered.c, which is generated /* This file tests in test-hashmap-plain.c, and tests in test-hashmap-ordered.c, which is generated
* from test-hashmap-plain.c. Hashmap tests should be added to test-hashmap-plain.c, and here only if * from test-hashmap-plain.c. Hashmap tests should be added to test-hashmap-plain.c, and here only if
@ -180,8 +127,6 @@ int main(int argc, const char *argv[]) {
test_trivial_compare_func(); test_trivial_compare_func();
test_string_compare_func(); test_string_compare_func();
test_iterated_cache(); test_iterated_cache();
test_hashmap_put_strdup();
test_hashmap_put_strdup_null();
return 0; return 0;
} }

View File

@ -140,23 +140,6 @@ static void test_read_etc_hostname(void) {
unlink(path); unlink(path);
} }
static void test_hostname_malloc(void) {
_cleanup_free_ char *h = NULL, *l = NULL;
assert_se(h = gethostname_malloc());
log_info("hostname_malloc: \"%s\"", h);
assert_se(l = gethostname_short_malloc());
log_info("hostname_short_malloc: \"%s\"", l);
}
static void test_fallback_hostname(void) {
if (!hostname_is_valid(FALLBACK_HOSTNAME, false)) {
log_error("Configured fallback hostname \"%s\" is not valid.", FALLBACK_HOSTNAME);
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
log_parse_environment(); log_parse_environment();
log_open(); log_open();
@ -164,9 +147,6 @@ int main(int argc, char *argv[]) {
test_hostname_is_valid(); test_hostname_is_valid();
test_hostname_cleanup(); test_hostname_cleanup();
test_read_etc_hostname(); test_read_etc_hostname();
test_hostname_malloc();
test_fallback_hostname();
return 0; return 0;
} }

View File

@ -60,7 +60,7 @@ DEFINE_PRIVATE_HASH_OPS(test_hash_ops, struct test, test_hash, test_compare);
static void test_struct(void) { static void test_struct(void) {
_cleanup_(prioq_freep) Prioq *q = NULL; _cleanup_(prioq_freep) Prioq *q = NULL;
_cleanup_set_free_ Set *s = NULL; _cleanup_(set_freep) Set *s = NULL;
unsigned previous = 0, i; unsigned previous = 0, i;
struct test *t; struct test *t;

View File

@ -3,8 +3,6 @@
#include "set.h" #include "set.h"
#include "strv.h" #include "strv.h"
const bool mempool_use_allowed = VALGRIND;
static void test_set_steal_first(void) { static void test_set_steal_first(void) {
_cleanup_set_free_ Set *m = NULL; _cleanup_set_free_ Set *m = NULL;
int seen[3] = {}; int seen[3] = {};
@ -88,32 +86,11 @@ static void test_set_put(void) {
assert_se(strv_length(t) == 3); assert_se(strv_length(t) == 3);
} }
static void test_set_put_strdup(void) {
_cleanup_set_free_ Set *m = NULL;
assert_se(set_put_strdup(&m, "aaa") == 1);
assert_se(set_put_strdup(&m, "aaa") == 0);
assert_se(set_put_strdup(&m, "bbb") == 1);
assert_se(set_put_strdup(&m, "bbb") == 0);
assert_se(set_put_strdup(&m, "aaa") == 0);
assert_se(set_size(m) == 2);
}
static void test_set_put_strdupv(void) {
_cleanup_set_free_ Set *m = NULL;
assert_se(set_put_strdupv(&m, STRV_MAKE("aaa", "aaa", "bbb", "bbb", "aaa")) == 2);
assert_se(set_put_strdupv(&m, STRV_MAKE("aaa", "aaa", "bbb", "bbb", "ccc")) == 1);
assert_se(set_size(m) == 3);
}
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
test_set_steal_first(); test_set_steal_first();
test_set_free_with_destructor(); test_set_free_with_destructor();
test_set_free_with_hash_ops(); test_set_free_with_hash_ops();
test_set_put(); test_set_put();
test_set_put_strdup();
test_set_put_strdupv();
return 0; return 0;
} }

View File

@ -3,7 +3,6 @@
#include "alloc-util.h" #include "alloc-util.h"
#include "log.h" #include "log.h"
#include "specifier.h" #include "specifier.h"
#include "stdio-util.h"
#include "string-util.h" #include "string-util.h"
#include "strv.h" #include "strv.h"
#include "tests.h" #include "tests.h"
@ -16,8 +15,6 @@ static void test_specifier_escape_one(const char *a, const char *b) {
} }
static void test_specifier_escape(void) { static void test_specifier_escape(void) {
log_info("/* %s */", __func__);
test_specifier_escape_one(NULL, NULL); test_specifier_escape_one(NULL, NULL);
test_specifier_escape_one("", ""); test_specifier_escape_one("", "");
test_specifier_escape_one("%", "%%"); test_specifier_escape_one("%", "%%");
@ -34,54 +31,12 @@ static void test_specifier_escape_strv_one(char **a, char **b) {
} }
static void test_specifier_escape_strv(void) { static void test_specifier_escape_strv(void) {
log_info("/* %s */", __func__);
test_specifier_escape_strv_one(NULL, NULL); test_specifier_escape_strv_one(NULL, NULL);
test_specifier_escape_strv_one(STRV_MAKE(NULL), STRV_MAKE(NULL)); test_specifier_escape_strv_one(STRV_MAKE(NULL), STRV_MAKE(NULL));
test_specifier_escape_strv_one(STRV_MAKE(""), STRV_MAKE("")); test_specifier_escape_strv_one(STRV_MAKE(""), STRV_MAKE(""));
test_specifier_escape_strv_one(STRV_MAKE("foo"), STRV_MAKE("foo")); test_specifier_escape_strv_one(STRV_MAKE("foo"), STRV_MAKE("foo"));
test_specifier_escape_strv_one(STRV_MAKE("%"), STRV_MAKE("%%")); test_specifier_escape_strv_one(STRV_MAKE("%"), STRV_MAKE("%%"));
test_specifier_escape_strv_one(STRV_MAKE("foo", "%", "foo%", "%foo", "foo%foo", "quux", "%%%"), test_specifier_escape_strv_one(STRV_MAKE("foo", "%", "foo%", "%foo", "foo%foo", "quux", "%%%"), STRV_MAKE("foo", "%%", "foo%%", "%%foo", "foo%%foo", "quux", "%%%%%%"));
STRV_MAKE("foo", "%%", "foo%%", "%%foo", "foo%%foo", "quux", "%%%%%%"));
}
/* Any specifier functions which don't need an argument. */
static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id, NULL },
{ 'b', specifier_boot_id, NULL },
{ 'H', specifier_host_name, NULL },
{ 'l', specifier_short_host_name, NULL },
{ 'v', specifier_kernel_release, NULL },
{ 'a', specifier_architecture, NULL },
{ 'o', specifier_os_id, NULL },
{ 'w', specifier_os_version_id, NULL },
{ 'B', specifier_os_build_id, NULL },
{ 'W', specifier_os_variant_id, NULL },
{ 'g', specifier_group_name, NULL },
{ 'G', specifier_group_id, NULL },
{ 'U', specifier_user_id, NULL },
{ 'u', specifier_user_name, NULL },
{ 'h', specifier_user_home, NULL },
{ 'T', specifier_tmp_dir, NULL },
{ 'V', specifier_var_tmp_dir, NULL },
{}
};
static void test_specifiers(void) {
log_info("/* %s */", __func__);
for (const Specifier *s = specifier_table; s->specifier; s++) {
char spec[3];
_cleanup_free_ char *resolved = NULL;
xsprintf(spec, "%%%c", s->specifier);
assert_se(specifier_printf(spec, specifier_table, NULL, &resolved) >= 0);
log_info("%%%c → %s", s->specifier, resolved);
}
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -89,7 +44,6 @@ int main(int argc, char *argv[]) {
test_specifier_escape(); test_specifier_escape();
test_specifier_escape_strv(); test_specifier_escape_strv();
test_specifiers();
return 0; return 0;
} }

View File

@ -239,9 +239,10 @@ static int set_time(int argc, char **argv, void *userdata) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to parse time specification '%s': %m", argv[1]); return log_error_errno(r, "Failed to parse time specification '%s': %m", argv[1]);
r = bus_call_method( r = sd_bus_call_method(bus,
bus, "org.freedesktop.timedate1",
bus_timedate, "/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetTime", "SetTime",
&error, &error,
NULL, NULL,
@ -259,7 +260,14 @@ static int set_timezone(int argc, char **argv, void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(bus, bus_timedate, "SetTimezone", &error, NULL, "sb", argv[1], arg_ask_password); r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetTimezone",
&error,
NULL,
"sb", argv[1], arg_ask_password);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set time zone: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set time zone: %s", bus_error_message(&error, r));
@ -277,9 +285,10 @@ static int set_local_rtc(int argc, char **argv, void *userdata) {
if (b < 0) if (b < 0)
return log_error_errno(b, "Failed to parse local RTC setting '%s': %m", argv[1]); return log_error_errno(b, "Failed to parse local RTC setting '%s': %m", argv[1]);
r = bus_call_method( r = sd_bus_call_method(bus,
bus, "org.freedesktop.timedate1",
bus_timedate, "/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetLocalRTC", "SetLocalRTC",
&error, &error,
NULL, NULL,
@ -301,7 +310,14 @@ static int set_ntp(int argc, char **argv, void *userdata) {
if (b < 0) if (b < 0)
return log_error_errno(b, "Failed to parse NTP setting '%s': %m", argv[1]); return log_error_errno(b, "Failed to parse NTP setting '%s': %m", argv[1]);
r = bus_call_method(bus, bus_timedate, "SetNTP", &error, NULL, "bb", b, arg_ask_password); r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetNTP",
&error,
NULL,
"bb", b, arg_ask_password);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set ntp: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set ntp: %s", bus_error_message(&error, r));
@ -315,7 +331,14 @@ static int list_timezones(int argc, char **argv, void *userdata) {
int r; int r;
char** zones; char** zones;
r = bus_call_method(bus, bus_timedate, "ListTimezones", &error, &reply, NULL); r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"ListTimezones",
&error,
&reply,
NULL);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to request list of time zones: %s", return log_error_errno(r, "Failed to request list of time zones: %s",
bus_error_message(&error, r)); bus_error_message(&error, r));
@ -820,7 +843,15 @@ static int parse_ifindex_bus(sd_bus *bus, const char *str) {
return r; return r;
assert(r < 0); assert(r < 0);
r = bus_call_method(bus, bus_network_mgr, "GetLinkByName", &error, &reply, "s", str); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"GetLinkByName",
&error,
&reply,
"s", str);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get ifindex of interfaces %s: %s", str, bus_error_message(&error, r)); return log_error_errno(r, "Failed to get ifindex of interfaces %s: %s", str, bus_error_message(&error, r));
@ -845,7 +876,13 @@ static int verb_ntp_servers(int argc, char **argv, void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &req, bus_network_mgr, "SetLinkNTP"); r = sd_bus_message_new_method_call(
bus,
&req,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"SetLinkNTP");
if (r < 0) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);
@ -877,7 +914,15 @@ static int verb_revert(int argc, char **argv, void *userdata) {
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(bus, bus_network_mgr, "RevertLinkNTP", &error, NULL, "i", ifindex); r = sd_bus_call_method(
bus,
"org.freedesktop.network1",
"/org/freedesktop/network1",
"org.freedesktop.network1.Manager",
"RevertLinkNTP",
&error,
NULL,
"i", ifindex);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to revert interface configuration: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to revert interface configuration: %s", bus_error_message(&error, r));

View File

@ -471,9 +471,11 @@ static int unit_start_or_stop(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *erro
assert(bus); assert(bus);
assert(error); assert(error);
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
start ? "StartUnit" : "StopUnit", start ? "StartUnit" : "StopUnit",
error, error,
&reply, &reply,
@ -513,9 +515,11 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *
log_unit_info(u, "%s unit.", enable ? "Enabling" : "Disabling"); log_unit_info(u, "%s unit.", enable ? "Enabling" : "Disabling");
if (enable) if (enable)
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"EnableUnitFiles", "EnableUnitFiles",
error, error,
NULL, NULL,
@ -523,9 +527,11 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *
u->name, u->name,
false, true); false, true);
else else
r = bus_call_method( r = sd_bus_call_method(
bus, bus,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"DisableUnitFiles", "DisableUnitFiles",
error, error,
NULL, NULL,
@ -535,7 +541,15 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *
if (r < 0) if (r < 0)
return r; return r;
r = bus_call_method(bus, bus_systemd_mgr, "Reload", error, NULL, NULL); r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"Reload",
error,
NULL,
NULL);
if (r < 0) if (r < 0)
return r; return r;
@ -938,10 +952,12 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error
u->path = mfree(u->path); u->path = mfree(u->path);
if (!c->slot_job_removed) { if (!c->slot_job_removed) {
r = bus_match_signal_async( r = sd_bus_match_signal_async(
bus, bus,
&slot, &slot,
bus_systemd_mgr, "org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"JobRemoved", "JobRemoved",
match_job_removed, NULL, c); match_job_removed, NULL, c);
if (r < 0) if (r < 0)

View File

@ -184,7 +184,6 @@ static const Specifier specifier_table[] = {
{ 'm', specifier_machine_id_safe, NULL }, { 'm', specifier_machine_id_safe, NULL },
{ 'b', specifier_boot_id, NULL }, { 'b', specifier_boot_id, NULL },
{ 'H', specifier_host_name, NULL }, { 'H', specifier_host_name, NULL },
{ 'l', specifier_short_host_name, NULL },
{ 'v', specifier_kernel_release, NULL }, { 'v', specifier_kernel_release, NULL },
{ 'a', specifier_architecture, NULL }, { 'a', specifier_architecture, NULL },
{ 'o', specifier_os_id, NULL }, { 'o', specifier_os_id, NULL },

View File

@ -23,7 +23,7 @@
static bool arg_verbose = false; static bool arg_verbose = false;
static bool arg_dry_run = false; static bool arg_dry_run = false;
static int exec_list(sd_device_enumerator *e, const char *action, Set **settle_set) { static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_set) {
sd_device *d; sd_device *d;
int r, ret = 0; int r, ret = 0;
@ -172,7 +172,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL; _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL; _cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_set_free_ Set *settle_set = NULL; _cleanup_set_free_free_ Set *settle_set = NULL;
usec_t ping_timeout_usec = 5 * USEC_PER_SEC; usec_t ping_timeout_usec = 5 * USEC_PER_SEC;
bool settle = false, ping = false; bool settle = false, ping = false;
int c, r; int c, r;
@ -342,7 +342,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
} }
if (settle) { if (settle) {
settle_set = set_new(&string_hash_ops_free); settle_set = set_new(&string_hash_ops);
if (!settle_set) if (!settle_set)
return log_oom(); return log_oom();
@ -377,8 +377,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
default: default:
assert_not_reached("Unknown device type"); assert_not_reached("Unknown device type");
} }
r = exec_list(e, action, settle_set);
r = exec_list(e, action, settle ? &settle_set : NULL);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -7,6 +7,198 @@ import re
from xml_helper import xml_parse, xml_print, tree from xml_helper import xml_parse, xml_print, tree
from copy import deepcopy from copy import deepcopy
TEMPLATE = '''\
<refentry id="systemd.directives" conditional="HAVE_PYTHON">
<refentryinfo>
<title>systemd.directives</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>systemd.directives</refentrytitle>
<manvolnum>7</manvolnum>
</refmeta>
<refnamediv>
<refname>systemd.directives</refname>
<refpurpose>Index of configuration directives</refpurpose>
</refnamediv>
<refsect1>
<title>Unit directives</title>
<para>Directives for configuring units, used in unit
files.</para>
<variablelist id='unit-directives' />
</refsect1>
<refsect1>
<title>Options on the kernel command line</title>
<para>Kernel boot options for configuring the behaviour of the
systemd process.</para>
<variablelist id='kernel-commandline-options' />
</refsect1>
<refsect1>
<title>Environment variables</title>
<para>Environment variables understood by the systemd manager
and other programs and environment variable-compatible settings.</para>
<variablelist id='environment-variables' />
</refsect1>
<refsect1>
<title>EFI variables</title>
<para>EFI variables understood by
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>
and other programs.</para>
<variablelist id='efi-variables' />
</refsect1>
<refsect1>
<title>UDEV directives</title>
<para>Directives for configuring systemd units through the
udev database.</para>
<variablelist id='udev-directives' />
</refsect1>
<refsect1>
<title>Network directives</title>
<para>Directives for configuring network links through the
net-setup-link udev builtin and networks through
systemd-networkd.</para>
<variablelist id='network-directives' />
</refsect1>
<refsect1>
<title>Journal fields</title>
<para>Fields in the journal events with a well known meaning.</para>
<variablelist id='journal-directives' />
</refsect1>
<refsect1>
<title>PAM configuration directives</title>
<para>Directives for configuring PAM behaviour.</para>
<variablelist id='pam-directives' />
</refsect1>
<refsect1>
<title><filename>/etc/crypttab</filename> and
<filename>/etc/fstab</filename> options</title>
<para>Options which influence mounted filesystems and
encrypted volumes.</para>
<variablelist id='fstab-options' />
</refsect1>
<refsect1>
<title><citerefentry><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>
directives</title>
<para>Directives for configuring systemd-nspawn containers.</para>
<variablelist id='nspawn-directives' />
</refsect1>
<refsect1>
<title>Program configuration options</title>
<para>Directives for configuring the behaviour of the
systemd process and other tools through configuration files.</para>
<variablelist id='config-directives' />
</refsect1>
<refsect1>
<title>Command line options</title>
<para>Command-line options accepted by programs in the
systemd suite.</para>
<variablelist id='options' />
</refsect1>
<refsect1>
<title>Constants</title>
<para>Various constant used and/or defined by systemd.</para>
<variablelist id='constants' />
</refsect1>
<refsect1>
<title>Miscellaneous options and directives</title>
<para>Other configuration elements which don't fit in
any of the above groups.</para>
<variablelist id='miscellaneous' />
</refsect1>
<refsect1>
<title>Files and directories</title>
<para>Paths and file names referred to in the
documentation.</para>
<variablelist id='filenames' />
</refsect1>
<refsect1>
<title>D-Bus interfaces</title>
<para>Interfaces exposed over D-Bus.</para>
<variablelist id='dbus-interface' />
</refsect1>
<refsect1>
<title>D-Bus methods</title>
<para>Methods exposed in the D-Bus interface.</para>
<variablelist id='dbus-method' />
</refsect1>
<refsect1>
<title>D-Bus properties</title>
<para>Properties exposed in the D-Bus interface.</para>
<variablelist id='dbus-property' />
</refsect1>
<refsect1>
<title>D-Bus signals</title>
<para>Signals emitted in the D-Bus interface.</para>
<variablelist id='dbus-signal' />
</refsect1>
<refsect1>
<title>Colophon</title>
<para id='colophon' />
</refsect1>
</refentry>
'''
COLOPHON = '''\ COLOPHON = '''\
This index contains {count} entries in {sections} sections, This index contains {count} entries in {sections} sections,
referring to {pages} individual manual pages. referring to {pages} individual manual pages.
@ -87,18 +279,6 @@ def _extract_directives(directive_groups, formatting, page):
storfile[name.text].append((pagename, section)) storfile[name.text].append((pagename, section))
formatting[name.text] = name formatting[name.text] = name
storfile = directive_groups['specifiers']
for name in t.iterfind(".//table[@class='specifiers']//entry/literal"):
if name.text[0] != '%' or name.getparent().text is not None:
continue
if name.attrib.get('index') == 'false':
continue
storfile[name.text].append((pagename, section))
formatting[name.text] = name
for name in t.iterfind(".//literal[@class='specifiers']"):
storfile[name.text].append((pagename, section))
formatting[name.text] = name
def _make_section(template, name, directives, formatting): def _make_section(template, name, directives, formatting):
varlist = template.find(".//*[@id='{}']".format(name)) varlist = template.find(".//*[@id='{}']".format(name))
for varname, manpages in sorted(directives.items()): for varname, manpages in sorted(directives.items()):
@ -150,9 +330,9 @@ def _make_page(template, directive_groups, formatting):
return template return template
def make_page(template_path, xml_files): def make_page(*xml_files):
"Extract directives from xml_files and return XML index tree." "Extract directives from xml_files and return XML index tree."
template = xml_parse(template_path) template = tree.fromstring(TEMPLATE)
names = [vl.get('id') for vl in template.iterfind('.//variablelist')] names = [vl.get('id') for vl in template.iterfind('.//variablelist')]
directive_groups = {name:collections.defaultdict(list) directive_groups = {name:collections.defaultdict(list)
for name in names} for name in names}
@ -167,7 +347,4 @@ def make_page(template_path, xml_files):
if __name__ == '__main__': if __name__ == '__main__':
with open(sys.argv[1], 'wb') as f: with open(sys.argv[1], 'wb') as f:
template_path = sys.argv[2] f.write(xml_print(make_page(*sys.argv[2:])))
xml_files = sys.argv[3:]
xml = make_page(template_path, xml_files)
f.write(xml_print(xml))

View File

@ -50,7 +50,7 @@ def mjoin(files):
return ' \\\n\t'.join(sorted(files) or '#') return ' \\\n\t'.join(sorted(files) or '#')
MESON_HEADER = '''\ MESON_HEADER = '''\
# Do not edit. Generated by update-man-rules.py. # Do not edit. Generated by make-man-rules.py.
# Update with: # Update with:
# ninja -C build man/update-man-rules # ninja -C build man/update-man-rules
manpages = [''' manpages = ['''