Merge pull request #9530 from keszybz/sd-bus-doc

More documentation for sd-bus
This commit is contained in:
Lennart Poettering 2018-07-16 15:01:12 +02:00 committed by GitHub
commit db9eee7e45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 758 additions and 77 deletions

76
NEWS
View File

@ -3327,11 +3327,10 @@ CHANGES WITH 226:
correct dequeuing of real-time signals, without losing
signal events.
* When systemd requests a PolicyKit decision when managing
units it will now add additional fields to the request,
including unit name and desired operation. This enables more
powerful PolicyKit policies, that make decisions depending
on these parameters.
* When systemd requests a polkit decision when managing units it
will now add additional fields to the request, including unit
name and desired operation. This enables more powerful polkit
policies, that make decisions depending on these parameters.
* nspawn learnt support for .nspawn settings files, that may
accompany the image files or directories of containers, and
@ -3366,13 +3365,12 @@ CHANGES WITH 225:
options and allows other programs to query the values.
* SELinux access control when enabling/disabling units is no
longer enforced with this release. The previous
implementation was incorrect, and a new corrected
implementation is not yet available. As unit file operations
are still protected via PolicyKit and D-Bus policy this is
not a security problem. Yet, distributions which care about
optimal SELinux support should probably not stabilize on
this release.
longer enforced with this release. The previous implementation
was incorrect, and a new corrected implementation is not yet
available. As unit file operations are still protected via
polkit and D-Bus policy this is not a security problem. Yet,
distributions which care about optimal SELinux support should
probably not stabilize on this release.
* sd-bus gained support for matches of type "arg0has=", that
test for membership of strings in string arrays sent in bus
@ -3744,11 +3742,10 @@ CHANGES WITH 220:
* systemd-importd gained support for verifying downloaded
images with gpg2 (previously only gpg1 was supported).
* systemd-machined, systemd-logind, systemd: most bus calls
are now accessible to unprivileged processes via
PolicyKit. Also, systemd-logind will now allow users to kill
their own sessions without further privileges or
authorization.
* systemd-machined, systemd-logind, systemd: most bus calls are
now accessible to unprivileged processes via polkit. Also,
systemd-logind will now allow users to kill their own sessions
without further privileges or authorization.
* systemd-shutdownd has been removed. This service was
previously responsible for implementing scheduled shutdowns
@ -4530,11 +4527,11 @@ CHANGES WITH 217:
directly from now on, again.
* Support for the new ALLOW_INTERACTIVE_AUTHORIZATION D-Bus
message flag has been added for all of systemd's PolicyKit
authenticated method calls has been added. In particular
this now allows optional interactive authorization via
PolicyKit for many of PID1's privileged operations such as
unit file enabling and disabling.
message flag has been added for all of systemd's polkit
authenticated method calls has been added. In particular this
now allows optional interactive authorization via polkit for
many of PID1's privileged operations such as unit file
enabling and disabling.
* "udevadm hwdb --update" learnt a new switch "--usr" for
placing the rebuilt hardware database in /usr instead of
@ -4613,11 +4610,11 @@ CHANGES WITH 216:
well as the user/group databases, which should enhance
compatibility with certain tools like grpck.
* A number of bus APIs of PID 1 now optionally consult
PolicyKit to permit access for otherwise unprivileged
clients under certain conditions. Note that this currently
doesn't support interactive authentication yet, but this is
expected to be added eventually, too.
* A number of bus APIs of PID 1 now optionally consult polkit to
permit access for otherwise unprivileged clients under certain
conditions. Note that this currently doesn't support
interactive authentication yet, but this is expected to be
added eventually, too.
* /etc/machine-info now has new fields for configuring the
deployment environment of the machine, as well as the
@ -7090,8 +7087,8 @@ CHANGES WITH 198:
the rest of the package. It also has been updated to work
correctly in initrds.
* Policykit previously has been runtime optional, and is now
also compile time optional via a configure switch.
* polkit previously has been runtime optional, and is now also
compile time optional via a configure switch.
* systemd-analyze has been reimplemented in C. Also "systemctl
dot" has moved into systemd-analyze.
@ -7259,9 +7256,9 @@ CHANGES WITH 197:
user/vendor or is automatically determined from ACPI and DMI
information if possible.
* A number of PolicyKit actions are now bound together with
"imply" rules. This should simplify creating UIs because
many actions will now authenticate similar ones as well.
* A number of polkit actions are now bound together with "imply"
rules. This should simplify creating UIs because many actions
will now authenticate similar ones as well.
* Unit files learnt a new condition ConditionACPower= which
may be used to conditionalize a unit depending on whether an
@ -7400,14 +7397,13 @@ CHANGES WITH 196:
to maintain the necessary patches downstream, or find a
different solution. (Talk to us if you have questions!)
* Various systemd components will now bypass PolicyKit checks
for root and otherwise handle properly if PolicyKit is not
found to be around. This should fix most issues for
PolicyKit-less systems. Quite frankly this should have been
this way since day one. It is absolutely our intention to
make systemd work fine on PolicyKit-less systems, and we
consider it a bug if something does not work as it should if
PolicyKit is not around.
* Various systemd components will now bypass polkit checks for
root and otherwise handle properly if polkit is not found to
be around. This should fix most issues for polkit-less
systems. Quite frankly this should have been this way since
day one. It is absolutely our intention to make systemd work
fine on polkit-less systems, and we consider it a bug if
something does not work as it should if polkit is not around.
* For embedded systems it is now possible to build udev and
systemd without blkid and/or kmod support.

