Compare commits
51 Commits
6bae4b905c
...
d910f4c2b2
Author | SHA1 | Date |
---|---|---|
Michal Sekletar | d910f4c2b2 | |
Lennart Poettering | c60bc8d4fb | |
Lennart Poettering | 7c5137329d | |
Lennart Poettering | bb5da6c385 | |
Vito Caputo | 5e55340ad4 | |
Vito Caputo | 43fe4f7613 | |
Vito Caputo | 8010c205dd | |
Vito Caputo | 7ad61613de | |
Vito Caputo | d96f9abc95 | |
Vito Caputo | bf5c8177f8 | |
Vito Caputo | a63d7e7bf6 | |
Vito Caputo | 7b38987880 | |
Vito Caputo | 1ecaac5c30 | |
Vito Caputo | 8a048c8c42 | |
Vito Caputo | 92cb8ebcb4 | |
Vito Caputo | 14456f7607 | |
Vito Caputo | 5d990cc571 | |
Vito Caputo | e3c8ec3b33 | |
Vito Caputo | de770b6042 | |
Vito Caputo | 8a1596aab5 | |
Vito Caputo | 54e27bb5c0 | |
Zbigniew Jędrzejewski-Szmek | b6c93a5a44 | |
Zbigniew Jędrzejewski-Szmek | e97708fa3e | |
Zbigniew Jędrzejewski-Szmek | eef4b80033 | |
Zbigniew Jędrzejewski-Szmek | 5cea17a177 | |
Lennart Poettering | b36dc5cebd | |
Zbigniew Jędrzejewski-Szmek | 6dbf40256b | |
Zbigniew Jędrzejewski-Szmek | 6552874506 | |
Lennart Poettering | 6a49603e08 | |
Lennart Poettering | c0440512e6 | |
Lennart Poettering | 28a7f10620 | |
Lennart Poettering | cba116991d | |
Lennart Poettering | 5e86c82acd | |
Lennart Poettering | c06bcd4d68 | |
Lennart Poettering | 1f7c6f906b | |
Lennart Poettering | 6d68a0b3dd | |
Zbigniew Jędrzejewski-Szmek | 0d525a3e93 | |
Zbigniew Jędrzejewski-Szmek | 282230882c | |
Zbigniew Jędrzejewski-Szmek | c62e7d041f | |
Zbigniew Jędrzejewski-Szmek | 06689b8d11 | |
Zbigniew Jędrzejewski-Szmek | dd1e33c8dc | |
Zbigniew Jędrzejewski-Szmek | 1f63c72d2e | |
Zbigniew Jędrzejewski-Szmek | e57ac1b017 | |
Zbigniew Jędrzejewski-Szmek | 2f063186d5 | |
Zbigniew Jędrzejewski-Szmek | 476a63e9c0 | |
Zbigniew Jędrzejewski-Szmek | 2204f018cd | |
Zbigniew Jędrzejewski-Szmek | eb1c1dc029 | |
Zbigniew Jędrzejewski-Szmek | 25b3e2a835 | |
Zbigniew Jędrzejewski-Szmek | c73bb51364 | |
Zbigniew Jędrzejewski-Szmek | de747a0008 | |
Zbigniew Jędrzejewski-Szmek | be32732168 |
7
TODO
7
TODO
|
@ -22,6 +22,12 @@ 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.
|
||||||
|
|
||||||
|
@ -220,7 +226,6 @@ 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?
|
||||||
|
|
|
@ -168,6 +168,10 @@ 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 `discard` setting of the user record either the backing
|
Depending on the `luksDiscard` 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.
|
||||||
|
|
|
@ -455,6 +455,10 @@ 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.
|
||||||
|
@ -648,11 +652,12 @@ 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`,
|
||||||
`luksCipher`, `luksCipherMode`, `luksVolumeKeySize`, `luksPbkdfHashAlgorithm`,
|
`luksOfflineDiscard`, `luksOfflineDiscard`, `luksCipher`, `luksCipherMode`,
|
||||||
`luksPbkdfType`, `luksPbkdfTimeCostUSec`, `luksPbkdfMemoryCost`,
|
`luksVolumeKeySize`, `luksPbkdfHashAlgorithm`, `luksPbkdfType`,
|
||||||
`luksPbkdfParallelThreads`, `rateLimitIntervalUSec`, `rateLimitBurst`,
|
`luksPbkdfTimeCostUSec`, `luksPbkdfMemoryCost`, `luksPbkdfParallelThreads`,
|
||||||
`enforcePasswordPolicy`, `autoLogin`, `stopDelayUSec`, `killProcesses`,
|
`rateLimitIntervalUSec`, `rateLimitBurst`, `enforcePasswordPolicy`,
|
||||||
`passwordChangeMinUSec`, `passwordChangeMaxUSec`, `passwordChangeWarnUSec`,
|
`autoLogin`, `stopDelayUSec`, `killProcesses`, `passwordChangeMinUSec`,
|
||||||
|
`passwordChangeMaxUSec`, `passwordChangeWarnUSec`,
|
||||||
`passwordChangeInactiveUSec`, `passwordChangeNow`, `pkcs11TokenUri`.
|
`passwordChangeInactiveUSec`, `passwordChangeNow`, `pkcs11TokenUri`.
|
||||||
|
|
||||||
## Fields in the `binding` section
|
## Fields in the `binding` section
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
<!-- 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>
|
|
@ -544,6 +544,16 @@
|
||||||
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>
|
||||||
|
|
|
@ -110,9 +110,9 @@ endif
|
||||||
|
|
||||||
systemd_directives_xml = custom_target(
|
systemd_directives_xml = custom_target(
|
||||||
'systemd.directives.xml',
|
'systemd.directives.xml',
|
||||||
input : source_xml_files,
|
input : ['directives-template.xml', source_xml_files],
|
||||||
output : 'systemd.directives.xml',
|
output : 'systemd.directives.xml',
|
||||||
command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)
|
command : [make_directive_index_py, '@OUTPUT@', '@INPUT@'])
|
||||||
|
|
||||||
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/make-man-rules.py $(git ls-files ":/man/*.xml") >t && '.format(project_source_root) +
|
'python3 @0@/tools/update-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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Do not edit. Generated by make-man-rules.py.
|
# Do not edit. Generated by update-man-rules.py.
|
||||||
# Update with:
|
# Update with:
|
||||||
# ninja -C build man/update-man-rules
|
# ninja -C build man/update-man-rules
|
||||||
manpages = [
|
manpages = [
|
||||||
|
@ -720,7 +720,11 @@ 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_notifyf', 'sd_pid_notify', 'sd_pid_notify_with_fds', 'sd_pid_notifyf', 'sd_notify_barrier'],
|
['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',
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
<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>
|
||||||
|
|
|
@ -47,6 +47,55 @@
|
||||||
<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>
|
||||||
|
|
|
@ -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>
|
<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" />
|
||||||
|
|
|
@ -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>%%</literal>. If this
|
to this setting, literal percent characters should hence be written as <literal
|
||||||
mount is a bind mount and the specified path does not exist yet it is created as
|
class='specifiers'>%%</literal>. If this mount is a bind mount and the specified path does not exist
|
||||||
directory.</para></listitem>
|
yet it is created as 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>%%</literal>.</para></listitem>
|
should hence be written as <literal class='specifiers'>%%</literal>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -184,11 +184,13 @@
|
||||||
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> for more
|
<citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||||
information.) If this refers to a file, a dependency on the respective mount unit is automatically
|
for more information.) If this refers to a file, a dependency on the respective mount unit is
|
||||||
created. (See <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
automatically created. (See
|
||||||
for more information.) This option is mandatory. Note that the usual specifier expansion is applied to this
|
<citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
|
||||||
setting, literal percent characters should hence be written as <literal>%%</literal>.</para></listitem>
|
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 class='specifiers'>%%</literal>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -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>
|
<table class='specifiers'>
|
||||||
<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,7 +1710,8 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<row>
|
<row>
|
||||||
<!-- 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. -->
|
<!-- 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. -->
|
||||||
<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>
|
||||||
|
@ -1740,11 +1741,17 @@
|
||||||
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 slightly more verbose explanation here, referring to the reload cycle. -->
|
<!-- 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. -->
|
||||||
<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>
|
||||||
|
|
|
@ -234,10 +234,12 @@ r - 500-900
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Specifiers</title>
|
<title>Specifiers</title>
|
||||||
|
|
||||||
<para>Specifiers can be used in the "Name", "ID", "GECOS", "Home directory", and "Shell" fields.
|
<para>Specifiers can be used in the <literal>Name</literal>, <literal>ID</literal>,
|
||||||
An unknown or unresolvable specifier is treated as invalid configuration.
|
<literal>GECOS</literal>, <literal>Home directory</literal>, and <literal>Shell</literal> fields. An
|
||||||
The following expansions are understood:</para>
|
unknown or unresolvable specifier is treated as invalid configuration. The following expansions are
|
||||||
<table>
|
understood:</para>
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
@ -255,6 +257,7 @@ 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>
|
||||||
|
|
|
@ -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>
|
<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" />
|
||||||
|
@ -646,6 +646,7 @@ 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>
|
||||||
|
|
27
meson.build
27
meson.build
|
@ -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/meson-check-compilation.sh')
|
check_compilation_sh = find_program('tools/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,7 +639,14 @@ endforeach
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
conf.set_quoted('FALLBACK_HOSTNAME', get_option('fallback-hostname'))
|
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'] : [])
|
||||||
|
|
||||||
|
@ -3244,8 +3251,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/meson-hwdb-update.sh')
|
hwdb_update_sh = find_program('tools/hwdb-update.sh')
|
||||||
autosuspend_update_sh = find_program('tools/meson-autosuspend-update.sh')
|
autosuspend_update_sh = find_program('tools/autosuspend-update.sh')
|
||||||
|
|
||||||
subdir('sysctl.d')
|
subdir('sysctl.d')
|
||||||
subdir('sysusers.d')
|
subdir('sysusers.d')
|
||||||
|
@ -3286,13 +3293,13 @@ meson.add_install_script('sh', '-c', 'touch $DESTDIR@0@'.format(prefixdir))
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
meson_check_help = find_program('tools/meson-check-help.sh')
|
check_help = find_program('tools/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,
|
||||||
meson_check_help,
|
check_help,
|
||||||
args : exec.full_path())
|
args : exec.full_path())
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
@ -3371,10 +3378,10 @@ if git.found()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if git.found()
|
if git.found()
|
||||||
meson_git_contrib_sh = find_program('tools/meson-git-contrib.sh')
|
git_contrib_sh = find_program('tools/git-contrib.sh')
|
||||||
run_target(
|
run_target(
|
||||||
'git-contrib',
|
'git-contrib',
|
||||||
command : [meson_git_contrib_sh])
|
command : [git_contrib_sh])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if git.found()
|
if git.found()
|
||||||
|
@ -3398,11 +3405,11 @@ endif
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
meson_check_api_docs_sh = find_program('tools/meson-check-api-docs.sh')
|
check_api_docs_sh = find_program('tools/check-api-docs.sh')
|
||||||
run_target(
|
run_target(
|
||||||
'check-api-docs',
|
'check-api-docs',
|
||||||
depends : [man, libsystemd, libudev],
|
depends : [man, libsystemd, libudev],
|
||||||
command : [meson_check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
|
command : [check_api_docs_sh, libsystemd.full_path(), libudev.full_path()])
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog
|
watchdog_opt = service_watchdog == '' ? 'disabled' : service_watchdog
|
||||||
|
|
|
@ -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_free(i->system_call_filter);
|
set_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,11 +1728,7 @@ static int property_read_system_call_filter(
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
r = set_ensure_allocated(&info->system_call_filter, &string_hash_ops);
|
r = set_put_strdup(&info->system_call_filter, name);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = set_put_strdup(info->system_call_filter, name);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,14 +349,7 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1284,15 +1277,7 @@ static int dot(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "ListUnits", &error, &reply, "");
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1334,15 +1319,7 @@ static int dump_fallback(sd_bus *bus) {
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "Dump", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1370,15 +1347,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "DumpByFileDescriptor", &error, &reply, NULL);
|
||||||
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))
|
||||||
|
@ -1444,15 +1413,7 @@ 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 = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1469,14 +1430,7 @@ 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 = sd_bus_get_property_string(
|
r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1500,15 +1454,7 @@ 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 = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1525,14 +1471,7 @@ 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 = sd_bus_get_property_string(
|
r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1655,7 +1594,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_freep) Set *syscalls = NULL;
|
_cleanup_set_free_ Set *syscalls = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -1691,11 +1630,7 @@ 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_ensure_allocated(&syscalls, &string_hash_ops);
|
r = set_put_strdup(&syscalls, e);
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -1735,7 +1670,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_freep) Set *kernel = NULL;
|
_cleanup_set_free_ Set *kernel = NULL;
|
||||||
int i, k;
|
int i, k;
|
||||||
|
|
||||||
k = load_kernel_syscalls(&kernel);
|
k = load_kernel_syscalls(&kernel);
|
||||||
|
@ -2121,15 +2056,7 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
/* get ServiceWatchdogs */
|
/* get ServiceWatchdogs */
|
||||||
r = sd_bus_get_property_trivial(
|
r = bus_get_property_trivial(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, 'b', &b);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -2141,15 +2068,7 @@ 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 = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, "b", b);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,10 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ 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);
|
||||||
|
|
|
@ -76,6 +76,7 @@ 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);
|
||||||
|
|
|
@ -1775,41 +1775,54 @@ 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);
|
||||||
vdup = strdup(v);
|
if (!kdup)
|
||||||
if (!kdup || !vdup)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
if (v) {
|
||||||
|
vdup = strdup(v);
|
||||||
|
if (!vdup)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
r = hashmap_put(*h, kdup, vdup);
|
r = hashmap_put(*h, kdup, vdup);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (r == -EEXIST && streq(v, hashmap_get(*h, kdup)))
|
if (r == -EEXIST && streq_ptr(v, hashmap_get(*h, kdup)))
|
||||||
return 0;
|
return 0;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(r > 0); /* 0 would mean vdup is already in the hashmap, which cannot be */
|
/* 0 with non-null vdup 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 0;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (set_contains(s, (char*) p))
|
r = set_ensure_allocated(s, &string_hash_ops_free);
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ 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.
|
||||||
|
@ -38,10 +39,28 @@ char* gethostname_malloc(void) {
|
||||||
|
|
||||||
assert_se(uname(&u) >= 0);
|
assert_se(uname(&u) >= 0);
|
||||||
|
|
||||||
if (isempty(u.nodename) || streq(u.nodename, "(none)"))
|
s = u.nodename;
|
||||||
return strdup(FALLBACK_HOSTNAME);
|
if (isempty(s) || streq(s, "(none)"))
|
||||||
|
s = FALLBACK_HOSTNAME;
|
||||||
|
|
||||||
return strdup(u.nodename);
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
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_;
|
||||||
|
|
|
@ -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) \
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
|
@ -3634,7 +3634,7 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = {
|
static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = {
|
||||||
|
|
|
@ -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_freep) Set *affected = NULL;
|
_cleanup_set_free_ Set *affected = NULL;
|
||||||
Iterator i;
|
Iterator i;
|
||||||
Job *j, *a;
|
Job *j, *a;
|
||||||
int r;
|
int r;
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,7 @@ 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 },
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,12 +66,6 @@ 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);
|
||||||
|
@ -122,7 +116,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, &home_mgr, "ListHomes", &error, &reply, NULL);
|
r = bus_call_method(bus, 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));
|
||||||
|
|
||||||
|
@ -385,7 +379,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, &home_mgr, "ActivateHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ActivateHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -427,7 +421,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, &home_mgr, "DeactivateHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "DeactivateHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -534,9 +528,9 @@ static int inspect_home(int argc, char *argv[], void *userdata) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bus_call_method(bus, &home_mgr, "GetUserRecordByName", &error, &reply, "s", *i);
|
r = bus_call_method(bus, bus_home_mgr, "GetUserRecordByName", &error, &reply, "s", *i);
|
||||||
} else
|
} else
|
||||||
r = bus_call_method(bus, &home_mgr, "GetUserRecordByUID", &error, &reply, "u", (uint32_t) uid);
|
r = bus_call_method(bus, 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));
|
||||||
|
@ -610,7 +604,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, &home_mgr, "AuthenticateHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "AuthenticateHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1431,7 +1425,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, &home_mgr, "CreateHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "CreateHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1482,7 +1476,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, &home_mgr, "RemoveHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "RemoveHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1545,7 +1539,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, &home_mgr, "GetUserRecordByName", &error, &reply, "s", username);
|
r = bus_call_method(bus, 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));
|
||||||
|
|
||||||
|
@ -1631,7 +1625,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, &home_mgr, "UpdateHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "UpdateHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1668,7 +1662,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, &home_mgr, "ResizeHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ResizeHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1701,7 +1695,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, &home_mgr, "ChangePasswordHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1773,7 +1767,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, &home_mgr, "ChangePasswordHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ChangePasswordHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1852,7 +1846,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, &home_mgr, "ResizeHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ResizeHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1889,7 +1883,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, &home_mgr, "LockHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "LockHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1928,7 +1922,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, &home_mgr, "UnlockHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "UnlockHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1991,7 +1985,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, &home_mgr, "AcquireHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "AcquireHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -2031,7 +2025,7 @@ static int with_home(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bus_call_method(bus, &home_mgr, "GetHomeByName", &error, &reply, "s", argv[1]);
|
r = bus_call_method(bus, 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));
|
||||||
|
|
||||||
|
@ -2058,7 +2052,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, &home_mgr, "ReleaseHome");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "ReleaseHome");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -2087,7 +2081,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, &home_mgr, "LockAllHomes");
|
r = bus_message_new_method_call(bus, &m, bus_home_mgr, "LockAllHomes");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -2232,6 +2226,9 @@ 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"
|
||||||
|
@ -2285,6 +2282,7 @@ 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,
|
||||||
|
@ -2378,6 +2376,7 @@ 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 },
|
||||||
|
@ -2947,6 +2946,25 @@ 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: {
|
||||||
|
|
|
@ -1002,6 +1002,8 @@ 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) {
|
||||||
|
@ -1017,7 +1019,11 @@ 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() */
|
||||||
|
|
||||||
execl(SYSTEMD_HOMEWORK_PATH, SYSTEMD_HOMEWORK_PATH, verb, NULL);
|
/* Allow overriding the homework path via an environment variable, to make debugging
|
||||||
|
* 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -893,19 +893,19 @@ int home_store_header_identity_luks(
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_fitrim(int root_fd) {
|
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. */
|
* effect on activation. (Also, optionally, trim on logout) */
|
||||||
|
|
||||||
assert(root_fd >= 0);
|
assert(root_fd >= 0);
|
||||||
|
|
||||||
if (ioctl(root_fd, FITRIM, &range) < 0) {
|
if (ioctl(root_fd, FITRIM, &range) < 0) {
|
||||||
if (IN_SET(errno, ENOTTY, EOPNOTSUPP, EBADF)) {
|
if (ERRNO_IS_NOT_SUPPORTED(errno) || errno == 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,15 +918,32 @@ static int run_fitrim(int root_fd) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int run_fallocate(int backing_fd, const struct stat *st) {
|
int run_fitrim_by_path(const char *root_path) {
|
||||||
|
_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;
|
||||||
|
|
||||||
|
@ -955,6 +972,16 @@ static 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,
|
||||||
|
@ -1111,7 +1138,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_discard(h) || user_record_luks_offline_discard(h),
|
||||||
&cd,
|
&cd,
|
||||||
&found_luks_uuid,
|
&found_luks_uuid,
|
||||||
&volume_key,
|
&volume_key,
|
||||||
|
@ -1147,6 +1174,9 @@ 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);
|
||||||
|
@ -1259,6 +1289,7 @@ 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);
|
||||||
|
|
||||||
|
@ -1267,6 +1298,7 @@ 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.");
|
||||||
|
|
||||||
|
@ -1279,6 +1311,7 @@ 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
|
||||||
|
@ -1293,23 +1326,45 @@ 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 is already detached.", dm_name);
|
log_debug_errno(r, "LUKS device %s has already been detached.", dm_name);
|
||||||
return false;
|
we_detached = 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);
|
||||||
else if (r < 0)
|
we_detached = false;
|
||||||
|
} 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.");
|
||||||
return true;
|
we_detached = 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(
|
||||||
|
@ -1918,7 +1973,9 @@ 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)) {
|
if (user_record_luks_discard(h) || user_record_luks_offline_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");
|
||||||
|
@ -2004,7 +2061,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_discard(h) || user_record_luks_offline_discard(h),
|
||||||
h,
|
h,
|
||||||
&cd);
|
&cd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -2084,6 +2141,12 @@ 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");
|
||||||
|
@ -2102,6 +2165,12 @@ 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);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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);
|
||||||
|
|
||||||
|
@ -36,3 +37,8 @@ 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);
|
||||||
|
|
|
@ -163,7 +163,15 @@ 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");
|
||||||
|
@ -177,8 +185,20 @@ 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);
|
||||||
|
@ -666,6 +686,12 @@ 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));
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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;
|
||||||
|
@ -28,6 +29,8 @@ 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;
|
||||||
|
@ -36,6 +39,7 @@ 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, \
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,6 @@
|
||||||
#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,
|
||||||
|
@ -131,7 +125,7 @@ static int acquire_user_record(
|
||||||
if (r != PAM_SUCCESS)
|
if (r != PAM_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = bus_call_method(bus, &home_mgr, "GetUserRecordByName", &error, &reply, "s", username);
|
r = bus_call_method(bus, 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)) {
|
||||||
|
@ -457,7 +451,7 @@ static int acquire_home(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bus_message_new_method_call(bus, &m, &home_mgr, do_auth ? "AcquireHome" : "RefHome");
|
r = bus_message_new_method_call(bus, &m, bus_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);
|
||||||
|
|
||||||
|
@ -666,7 +660,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, &home_mgr, "ReleaseHome");
|
r = bus_message_new_method_call(bus, &m, bus_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);
|
||||||
|
|
||||||
|
@ -892,7 +886,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, &home_mgr, "ChangePasswordHome");
|
r = bus_message_new_method_call(bus, &m, bus_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);
|
||||||
|
|
||||||
|
|
|
@ -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_free(enumerator->match_subsystem);
|
set_free(enumerator->match_subsystem);
|
||||||
set_free_free(enumerator->nomatch_subsystem);
|
set_free(enumerator->nomatch_subsystem);
|
||||||
hashmap_free_free_free(enumerator->match_sysattr);
|
hashmap_free(enumerator->match_sysattr);
|
||||||
hashmap_free_free_free(enumerator->nomatch_sysattr);
|
hashmap_free(enumerator->nomatch_sysattr);
|
||||||
hashmap_free_free_free(enumerator->match_property);
|
hashmap_free(enumerator->match_property);
|
||||||
set_free_free(enumerator->match_sysname);
|
set_free(enumerator->match_sysname);
|
||||||
set_free_free(enumerator->match_tag);
|
set_free(enumerator->match_tag);
|
||||||
set_free_free(enumerator->match_parent);
|
set_free(enumerator->match_parent);
|
||||||
|
|
||||||
return mfree(enumerator);
|
return mfree(enumerator);
|
||||||
}
|
}
|
||||||
|
@ -97,89 +97,49 @@ _public_ int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enum
|
||||||
else
|
else
|
||||||
set = &enumerator->nomatch_subsystem;
|
set = &enumerator->nomatch_subsystem;
|
||||||
|
|
||||||
r = set_ensure_allocated(set, NULL);
|
r = set_put_strdup(set, subsystem);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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_ensure_allocated(hashmap, NULL);
|
r = hashmap_put_strdup(hashmap, sysattr, value);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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_ensure_allocated(&enumerator->match_property, NULL);
|
r = hashmap_put_strdup(&enumerator->match_property, property, value);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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) {
|
||||||
|
@ -188,17 +148,13 @@ _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_ensure_allocated(&enumerator->match_sysname, NULL);
|
r = set_put_strdup(&enumerator->match_sysname, sysname);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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) {
|
||||||
|
@ -207,52 +163,41 @@ _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_ensure_allocated(&enumerator->match_tag, NULL);
|
r = set_put_strdup(&enumerator->match_tag, tag);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
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_return(enumerator, -EINVAL);
|
assert(enumerator);
|
||||||
assert_return(parent, -EINVAL);
|
assert(parent);
|
||||||
|
|
||||||
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_ensure_allocated(&enumerator->match_parent, NULL);
|
r = set_put_strdup(&enumerator->match_parent, path);
|
||||||
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 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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) {
|
||||||
device_enumerator_clear_match_parent(enumerator);
|
assert_return(enumerator, -EINVAL);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +208,7 @@ _public_ int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enum
|
||||||
|
|
||||||
enumerator->scan_uptodate = false;
|
enumerator->scan_uptodate = false;
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) {
|
int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) {
|
||||||
|
@ -273,7 +218,7 @@ int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator)
|
||||||
|
|
||||||
enumerator->scan_uptodate = false;
|
enumerator->scan_uptodate = false;
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_compare(sd_device * const *_a, sd_device * const *_b) {
|
static int device_compare(sd_device * const *_a, sd_device * const *_b) {
|
||||||
|
|
|
@ -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_free(device->sysattrs);
|
set_free(device->sysattrs);
|
||||||
set_free_free(device->tags);
|
set_free(device->tags);
|
||||||
set_free_free(device->devlinks);
|
set_free(device->devlinks);
|
||||||
|
|
||||||
return mfree(device);
|
return mfree(device);
|
||||||
}
|
}
|
||||||
|
@ -1078,11 +1078,7 @@ 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_ensure_allocated(&device->tags, &string_hash_ops);
|
r = set_put_strdup(&device->tags, tag);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = set_put_strdup(device->tags, tag);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -1098,11 +1094,7 @@ int device_add_devlink(sd_device *device, const char *devlink) {
|
||||||
assert(device);
|
assert(device);
|
||||||
assert(devlink);
|
assert(devlink);
|
||||||
|
|
||||||
r = set_ensure_allocated(&device->devlinks, &string_hash_ops);
|
r = set_put_strdup(&device->devlinks, devlink);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = set_put_strdup(device->devlinks, devlink);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -1591,10 +1583,6 @@ 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;
|
||||||
|
@ -1613,7 +1601,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,13 +163,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_locale, "SetLocale");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -215,11 +209,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.locale1",
|
bus_locale,
|
||||||
"/org/freedesktop/locale1",
|
|
||||||
"org.freedesktop.locale1",
|
|
||||||
"SetVConsoleKeyboard",
|
"SetVConsoleKeyboard",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -258,11 +250,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.locale1",
|
bus_locale,
|
||||||
"/org/freedesktop/locale1",
|
|
||||||
"org.freedesktop.locale1",
|
|
||||||
"SetX11Keyboard",
|
"SetX11Keyboard",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -64,14 +64,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "GetSession", error, &reply, "s", session_id);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -130,14 +123,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "ListSessions", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -211,14 +197,7 @@ static int list_users(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "ListUsers", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -268,14 +247,7 @@ static int list_seats(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "ListSeats", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -961,14 +933,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "GetSeat", &error, &reply, "s", argv[i]);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1017,11 +982,9 @@ static int activate(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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" :
|
||||||
|
@ -1050,11 +1013,9 @@ static int kill_session(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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);
|
||||||
|
@ -1101,11 +1062,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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);
|
||||||
|
@ -1133,14 +1092,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "TerminateUser", &error, NULL, "u", (uint32_t) uid);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -1168,11 +1120,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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);
|
||||||
|
@ -1195,15 +1145,12 @@ static int attach(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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));
|
||||||
}
|
}
|
||||||
|
@ -1221,14 +1168,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "FlushDevices", &error, NULL, "b", true);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1245,11 +1185,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.login1",
|
bus_login_mgr,
|
||||||
"/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);
|
||||||
|
@ -1271,14 +1209,7 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "TerminateSeat", &error, NULL, "s", argv[i]);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1625,11 +1625,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
m->bus,
|
m->bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"StartUnit",
|
"StartUnit",
|
||||||
error,
|
error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -3981,13 +3979,7 @@ int manager_start_scope(
|
||||||
assert(pid > 1);
|
assert(pid > 1);
|
||||||
assert(job);
|
assert(job);
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(manager->bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
manager->bus,
|
|
||||||
&m,
|
|
||||||
"org.freedesktop.systemd1",
|
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"StartTransientUnit");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -4074,11 +4066,9 @@ int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error,
|
||||||
assert(unit);
|
assert(unit);
|
||||||
assert(job);
|
assert(job);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
manager->bus,
|
manager->bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"StartUnit",
|
"StartUnit",
|
||||||
error,
|
error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -4097,11 +4087,9 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
|
||||||
assert(unit);
|
assert(unit);
|
||||||
assert(job);
|
assert(job);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
manager->bus,
|
manager->bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"StopUnit",
|
"StopUnit",
|
||||||
error,
|
error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -4159,11 +4147,9 @@ int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo
|
||||||
assert(manager);
|
assert(manager);
|
||||||
assert(unit);
|
assert(unit);
|
||||||
|
|
||||||
return sd_bus_call_method(
|
return bus_call_method(
|
||||||
manager->bus,
|
manager->bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"KillUnit",
|
"KillUnit",
|
||||||
error,
|
error,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#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"
|
||||||
|
@ -632,25 +633,11 @@ static int manager_connect_bus(Manager *m) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "JobRemoved", match_job_removed, NULL, m);
|
||||||
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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "UnitRemoved", match_unit_removed, NULL, m);
|
||||||
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");
|
||||||
|
|
||||||
|
@ -665,26 +652,11 @@ 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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "Reloading", match_reloading, NULL, m);
|
||||||
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 = sd_bus_call_method_async(
|
r = bus_call_method_async(m->bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL);
|
||||||
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");
|
||||||
|
|
||||||
|
|
|
@ -789,13 +789,7 @@ _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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_login_mgr, "CreateSession");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -984,15 +978,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
|
||||||
if (r != PAM_SUCCESS)
|
if (r != PAM_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_login_mgr, "ReleaseSession", &error, NULL, "s", id);
|
||||||
"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;
|
||||||
|
|
|
@ -552,14 +552,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(container_bus, bus_systemd_mgr, "StartUnit", error, NULL, "ss", getty, "replace");
|
||||||
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;
|
||||||
|
|
||||||
|
@ -668,13 +661,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(container_bus, &tm, bus_systemd_mgr, "StartTransientUnit");
|
||||||
container_bus,
|
|
||||||
&tm,
|
|
||||||
"org.freedesktop.systemd1",
|
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"StartTransientUnit");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
|
|
@ -108,14 +108,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, method, &error, &reply, "s", name);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -179,14 +172,7 @@ static int call_get_addresses(
|
||||||
assert(prefix);
|
assert(prefix);
|
||||||
assert(prefix2);
|
assert(prefix2);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -283,14 +269,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -369,14 +348,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -493,14 +465,7 @@ static int print_uid_shift(sd_bus *bus, const char *name) {
|
||||||
assert(bus);
|
assert(bus);
|
||||||
assert(name);
|
assert(name);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "GetMachineUIDShift", &error, &reply, "s", name);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -751,14 +716,7 @@ 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 = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "GetMachine", &error, &reply, "s", argv[i]);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -780,13 +738,7 @@ static int print_image_hostname(sd_bus *bus, const char *name) {
|
||||||
const char *hn;
|
const char *hn;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "GetImageHostname", NULL, &reply, "s", name);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -807,13 +759,7 @@ static int print_image_machine_id(sd_bus *bus, const char *name) {
|
||||||
size_t size;
|
size_t size;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineID", NULL, &reply, "s", name);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -834,13 +780,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineInfo", NULL, &reply, "s", name);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -1093,15 +1033,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, &reply, "s", argv[i]);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1131,11 +1063,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.machine1",
|
bus_machine_mgr,
|
||||||
"/org/freedesktop/machine1",
|
|
||||||
"org.freedesktop.machine1.Manager",
|
|
||||||
"KillMachine",
|
"KillMachine",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1171,15 +1101,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "TerminateMachine", &error, NULL, "s", argv[i]);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -1213,12 +1135,10 @@ static int copy_files(int argc, char *argv[], void *userdata) {
|
||||||
host_path = abs_host_path;
|
host_path = abs_host_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(
|
||||||
bus,
|
bus,
|
||||||
&m,
|
&m,
|
||||||
"org.freedesktop.machine1",
|
bus_machine_mgr,
|
||||||
"/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);
|
||||||
|
@ -1249,11 +1169,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.machine1",
|
bus_machine_mgr,
|
||||||
"/org/freedesktop/machine1",
|
|
||||||
"org.freedesktop.machine1.Manager",
|
|
||||||
"BindMountMachine",
|
"BindMountMachine",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1425,15 +1343,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "OpenMachineLogin", &error, &reply, "s", machine);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1498,13 +1408,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "OpenMachineShell");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1545,13 +1449,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "RemoveImage");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1577,11 +1475,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.machine1",
|
bus_machine_mgr,
|
||||||
"/org/freedesktop/machine1",
|
|
||||||
"org.freedesktop.machine1.Manager",
|
|
||||||
"RenameImage",
|
"RenameImage",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1602,13 +1498,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CloneImage");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1641,15 +1531,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -1663,15 +1545,7 @@ static int image_exists(sd_bus *bus, const char *name) {
|
||||||
assert(bus);
|
assert(bus);
|
||||||
assert(name);
|
assert(name);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, NULL, "s", name);
|
||||||
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;
|
||||||
|
@ -1933,12 +1807,10 @@ 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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(
|
||||||
bus,
|
bus,
|
||||||
&slot_job_removed,
|
&slot_job_removed,
|
||||||
"org.freedesktop.import1",
|
bus_import_mgr,
|
||||||
"/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)
|
||||||
|
@ -2022,13 +1894,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportTar");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2089,13 +1955,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportRaw");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2150,13 +2010,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportFileSystem");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2215,13 +2069,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportTar");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2264,13 +2112,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportRaw");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2326,13 +2168,7 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullTar");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2389,13 +2225,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullRaw");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2438,14 +2268,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_import_mgr, "ListTransfers", &error, &reply, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -2542,15 +2365,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_import_mgr, "CancelTransfer", &error, NULL, "u", id);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -2577,26 +2392,10 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "SetPoolLimit", &error, NULL, "t", limit);
|
||||||
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));
|
||||||
|
@ -2616,13 +2415,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CleanPool");
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -1577,16 +1577,7 @@ int manager_unref_unit(
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(unit);
|
assert(unit);
|
||||||
|
|
||||||
return sd_bus_call_method(
|
return bus_call_method(m->bus, bus_systemd_mgr, "UnrefUnit", error, NULL, "s", unit);
|
||||||
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) {
|
||||||
|
@ -1596,15 +1587,7 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
|
||||||
assert(manager);
|
assert(manager);
|
||||||
assert(unit);
|
assert(unit);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(manager->bus, bus_systemd_mgr, "StopUnit", error, &reply, "ss", unit, "fail");
|
||||||
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)) {
|
||||||
|
@ -1641,15 +1624,7 @@ int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_erro
|
||||||
assert(manager);
|
assert(manager);
|
||||||
assert(unit);
|
assert(unit);
|
||||||
|
|
||||||
return sd_bus_call_method(
|
return bus_call_method(manager->bus, bus_systemd_mgr, "KillUnit", error, NULL, "ssi", unit, "all", signo);
|
||||||
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) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#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"
|
||||||
|
@ -193,25 +194,11 @@ static int manager_connect_bus(Manager *m) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "JobRemoved", match_job_removed, NULL, m);
|
||||||
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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "UnitRemoved", match_unit_removed, NULL, m);
|
||||||
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");
|
||||||
|
|
||||||
|
@ -226,26 +213,11 @@ 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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "Reloading", match_reloading, NULL, m);
|
||||||
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 = sd_bus_call_method_async(
|
r = bus_call_method_async(m->bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL);
|
||||||
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");
|
||||||
|
|
||||||
|
|
|
@ -551,13 +551,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -638,13 +632,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -854,13 +842,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StopUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -2302,15 +2302,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "RenewLink", &error, NULL, "i", index);
|
||||||
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));
|
||||||
|
@ -2344,15 +2336,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "ForceRenewLink", &error, NULL, "i", index);
|
||||||
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));
|
||||||
|
@ -2391,13 +2375,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "Reload", &error, NULL, NULL);
|
||||||
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");
|
||||||
|
|
||||||
|
@ -2433,13 +2411,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "ReconfigureLink", &error, NULL, "i", index);
|
||||||
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];
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,16 +199,12 @@ 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_free_ Set *controllers = NULL;
|
_cleanup_set_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;
|
||||||
|
@ -237,7 +233,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;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +299,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_free_ Set *controllers = NULL;
|
_cleanup_set_free_ Set *controllers = NULL;
|
||||||
const char *cgroup_root = "/sys/fs/cgroup", *c;
|
const char *cgroup_root = "/sys/fs/cgroup", *c;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
|
@ -122,11 +122,9 @@ int register_machine(
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
if (keep_unit) {
|
if (keep_unit) {
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.machine1",
|
bus_machine_mgr,
|
||||||
"/org/freedesktop/machine1",
|
|
||||||
"org.freedesktop.machine1.Manager",
|
|
||||||
"RegisterMachineWithNetwork",
|
"RegisterMachineWithNetwork",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -141,13 +139,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CreateMachineWithNetwork");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -218,16 +210,7 @@ int unregister_machine(
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_machine_mgr, "UnregisterMachine", &error, NULL, "s", machine_name);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -262,13 +245,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -354,26 +331,15 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "AbandonScope", &error, NULL, "s", scope);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"KillUnit",
|
"KillUnit",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -386,16 +352,7 @@ int terminate_scope(
|
||||||
sd_bus_error_free(&error);
|
sd_bus_error_free(&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "UnrefUnit", &error, NULL, "s", scope);
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#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"
|
||||||
|
@ -128,14 +129,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name);
|
||||||
"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;
|
||||||
|
|
||||||
|
@ -287,14 +281,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name);
|
||||||
"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;
|
||||||
|
|
||||||
|
@ -464,15 +451,7 @@ enum nss_status _nss_mymachines_getpwnam_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "MapFromMachineUser", &error, &reply, "su", machine, (uint32_t) uid);
|
||||||
"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;
|
||||||
|
@ -548,15 +527,7 @@ enum nss_status _nss_mymachines_getpwuid_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "MapToMachineUser", &error, &reply, "u", (uint32_t) uid);
|
||||||
"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;
|
||||||
|
@ -647,15 +618,7 @@ enum nss_status _nss_mymachines_getgrnam_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "MapFromMachineGroup", &error, &reply, "su", machine, (uint32_t) gid);
|
||||||
"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;
|
||||||
|
@ -728,15 +691,7 @@ enum nss_status _nss_mymachines_getgrgid_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_machine_mgr, "MapToMachineGroup", &error, &reply, "u", (uint32_t) gid);
|
||||||
"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;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#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"
|
||||||
|
@ -142,13 +143,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
"org.freedesktop.resolve1",
|
|
||||||
"/org/freedesktop/resolve1",
|
|
||||||
"org.freedesktop.resolve1.Manager",
|
|
||||||
"ResolveHostname");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -322,13 +317,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
"org.freedesktop.resolve1",
|
|
||||||
"/org/freedesktop/resolve1",
|
|
||||||
"org.freedesktop.resolve1.Manager",
|
|
||||||
"ResolveHostname");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -514,13 +503,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveAddress");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
"org.freedesktop.resolve1",
|
|
||||||
"/org/freedesktop/resolve1",
|
|
||||||
"org.freedesktop.resolve1.Manager",
|
|
||||||
"ResolveAddress");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
|
@ -1156,10 +1156,6 @@ 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;
|
||||||
|
@ -1172,7 +1168,7 @@ int portable_detach(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Filter out duplicates */
|
/* Filter out duplicates */
|
||||||
if (set_get(unit_files, de->d_name))
|
if (set_contains(unit_files, de->d_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dirent_ensure_type(d, de);
|
dirent_ensure_type(d, de);
|
||||||
|
@ -1197,7 +1193,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);
|
||||||
|
|
||||||
|
@ -1310,7 +1306,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_free_ Set *unit_files = NULL;
|
_cleanup_set_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;
|
||||||
|
@ -1336,10 +1332,6 @@ 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;
|
||||||
|
|
||||||
|
@ -1347,7 +1339,7 @@ static int portable_get_state_internal(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Filter out duplicates */
|
/* Filter out duplicates */
|
||||||
if (set_get(unit_files, de->d_name))
|
if (set_contains(unit_files, de->d_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dirent_ensure_type(d, de);
|
dirent_ensure_type(d, de);
|
||||||
|
@ -1372,7 +1364,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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,13 +239,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "GetImageMetadata");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -554,13 +548,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "GetImageMetadata");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -643,13 +631,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "AttachImage");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -697,15 +679,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "DetachImage", &error, &reply, "sb", image, arg_runtime);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -726,15 +700,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "ListImages", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -811,13 +777,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_portable_mgr, "RemoveImage");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -851,15 +811,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -888,26 +840,10 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "SetPoolLimit", &error, NULL, "t", limit);
|
||||||
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));
|
||||||
|
@ -931,15 +867,7 @@ static int is_image_attached(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_portable_mgr, "GetImageState", &error, &reply, "s", image);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -964,14 +892,7 @@ static int dump_profiles(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_get_property_strv(
|
r = bus_get_property_strv(bus, bus_portable_mgr, "Profiles", &error, &l);
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -169,13 +169,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveHostname");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -286,13 +280,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveAddress");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -421,13 +409,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveRecord");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -689,13 +671,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveService");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -994,14 +970,7 @@ static int show_statistics(int argc, char **argv, void *userdata) {
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
r = sd_bus_get_property_trivial(bus,
|
r = bus_get_property_trivial(bus, bus_resolve_mgr, "DNSSECSupported", &error, 'b', &dnssec_supported);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1010,14 +979,7 @@ static int show_statistics(int argc, char **argv, void *userdata) {
|
||||||
yes_no(dnssec_supported),
|
yes_no(dnssec_supported),
|
||||||
ansi_normal());
|
ansi_normal());
|
||||||
|
|
||||||
r = sd_bus_get_property(bus,
|
r = bus_get_property(bus, bus_resolve_mgr, "TransactionStatistics", &error, &reply, "(tt)");
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1029,14 +991,7 @@ static int show_statistics(int argc, char **argv, void *userdata) {
|
||||||
|
|
||||||
reply = sd_bus_message_unref(reply);
|
reply = sd_bus_message_unref(reply);
|
||||||
|
|
||||||
r = sd_bus_get_property(bus,
|
r = bus_get_property(bus, bus_resolve_mgr, "CacheStatistics", &error, &reply, "(ttt)");
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1049,14 +1004,7 @@ static int show_statistics(int argc, char **argv, void *userdata) {
|
||||||
|
|
||||||
reply = sd_bus_message_unref(reply);
|
reply = sd_bus_message_unref(reply);
|
||||||
|
|
||||||
r = sd_bus_get_property(bus,
|
r = bus_get_property(bus, bus_resolve_mgr, "DNSSECStatistics", &error, &reply, "(tttt)");
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1124,14 +1072,7 @@ static int reset_statistics(int argc, char **argv, void *userdata) {
|
||||||
sd_bus *bus = userdata;
|
sd_bus *bus = userdata;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_resolve_mgr, "ResetStatistics", &error, NULL, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1143,14 +1084,7 @@ static int flush_caches(int argc, char **argv, void *userdata) {
|
||||||
sd_bus *bus = userdata;
|
sd_bus *bus = userdata;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_resolve_mgr, "FlushCaches", &error, NULL, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1162,14 +1096,7 @@ static int reset_server_features(int argc, char **argv, void *userdata) {
|
||||||
sd_bus *bus = userdata;
|
sd_bus *bus = userdata;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_resolve_mgr, "ResetServerFeatures", &error, NULL, NULL);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -1921,18 +1848,12 @@ static int verb_status(int argc, char **argv, void *userdata) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call_dns(sd_bus *bus, char **dns, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
|
static int call_dns(sd_bus *bus, char **dns, const BusLocator *locator, 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDNS");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
destination,
|
|
||||||
path,
|
|
||||||
interface,
|
|
||||||
"SetLinkDNS");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -1997,19 +1918,11 @@ 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,
|
r = call_dns(bus, argv + 2, bus_resolve_mgr, &error);
|
||||||
"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,
|
r = call_dns(bus, argv + 2, bus_network_mgr, &error);
|
||||||
"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 &&
|
||||||
|
@ -2022,18 +1935,12 @@ static int verb_dns(int argc, char **argv, void *userdata) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call_domain(sd_bus *bus, char **domain, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
|
static int call_domain(sd_bus *bus, char **domain, const BusLocator *locator, 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDomains");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
destination,
|
|
||||||
path,
|
|
||||||
interface,
|
|
||||||
"SetLinkDomains");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -2092,19 +1999,11 @@ 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,
|
r = call_domain(bus, argv + 2, bus_resolve_mgr, &error);
|
||||||
"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,
|
r = call_domain(bus, argv + 2, bus_network_mgr, &error);
|
||||||
"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 &&
|
||||||
|
@ -2140,27 +2039,11 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDefaultRoute", &error, NULL, "ib", arg_ifindex, b);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "SetLinkDefaultRoute", &error, NULL, "ib", arg_ifindex, b);
|
||||||
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 &&
|
||||||
|
@ -2192,27 +2075,11 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkLLMNR", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "SetLinkLLMNR", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 &&
|
||||||
|
@ -2244,23 +2111,13 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkMulticastDNS", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.network1",
|
bus_network_mgr,
|
||||||
"/org/freedesktop/network1",
|
|
||||||
"org.freedesktop.network1.Manager",
|
|
||||||
"SetLinkMulticastDNS",
|
"SetLinkMulticastDNS",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -2296,23 +2153,13 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDNSOverTLS", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.network1",
|
bus_network_mgr,
|
||||||
"/org/freedesktop/network1",
|
|
||||||
"org.freedesktop.network1.Manager",
|
|
||||||
"SetLinkDNSOverTLS",
|
"SetLinkDNSOverTLS",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -2348,27 +2195,11 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "SetLinkDNSSEC", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "SetLinkDNSSEC", &error, NULL, "is", arg_ifindex, argv[2]);
|
||||||
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 &&
|
||||||
|
@ -2381,17 +2212,11 @@ static int verb_dnssec(int argc, char **argv, void *userdata) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call_nta(sd_bus *bus, char **nta, const char *destination, const char *path, const char *interface, sd_bus_error *error) {
|
static int call_nta(sd_bus *bus, char **nta, const BusLocator *locator, 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, locator, "SetLinkDNSSECNegativeTrustAnchors");
|
||||||
bus,
|
|
||||||
&req,
|
|
||||||
destination,
|
|
||||||
path,
|
|
||||||
interface,
|
|
||||||
"SetLinkDNSSECNegativeTrustAnchors");
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
@ -2442,19 +2267,11 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = call_nta(bus, clear ? NULL : argv + 2,
|
r = call_nta(bus, clear ? NULL : argv + 2, bus_resolve_mgr, &error);
|
||||||
"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,
|
r = call_nta(bus, clear ? NULL : argv + 2, bus_network_mgr, &error);
|
||||||
"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 &&
|
||||||
|
@ -2483,27 +2300,11 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_resolve_mgr, "RevertLink", &error, NULL, "i", arg_ifindex);
|
||||||
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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "RevertLinkDNS", &error, NULL, "i", arg_ifindex);
|
||||||
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 &&
|
||||||
|
|
|
@ -184,11 +184,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -1166,13 +1166,7 @@ static int start_transient_service(
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1420,13 +1414,7 @@ static int start_transient_scope(sd_bus *bus) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1610,13 +1598,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "StartTransientUnit");
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* 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"
|
||||||
|
};
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* 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;
|
|
@ -1695,14 +1695,10 @@ 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_free_ Set *nodes = NULL;
|
_cleanup_set_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_ensure_allocated(&nodes, &string_hash_ops);
|
r = set_put_strdup(&nodes, impl->children[i]->path);
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#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"
|
||||||
|
@ -22,12 +23,6 @@ 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 {
|
||||||
|
|
|
@ -65,7 +65,7 @@ void bus_wait_for_jobs_free(BusWaitForJobs *d) {
|
||||||
if (!d)
|
if (!d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_free_free(d->jobs);
|
set_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,15 +315,9 @@ 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);
|
||||||
|
|
||||||
r = set_ensure_allocated(&d->jobs, &string_hash_ops);
|
return set_put_strdup(&d->jobs, path);
|
||||||
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) {
|
||||||
|
|
|
@ -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(Set *fields, const char *name, size_t n) {
|
static int field_set_test(const Set *fields, const char *name, size_t n) {
|
||||||
char *s = NULL;
|
char *s;
|
||||||
|
|
||||||
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,
|
||||||
Set *output_fields,
|
const 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,
|
||||||
Set *output_fields,
|
const 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,
|
||||||
Set *output_fields,
|
const 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,
|
||||||
Set *output_fields,
|
const 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_get(output_fields, name))
|
if (output_fields && !set_contains(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,
|
||||||
Set *output_fields,
|
const 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,
|
||||||
Set *output_fields,
|
const 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,
|
||||||
Set *output_fields,
|
const Set *output_fields,
|
||||||
const size_t highlight[2]) = {
|
const size_t highlight[2]) = {
|
||||||
|
|
||||||
[OUTPUT_SHORT] = output_short,
|
[OUTPUT_SHORT] = output_short,
|
||||||
|
@ -1133,30 +1133,25 @@ int show_journal_entry(
|
||||||
const size_t highlight[2],
|
const size_t highlight[2],
|
||||||
bool *ellipsized) {
|
bool *ellipsized) {
|
||||||
|
|
||||||
int ret;
|
_cleanup_set_free_ Set *fields = NULL;
|
||||||
_cleanup_set_free_free_ Set *fields = NULL;
|
int r;
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if (output_fields) {
|
r = set_put_strdupv(&fields, output_fields);
|
||||||
fields = set_new(&string_hash_ops);
|
if (r < 0)
|
||||||
if (!fields)
|
return r;
|
||||||
return log_oom();
|
|
||||||
|
|
||||||
ret = set_put_strdupv(fields, output_fields);
|
r = output_funcs[mode](f, j, mode, n_columns, flags, fields, highlight);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = output_funcs[mode](f, j, mode, n_columns, flags, fields, highlight);
|
if (ellipsized && r > 0)
|
||||||
|
|
||||||
if (ellipsized && ret > 0)
|
|
||||||
*ellipsized = true;
|
*ellipsized = true;
|
||||||
|
|
||||||
return ret;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) {
|
static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) {
|
||||||
|
|
|
@ -25,6 +25,8 @@ 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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,17 @@ 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;
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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: %s\n", yes_no(user_record_luks_discard(hr)));
|
printf("LUKS Discard: online=%s offline=%s\n", yes_no(user_record_luks_discard(hr)), yes_no(user_record_luks_offline_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));
|
||||||
|
|
|
@ -52,6 +52,7 @@ 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,
|
||||||
|
@ -944,6 +945,7 @@ 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 },
|
||||||
|
@ -1276,6 +1278,7 @@ 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 },
|
||||||
|
@ -1500,6 +1503,27 @@ 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);
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,7 @@ 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;
|
||||||
|
@ -332,6 +333,7 @@ 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);
|
||||||
|
|
|
@ -547,13 +547,7 @@ static int get_unit_list(
|
||||||
assert(unit_infos);
|
assert(unit_infos);
|
||||||
assert(_reply);
|
assert(_reply);
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitsByPatterns");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -574,13 +568,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitsFiltered");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1620,13 +1608,7 @@ static int list_unit_files(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitFilesByPatterns");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1658,13 +1640,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "ListUnitFiles");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2178,15 +2154,7 @@ static int determine_default(char **ret_name) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "GetDefaultTarget", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -2245,15 +2213,7 @@ static int set_default(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "SetDefaultTarget", &error, &reply, "sb", unit, 1);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -2296,15 +2256,7 @@ static int output_waiting_jobs(sd_bus *bus, Table *table, uint32_t id, const cha
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, method, &error, &reply, "u", id);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -2429,15 +2381,7 @@ static int list_jobs(int argc, char *argv[], void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "ListJobs", &error, &reply, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -2493,15 +2437,7 @@ 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 = sd_bus_call_method(
|
q = bus_call_method(bus, bus_systemd_mgr, "CancelJob", &error, NULL, "u", id);
|
||||||
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)
|
||||||
|
@ -2523,15 +2459,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "GetUnit", NULL, &reply, "s", unit);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -2955,11 +2883,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"EnqueueUnitJob",
|
"EnqueueUnitJob",
|
||||||
&enqueue_error,
|
&enqueue_error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -3005,15 +2931,7 @@ static int start_unit_one(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, method, error, &reply, "ss", name, mode);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -3202,15 +3120,7 @@ static int start_unit(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_wait) {
|
if (arg_wait) {
|
||||||
r = sd_bus_call_method_async(
|
r = bus_call_method_async(bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL);
|
||||||
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");
|
||||||
|
|
||||||
|
@ -3277,18 +3187,7 @@ static int logind_set_wall_message(void) {
|
||||||
if (arg_dry_run)
|
if (arg_dry_run)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "SetWallMessage", &error, NULL, "sb", m, !arg_no_wall);
|
||||||
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;
|
||||||
|
@ -3330,15 +3229,7 @@ static int logind_reboot(enum action a) {
|
||||||
if (arg_dry_run)
|
if (arg_dry_run)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, actions[a].method, &error, NULL, "b", arg_ask_password);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -3378,15 +3269,7 @@ static int logind_check_inhibitors(enum action a) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "ListInhibitors", NULL, &reply, NULL);
|
||||||
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;
|
||||||
|
@ -3481,15 +3364,7 @@ static int prepare_firmware_setup(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "SetRebootToFirmwareSetup", &error, NULL, "b", true);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -3514,15 +3389,7 @@ static int prepare_boot_loader_menu(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "SetRebootToBootLoaderMenu", &error, NULL, "t", arg_boot_loader_menu);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -3547,15 +3414,7 @@ static int prepare_boot_loader_entry(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "SetRebootToBootLoaderEntry", &error, NULL, "s", arg_boot_loader_entry);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -3658,15 +3517,7 @@ static int set_exit_code(uint8_t code) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "SetExitCode", &error, NULL, "y", code);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -3871,11 +3722,9 @@ 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 = sd_bus_call_method(
|
q = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"KillUnit",
|
"KillUnit",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -3933,15 +3782,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "RefUnit", &error, NULL, "s", *name);
|
||||||
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)
|
||||||
|
@ -3950,13 +3791,7 @@ static int clean_or_freeze_unit(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -5794,15 +5629,7 @@ static int get_unit_dbus_path_by_pid(
|
||||||
char *u;
|
char *u;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitByPID", &error, &reply, "u", pid);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6131,13 +5958,7 @@ static int set_property(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
polkit_agent_open_maybe();
|
polkit_agent_open_maybe();
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetUnitProperties");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -6204,13 +6025,7 @@ static int daemon_reload(int argc, char *argv[], void *userdata) {
|
||||||
assert_not_reached("Unexpected action");
|
assert_not_reached("Unexpected action");
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -6258,15 +6073,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, method, &error, NULL, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6298,15 +6105,7 @@ 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 = sd_bus_call_method(
|
q = bus_call_method(bus, bus_systemd_mgr, "ResetFailedUnit", &error, NULL, "s", *name);
|
||||||
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)
|
||||||
|
@ -6347,15 +6146,7 @@ static int show_environment(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
r = sd_bus_get_property(
|
r = bus_get_property(bus, bus_systemd_mgr, "Environment", &error, &reply, "as");
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6436,15 +6227,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "SwitchRoot", &error, NULL, "ss", root, init);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -6466,14 +6249,7 @@ 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 = sd_bus_get_property_string(
|
r = bus_get_property_string(bus, bus_systemd_mgr, "LogLevel", &error, &level);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6482,15 +6258,7 @@ static int log_level(int argc, char *argv[], void *userdata) {
|
||||||
} else {
|
} else {
|
||||||
assert(argc == 2);
|
assert(argc == 2);
|
||||||
|
|
||||||
r = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "LogLevel", &error, "s", argv[1]);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -6510,14 +6278,7 @@ 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 = sd_bus_get_property_string(
|
r = bus_get_property_string(bus, bus_systemd_mgr, "LogTarget", &error, &target);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6526,15 +6287,7 @@ static int log_target(int argc, char *argv[], void *userdata) {
|
||||||
} else {
|
} else {
|
||||||
assert(argc == 2);
|
assert(argc == 2);
|
||||||
|
|
||||||
r = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "LogTarget", &error, "s", argv[1]);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -6555,15 +6308,7 @@ static int service_watchdogs(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
/* get ServiceWatchdogs */
|
/* get ServiceWatchdogs */
|
||||||
r = sd_bus_get_property_trivial(
|
r = bus_get_property_trivial(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, 'b', &b);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -6577,15 +6322,7 @@ 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 = sd_bus_set_property(
|
r = bus_set_property(bus, bus_systemd_mgr, "ServiceWatchdogs", &error, "b", b);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -6613,13 +6350,7 @@ static int set_environment(int argc, char *argv[], void *userdata) {
|
||||||
? "SetEnvironment"
|
? "SetEnvironment"
|
||||||
: "UnsetEnvironment";
|
: "UnsetEnvironment";
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -6646,13 +6377,7 @@ static int import_environment(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
polkit_agent_open_maybe();
|
polkit_agent_open_maybe();
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "SetEnvironment");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -7091,13 +6816,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
|
||||||
} else
|
} else
|
||||||
assert_not_reached("Unknown verb");
|
assert_not_reached("Unknown verb");
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||||
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);
|
||||||
|
|
||||||
|
@ -7233,13 +6952,7 @@ static int add_dependency(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
polkit_agent_open_maybe();
|
polkit_agent_open_maybe();
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "AddDependencyUnitFiles");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -7295,11 +7008,9 @@ static int preset_all(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
polkit_agent_open_maybe();
|
polkit_agent_open_maybe();
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"PresetAllUnitFiles",
|
"PresetAllUnitFiles",
|
||||||
&error,
|
&error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -7356,15 +7067,7 @@ static int show_installation_targets(sd_bus *bus, const char *name) {
|
||||||
const char *link;
|
const char *link;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitFileLinks", &error, &reply, "sb", name, arg_runtime);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -7441,15 +7144,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "GetUnitFileState", &error, &reply, "s", *name);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -7480,14 +7175,7 @@ static int match_startup_finished(sd_bus_message *m, void *userdata, sd_bus_erro
|
||||||
|
|
||||||
assert(state);
|
assert(state);
|
||||||
|
|
||||||
r = sd_bus_get_property_string(
|
r = bus_get_property_string(sd_bus_message_get_bus(m), bus_systemd_mgr, "SystemState", NULL, state);
|
||||||
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;
|
||||||
|
@ -7516,12 +7204,10 @@ 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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(
|
||||||
bus,
|
bus,
|
||||||
&slot_startup_finished,
|
&slot_startup_finished,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/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) {
|
||||||
|
@ -7530,14 +7216,7 @@ static int is_system_running(int argc, char *argv[], void *userdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_get_property_string(
|
r = bus_get_property_string(bus, bus_systemd_mgr, "SystemState", &error, &state);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -8295,14 +7974,7 @@ static int help_boot_loader_entry(void) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_get_property_strv(
|
r = bus_get_property_strv(bus, bus_login_mgr, "BootLoaderEntries", &error, &l);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -9414,17 +9086,7 @@ static int logind_schedule_shutdown(void) {
|
||||||
|
|
||||||
(void) logind_set_wall_message();
|
(void) logind_set_wall_message();
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "ScheduleShutdown", &error, NULL, "st", action, arg_when);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -9526,14 +9188,7 @@ static int logind_cancel_shutdown(void) {
|
||||||
|
|
||||||
(void) logind_set_wall_message();
|
(void) logind_set_wall_message();
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_login_mgr, "CancelScheduledShutdown", &error, NULL, NULL);
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -1392,6 +1392,7 @@ 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 },
|
||||||
|
|
|
@ -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'],
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* 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;
|
||||||
|
@ -109,6 +110,58 @@ 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
|
||||||
|
@ -127,6 +180,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,23 @@ 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();
|
||||||
|
@ -147,6 +164,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_freep) Set *s = NULL;
|
_cleanup_set_free_ Set *s = NULL;
|
||||||
unsigned previous = 0, i;
|
unsigned previous = 0, i;
|
||||||
struct test *t;
|
struct test *t;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#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] = {};
|
||||||
|
@ -86,11 +88,32 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#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"
|
||||||
|
@ -15,6 +16,8 @@ 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("%", "%%");
|
||||||
|
@ -31,12 +34,54 @@ 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", "%%%"), 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", "%%%%%%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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[]) {
|
||||||
|
@ -44,6 +89,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,10 +239,9 @@ 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 = sd_bus_call_method(bus,
|
r = bus_call_method(
|
||||||
"org.freedesktop.timedate1",
|
bus,
|
||||||
"/org/freedesktop/timedate1",
|
bus_timedate,
|
||||||
"org.freedesktop.timedate1",
|
|
||||||
"SetTime",
|
"SetTime",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -260,14 +259,7 @@ 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 = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_timedate, "SetTimezone", &error, NULL, "sb", argv[1], arg_ask_password);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -285,10 +277,9 @@ 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 = sd_bus_call_method(bus,
|
r = bus_call_method(
|
||||||
"org.freedesktop.timedate1",
|
bus,
|
||||||
"/org/freedesktop/timedate1",
|
bus_timedate,
|
||||||
"org.freedesktop.timedate1",
|
|
||||||
"SetLocalRTC",
|
"SetLocalRTC",
|
||||||
&error,
|
&error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -310,14 +301,7 @@ 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 = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_timedate, "SetNTP", &error, NULL, "bb", b, arg_ask_password);
|
||||||
"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));
|
||||||
|
|
||||||
|
@ -331,14 +315,7 @@ static int list_timezones(int argc, char **argv, void *userdata) {
|
||||||
int r;
|
int r;
|
||||||
char** zones;
|
char** zones;
|
||||||
|
|
||||||
r = sd_bus_call_method(bus,
|
r = bus_call_method(bus, bus_timedate, "ListTimezones", &error, &reply, NULL);
|
||||||
"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));
|
||||||
|
@ -843,15 +820,7 @@ static int parse_ifindex_bus(sd_bus *bus, const char *str) {
|
||||||
return r;
|
return r;
|
||||||
assert(r < 0);
|
assert(r < 0);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "GetLinkByName", &error, &reply, "s", str);
|
||||||
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));
|
||||||
|
|
||||||
|
@ -876,13 +845,7 @@ 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 = sd_bus_message_new_method_call(
|
r = bus_message_new_method_call(bus, &req, bus_network_mgr, "SetLinkNTP");
|
||||||
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);
|
||||||
|
|
||||||
|
@ -914,15 +877,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_network_mgr, "RevertLinkNTP", &error, NULL, "i", ifindex);
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
@ -471,11 +471,9 @@ static int unit_start_or_stop(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *erro
|
||||||
assert(bus);
|
assert(bus);
|
||||||
assert(error);
|
assert(error);
|
||||||
|
|
||||||
r = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
start ? "StartUnit" : "StopUnit",
|
start ? "StartUnit" : "StopUnit",
|
||||||
error,
|
error,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -515,11 +513,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"EnableUnitFiles",
|
"EnableUnitFiles",
|
||||||
error,
|
error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -527,11 +523,9 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/org/freedesktop/systemd1",
|
|
||||||
"org.freedesktop.systemd1.Manager",
|
|
||||||
"DisableUnitFiles",
|
"DisableUnitFiles",
|
||||||
error,
|
error,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -541,15 +535,7 @@ 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 = sd_bus_call_method(
|
r = bus_call_method(bus, bus_systemd_mgr, "Reload", error, NULL, NULL);
|
||||||
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;
|
||||||
|
|
||||||
|
@ -952,12 +938,10 @@ 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 = sd_bus_match_signal_async(
|
r = bus_match_signal_async(
|
||||||
bus,
|
bus,
|
||||||
&slot,
|
&slot,
|
||||||
"org.freedesktop.systemd1",
|
bus_systemd_mgr,
|
||||||
"/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)
|
||||||
|
|
|
@ -184,6 +184,7 @@ 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 },
|
||||||
|
|
|
@ -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_free_ Set *settle_set = NULL;
|
_cleanup_set_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);
|
settle_set = set_new(&string_hash_ops_free);
|
||||||
if (!settle_set)
|
if (!settle_set)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
@ -377,7 +377,8 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -7,198 +7,6 @@ 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.
|
||||||
|
@ -279,6 +87,18 @@ 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()):
|
||||||
|
@ -330,9 +150,9 @@ def _make_page(template, directive_groups, formatting):
|
||||||
|
|
||||||
return template
|
return template
|
||||||
|
|
||||||
def make_page(*xml_files):
|
def make_page(template_path, xml_files):
|
||||||
"Extract directives from xml_files and return XML index tree."
|
"Extract directives from xml_files and return XML index tree."
|
||||||
template = tree.fromstring(TEMPLATE)
|
template = xml_parse(template_path)
|
||||||
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}
|
||||||
|
@ -347,4 +167,7 @@ def make_page(*xml_files):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with open(sys.argv[1], 'wb') as f:
|
with open(sys.argv[1], 'wb') as f:
|
||||||
f.write(xml_print(make_page(*sys.argv[2:])))
|
template_path = sys.argv[2]
|
||||||
|
xml_files = sys.argv[3:]
|
||||||
|
xml = make_page(template_path, xml_files)
|
||||||
|
f.write(xml_print(xml))
|
||||||
|
|
|
@ -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 make-man-rules.py.
|
# Do not edit. Generated by update-man-rules.py.
|
||||||
# Update with:
|
# Update with:
|
||||||
# ninja -C build man/update-man-rules
|
# ninja -C build man/update-man-rules
|
||||||
manpages = ['''
|
manpages = ['''
|
Loading…
Reference in New Issue