2
README
View File

@ -173,7 +173,7 @@ REQUIREMENTS:
NOTE: If using dbus < 1.9.18, you should override the default
policy directory (--with-dbuspolicydir=/etc/dbus-1/system.d).
dracut (optional)
PolicyKit (optional)
polkit (optional)
To build in directory build/:
meson build/ && ninja -C build

View File

@ -117,8 +117,8 @@ systemd_index_xml = custom_target(
output : 'systemd.index.xml',
command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)
foreach tuple : want_man or want_html ? [['systemd.directives', '7', systemd_directives_xml],
['systemd.index', '7', systemd_index_xml]] : []
foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directives_xml],
['systemd.index', '7', systemd_index_xml]] : []
stem = tuple[0]
section = tuple[1]
xml = tuple[2]

View File

@ -204,11 +204,18 @@ manpages = [
['sd_bus_message_append_string_iovec', 'sd_bus_message_append_string_space'],
''],
['sd_bus_message_append_strv', '3', [], ''],
['sd_bus_message_copy', '3', [], ''],
['sd_bus_message_get_cookie', '3', ['sd_bus_message_get_reply_cookie'], ''],
['sd_bus_message_get_monotonic_usec',
'3',
['sd_bus_message_get_realtime_usec', 'sd_bus_message_get_seqnum'],
''],
['sd_bus_message_new_method_error',
'3',
['sd_bus_message_new_method_errno',
'sd_bus_message_new_method_errnof',
'sd_bus_message_new_method_errorf'],
''],
['sd_bus_message_read', '3', ['sd_bus_message_readv'], ''],
['sd_bus_message_read_basic', '3', [], ''],
['sd_bus_message_set_destination', '3', ['sd_bus_message_set_sender'], ''],
@ -222,6 +229,12 @@ manpages = [
['sd_bus_path_decode', 'sd_bus_path_decode_many', 'sd_bus_path_encode_many'],
''],
['sd_bus_process', '3', [], ''],
['sd_bus_reply_method_error',
'3',
['sd_bus_reply_method_errno',
'sd_bus_reply_method_errnof',
'sd_bus_reply_method_errorf'],
''],
['sd_bus_request_name',
'3',
['sd_bus_release_name',
@ -229,6 +242,14 @@ manpages = [
'sd_bus_request_name_async'],
''],
['sd_bus_set_connected_signal', '3', ['sd_bus_get_connected_signal'], ''],
['sd_bus_set_description',
'3',
['sd_bus_get_allow_interactive_authorization',
'sd_bus_get_description',
'sd_bus_set_allow_interactive_authorization',
'sd_bus_set_anonymous',
'sd_bus_set_trusted'],
''],
['sd_bus_set_sender', '3', ['sd_bus_get_sender'], ''],
['sd_bus_set_watch_bind', '3', ['sd_bus_get_watch_bind'], ''],
['sd_bus_slot_set_destroy_callback',

View File

@ -43,34 +43,42 @@
</para>
<para>See
<citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_name_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_owner_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_array</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_string_memfd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_cookie</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_negotiate_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_path_encode</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_allow_interactive_authorization</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_prepare</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_add_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<literallayout><citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_n_queued_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_array</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_string_memfd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_copy</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_cookie</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_get_monotonic_usec</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_read_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_negotiate_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_path_encode</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_reply_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_watch_bind</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_set_slot_destroy_callback</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_slot_floating</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_add_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</literallayout>
for more information about the functions available.</para>
</refsect1>

115
man/sd_bus_message_copy.xml Normal file
View File

@ -0,0 +1,115 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="sd_bus_message_copy" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_message_copy</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_message_copy</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_message_copy</refname>
<refpurpose>Copy the contents of one message to another</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int sd_bus_message_copy</funcdef>
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
<paramdef>sd_bus_message *<parameter>source</parameter></paramdef>
<paramdef>int <parameter>all</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_message_copy()</function> copies the contents from
message <parameter>source</parameter> to <parameter>m</parameter>. If
<parameter>all</parameter> is false, a single complete type is copied
(basic or container). If <parameter>all</parameter> is true, the contents
are copied until the end of the currently open container or the end
of <parameter>source</parameter>.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, this call returns true if anything was copied, and false if
there was nothing to copy. On failure, it returns a negative errno-style error
code.</para>
</refsect1>
<refsect1 id='errors'>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para><parameter>source</parameter> or <parameter>m</parameter> are
<constant>NULL</constant>.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>Message <parameter>m</parameter> has been sealed or
<parameter>source</parameter> has <emphasis>not</emphasis> been sealed.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ESTALE</constant></term>
<listitem><para>Destination message is in invalid state.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENXIO</constant></term>
<listitem><para>Destination message cannot be appended to.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,190 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="sd_bus_message_new_method_error"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_message_new_method_error</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_message_new_method_error</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_message_new_method_error</refname>
<refname>sd_bus_message_new_method_errorf</refname>
<refname>sd_bus_message_new_method_errno</refname>
<refname>sd_bus_message_new_method_errnof</refname>
<refpurpose>Create a an error reply for a method call</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int sd_bus_message_new_method_error</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
<paramdef>const sd_bus_error *<parameter>e</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_message_new_method_errorf</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
<paramdef>const char *<parameter>name</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
<paramdef></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_message_new_method_errno</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
<paramdef>int <parameter>error</parameter></paramdef>
<paramdef>const sd_bus_error *<parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_message_new_method_errnof</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>sd_bus_message **<parameter>m</parameter></paramdef>
<paramdef>int <parameter>error</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>The <function>sd_bus_message_new_method_error()</function> function creates
a new bus message object that is an error reply to the
<parameter>call</parameter> message, and returns it in the
<parameter>m</parameter> output parameter. The error information from error
<parameter>e</parameter> is appended: the <parameter>name</parameter> field of
<parameter>e</parameter> is used as the error identifier in the reply header (for
example an error name such as
<literal>org.freedesktop.DBus.Error.NotSupported</literal> or the equivalent
symbolic <constant>SD_BUS_ERROR_NOT_SUPPORTED</constant>), and the
<parameter>message</parameter> field is set as the human readable error message
string if present. The error <parameter>e</parameter> must have the
<parameter>name</parameter> field set, see
<citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
<para>The <function>sd_bus_message_new_method_errorf()</function> function
creates an error reply similarly to
<function>sd_bus_message_new_method_error()</function>, but instead of a ready
error structure, it takes an error identifier string <parameter>name</parameter>,
plus a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string <parameter>format</parameter> and corresponding arguments. An error
reply is sent with the error identifier <parameter>name</parameter> and the
formatted string as the message. <parameter>name</parameter> and
<parameter>format</parameter> must not be <constant>NULL</constant>.
</para>
<para>The <function>sd_bus_message_new_method_errno()</function> function creates
an error reply similarly to
<function>sd_bus_message_new_method_error()</function>, but in addition to the
error structure <parameter>p</parameter>, it takes an
<citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
error value in parameter <parameter>error</parameter>. If the error
<parameter>p</parameter> is set (see
<citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
it is used in the reply. Otherwise, <parameter>error</parameter> is translated to
an error identifier and used to create a new error structure using
<citerefentry><refentrytitle>sd_bus_error_set_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and that is used in the reply. (If <parameter>error</parameter> is zero, no error
is actually set, and an error reply with no information is created.)</para>
<para>The <function>sd_bus_message_new_method_errnof()</function> function
creates an error reply similarly to
<function>sd_bus_message_new_method_error()</function>. It takes an
<citerefentry><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
error value in parameter <parameter>error</parameter>, plus a <citerefentry
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
format string <parameter>format</parameter> and corresponding arguments.
<literal>%m</literal> may be used in the format string to refer to the error
string corresponding to the specified errno code. The error message is initalized
using the error identifier generated from <constant>error</constant> and the
formatted string. (If <parameter>error</parameter> is zero, no error is actually
set, and an error reply with no information is created.)</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>These functions return 0 if the error reply was successfully created, and a
negative errno-style error code otherwise.</para>
</refsect1>
<refsect1 id='errors'>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The call message <parameter>call</parameter> or the output
parameter <parameter>m</parameter> are <constant>NULL</constant>.</para>
<para>Message <parameter>call</parameter> is not a method call
message.</para>
<para>The error <parameter>error</parameter> parameter to
<function>sd_bus_message_new_method_error</function> is not set, see
<citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>Message <parameter>call</parameter> has been sealed.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOTCONN</constant></term>
<listitem><para>The bus to which message <parameter>call</parameter> is
attached is not connected.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,161 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="sd_bus_reply_method_error"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_reply_method_error</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_reply_method_error</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_reply_method_error</refname>
<refname>sd_bus_reply_method_errorf</refname>
<refname>sd_bus_reply_method_errno</refname>
<refname>sd_bus_reply_method_errnof</refname>
<refpurpose>Reply with an error to a method call</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int sd_bus_reply_method_error</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>const sd_bus_error *<parameter>e</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_reply_method_errorf</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>const char *<parameter>name</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
<paramdef></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_reply_method_errno</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>int <parameter>error</parameter></paramdef>
<paramdef>const sd_bus_error *<parameter>p</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int sd_bus_reply_method_errnof</funcdef>
<paramdef>sd_bus_message *<parameter>call</parameter></paramdef>
<paramdef>int <parameter>error</parameter></paramdef>
<paramdef>const char *<parameter>format</parameter></paramdef>
<paramdef></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>The <function>sd_bus_reply_method_error()</function> function sends an
error reply to the <parameter>call</parameter> message. The error structure
<parameter>e</parameter> specifies the error to send, and is used as described in
<citerefentry><refentrytitle>sd_bus_message_new_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
If no reply is expected to <parameter>call</parameter>, this function returns
success without sending reply.</para>
<para>The <function>sd_bus_reply_method_errorf()</function> is to
<function>sd_bus_reply_method_error()</function> what
<function>sd_bus_message_new_method_errorf()</function> is to
<function>sd_bus_message_new_method_error()</function>.</para>
<para>The <function>sd_bus_reply_method_errno()</function> is to
<function>sd_bus_reply_method_error()</function> what
<function>sd_bus_message_new_method_errno()</function> is to
<function>sd_bus_message_new_method_error()</function>.</para>
<para>The <function>sd_bus_reply_method_errnof()</function> is to
<function>sd_bus_reply_method_error()</function> what
<function>sd_bus_message_new_method_errnof()</function> is to
<function>sd_bus_message_new_method_error()</function>.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>These functions return 0 if the error reply was successfully sent or if
none was expected, and a negative errno-style error code otherwise.</para>
</refsect1>
<refsect1 id='errors'>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>The call message <parameter>call</parameter> is
<constant>NULL</constant>.</para>
<para>Message <parameter>call</parameter> is not a method call message.
</para>
<para>Message <parameter>call</parameter> is not attached to a bus.</para>
<para>The error <parameter>error</parameter> parameter to
<function>sd_bus_reply_method_error</function> is not set, see
<citerefentry><refentrytitle>sd_bus_error_is_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>Message <parameter>call</parameter> has been sealed.
</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOTCONN</constant></term>
<listitem><para>The bus to which message <parameter>call</parameter> is
attached is not connected.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
</variablelist>
<para>In addition, any error message returned by
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>1</manvolnum></citerefentry>
may be returned.</para>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,188 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="sd_bus_set_description" xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_set_description</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_set_description</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_set_description</refname>
<refname>sd_bus_get_description</refname>
<refname>sd_bus_set_anonymous</refname>
<refname>sd_bus_set_trusted</refname>
<refname>sd_bus_set_allow_interactive_authorization</refname>
<refname>sd_bus_get_allow_interactive_authorization</refname>
<refpurpose>Set or query properties of a bus object</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_set_description</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char *<parameter>description</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_get_description</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>const char **<parameter>description</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_set_anonymous</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>int <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_set_trusted</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>int <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_set_allow_interactive_authorization</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>int <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_get_allow_interactive_authorization</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_set_description()</function> sets the description string
that is used in logging to the specified string. The string is copied internally
and freed when the bus object is deallocated. The
<parameter>description</parameter> argument may be <constant>NULL</constant>, in
which case the description is unset. This function must be called before the bus
has been started.</para>
<para><function>sd_bus_get_description()</function> returns a description string
in <parameter>description</parameter>. This string may have been previously set
with <function>sd_bus_set_description()</function> or
<citerefentry><refentrytitle>sd_bus_open_with_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>
or similar. If not set this way, a default string like <literal>system</literal>
or <literal>user</literal> will be returned for the system or user buses,
and <constant>NULL</constant> otherwise.</para>
<para><function>sd_bus_set_anonymous()</function> enables or disables "anonymous
authentication", i.e. lack of authentication, of the bus peer. This function must
be called before the bus has been started. See the <ulink
url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms">Authentication
Mechanisms</ulink> section of the D-Bus specification for details.</para>
<para><function>sd_bus_set_trusted()</function> sets the "trusted" state on the
<parameter>bus</parameter> object. If true, all connections on the bus are
trusted and access to all privileged and unprivileged methods is granted. This
function must be called before the bus has been started.</para>
<para><function>sd_bus_set_allow_interactive_authorization()</function>
enables or disables interactive authorization for method calls. If true,
messages are marked with the
<constant>ALLOW_INTERACTIVE_AUTHORIZATION</constant> flag specified by the
<ulink
url="view-source:https://dbus.freedesktop.org/doc/dbus-specification.html">D-Bus</ulink>
specification, informing the receiving side that the caller is prepared to
wait for interactive authorization, which might take a considerable time to
complete. If this flag is set, the user may be queried for passwords or
confirmation via <ulink
url="http://www.freedesktop.org/wiki/Software/polkit">polkit</ulink> or a
similar framework.</para>
<para><function>sd_bus_get_allow_interactive_authorization()</function> returns
true if interactive authorization is allowed and false if not.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, these functions return 0 or a positive integer. On failure,
they return a negative errno-style error code.</para>
</refsect1>
<refsect1>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>An argument is invalid.</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>The bus cannot be resolved.</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term><constant>-EPERM</constant></term>
<listitem><para>The bus has already been started.</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus was created in a different process.</para></listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
<term><constant>-ENOMEM</constant></term>
<listitem><para>Memory allocation failed.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_open_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_open_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -45,8 +45,10 @@
a session, then this ID is reused as the session ID. Otherwise, an independent session counter is
used.</para></listitem>
<listitem><para>Providing PolicyKit-based access for users for
operations such as system shutdown or sleep</para></listitem>
<listitem><para>Providing <ulink
url="http://www.freedesktop.org/wiki/Software/polkit">polkit</ulink>-based
access for users for operations such as system shutdown or sleep</para>
</listitem>
<listitem><para>Implementing a shutdown/sleep inhibition logic
for applications</para></listitem>

View File

@ -220,7 +220,7 @@ option('smack', type : 'boolean',
option('smack-run-label', type : 'string',
description : 'run systemd --system itself with a specific SMACK label')
option('polkit', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'PolicyKit support')
description : 'polkit support')
option('ima', type : 'boolean',
description : 'IMA support')

View File

@ -50,7 +50,7 @@ int bus_job_method_cancel(sd_bus_message *message, void *userdata, sd_bus_error
/* Access is granted to the job owner */
if (!sd_bus_track_contains(j->bus_track, sd_bus_message_get_sender(message))) {
/* And for everybody else consult PolicyKit */
/* And for everybody else consult polkit */
r = bus_verify_manage_units_async(j->unit->manager, message, error);
if (r < 0)
return r;

View File

@ -3178,7 +3178,7 @@ static int logind_set_wall_message(void) {
#endif
/* Ask systemd-logind, which might grant access to unprivileged users
* through PolicyKit */
* through polkit */
static int logind_reboot(enum action a) {
#if ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@ -8419,7 +8419,7 @@ static int halt_main(void) {
}
/* Try logind if we are a normal user and no special
* mode applies. Maybe PolicyKit allows us to shutdown
* mode applies. Maybe polkit allows us to shutdown
* the machine. */
if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT, ACTION_HALT)) {
r = logind_reboot(arg_action);