[systemd-commits] 24 commits - Makefile.am Makefile-man.am man/sd_bus_creds_get_pid.xml man/sd_bus_creds_new_from_pid.xml man/sd_bus_error_add_map.xml man/sd-bus-errors.xml man/sd_bus_error.xml man/sd_bus_message_append_array.xml man/sd_bus_message_append_basic.xml man/sd_bus_message_append.xml man/sd_bus_negotiate_fds.xml man/sd_bus_request_name.xml man/sd_pid_get_session.xml man/systemd.journal-fields.xml src/backlight src/basic src/binfmt src/core src/firstboot src/gpt-auto-generator src/hibernate-resume src/journal-remote src/login src/machine src/network src/nspawn src/resolve src/rfkill src/shared src/sleep src/test src/udev src/user-sessions src/vconsole

David Herrmann dvdhrm at kemper.freedesktop.org
Thu Jul 9 02:54:20 PDT 2015


 Makefile-man.am                             |  215 +++++++++++++++++
 Makefile.am                                 |    6 
 man/sd-bus-errors.xml                       |  309 +++++++++++++++++++++++++
 man/sd_bus_creds_get_pid.xml                |   59 +++-
 man/sd_bus_creds_new_from_pid.xml           |  150 ++++++++----
 man/sd_bus_error.xml                        |  344 ++++++++++++----------------
 man/sd_bus_error_add_map.xml                |  173 ++++++++++++++
 man/sd_bus_message_append.xml               |   64 +++--
 man/sd_bus_message_append_array.xml         |  123 +++++-----
 man/sd_bus_message_append_basic.xml         |   51 ++--
 man/sd_bus_negotiate_fds.xml                |    2 
 man/sd_bus_request_name.xml                 |   15 -
 man/sd_pid_get_session.xml                  |   83 ++++--
 man/systemd.journal-fields.xml              |    1 
 src/backlight/backlight.c                   |    2 
 src/basic/capability.c                      |    2 
 src/basic/cgroup-util.c                     |   12 
 src/basic/fileio-label.c                    |    2 
 src/basic/fileio.c                          |   78 +++---
 src/basic/fileio.h                          |   12 
 src/basic/smack-util.c                      |    2 
 src/basic/util.c                            |    2 
 src/binfmt/binfmt.c                         |    6 
 src/core/execute.c                          |    2 
 src/core/machine-id-setup.c                 |    2 
 src/core/main.c                             |    2 
 src/core/smack-setup.c                      |    2 
 src/firstboot/firstboot.c                   |    4 
 src/gpt-auto-generator/gpt-auto-generator.c |    3 
 src/hibernate-resume/hibernate-resume.c     |    2 
 src/journal-remote/journal-gatewayd.c       |    2 
 src/login/logind-dbus.c                     |    4 
 src/login/logind-user-dbus.c                |    6 
 src/machine/machine-dbus.c                  |   14 -
 src/network/networkd-link.c                 |    6 
 src/network/networkd-network-bus.c          |    6 
 src/nspawn/nspawn.c                         |    8 
 src/resolve/resolved-dns-packet.c           |    2 
 src/rfkill/rfkill.c                         |    2 
 src/shared/sysctl-util.c                    |    2 
 src/sleep/sleep.c                           |    4 
 src/test/test-btrfs.c                       |    2 
 src/test/test-copy.c                        |    6 
 src/test/test-fileio.c                      |   24 +
 src/test/test-util.c                        |   20 -
 src/udev/udevd.c                            |   10 
 src/user-sessions/user-sessions.c           |    2 
 src/vconsole/vconsole-setup.c               |    4 
 48 files changed, 1336 insertions(+), 518 deletions(-)

New commits:
commit a0f7095171f03517bb44f91c67098ddd53537b54
Merge: 313b98a 207dffe
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 19:00:18 2015 -0300

    Merge pull request #526 from phomes/master
    
    machine: remove unused variables


commit 207dffe2ff2db95aa9974bdca35283ce6a636834
Author: Thomas Hindoe Paaboel Andersen <phomes at gmail.com>
Date:   Wed Jul 8 23:45:49 2015 +0200

    machine: remove unused variables

diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 38a4c7b..dc42ffd 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -55,7 +55,6 @@ static int property_get_id(
                 sd_bus_error *error) {
 
         Machine *m = userdata;
-        int r;
 
         assert(bus);
         assert(reply);
@@ -100,7 +99,6 @@ static int property_get_netif(
                 sd_bus_error *error) {
 
         Machine *m = userdata;
-        int r;
 
         assert(bus);
         assert(reply);

commit 313b98a03bd51628e9268a7d5d89501fa811438e
Merge: 593b07d 6f068ae
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 17:37:06 2015 -0300

    Merge pull request #522 from mbiebl/no-install-readme-md
    
    build-sys: Do not install README.md as end-user documentation


commit 6f068aef44b86bb98942f07356ee0484da26d3d4
Author: Michael Biebl <biebl at debian.org>
Date:   Wed Jul 8 22:27:27 2015 +0200

    build-sys: Do not install README.md as end-user documentation
    
    This file is mostly GitHub glue and not particularly useful to
    end-users. So only add it to the dist tarball but do not install it as
    documentation.

diff --git a/Makefile.am b/Makefile.am
index df27088..e178bdc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -639,7 +639,6 @@ UNINSTALL_DATA_HOOKS += units-uninstall-hook
 
 dist_doc_DATA = \
 	README \
-	README.md \
 	NEWS \
 	CODING_STYLE \
 	LICENSE.LGPL2.1 \
@@ -650,6 +649,7 @@ dist_doc_DATA = \
 	src/libsystemd/sd-bus/GVARIANT-SERIALIZATION
 
 EXTRA_DIST += \
+	README.md \
 	autogen.sh \
 	.dir-locals.el \
 	.vimrc \

commit 593b07d25d31132ce2fc673bb607a17084e1afd6
Merge: 1434eb3 0f82610
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 17:24:20 2015 -0300

    Merge pull request #516 from utezduyar/consistent-get-callback-return
    
    property callback returns are consistent


commit 1434eb3838581f8ee1cef1f15ce9bcd45398183c
Merge: 380aea0 ad118bd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 17:13:53 2015 -0300

    Merge pull request #500 from zonque/fileio
    
    fileio: consolidate write_string_file*()


commit 380aea0c5ba373df9fe37bdf0404442bd9034b92
Merge: 1ad9e2f 2a2e6a0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 16:50:48 2015 -0300

    Merge pull request #520 from zonque/pr-384-rework
    
    man-pages: PR 384 rework


commit 2a2e6a0845dedf57233d2c8a89201a563e0c3c6d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 23 21:41:15 2015 +0200

    man: minor updates to the sd_bus_request_name() documentation

diff --git a/man/sd_bus_request_name.xml b/man/sd_bus_request_name.xml
index 9b0a93d..f07ae09 100644
--- a/man/sd_bus_request_name.xml
+++ b/man/sd_bus_request_name.xml
@@ -45,7 +45,7 @@
   <refnamediv>
     <refname>sd_bus_request_name</refname>
     <refname>sd_bus_release_name</refname>
-    <refpurpose>Request or release a well-known name on a bus</refpurpose>
+    <refpurpose>Request or release a well-known service name on a bus</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
@@ -71,9 +71,9 @@
     <title>Description</title>
 
     <para><function>sd_bus_request_name()</function> requests a
-    well-known name on a bus. It takes a bus connection, a valid bus
-    name and a flags parameter. The flags parameter is a combination
-    of the following flags:</para>
+    well-known service name on a bus. It takes a bus connection, a
+    valid bus name and a flags parameter. The flags parameter is a
+    combination of the following flags:</para>
 
     <variablelist>
       <varlistentry>
@@ -166,8 +166,11 @@
       <varlistentry>
         <term><constant>-EINVAL</constant></term>
 
-        <listitem><para>A specified parameter is
-        invalid.</para></listitem>
+        <listitem><para>A specified parameter is invalid. This is also
+        generated when the requested name is a special service name
+        reserved by the D-Bus specification, or when the operation is
+        requested on a connection that does not refer to a
+        bus.</para></listitem>
       </varlistentry>
 
       <varlistentry>

commit dddbc69577820e6ecce17d3ac836ad865fcbcde2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 23 21:22:56 2015 +0200

    man: document user slice sd-login calls we added a while back

diff --git a/Makefile-man.am b/Makefile-man.am
index 08d22b3..218a299 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -1937,11 +1937,13 @@ MANPAGES_ALIAS += \
 	man/sd_peer_get_session.3 \
 	man/sd_peer_get_slice.3 \
 	man/sd_peer_get_unit.3 \
+	man/sd_peer_get_user_slice.3 \
 	man/sd_peer_get_user_unit.3 \
 	man/sd_pid_get_machine_name.3 \
 	man/sd_pid_get_owner_uid.3 \
 	man/sd_pid_get_slice.3 \
 	man/sd_pid_get_unit.3 \
+	man/sd_pid_get_user_slice.3 \
 	man/sd_pid_get_user_unit.3 \
 	man/sd_seat_can_graphical.3 \
 	man/sd_seat_can_multi_session.3 \
@@ -1979,11 +1981,13 @@ man/sd_peer_get_owner_uid.3: man/sd_pid_get_session.3
 man/sd_peer_get_session.3: man/sd_pid_get_session.3
 man/sd_peer_get_slice.3: man/sd_pid_get_session.3
 man/sd_peer_get_unit.3: man/sd_pid_get_session.3
+man/sd_peer_get_user_slice.3: man/sd_pid_get_session.3
 man/sd_peer_get_user_unit.3: man/sd_pid_get_session.3
 man/sd_pid_get_machine_name.3: man/sd_pid_get_session.3
 man/sd_pid_get_owner_uid.3: man/sd_pid_get_session.3
 man/sd_pid_get_slice.3: man/sd_pid_get_session.3
 man/sd_pid_get_unit.3: man/sd_pid_get_session.3
+man/sd_pid_get_user_slice.3: man/sd_pid_get_session.3
 man/sd_pid_get_user_unit.3: man/sd_pid_get_session.3
 man/sd_seat_can_graphical.3: man/sd_seat_get_active.3
 man/sd_seat_can_multi_session.3: man/sd_seat_get_active.3
@@ -2049,6 +2053,9 @@ man/sd_peer_get_slice.html: man/sd_pid_get_session.html
 man/sd_peer_get_unit.html: man/sd_pid_get_session.html
 	$(html-alias)
 
+man/sd_peer_get_user_slice.html: man/sd_pid_get_session.html
+	$(html-alias)
+
 man/sd_peer_get_user_unit.html: man/sd_pid_get_session.html
 	$(html-alias)
 
@@ -2064,6 +2071,9 @@ man/sd_pid_get_slice.html: man/sd_pid_get_session.html
 man/sd_pid_get_unit.html: man/sd_pid_get_session.html
 	$(html-alias)
 
+man/sd_pid_get_user_slice.html: man/sd_pid_get_session.html
+	$(html-alias)
+
 man/sd_pid_get_user_unit.html: man/sd_pid_get_session.html
 	$(html-alias)
 
diff --git a/man/sd_pid_get_session.xml b/man/sd_pid_get_session.xml
index b46d471..9c6706c 100644
--- a/man/sd_pid_get_session.xml
+++ b/man/sd_pid_get_session.xml
@@ -49,15 +49,17 @@
     <refname>sd_pid_get_owner_uid</refname>
     <refname>sd_pid_get_machine_name</refname>
     <refname>sd_pid_get_slice</refname>
+    <refname>sd_pid_get_user_slice</refname>
     <refname>sd_peer_get_session</refname>
     <refname>sd_peer_get_unit</refname>
     <refname>sd_peer_get_user_unit</refname>
     <refname>sd_peer_get_owner_uid</refname>
     <refname>sd_peer_get_machine_name</refname>
     <refname>sd_peer_get_slice</refname>
-    <refpurpose>Determine session, service, owner of a
-    session, container/VM or slice of a specific
-    PID or socket peer</refpurpose>
+    <refname>sd_peer_get_user_slice</refname>
+    <refpurpose>Determine session, unit, owner of a session,
+    container/VM or slice of a specific PID or socket
+    peer</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
@@ -101,6 +103,12 @@
       </funcprototype>
 
       <funcprototype>
+        <funcdef>int <function>sd_pid_get_user_slice</function></funcdef>
+        <paramdef>pid_t <parameter>pid</parameter></paramdef>
+        <paramdef>char **<parameter>slice</parameter></paramdef>
+      </funcprototype>
+
+      <funcprototype>
         <funcdef>int <function>sd_peer_get_session</function></funcdef>
         <paramdef>int <parameter>fd</parameter></paramdef>
         <paramdef>char **<parameter>session</parameter></paramdef>
@@ -135,6 +143,12 @@
         <paramdef>int <parameter>fd</parameter></paramdef>
         <paramdef>char **<parameter>slice</parameter></paramdef>
       </funcprototype>
+
+      <funcprototype>
+        <funcdef>int <function>sd_peer_get_user_slice</function></funcdef>
+        <paramdef>int <parameter>fd</parameter></paramdef>
+        <paramdef>char **<parameter>slice</parameter></paramdef>
+      </funcprototype>
     </funcsynopsis>
   </refsynopsisdiv>
 
@@ -155,30 +169,29 @@
     call after use.</para>
 
     <para><function>sd_pid_get_unit()</function> may be used to
-    determine the systemd system unit (i.e. system service) identifier
-    of a process identified by the specified PID. The unit name is a
-    short string, suitable for usage in file system paths. Note that
-    not all processes are part of a system unit/service (e.g. user
-    processes, or kernel threads). For processes not being part of a
-    systemd system unit this function will fail with -ENXIO (More
-    specifically: this call will not work for processes that are part
-    of user units, use <function>sd_pid_get_user_unit()</function> for
-    that.) The returned string needs to be freed with the libc
-    <citerefentry
+    determine the systemd system unit (i.e. system service or scope
+    unit) identifier of a process identified by the specified PID. The
+    unit name is a short string, suitable for usage in file system
+    paths. Note that not all processes are part of a system
+    unit/service (e.g. user processes, or kernel threads). For
+    processes not being part of a systemd system unit this function
+    will fail with -ENXIO (More specifically: this call will not work
+    for kernel threads.) The returned string needs to be freed with
+    the libc <citerefentry
     project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     call after use.</para>
 
     <para><function>sd_pid_get_user_unit()</function> may be used to
-    determine the systemd user unit (i.e. user service) identifier of
-    a process identified by the specified PID. This is similar to
-    <function>sd_pid_get_unit()</function> but applies to user units
-    instead of system units.</para>
+    determine the systemd user unit (i.e. user service or scope unit)
+    identifier of a process identified by the specified PID. This is
+    similar to <function>sd_pid_get_unit()</function> but applies to
+    user units instead of system units.</para>
 
     <para><function>sd_pid_get_owner_uid()</function> may be used to
-    determine the Unix user identifier of the owner of the session of
-    a process identified the specified PID. Note that this function
-    will succeed for user processes which are shared between multiple
-    login sessions of the same user, where
+    determine the Unix UID (user identifier) of the owner of the
+    session of a process identified the specified PID. Note that this
+    function will succeed for user processes which are shared between
+    multiple login sessions of the same user, where
     <function>sd_pid_get_session()</function> will fail. For processes
     not being part of a login session and not being a shared process
     of a user this function will fail with -ENXIO.</para>
@@ -200,6 +213,10 @@
     <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     call after use.</para>
 
+    <para>Similar, <function>sd_pid_get_user_slice()</function>
+    returns the user slice (as managed by the user's systemd instance)
+    of a process.</para>
+
     <para>If the <varname>pid</varname> parameter of any of these
     functions is passed as 0, the operation is executed for the
     calling process.</para>
@@ -208,10 +225,14 @@
     <function>sd_peer_get_unit()</function>,
     <function>sd_peer_get_user_unit()</function>,
     <function>sd_peer_get_owner_uid()</function>,
-    <function>sd_peer_get_machine_name()</function> and
-    <function>sd_peer_get_slice()</function> calls operate similar to
-    their PID counterparts, but operate on a connected AF_UNIX socket
-    and retrieve information about the connected peer process.</para>
+    <function>sd_peer_get_machine_name()</function>,
+    <function>sd_peer_get_slice()</function> and
+    <function>sd_peer_get_user_slice()</function> calls operate
+    similar to their PID counterparts, but operate on a connected
+    AF_UNIX socket and retrieve information about the connected peer
+    process. Note that these fields are retrieved via
+    <filename>/proc</filename>, and hence are not suitable for
+    authorization purposes, as they are subject to races.</para>
   </refsect1>
 
   <refsect1>
@@ -262,15 +283,17 @@
     <function>sd_pid_get_owner_uid()</function>,
     <function>sd_pid_get_machine_name()</function>,
     <function>sd_pid_get_slice()</function>,
+    <function>sd_pid_get_user_slice()</function>,
     <function>sd_peer_get_session()</function>,
     <function>sd_peer_get_unit()</function>,
     <function>sd_peer_get_user_unit()</function>,
     <function>sd_peer_get_owner_uid()</function>,
-    <function>sd_peer_get_machine_name()</function> and
-    <function>sd_peer_get_slice()</function> interfaces are
-    available as a shared library, which can be compiled
-    and linked to with the
-    <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    <function>sd_peer_get_machine_name()</function>,
+    <function>sd_peer_get_slice()</function> and
+    <function>sd_peer_get_user_slice()</function> interfaces are
+    available as a shared library, which can be compiled and linked to
+    with the <constant>libsystemd</constant> <citerefentry
+    project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     file.</para>
 
     <para>Note that the login session identifier as

commit 02855643499f63045159fec72f23a339ef5a64d6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 23 20:44:15 2015 +0200

    man: fix sd_bus_negotiate_timestamps documentation link-up

diff --git a/Makefile-man.am b/Makefile-man.am
index 950207b..08d22b3 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -285,7 +285,7 @@ MANPAGES_ALIAS += \
 	man/sd_bus_message_get_reply_cookie.3 \
 	man/sd_bus_message_get_seqnum.3 \
 	man/sd_bus_negotiate_creds.3 \
-	man/sd_bus_negotiate_timestamps.3 \
+	man/sd_bus_negotiate_timestamp.3 \
 	man/sd_bus_open.3 \
 	man/sd_bus_open_system.3 \
 	man/sd_bus_open_system_machine.3 \
@@ -571,7 +571,7 @@ man/sd_bus_message_get_realtime_usec.3: man/sd_bus_message_get_monotonic_usec.3
 man/sd_bus_message_get_reply_cookie.3: man/sd_bus_message_get_cookie.3
 man/sd_bus_message_get_seqnum.3: man/sd_bus_message_get_monotonic_usec.3
 man/sd_bus_negotiate_creds.3: man/sd_bus_negotiate_fds.3
-man/sd_bus_negotiate_timestamps.3: man/sd_bus_negotiate_fds.3
+man/sd_bus_negotiate_timestamp.3: man/sd_bus_negotiate_fds.3
 man/sd_bus_open.3: man/sd_bus_default.3
 man/sd_bus_open_system.3: man/sd_bus_default.3
 man/sd_bus_open_system_machine.3: man/sd_bus_default.3
@@ -1103,7 +1103,7 @@ man/sd_bus_message_get_seqnum.html: man/sd_bus_message_get_monotonic_usec.html
 man/sd_bus_negotiate_creds.html: man/sd_bus_negotiate_fds.html
 	$(html-alias)
 
-man/sd_bus_negotiate_timestamps.html: man/sd_bus_negotiate_fds.html
+man/sd_bus_negotiate_timestamp.html: man/sd_bus_negotiate_fds.html
 	$(html-alias)
 
 man/sd_bus_open.html: man/sd_bus_default.html
diff --git a/man/sd_bus_negotiate_fds.xml b/man/sd_bus_negotiate_fds.xml
index 04042f2..1be44e2 100644
--- a/man/sd_bus_negotiate_fds.xml
+++ b/man/sd_bus_negotiate_fds.xml
@@ -44,7 +44,7 @@
 
   <refnamediv>
     <refname>sd_bus_negotiate_fds</refname>
-    <refname>sd_bus_negotiate_timestamps</refname>
+    <refname>sd_bus_negotiate_timestamp</refname>
     <refname>sd_bus_negotiate_creds</refname>
 
     <refpurpose>Control feature negotiation on bus connections</refpurpose>

commit f6f7a9848e27fbc1748aec9264e58a2aeaf736db
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 23 20:42:57 2015 +0200

    man: fully document sd_bus_creds subsystem
    
    [@zonque: typo fixed, reported by @ronnychevalier]

diff --git a/Makefile-man.am b/Makefile-man.am
index 35874e0..950207b 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -227,6 +227,7 @@ MANPAGES_ALIAS += \
 	man/reboot.8 \
 	man/sd_bus_creds_get_audit_login_uid.3 \
 	man/sd_bus_creds_get_audit_session_id.3 \
+	man/sd_bus_creds_get_augmented_mask.3 \
 	man/sd_bus_creds_get_cgroup.3 \
 	man/sd_bus_creds_get_cmdline.3 \
 	man/sd_bus_creds_get_comm.3 \
@@ -252,6 +253,7 @@ MANPAGES_ALIAS += \
 	man/sd_bus_creds_get_uid.3 \
 	man/sd_bus_creds_get_unique_name.3 \
 	man/sd_bus_creds_get_unit.3 \
+	man/sd_bus_creds_get_user_slice.3 \
 	man/sd_bus_creds_get_user_unit.3 \
 	man/sd_bus_creds_get_well_known_names.3 \
 	man/sd_bus_creds_has_bounding_cap.3 \
@@ -511,6 +513,7 @@ man/poweroff.8: man/halt.8
 man/reboot.8: man/halt.8
 man/sd_bus_creds_get_audit_login_uid.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_audit_session_id.3: man/sd_bus_creds_get_pid.3
+man/sd_bus_creds_get_augmented_mask.3: man/sd_bus_creds_new_from_pid.3
 man/sd_bus_creds_get_cgroup.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_cmdline.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_comm.3: man/sd_bus_creds_get_pid.3
@@ -536,6 +539,7 @@ man/sd_bus_creds_get_tty.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_uid.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_unique_name.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_unit.3: man/sd_bus_creds_get_pid.3
+man/sd_bus_creds_get_user_slice.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_user_unit.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_get_well_known_names.3: man/sd_bus_creds_get_pid.3
 man/sd_bus_creds_has_bounding_cap.3: man/sd_bus_creds_get_pid.3
@@ -925,6 +929,9 @@ man/sd_bus_creds_get_audit_login_uid.html: man/sd_bus_creds_get_pid.html
 man/sd_bus_creds_get_audit_session_id.html: man/sd_bus_creds_get_pid.html
 	$(html-alias)
 
+man/sd_bus_creds_get_augmented_mask.html: man/sd_bus_creds_new_from_pid.html
+	$(html-alias)
+
 man/sd_bus_creds_get_cgroup.html: man/sd_bus_creds_get_pid.html
 	$(html-alias)
 
@@ -1000,6 +1007,9 @@ man/sd_bus_creds_get_unique_name.html: man/sd_bus_creds_get_pid.html
 man/sd_bus_creds_get_unit.html: man/sd_bus_creds_get_pid.html
 	$(html-alias)
 
+man/sd_bus_creds_get_user_slice.html: man/sd_bus_creds_get_pid.html
+	$(html-alias)
+
 man/sd_bus_creds_get_user_unit.html: man/sd_bus_creds_get_pid.html
 	$(html-alias)
 
diff --git a/man/sd_bus_creds_get_pid.xml b/man/sd_bus_creds_get_pid.xml
index 13f885c..4162fab 100644
--- a/man/sd_bus_creds_get_pid.xml
+++ b/man/sd_bus_creds_get_pid.xml
@@ -61,8 +61,9 @@
     <refname>sd_bus_creds_get_cmdline</refname>
     <refname>sd_bus_creds_get_cgroup</refname>
     <refname>sd_bus_creds_get_unit</refname>
-    <refname>sd_bus_creds_get_user_unit</refname>
     <refname>sd_bus_creds_get_slice</refname>
+    <refname>sd_bus_creds_get_user_unit</refname>
+    <refname>sd_bus_creds_get_user_slice</refname>
     <refname>sd_bus_creds_get_session</refname>
     <refname>sd_bus_creds_get_owner_uid</refname>
     <refname>sd_bus_creds_has_effective_cap</refname>
@@ -193,13 +194,19 @@
       </funcprototype>
 
       <funcprototype>
+        <funcdef>int <function>sd_bus_creds_get_slice</function></funcdef>
+        <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
+        <paramdef>const char **<parameter>slice</parameter></paramdef>
+      </funcprototype>
+
+      <funcprototype>
         <funcdef>int <function>sd_bus_creds_get_user_unit</function></funcdef>
         <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
         <paramdef>const char **<parameter>unit</parameter></paramdef>
       </funcprototype>
 
       <funcprototype>
-        <funcdef>int <function>sd_bus_creds_get_slice</function></funcdef>
+        <funcdef>int <function>sd_bus_creds_get_user_slice</function></funcdef>
         <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
         <paramdef>const char **<parameter>slice</parameter></paramdef>
       </funcprototype>
@@ -288,9 +295,9 @@
   <refsect1>
     <title>Description</title>
 
-    <para>These functions return information from an
-    <parameter>sd_bus_creds</parameter> credential object. Credential
-    objects may be created with
+    <para>These functions return credential information from an
+    <parameter>sd_bus_creds</parameter> object. Credential objects may
+    be created with
     <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
     in which case they describe the credentials of the process
     identified by the specified PID, with
@@ -301,7 +308,13 @@
     in which case they describe the credentials of the creator of a
     bus, or with
     <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-    in which case they describe the credentials of the sender of the message.</para>
+    in which case they describe the credentials of the sender of the
+    message.</para>
+
+    <para>Not all credential fields are part of every
+    <literal>sd_bus_creds</literal> object. Use
+    <citerefentry><refentrytitle>sd_bus_creds_get_mask</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    to determine the mask of fields available.</para>
 
     <para><function>sd_bus_creds_get_pid()</function> will retrieve
     the PID (process identifier). Similar,
@@ -374,19 +387,22 @@
     <para><function>sd_bus_creds_get_slice()</function> will retrieve
     the systemd slice (a unit in the system instance of systemd) that
     the process is part of. See
-    <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
+    <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Similar,
+    <function>sd_bus_creds_get_user_slice()</function> retrieves the
+    systemd slice of the process, in the user instance of systemd.
     </para>
 
     <para><function>sd_bus_creds_get_session()</function> will
-    retrieve the logind session that the process is part of. See
+    retrieve the identifier of the login session that the process is
+    part of. See
     <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>. For
     processes that are not part of a session returns -ENXIO.
     </para>
 
     <para><function>sd_bus_creds_get_owner_uid()</function> will
     retrieve the numeric UID (user identifier) of the user who owns
-    the session that the process is part of. See
-    <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+    the login session that the process is part of. See
+    <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
     For processes that are not part of a session returns -ENXIO.
     </para>
 
@@ -395,7 +411,7 @@
     <parameter>capability</parameter> was set in the effective
     capabilities mask. A positive return value means that is was
     set, zero means that it was not set, and a negative return
-    value signifies an error. See
+    value indicates an error. See
     <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
     and <varname>Capabilities=</varname> and
     <varname>CapabilityBoundingSet=</varname> settings in
@@ -427,8 +443,8 @@
     processes that are not part of an audit session.</para>
 
     <para><function>sd_bus_creds_get_tty()</function> will retrieve
-    the controlling TTY. Returns -ENXIO for processes that have no
-    controlling TTY.</para>
+    the controlling TTY, without the prefixing "/dev/". Returns -ENXIO
+    for processes that have no controlling TTY.</para>
 
     <para><function>sd_bus_creds_get_unique_name()</function> will
     retrieve the D-Bus unique name. See <ulink
@@ -489,8 +505,9 @@
         <listitem><para>Given field is not specified for the described
         process or peer. This will be returned by
         <function>sd_bus_get_unit()</function>,
-        <function>sd_bus_get_user_unit()</function>,
         <function>sd_bus_get_slice()</function>,
+        <function>sd_bus_get_user_unit()</function>,
+        <function>sd_bus_get_user_slice()</function>,
         <function>sd_bus_get_session()</function>, and
         <function>sd_bus_get_owner_uid()</function> if the process is
         not part of a systemd system unit, systemd user unit, systemd
@@ -526,10 +543,11 @@
   <refsect1>
     <title>Notes</title>
 
-    <para><function>sd_bus_open_user()</function> and other functions
-    described here are available as a shared library, which can be
-    compiled and linked to with the
-    <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    <para><function>sd_bus_creds_get_pid()</function> and the other
+    functions described here are available as a shared library, which
+    can be compiled and linked to with the
+    <constant>libsystemd</constant> <citerefentry
+    project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     file.</para>
   </refsect1>
 
@@ -539,8 +557,9 @@
     <para>
       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
+      <citerefentry project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
+      <citerefentry project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
       <citerefentry project='man-pages'><refentrytitle>credentials</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
       <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
diff --git a/man/sd_bus_creds_new_from_pid.xml b/man/sd_bus_creds_new_from_pid.xml
index 8c054a5..a78d3f5 100644
--- a/man/sd_bus_creds_new_from_pid.xml
+++ b/man/sd_bus_creds_new_from_pid.xml
@@ -45,6 +45,7 @@
   <refnamediv>
     <refname>sd_bus_creds_new_from_pid</refname>
     <refname>sd_bus_creds_get_mask</refname>
+    <refname>sd_bus_creds_get_augmented_mask</refname>
     <refname>sd_bus_creds_ref</refname>
     <refname>sd_bus_creds_unref</refname>
 
@@ -68,6 +69,11 @@
       </funcprototype>
 
       <funcprototype>
+        <funcdef>uint64_t <function>sd_bus_creds_get_augmented_mask</function></funcdef>
+        <paramdef>const sd_bus_creds *<parameter>c</parameter></paramdef>
+      </funcprototype>
+
+      <funcprototype>
         <funcdef>sd_bus_creds *<function>sd_bus_creds_ref</function></funcdef>
         <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
       </funcprototype>
@@ -80,17 +86,26 @@
 
     <para>
       <constant>SD_BUS_CREDS_PID</constant>,
+      <constant>SD_BUS_CREDS_PPID</constant>,
       <constant>SD_BUS_CREDS_TID</constant>,
       <constant>SD_BUS_CREDS_UID</constant>,
+      <constant>SD_BUS_CREDS_EUID</constant>,
+      <constant>SD_BUS_CREDS_SUID</constant>,
+      <constant>SD_BUS_CREDS_FSUID</constant>,
       <constant>SD_BUS_CREDS_GID</constant>,
+      <constant>SD_BUS_CREDS_EGID</constant>,
+      <constant>SD_BUS_CREDS_SGID</constant>,
+      <constant>SD_BUS_CREDS_FSGID</constant>,
+      <constant>SD_BUS_CREDS_SUPPLEMENTARY_GIDS</constant>,
       <constant>SD_BUS_CREDS_COMM</constant>,
       <constant>SD_BUS_CREDS_TID_COMM</constant>,
       <constant>SD_BUS_CREDS_EXE</constant>,
       <constant>SD_BUS_CREDS_CMDLINE</constant>,
       <constant>SD_BUS_CREDS_CGROUP</constant>,
       <constant>SD_BUS_CREDS_UNIT</constant>,
-      <constant>SD_BUS_CREDS_USER_UNIT</constant>,
       <constant>SD_BUS_CREDS_SLICE</constant>,
+      <constant>SD_BUS_CREDS_USER_UNIT</constant>,
+      <constant>SD_BUS_CREDS_USER_SLICE</constant>,
       <constant>SD_BUS_CREDS_SESSION</constant>,
       <constant>SD_BUS_CREDS_OWNER_UID</constant>,
       <constant>SD_BUS_CREDS_EFFECTIVE_CAPS</constant>,
@@ -100,8 +115,11 @@
       <constant>SD_BUS_CREDS_SELINUX_CONTEXT</constant>,
       <constant>SD_BUS_CREDS_AUDIT_SESSION_ID</constant>,
       <constant>SD_BUS_CREDS_AUDIT_LOGIN_UID</constant>,
+      <constant>SD_BUS_CREDS_TTY</constant>,
       <constant>SD_BUS_CREDS_UNIQUE_NAME</constant>,
       <constant>SD_BUS_CREDS_WELL_KNOWN_NAMES</constant>,
+      <constant>SD_BUS_CREDS_DESCRIPTION</constant>,
+      <constant>SD_BUS_CREDS_AUGMENT</constant>,
       <constant>_SD_BUS_CREDS_ALL</constant>
     </para>
   </refsynopsisdiv>
@@ -109,25 +127,39 @@
   <refsect1>
     <title>Description</title>
 
-    <para><function>sd_bus_creds_new_from_pid()</function> creates a new
-    credentials object and fills it with information about the process
-    <parameter>pid</parameter>. This pointer to this object will
-    be stored in <parameter>ret</parameter> pointer.</para>
+    <para><function>sd_bus_creds_new_from_pid()</function> creates a
+    new credentials object and fills it with information about the
+    process <parameter>pid</parameter>. The pointer to this object
+    will be stored in <parameter>ret</parameter> pointer. Note that
+    credential objects may also be created and retrieved via
+    <citerefentry><refentrytitle>sd_bus_get_name_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+    <citerefentry><refentrytitle>sd_bus_get_owner_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    and
+    <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
 
     <para>The information that will be stored is determined by
     <parameter>creds_mask</parameter>. It may contain a subset of ORed
     constants <constant>SD_BUS_CREDS_PID</constant>,
+    <constant>SD_BUS_CREDS_PPID</constant>,
     <constant>SD_BUS_CREDS_TID</constant>,
     <constant>SD_BUS_CREDS_UID</constant>,
+    <constant>SD_BUS_CREDS_EUID</constant>,
+    <constant>SD_BUS_CREDS_SUID</constant>,
+    <constant>SD_BUS_CREDS_FSUID</constant>,
     <constant>SD_BUS_CREDS_GID</constant>,
+    <constant>SD_BUS_CREDS_EGID</constant>,
+    <constant>SD_BUS_CREDS_SGID</constant>,
+    <constant>SD_BUS_CREDS_FSGID</constant>,
+    <constant>SD_BUS_CREDS_SUPPLEMENTARY_GIDS</constant>,
     <constant>SD_BUS_CREDS_COMM</constant>,
     <constant>SD_BUS_CREDS_TID_COMM</constant>,
     <constant>SD_BUS_CREDS_EXE</constant>,
     <constant>SD_BUS_CREDS_CMDLINE</constant>,
     <constant>SD_BUS_CREDS_CGROUP</constant>,
     <constant>SD_BUS_CREDS_UNIT</constant>,
-    <constant>SD_BUS_CREDS_USER_UNIT</constant>,
     <constant>SD_BUS_CREDS_SLICE</constant>,
+    <constant>SD_BUS_CREDS_USER_UNIT</constant>,
+    <constant>SD_BUS_CREDS_USER_SLICE</constant>,
     <constant>SD_BUS_CREDS_SESSION</constant>,
     <constant>SD_BUS_CREDS_OWNER_UID</constant>,
     <constant>SD_BUS_CREDS_EFFECTIVE_CAPS</constant>,
@@ -137,34 +169,71 @@
     <constant>SD_BUS_CREDS_SELINUX_CONTEXT</constant>,
     <constant>SD_BUS_CREDS_AUDIT_SESSION_ID</constant>,
     <constant>SD_BUS_CREDS_AUDIT_LOGIN_UID</constant>,
+    <constant>SD_BUS_CREDS_TTY</constant>,
     <constant>SD_BUS_CREDS_UNIQUE_NAME</constant>,
     <constant>SD_BUS_CREDS_WELL_KNOWN_NAMES</constant>,
-    or <constant>_SD_BUS_CREDS_ALL</constant> to indicate
-    all known fields.</para>
+    <constant>SD_BUS_CREDS_DESCRIPTION</constant>. Use the special
+    value <constant>_SD_BUS_CREDS_ALL</constant> to request all
+    supported fields. The <constant>SD_BUS_CREDS_AUGMENT</constant>
+    may not be ORed into the mask for invocations of
+    <function>sd_bus_creds_new_from_pid()</function>.</para>
 
     <para>Fields can be retrieved from the credentials object using
     <citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     and other functions which correspond directly to the constants
     listed above.</para>
 
-    <para>A mask of fields which were actually successfully set
-    (acquired from <filename>/proc</filename>, etc.) can be retrieved
-    with <function>sd_bus_creds_get_mask()</function>. If the
-    credentials object was created with
+    <para>A mask of fields which were actually successfully retrieved
+    can be retrieved with
+    <function>sd_bus_creds_get_mask()</function>. If the credentials
+    object was created with
     <function>sd_bus_creds_new_from_pid()</function>, this will be a
     subset of fields requested in <parameter>creds_mask</parameter>.
     </para>
 
-    <para><function>sd_bus_creds_ref</function> creates a new
+    <para>Similar to <function>sd_bus_creds_get_mask()</function> the
+    function <function>sd_bus_creds_get_augmented_mask()</function>
+    returns a bitmask of field constants. The mask indicates which
+    credential fields have been retrieved in a non-atomic fashion. For
+    credential objects created via
+    <function>sd_bus_creds_new_from_pid()</function> this mask will be
+    identical to the mask returned by
+    <function>sd_bus_creds_get_mask()</function>. However, for
+    credential objects retrieved via
+    <function>sd_bus_get_name_creds()</function> this mask will be set
+    for the credential fields that could not be determined atomically
+    at peer connection time, and which were later added by reading
+    augmenting credential data from
+    <filename>/proc</filename>. Similar, for credential objects
+    retrieved via <function>sd_bus_get_owner_creds()</function> the
+    mask is set for the fields that could not be determined atomically
+    at bus creation time, but have been augmented. Similar, for
+    credential objects retrieved via
+    <function>sd_bus_message_get_creds()</function> the mask is set
+    for the fields that could not be determined atomically at message
+    send time, but have been augmented. The mask returned by
+    <function>sd_bus_creds_get_augmented_mask()</function> is always a
+    subset of (or identical to) the mask returned by
+    <function>sd_bus_creds_get_mask()</function> for the same
+    object. The latter call hence returns all credential fields
+    available in the credential object, the former then marks the
+    subset of those that have been augmented. Note that augmented
+    fields are unsuitable for authorization decisions as they may be
+    retrieved at different times, thus being subject to races. Hence
+    augmented fields should be used exclusively for informational
+    purposes.
+    </para>
+
+    <para><function>sd_bus_creds_ref()</function> creates a new
     reference to the credentials object <parameter>c</parameter>. This
     object will not be destroyed until
-    <function>sd_bus_creds_unref</function> has been called as many
+    <function>sd_bus_creds_unref()</function> has been called as many
     times plus once more. Once the reference count has dropped to zero,
     <parameter>c</parameter> cannot be used anymore, so further
     calls to <function>sd_bus_creds_ref(c)</function> or
     <function>sd_bus_creds_unref(c)</function> are illegal.</para>
 
-    <para><function>sd_bus_creds_unref</function> destroys a reference
+    <para><function>sd_bus_creds_unref()</function> destroys a reference
     to <parameter>c</parameter>.</para>
   </refsect1>
 
@@ -178,10 +247,15 @@
     <para><function>sd_bus_creds_get_mask()</function> returns the
     mask of successfully acquired fields.</para>
 
-    <para><function>sd_bus_creds_ref</function> always returns the
+    <para><function>sd_bus_creds_get_augmented_mask()</function>
+    returns the mask of fields that have been augmented from data in
+    <filename>/proc</filename>, and are thus not suitable for
+    authorization decisions.</para>
+
+    <para><function>sd_bus_creds_ref()</function> always returns the
     argument.</para>
 
-    <para><function>sd_bus_creds_unref</function> always returns
+    <para><function>sd_bus_creds_unref()</function> always returns
     <constant>NULL</constant>.</para>
   </refsect1>
 
@@ -222,16 +296,23 @@
 
         <listitem><para>Memory allocation failed.</para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><constant>-EOPNOTSUPP</constant></term>
+
+        <listitem><para>One of the requested fields is unknown to the local system.</para></listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
   <refsect1>
     <title>Notes</title>
 
-    <para><function>sd_bus_creds_new_from_pid()</function> is
-    available as a shared library, which can be compiled and linked to
-    with the
-    <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    <para><function>sd_bus_creds_new_from_pid()</function> and the
+    other calls described here are available as a shared library,
+    which can be compiled and linked to with the
+    <constant>libsystemd</constant> <citerefentry
+    project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     file.</para>
   </refsect1>
 
@@ -241,31 +322,10 @@
     <para>
       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_tid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_gid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_comm</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_tid_comm</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_exe</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_cmdline</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_cgroup</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_unit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_user_unit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_slice</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_session</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_owner_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_has_effective_cap</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_has_permitted_cap</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_has_inheritable_cap</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_has_bounding_cap</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_selinux_context</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_audit_session_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_audit_login_uid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_unique_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_creds_get_well_known_names</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_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     </para>
   </refsect1>
 

commit 9d3e5d11bee9ab29a479e534622bb1b23daf9fab
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jun 23 19:37:28 2015 +0200

    man: fully document sd-bus' error APIs
    
    [@zonque: Some minor nits fixed as pointed out by @ronnychevalier,
     dropped class='sd-bus-errors' to fix python logic]

diff --git a/Makefile-man.am b/Makefile-man.am
index 74a1f4c..35874e0 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -24,6 +24,7 @@ MANPAGES += \
 	man/machine-id.5 \
 	man/machine-info.5 \
 	man/os-release.5 \
+	man/sd-bus-errors.3 \
 	man/sd-daemon.3 \
 	man/sd-id128.3 \
 	man/sd-journal.3 \
@@ -32,6 +33,7 @@ MANPAGES += \
 	man/sd_bus_creds_new_from_pid.3 \
 	man/sd_bus_default.3 \
 	man/sd_bus_error.3 \
+	man/sd_bus_error_add_map.3 \
 	man/sd_bus_message_append.3 \
 	man/sd_bus_message_append_array.3 \
 	man/sd_bus_message_append_basic.3 \
@@ -161,6 +163,40 @@ MANPAGES += \
 	man/udevadm.8
 MANPAGES_ALIAS += \
 	man/SD_ALERT.3 \
+	man/SD_BUS_ERROR_ACCESS_DENIED.3 \
+	man/SD_BUS_ERROR_ADDRESS_IN_USE.3 \
+	man/SD_BUS_ERROR_AUTH_FAILED.3 \
+	man/SD_BUS_ERROR_BAD_ADDRESS.3 \
+	man/SD_BUS_ERROR_DISCONNECTED.3 \
+	man/SD_BUS_ERROR_END.3 \
+	man/SD_BUS_ERROR_FAILED.3 \
+	man/SD_BUS_ERROR_FILE_EXISTS.3 \
+	man/SD_BUS_ERROR_FILE_NOT_FOUND.3 \
+	man/SD_BUS_ERROR_INCONSISTENT_MESSAGE.3 \
+	man/SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED.3 \
+	man/SD_BUS_ERROR_INVALID_ARGS.3 \
+	man/SD_BUS_ERROR_INVALID_SIGNATURE.3 \
+	man/SD_BUS_ERROR_IO_ERROR.3 \
+	man/SD_BUS_ERROR_LIMITS_EXCEEDED.3 \
+	man/SD_BUS_ERROR_MAKE_CONST.3 \
+	man/SD_BUS_ERROR_MAP.3 \
+	man/SD_BUS_ERROR_MATCH_RULE_INVALID.3 \
+	man/SD_BUS_ERROR_MATCH_RULE_NOT_FOUND.3 \
+	man/SD_BUS_ERROR_NAME_HAS_NO_OWNER.3 \
+	man/SD_BUS_ERROR_NOT_SUPPORTED.3 \
+	man/SD_BUS_ERROR_NO_MEMORY.3 \
+	man/SD_BUS_ERROR_NO_NETWORK.3 \
+	man/SD_BUS_ERROR_NO_REPLY.3 \
+	man/SD_BUS_ERROR_NO_SERVER.3 \
+	man/SD_BUS_ERROR_NULL.3 \
+	man/SD_BUS_ERROR_PROPERTY_READ_ONLY.3 \
+	man/SD_BUS_ERROR_SERVICE_UNKNOWN.3 \
+	man/SD_BUS_ERROR_TIMEOUT.3 \
+	man/SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN.3 \
+	man/SD_BUS_ERROR_UNKNOWN_INTERFACE.3 \
+	man/SD_BUS_ERROR_UNKNOWN_METHOD.3 \
+	man/SD_BUS_ERROR_UNKNOWN_OBJECT.3 \
+	man/SD_BUS_ERROR_UNKNOWN_PROPERTY.3 \
 	man/SD_CRIT.3 \
 	man/SD_DEBUG.3 \
 	man/SD_EMERG.3 \
@@ -231,10 +267,13 @@ MANPAGES_ALIAS += \
 	man/sd_bus_error_get_errno.3 \
 	man/sd_bus_error_has_name.3 \
 	man/sd_bus_error_is_set.3 \
+	man/sd_bus_error_map.3 \
 	man/sd_bus_error_set.3 \
 	man/sd_bus_error_set_const.3 \
 	man/sd_bus_error_set_errno.3 \
 	man/sd_bus_error_set_errnof.3 \
+	man/sd_bus_error_set_errnofv.3 \
+	man/sd_bus_error_setf.3 \
 	man/sd_bus_message_append_array_iovec.3 \
 	man/sd_bus_message_append_array_memfd.3 \
 	man/sd_bus_message_append_array_space.3 \
@@ -408,6 +447,40 @@ MANPAGES_ALIAS += \
 	man/udev_unref.3 \
 	man/user.conf.d.5
 man/SD_ALERT.3: man/sd-daemon.3
+man/SD_BUS_ERROR_ACCESS_DENIED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_ADDRESS_IN_USE.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_AUTH_FAILED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_BAD_ADDRESS.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_DISCONNECTED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_END.3: man/sd_bus_error_add_map.3
+man/SD_BUS_ERROR_FAILED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_FILE_EXISTS.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_FILE_NOT_FOUND.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_INCONSISTENT_MESSAGE.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_INVALID_ARGS.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_INVALID_SIGNATURE.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_IO_ERROR.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_LIMITS_EXCEEDED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_MAKE_CONST.3: man/sd_bus_error.3
+man/SD_BUS_ERROR_MAP.3: man/sd_bus_error_add_map.3
+man/SD_BUS_ERROR_MATCH_RULE_INVALID.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_MATCH_RULE_NOT_FOUND.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NAME_HAS_NO_OWNER.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NOT_SUPPORTED.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NO_MEMORY.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NO_NETWORK.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NO_REPLY.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NO_SERVER.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_NULL.3: man/sd_bus_error.3
+man/SD_BUS_ERROR_PROPERTY_READ_ONLY.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_SERVICE_UNKNOWN.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_TIMEOUT.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_UNKNOWN_INTERFACE.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_UNKNOWN_METHOD.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_UNKNOWN_OBJECT.3: man/sd-bus-errors.3
+man/SD_BUS_ERROR_UNKNOWN_PROPERTY.3: man/sd-bus-errors.3
 man/SD_CRIT.3: man/sd-daemon.3
 man/SD_DEBUG.3: man/sd-daemon.3
 man/SD_EMERG.3: man/sd-daemon.3
@@ -478,10 +551,13 @@ man/sd_bus_error_free.3: man/sd_bus_error.3
 man/sd_bus_error_get_errno.3: man/sd_bus_error.3
 man/sd_bus_error_has_name.3: man/sd_bus_error.3
 man/sd_bus_error_is_set.3: man/sd_bus_error.3
+man/sd_bus_error_map.3: man/sd_bus_error_add_map.3
 man/sd_bus_error_set.3: man/sd_bus_error.3
 man/sd_bus_error_set_const.3: man/sd_bus_error.3
 man/sd_bus_error_set_errno.3: man/sd_bus_error.3
 man/sd_bus_error_set_errnof.3: man/sd_bus_error.3
+man/sd_bus_error_set_errnofv.3: man/sd_bus_error.3
+man/sd_bus_error_setf.3: man/sd_bus_error.3
 man/sd_bus_message_append_array_iovec.3: man/sd_bus_message_append_array.3
 man/sd_bus_message_append_array_memfd.3: man/sd_bus_message_append_array.3
 man/sd_bus_message_append_array_space.3: man/sd_bus_message_append_array.3
@@ -657,6 +733,108 @@ man/user.conf.d.5: man/systemd-system.conf.5
 man/SD_ALERT.html: man/sd-daemon.html
 	$(html-alias)
 
+man/SD_BUS_ERROR_ACCESS_DENIED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_ADDRESS_IN_USE.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_AUTH_FAILED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_BAD_ADDRESS.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_DISCONNECTED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_END.html: man/sd_bus_error_add_map.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_FAILED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_FILE_EXISTS.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_FILE_NOT_FOUND.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_INCONSISTENT_MESSAGE.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_INVALID_ARGS.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_INVALID_SIGNATURE.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_IO_ERROR.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_LIMITS_EXCEEDED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_MAKE_CONST.html: man/sd_bus_error.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_MAP.html: man/sd_bus_error_add_map.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_MATCH_RULE_INVALID.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_MATCH_RULE_NOT_FOUND.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NAME_HAS_NO_OWNER.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NOT_SUPPORTED.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NO_MEMORY.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NO_NETWORK.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NO_REPLY.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NO_SERVER.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_NULL.html: man/sd_bus_error.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_PROPERTY_READ_ONLY.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_SERVICE_UNKNOWN.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_TIMEOUT.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_UNKNOWN_INTERFACE.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_UNKNOWN_METHOD.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_UNKNOWN_OBJECT.html: man/sd-bus-errors.html
+	$(html-alias)
+
+man/SD_BUS_ERROR_UNKNOWN_PROPERTY.html: man/sd-bus-errors.html
+	$(html-alias)
+
 man/SD_CRIT.html: man/sd-daemon.html
 	$(html-alias)
 
@@ -867,6 +1045,9 @@ man/sd_bus_error_has_name.html: man/sd_bus_error.html
 man/sd_bus_error_is_set.html: man/sd_bus_error.html
 	$(html-alias)
 
+man/sd_bus_error_map.html: man/sd_bus_error_add_map.html
+	$(html-alias)
+
 man/sd_bus_error_set.html: man/sd_bus_error.html
 	$(html-alias)
 
@@ -879,6 +1060,12 @@ man/sd_bus_error_set_errno.html: man/sd_bus_error.html
 man/sd_bus_error_set_errnof.html: man/sd_bus_error.html
 	$(html-alias)
 
+man/sd_bus_error_set_errnofv.html: man/sd_bus_error.html
+	$(html-alias)
+
+man/sd_bus_error_setf.html: man/sd_bus_error.html
+	$(html-alias)
+
 man/sd_bus_message_append_array_iovec.html: man/sd_bus_message_append_array.html
 	$(html-alias)
 
@@ -2015,6 +2202,7 @@ EXTRA_DIST += \
 	man/pam_systemd.xml \
 	man/resolved.conf.xml \
 	man/runlevel.xml \
+	man/sd-bus-errors.xml \
 	man/sd-daemon.xml \
 	man/sd-id128.xml \
 	man/sd-journal.xml \
@@ -2024,6 +2212,7 @@ EXTRA_DIST += \
 	man/sd_bus_creds_new_from_pid.xml \
 	man/sd_bus_default.xml \
 	man/sd_bus_error.xml \
+	man/sd_bus_error_add_map.xml \
 	man/sd_bus_message_append.xml \
 	man/sd_bus_message_append_array.xml \
 	man/sd_bus_message_append_basic.xml \
diff --git a/man/sd-bus-errors.xml b/man/sd-bus-errors.xml
new file mode 100644
index 0000000..d6bbd7f
--- /dev/null
+++ b/man/sd-bus-errors.xml
@@ -0,0 +1,309 @@
+<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+  This file is part of systemd.
+
+  Copyright 2015 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<refentry id="sd-bus-errors">
+
+  <refentryinfo>
+    <title>sd-bus-errors</title>
+    <productname>systemd</productname>
+
+    <authorgroup>
+      <author>
+        <contrib>Developer</contrib>
+        <firstname>Lennart</firstname>
+        <surname>Poettering</surname>
+        <email>lennart at poettering.net</email>
+      </author>
+    </authorgroup>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>sd-bus-errors</refentrytitle>
+    <manvolnum>3</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>sd-bus-errors</refname>
+    <refname>SD_BUS_ERROR_FAILED</refname>
+    <refname>SD_BUS_ERROR_NO_MEMORY</refname>
+    <refname>SD_BUS_ERROR_SERVICE_UNKNOWN</refname>
+    <refname>SD_BUS_ERROR_NAME_HAS_NO_OWNER</refname>
+    <refname>SD_BUS_ERROR_NO_REPLY</refname>
+    <refname>SD_BUS_ERROR_IO_ERROR</refname>
+    <refname>SD_BUS_ERROR_BAD_ADDRESS</refname>
+    <refname>SD_BUS_ERROR_NOT_SUPPORTED</refname>
+    <refname>SD_BUS_ERROR_LIMITS_EXCEEDED</refname>
+    <refname>SD_BUS_ERROR_ACCESS_DENIED</refname>
+    <refname>SD_BUS_ERROR_AUTH_FAILED</refname>
+    <refname>SD_BUS_ERROR_NO_SERVER</refname>
+    <refname>SD_BUS_ERROR_TIMEOUT</refname>
+    <refname>SD_BUS_ERROR_NO_NETWORK</refname>
+    <refname>SD_BUS_ERROR_ADDRESS_IN_USE</refname>
+    <refname>SD_BUS_ERROR_DISCONNECTED</refname>
+    <refname>SD_BUS_ERROR_INVALID_ARGS</refname>
+    <refname>SD_BUS_ERROR_FILE_NOT_FOUND</refname>
+    <refname>SD_BUS_ERROR_FILE_EXISTS</refname>
+    <refname>SD_BUS_ERROR_UNKNOWN_METHOD</refname>
+    <refname>SD_BUS_ERROR_UNKNOWN_OBJECT</refname>
+    <refname>SD_BUS_ERROR_UNKNOWN_INTERFACE</refname>
+    <refname>SD_BUS_ERROR_UNKNOWN_PROPERTY</refname>
+    <refname>SD_BUS_ERROR_PROPERTY_READ_ONLY</refname>
+    <refname>SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN</refname>
+    <refname>SD_BUS_ERROR_INVALID_SIGNATURE</refname>
+    <refname>SD_BUS_ERROR_INCONSISTENT_MESSAGE</refname>
+    <refname>SD_BUS_ERROR_MATCH_RULE_NOT_FOUND</refname>
+    <refname>SD_BUS_ERROR_MATCH_RULE_INVALID</refname>
+    <refname>SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED</refname>
+
+    <refpurpose>Standard D-Bus error names</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
+
+<funcsynopsisinfo>#define SD_BUS_ERROR_FAILED                     "org.freedesktop.DBus.Error.Failed"
+#define SD_BUS_ERROR_NO_MEMORY                  "org.freedesktop.DBus.Error.NoMemory"
+#define SD_BUS_ERROR_SERVICE_UNKNOWN            "org.freedesktop.DBus.Error.ServiceUnknown"
+#define SD_BUS_ERROR_NAME_HAS_NO_OWNER          "org.freedesktop.DBus.Error.NameHasNoOwner"
+#define SD_BUS_ERROR_NO_REPLY                   "org.freedesktop.DBus.Error.NoReply"
+#define SD_BUS_ERROR_IO_ERROR                   "org.freedesktop.DBus.Error.IOError"
+#define SD_BUS_ERROR_BAD_ADDRESS                "org.freedesktop.DBus.Error.BadAddress"
+#define SD_BUS_ERROR_NOT_SUPPORTED              "org.freedesktop.DBus.Error.NotSupported"
+#define SD_BUS_ERROR_LIMITS_EXCEEDED            "org.freedesktop.DBus.Error.LimitsExceeded"
+#define SD_BUS_ERROR_ACCESS_DENIED              "org.freedesktop.DBus.Error.AccessDenied"
+#define SD_BUS_ERROR_AUTH_FAILED                "org.freedesktop.DBus.Error.AuthFailed"
+#define SD_BUS_ERROR_NO_SERVER                  "org.freedesktop.DBus.Error.NoServer"
+#define SD_BUS_ERROR_TIMEOUT                    "org.freedesktop.DBus.Error.Timeout"
+#define SD_BUS_ERROR_NO_NETWORK                 "org.freedesktop.DBus.Error.NoNetwork"
+#define SD_BUS_ERROR_ADDRESS_IN_USE             "org.freedesktop.DBus.Error.AddressInUse"
+#define SD_BUS_ERROR_DISCONNECTED               "org.freedesktop.DBus.Error.Disconnected"
+#define SD_BUS_ERROR_INVALID_ARGS               "org.freedesktop.DBus.Error.InvalidArgs"
+#define SD_BUS_ERROR_FILE_NOT_FOUND             "org.freedesktop.DBus.Error.FileNotFound"
+#define SD_BUS_ERROR_FILE_EXISTS                "org.freedesktop.DBus.Error.FileExists"
+#define SD_BUS_ERROR_UNKNOWN_METHOD             "org.freedesktop.DBus.Error.UnknownMethod"
+#define SD_BUS_ERROR_UNKNOWN_OBJECT             "org.freedesktop.DBus.Error.UnknownObject"
+#define SD_BUS_ERROR_UNKNOWN_INTERFACE          "org.freedesktop.DBus.Error.UnknownInterface"
+#define SD_BUS_ERROR_UNKNOWN_PROPERTY           "org.freedesktop.DBus.Error.UnknownProperty"
+#define SD_BUS_ERROR_PROPERTY_READ_ONLY         "org.freedesktop.DBus.Error.PropertyReadOnly"
+#define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN    "org.freedesktop.DBus.Error.UnixProcessIdUnknown"
+#define SD_BUS_ERROR_INVALID_SIGNATURE          "org.freedesktop.DBus.Error.InvalidSignature"
+#define SD_BUS_ERROR_INCONSISTENT_MESSAGE       "org.freedesktop.DBus.Error.InconsistentMessage"
+#define SD_BUS_ERROR_MATCH_RULE_NOT_FOUND       "org.freedesktop.DBus.Error.MatchRuleNotFound"
+#define SD_BUS_ERROR_MATCH_RULE_INVALID         "org.freedesktop.DBus.Error.MatchRuleInvalid"
+#define SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED \
+                                                "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired"</funcsynopsisinfo>
+
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>In addition to the error names user programs define, D-Bus
+    knows a number of generic, standardized error names, that are
+    listed below.</para>
+
+    <para>In addition to this list, in sd-bus the special error
+    namespace <literal>System.Error.</literal> is used to map
+    arbitrary Linux system errors (as defined by <citerefentry
+    project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
+    to D-Bus errors and back. For example, the error
+    <constant>EUCLEAN</constant> is mapped to
+    <literal>System.Error.EUCLEAN</literal> and back.</para>
+
+    <variablelist>
+
+      <varlistentry>
+         <term><varname>SD_BUS_ERROR_FAILED</varname></term>
+         <listitem><para>A generic error indication. See the error
+         message for further details. This error name should be
+         avoided, in favour of a more expressive error
+         name.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NO_MEMORY</varname></term>
+        <listitem><para>A memory allocation failed, and the requested
+        operation could not be completed.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_SERVICE_UNKNOWN</varname></term>
+        <listitem><para>The contacted bus service is unknown and
+        cannot be activated.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NAME_HAS_NO_OWNER</varname></term>
+        <listitem><para>The specified bus service name currently has
+        no owner.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NO_REPLY</varname></term>
+        <listitem><para>A message did not receive a reply. This error
+        is usually generated after a timeout.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_IO_ERROR</varname></term>
+        <listitem><para>Generic input/output error, for example when
+        accessing a socket or other IO context.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_BAD_ADDRESS</varname></term>
+        <listitem><para>The specified D-Bus bus address string is
+        malformed.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NOT_SUPPORTED</varname></term>
+        <listitem><para>The requested operation is not supported on
+        the local system.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_LIMITS_EXCEEDED</varname></term>
+        <listitem><para>Some limited resource has been
+        exhausted.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_ACCESS_DENIED</varname></term>
+        <listitem><para>Access to a resource has bee denied, due to security restrictions.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_AUTH_FAILED</varname></term>
+        <listitem><para>Authentication did not complete successfully.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NO_SERVER</varname></term>
+        <listitem><para>Unable to connect to the specified server.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_TIMEOUT</varname></term>
+        <listitem><para>An operation timed out. Note that method calls
+        which timeout generate a
+        <varname>SD_BUS_ERROR_NO_REPLY</varname>.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_NO_NETWORK</varname></term>
+        <listitem><para>No network available to execute requested network operation on.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_ADDRESS_IN_USE</varname></term>
+        <listitem><para>The specified network address is already being listened on.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_DISCONNECTED</varname></term>
+        <listitem><para>The connection has been terminated.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_INVALID_ARGS</varname></term>
+        <listitem><para>One or more invalid arguments have been passed.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_FILE_NOT_FOUND</varname></term>
+        <listitem><para>The requested file could not be found.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_FILE_EXISTS</varname></term>
+        <listitem><para>The requested file exists already.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_UNKNOWN_METHOD</varname></term>
+        <listitem><para>The requested method does not exist in the selected interface.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_UNKNOWN_OBJECT</varname></term>
+        <listitem><para>The requested object does not exist in the selected service.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_UNKNOWN_INTERFACE</varname></term>
+        <listitem><para>The requested interface does not exist on the selected object.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_UNKNOWN_PROPERTY</varname></term>
+        <listitem><para>The requested property does not exist in the selected interface.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_PROPERTY_READ_ONLY</varname></term>
+        <listitem><para>A write operation was requested on a read-only property.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN</varname></term>
+        <listitem><para>The requested PID is not known.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_INVALID_SIGNATURE</varname></term>
+        <listitem><para>The specified message signature is not
+        valid.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_INCONSISTENT_MESSAGE</varname></term>
+        <listitem><para>The passed message does not validate
+        correctly.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_MATCH_RULE_NOT_FOUND</varname></term>
+        <listitem><para>The specified match rule does not exist.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_MATCH_RULE_INVALID</varname></term>
+        <listitem><para>The specified match rule is invalid.</para></listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED</varname></term>
+        <listitem><para>Access to the requested operation is not
+        permitted, however, it might be available after interactive
+        authentication. This is usually returned by method calls
+        supporting a framework for additional interactive
+        authorization, when interactive authorization was not enabled
+        with the
+        <citerefentry><refentrytitle>sd_bus_message_set_allow_interactive_authorization</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+        for the method call message.</para></listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Notes</title>
+
+    <para>The various error definitions described here are available
+    as a shared library, which can be compiled and linked to with the
+    <constant>libsystemd</constant> <citerefentry
+    project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    file.</para>
+  </refsect1>
+
+  <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_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd_bus_message_set_allow_interactive_authorization</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry project='die-net'><refentrytitle>strerror</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    </para>
+  </refsect1>
+
+</refentry>
diff --git a/man/sd_bus_error.xml b/man/sd_bus_error.xml
index b8cb339..6dc4541 100644
--- a/man/sd_bus_error.xml
+++ b/man/sd_bus_error.xml
@@ -44,11 +44,15 @@
 
   <refnamediv>
     <refname>sd_bus_error</refname>
+    <refname>SD_BUS_ERROR_MAKE_CONST</refname>
+    <refname>SD_BUS_ERROR_NULL</refname>
     <refname>sd_bus_error_free</refname>
     <refname>sd_bus_error_set</refname>
+    <refname>sd_bus_error_setf</refname>
     <refname>sd_bus_error_set_const</refname>
     <refname>sd_bus_error_set_errno</refname>
     <refname>sd_bus_error_set_errnof</refname>
+    <refname>sd_bus_error_set_errnofv</refname>
     <refname>sd_bus_error_get_errno</refname>
     <refname>sd_bus_error_copy</refname>
     <refname>sd_bus_error_is_set</refname>
@@ -75,7 +79,7 @@
       </para>
 
       <funcprototype>
-        <funcdef>int <function>sd_bus_error_free</function></funcdef>
+        <funcdef>void <function>sd_bus_error_free</function></funcdef>
         <paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
       </funcprototype>
 
@@ -116,6 +120,14 @@
       </funcprototype>
 
       <funcprototype>
+        <funcdef>int <function>sd_bus_error_set_errnofv</function></funcdef>
+        <paramdef>sd_bus_error *<parameter>e</parameter></paramdef>
+        <paramdef>int <parameter>error</parameter></paramdef>
+        <paramdef>const char *<parameter>format</parameter></paramdef>
+        <paramdef>va_list ap</paramdef>
+      </funcprototype>
+
+      <funcprototype>
         <funcdef>int <function>sd_bus_error_get_errno</function></funcdef>
         <paramdef>const sd_bus_error *<parameter>e</parameter></paramdef>
       </funcprototype>
@@ -138,234 +150,194 @@
       </funcprototype>
     </funcsynopsis>
 
-    <para>
-      <constant>SD_BUS_ERROR_FAILED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NO_MEMORY</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_SERVICE_UNKNOWN</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NAME_HAS_NO_OWNER</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NO_REPLY</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_IO_ERROR</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_BAD_ADDRESS</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NOT_SUPPORTED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_LIMITS_EXCEEDED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_ACCESS_DENIED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_AUTH_FAILED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NO_SERVER</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_TIMEOUT</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_NO_NETWORK</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_ADDRESS_IN_USE</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_DISCONNECTED</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_INVALID_ARGS</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_FILE_NOT_FOUND</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_FILE_EXISTS</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_UNKNOWN_METHOD</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_UNKNOWN_OBJECT</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_UNKNOWN_INTERFACE</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_UNKNOWN_PROPERTY</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_PROPERTY_READ_ONLY</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_INVALID_SIGNATURE</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_INCONSISTENT_MESSAGE</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_MATCH_RULE_NOT_FOUND</constant>
-    </para>
-    <para>
-      <constant>SD_BUS_ERROR_MATCH_RULE_INVALID</constant>
-    </para>
-
   </refsynopsisdiv>
 
   <refsect1>
     <title>Description</title>
 
     <para>The <structname>sd_bus_error</structname> structure carries
-    information for a <filename>sd-bus</filename> error. The
-    functions described below can be used to set and query fields in
-    this structure. The <structfield>name</structfield> field contains a
-    short identifier of an error. It should follow the rules for error
-    names described in the D-Bus specification, subsection <ulink
+    information about a D-Bus error condition. The functions described
+    below may be used to set and query fields in this structure. The
+    <structfield>name</structfield> field contains a short identifier
+    of an error. It should follow the rules for error names described
+    in the D-Bus specification, subsection <ulink
     url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names">Valid
-    Names</ulink>. The <structfield>message</structfield> is a human
-    readable string describing the details. When no longer necessary,
-    resources held by this structure should be destroyed with
-    <function>sd_bus_error_free</function>.</para>
-
-    <para><function>sd_bus_error_set</function> will return an
-    errno-like negative value returned based on parameter
-    <parameter>name</parameter> (see
-    <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
-    Various well-known D-Bus errors are converted to specific values,
-    and the remaining ones to <constant>-ENXIO</constant>. Well-known
-    D-Bus error names are available as constants
-    <constant>SD_BUS_ERROR_FAILED</constant>, etc., listed above. If
+    Names</ulink>. A number of common, standardized error names are
+    described in
+    <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+    but additional domain-specific errors may be defined by
+    applications. The <structfield>message</structfield> field usually
+    contains a human readable string describing the details, but might
+    be NULL. An unset <structname>sd_bus_error</structname> structure
+    should have both fields initialized to NULL. Set an error
+    structure to <constant>SD_BUS_ERROR_NULL</constant> in order to
+    reset both fields to NULL. When no longer necessary, resources
+    held by the <structname>sd_bus_error</structname>structure should
+    be destroyed with <function>sd_bus_error_free()</function>.</para>
+
+    <para><function>sd_bus_error_set()</function> sets an error
+    structure to the specified name and message strings. The strings
+    will be copied into internal, newly allocated memory. It is
+    essential to free the error structure again when it is not
+    required anymore (see above). The function will return an
+    <varname>errno</varname>-like negative value (see <citerefentry
+    project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
+    determined from the specified error name.  Various well-known
+    D-Bus errors are converted to well-known <varname>errno</varname>
+    counterparts, and the other ones to <constant>-EIO</constant>. See
+    <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    for a list of well-known error names. Additional error mappings
+    may be defined with
+    <citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
+    <parameter>e</parameter> is NULL no error structure is initialized
+    but the error is still converted into an
+    <varname>errno</varname>-style error. If
     <parameter>name</parameter> is <constant>NULL</constant>, it is
     assumed that no error occurred, and 0 is returned. This means that
     this function may be conveniently used in a
-    <function>return</function> statement.</para>
-
-    <para>If <parameter>e</parameter> is not
-    <constant>NULL</constant>, <structfield>name</structfield> and
-    <structfield>message</structfield> in the
-    <structname>sd_bus_error</structname> structure
-    <parameter>e</parameter> points at will be filled in. As described above,
-    <parameter>name</parameter> may be <constant>NULL</constant>,
-    which is treated as no error. Parameter
-    <parameter>message</parameter> may also be
-    <constant>NULL</constant>, in which case no message is specified.
-    <function>sd_bus_error_set</function> will make internal copies of
-    specified strings.</para>
-
-    <para><function>sd_bus_error_setf</function> is similar to
-    <function>sd_bus_error_set</function>, but takes a
-    <citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    format string and corresponding arguments to generate
-    <structname>message</structname>.</para>
-
-    <para><function>sd_bus_error_set_const</function> is similar to
-    <function>sd_bus_error_set</function>, but string parameters are
-    not copied internally, and must remain valid for the lifetime of
-    <parameter>e</parameter>.</para>
-
-    <para><function>sd_bus_error_set_errno</function> will set
-    <structfield>name</structfield> based on an errno-like value.
-    <citerefentry project='die-net'><refentrytitle>strerror</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    <function>return</function> statement. If
+    <parameter>message</parameter> is NULL no message is set. This
+    call can fail if no memory may be allocated for the name and
+    message strings, in which case an
+    <constant>SD_BUS_ERROR_NO_MEMORY</constant> error might be set
+    instead and -ENOMEM returned. Do not use this call on error
+    structures that are already initialized. If you intend to reuse an
+    error structure free the old data stored in it with
+    <function>sd_bus_error_free()</function> first.</para>
+
+    <para><function>sd_bus_error_setf()</function> is similar to
+    <function>sd_bus_error_set()</function>, but takes a <citerefentry
+    project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    format string and corresponding arguments to generate the
+    <structfield>message</structfield> field.</para>
+
+    <para><function>sd_bus_error_set_const()</function> is similar to
+    <function>sd_bus_error_set()</function>, but the string parameters
+    are not copied internally, and must hence remain constant and
+    valid for the lifetime of <parameter>e</parameter>. Use this call
+    to avoid memory allocations when setting error structures. Since
+    this call does not allocate memory it will not fail with an
+    out-of-memory condition, as
+    <function>sd_bus_error_set()</function> can, as described
+    above. Alternatively, the
+    <constant>SD_BUS_ERROR_MAKE_CONST()</constant> macro may be used
+    to generate a literal, constant bus error structure
+    on-the-fly.</para>
+
+    <para><function>sd_bus_error_set_errno()</function> will set
+    <structfield>name</structfield> from an
+    <varname>errno</varname>-like value that is converted to a D-Bus
+    error. <citerefentry
+    project='die-net'><refentrytitle>strerror_r</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     will be used to set <structfield>message</structfield>. Well-known
     D-Bus error names will be used for <structfield>name</structfield>
-    if available, otherwise a name in the
-    <literal>System.Error</literal> namespace will be generated.
-    </para>
-
-    <para><function>sd_bus_error_set_errnof</function> is similar to
-    <function>sd_bus_error_set_errno</function>, but in addition to
-    <parameter>name</parameter>, takes a
-    <citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    format and corresponding arguments.
-    <structfield>name</structfield> will be generated from
+    if applicable, otherwise a name in the
+    <literal>System.Error.</literal> namespace will be generated. The
+    sign of the specified error number is ignored. The absolute value
+    is used implicitly. The call always returns a negative value, for
+    convenient usage in <function>return</function> statements. This
+    call might fail due to lack of memory, in which case an
+    <constant>SD_BUS_ERROR_NO_MEMORY</constant> error is set instead,
+    and -ENOMEM returned.</para>
+
+    <para><function>sd_bus_error_set_errnof()</function> is similar to
+    <function>sd_bus_error_set_errno()</function>, but in addition to
+    <parameter>error</parameter>, takes a <citerefentry
+    project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    format string and corresponding arguments.  The
+    <structfield>message</structfield> field will be generated from
     <parameter>format</parameter> and the arguments.</para>
 
-    <para><function>sd_bus_error_get_errno</function> will convert
-    <structname>e->name</structname> to an errno-like value using the
-    same rules as <function>sd_bus_error_set</function>.  If
+    <para><function>sd_bus_error_set_errnofv()</function> is similar to
+    <function>sd_bus_error_set_errnof()</function> but takes the
+    format string parameters as <citerefentry
+    project='man-pages'><refentrytitle>va_arg</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    parameter list.</para>
+
+    <para><function>sd_bus_error_get_errno()</function> converts the
+    <structfield>name</structfield> field of an error structure to an
+    <varname>errno</varname>-like (positive) value using the same
+    rules as <function>sd_bus_error_set()</function>.  If
     <parameter>e</parameter> is <constant>NULL</constant>, 0 will be
     returned.</para>
 
-    <para><function>sd_bus_error_copy</function> will initialize
+    <para><function>sd_bus_error_copy()</function> will initialize
     <parameter>dst</parameter> using the values in
     <parameter>e</parameter>. If the strings in
     <parameter>e</parameter> were set using
-    <function>sd_bus_set_error_const</function>, they will be shared.
-    Otherwise, they will be copied.</para>
+    <function>sd_bus_set_error_const()</function>, they will be shared.
+    Otherwise, they will be copied. Returns a converted
+    <varname>errno</varname>-like, negative error code.</para>
 
-    <para><function>sd_bus_error_is_set</function> will return
-    <constant>true</constant> if <parameter>e</parameter> is
+    <para><function>sd_bus_error_is_set()</function> will return a
+    non-zero value if <parameter>e</parameter> is
     non-<constant>NULL</constant> and an error has been set,
     <constant>false</constant> otherwise.</para>
 
-    <para><function>sd_bus_error_has_name</function> will return true
-    if <parameter>e</parameter> is non-<constant>NULL</constant> and
-    an error with the same <parameter>name</parameter> has been set,
+    <para><function>sd_bus_error_has_name()</function> will return a
+    non-zero value if <parameter>e</parameter> is
+    non-<constant>NULL</constant> and an error with the same
+    <parameter>name</parameter> has been set,
     <constant>false</constant> otherwise.</para>
 
-    <para><function>sd_bus_error_free</function> will destroy resources
-    held by <parameter>e</parameter>. The parameter itself will not
-    be deallocated, and must be
-    <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>d
-    by the caller if necessary.</para>
+    <para><function>sd_bus_error_free()</function> will destroy
+    resources held by <parameter>e</parameter>. The parameter itself
+    will not be deallocated, and must be <citerefentry
+    project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>d
+    by the caller if necessary. The function may also be called safely
+    on unset errors (error structures with both fields set to NULL),
+    in which case it performs no operation. This call will reset the
+    error structure after freeing the data, so that all fields are set
+    to NULL. The structure may be reused afterwards.</para>
   </refsect1>
 
   <refsect1>
     <title>Return Value</title>
 
-    <para>Functions <function>sd_bus_error_set</function>,
-    <function>sd_bus_error_setf</function>,
-    <function>sd_bus_error_set_const</function>, when successful,
+    <para>The functions <function>sd_bus_error_set()</function>,
+    <function>sd_bus_error_setf()</function>,
+    <function>sd_bus_error_set_const()</function>, when successful,
     return the negative errno value corresponding to the
     <parameter>name</parameter> parameter. Functions
-    <function>sd_bus_error_set_errno</function> and
-    <function>sd_bus_error_set_errnof</function>, when successful,
-    return the value of the <parameter>errno</parameter> parameter. If
-    an error occurs, one of the negative error values listed below
-    will be returned.</para>
-
-    <para><function>sd_bus_error_get_errno</function> returns
+    <function>sd_bus_error_set_errno()</function>,
+    <function>sd_bus_error_set_errnof()</function> and
+    <function>sd_bus_error_set_errnofv()</function>, when successful,
+    return the negative value of the <parameter>error</parameter>
+    parameter. If an error occurs, one of the negative error values
+    listed below will be returned.</para>
+
+    <para><function>sd_bus_error_get_errno()</function> returns
     <constant>false</constant> when <parameter>e</parameter> is
     <constant>NULL</constant>, and a positive errno value mapped from
     <parameter>e->name</parameter> otherwise.</para>
 
-    <para><function>sd_bus_error_copy</function> returns 0 or a
-    positive integer on success, and one of the negative error values
-    listed below otherwise.</para>
+    <para><function>sd_bus_error_copy()</function> returns 0 or a
+    positive integer on success, and a negative error value converted
+    from the error name otherwise.</para>
 
-    <para><function>sd_bus_error_is_set</function> returns
-    <constant>true</constant> when <parameter>e</parameter> and
-    <parameter>e->name</parameter> are non-<constant>NULL</constant>,
-    <constant>false</constant> otherwise.</para>
+    <para><function>sd_bus_error_is_set()</function> returns a
+    non-zero value when <parameter>e</parameter> and the
+    <structfield>name</structfield> field are
+    non-<constant>NULL</constant>, zero otherwise.</para>
 
-    <para><function>sd_bus_error_has_name</function> returns
-    <constant>true</constant> when <parameter>e</parameter> is
-    non-<constant>NULL</constant> and <parameter>e->name</parameter>
-    is equal to <parameter>name</parameter>,
-    <constant>false</constant> otherwise.</para>
+    <para><function>sd_bus_error_has_name()</function> returns a
+    non-zero value when <parameter>e</parameter> is
+    non-<constant>NULL</constant> and the
+    <structfield>name</structfield> field is equal to
+    <parameter>name</parameter>, zero otherwise.</para>
   </refsect1>
 
   <refsect1>
     <title>Reference ownership</title>
     <para><structname>sd_bus_error</structname> is not reference
     counted. Users should destroy resources held by it by calling
-    <function>sd_bus_error_free</function>.</para>
+    <function>sd_bus_error_free()</function>. Usually error structures
+    are allocated on the stack or passed in as function parameters,
+    but they may also be allocated dynamically, in which case it is
+    the duty of the caller to <citerefentry
+    project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    the memory held by the structure itself after freeing its contents
+    with <function>sd_bus_error_free()</function>.</para>
   </refsect1>
 
   <refsect1>
@@ -407,8 +379,10 @@
     <para>
       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd_bus_error_add_map</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry project='die-net'><refentrytitle>strerror</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+      <citerefentry project='die-net'><refentrytitle>strerror_r</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     </para>
   </refsect1>
 
diff --git a/man/sd_bus_error_add_map.xml b/man/sd_bus_error_add_map.xml
new file mode 100644
index 0000000..3fca63b
--- /dev/null
+++ b/man/sd_bus_error_add_map.xml
@@ -0,0 +1,173 @@
+<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+
+<!--
+  This file is part of systemd.
+
+  Copyright 2015 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<refentry id="sd_bus_error_add_map">
+
+  <refentryinfo>
+    <title>sd_bus_error_add_map</title>
+    <productname>systemd</productname>
+
+    <authorgroup>
+      <author>
+        <contrib>Developer</contrib>
+        <firstname>Lennart</firstname>
+        <surname>Poettering</surname>
+        <email>lennart at poettering.net</email>
+      </author>
+    </authorgroup>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>sd_bus_error_add_map</refentrytitle>
+    <manvolnum>3</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>sd_bus_error_add_map</refname>
+    <refname>sd_bus_error_map</refname>
+    <refname>SD_BUS_ERROR_MAP</refname>
+    <refname>SD_BUS_ERROR_END</refname>
+
+    <refpurpose>Additional sd-dbus error mappings</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
+
+      <funcsynopsisinfo>typedef struct {
+        const char *name;
+        int code;
+        ...
+} sd_bus_error_map;</funcsynopsisinfo>
+
+    </funcsynopsis>
+
+      <para>
+        <constant>SD_BUS_ERROR_MAP(<replaceable>name</replaceable>, <replaceable>code</replaceable>)</constant>
+      </para>
+      <para>
+        <constant>SD_BUS_ERROR_MAP_END</constant>
+      </para>
+
+      <funcprototype>
+        <funcdef>int <function>sd_bus_error_add_map</function></funcdef>
+        <paramdef>const sd_bus_map *<parameter>map</parameter></paramdef>
+      </funcprototype>
+
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>The <function>sd_bus_error_add_map()</function> call may be
+    used to register additional mappings for converting D-Bus errors
+    to Linux <varname>errno</varname>-style errors. The mappings
+    defined with this call are consulted by calls such as
+    <citerefentry><refentrytitle>sd_bus_error_set</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    or
+    <citerefentry><refentrytitle>sd_bus_error_get_errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By
+    default a number of generic, standardized mappings are known, as
+    documented in
+    <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Use
+    this call to add further, application-specific mappings.</para>
+
+    <para>The function takes a pointer to an array of
+    <structname>sd_bus_error_map</structname> structures. A reference
+    to the specified array is added to the lookup tables for error
+    mappings. Note that the structure is not copied, it is hence
+    essential that the array stays available and constant during the
+    entire remaining runtime of the process.</para>
+
+    <para>The mapping array should be put together with a series of
+    <constant>SD_BUS_ERROR_MAP()</constant> macro invocations, that
+    take a literal name string and a (positive)
+    <varname>errno</varname>-style error number. The last entry of the
+    array should be an invocation of the
+    <constant>SD_BUS_ERROR_MAP_END</constant> macro. The array should not be
+    put together without use of these two macros.</para>
+
+    <para>Note that the call is idempotent: it is safe to invoke it
+    multiple times with the parameter, which will only add the passed
+    mapping array once.</para>
+
+    <para>Note that the memory allocated by this call is not intended
+    to be freed during the lifetime of the process. It should not be
+    freed explicitly.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Return Value</title>
+
+    <para><function>sd_bus_error_add_map()</function> returns a
+    positive value when the new array was added to the lookup
+    tables. It returns zero when the same array was already added
+    before. On error, a negative <varname>errno</varname>-style error
+    code is returned. See below for known error codes.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Errors</title>
+
+    <para>Returned errors may indicate the following problems:</para>
+
+    <variablelist>
+
+      <varlistentry>
+        <term><constant>-EINVAL</constant></term>
+
+        <listitem><para>The specified mapping array is invalid.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><constant>-ENOMEM</constant></term>
+
+        <listitem><para>Memory allocation failed.</para></listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Notes</title>
+
+    <para>The various error definitions described here are available
+    as a shared library, which can be compiled and linked to with the
+    <constant>libsystemd</constant> <citerefentry
+    project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    file.</para>
+  </refsect1>
+
+  <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_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd-bus-errors</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry project='die-net'><refentrytitle>strerror_r</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    </para>
+  </refsect1>
+
+</refentry>
diff --git a/man/systemd.journal-fields.xml b/man/systemd.journal-fields.xml
index a101006..afe1200 100644
--- a/man/systemd.journal-fields.xml
+++ b/man/systemd.journal-fields.xml
@@ -440,7 +440,6 @@
       </varlistentry>
     </variablelist>
 
-
   </refsect1>
 
   <refsect1>

commit 1ad9e2f89c440d8b1316f1d5ea0fec51dc0ab287
Merge: 74d8a0d e821694
Author: Daniel Mack <github at zonque.org>
Date:   Wed Jul 8 12:17:47 2015 -0400

    Merge pull request #519 from poettering/man-bus-message-append
    
    man: update and extend the various sd_bus_message_append_*() man pages


commit 74d8a0d4b2205d1bd1d1f6871f76f8ea6051bd99
Merge: 008c1d3 0b1b17d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 13:00:20 2015 -0300

    Merge pull request #514 from teg/resolved-rrsig-marshal
    
    resolved: fix marshalling of RRSIG records


commit 008c1d3b8495b29d44923904d53330516726dd2a
Merge: 1161d5d 318b0fd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 8 12:46:49 2015 -0300

    Merge pull request #515 from xnox/no-dot-files
    
    automake: Do not install developer files on end-user systems.


commit 1161d5d28bb1f05a4b3837542db7cf3e23cc047e
Merge: b9fd7bb 9e19c04
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Jul 8 16:16:44 2015 +0200

    Merge pull request #510 from zonque/journal-gatewayd
    
    journal-gatewayd: fix tmpfile logic


commit 0f8261015380be71f8a63c8aa37926c2a32d1870
Author: Umut Tezduyar Lindskog <umuttl at axis.com>
Date:   Wed Jul 8 14:35:32 2015 +0200

    property callback returns are consistent
    
    It is no different to return 0 over 1 in the property
    callback. It is confusing to return 1 which made me think
    1 has a special purpose. This way code is consistent with
    the rest of the tree.

diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 0f72d70..36c0e86 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -103,11 +103,7 @@ static int property_get_sessions(
 
         }
 
-        r = sd_bus_message_close_container(reply);
-        if (r < 0)
-                return r;
-
-        return 1;
+        return sd_bus_message_close_container(reply);
 }
 
 static int property_get_idle_hint(
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 7813a0b..38a4c7b 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -61,11 +61,7 @@ static int property_get_id(
         assert(reply);
         assert(m);
 
-        r = sd_bus_message_append_array(reply, 'y', &m->id, 16);
-        if (r < 0)
-                return r;
-
-        return 1;
+        return sd_bus_message_append_array(reply, 'y', &m->id, 16);
 }
 
 static int property_get_state(
@@ -112,11 +108,7 @@ static int property_get_netif(
 
         assert_cc(sizeof(int) == sizeof(int32_t));
 
-        r = sd_bus_message_append_array(reply, 'i', m->netif, m->n_netif * sizeof(int));
-        if (r < 0)
-                return r;
-
-        return 1;
+        return sd_bus_message_append_array(reply, 'i', m->netif, m->n_netif * sizeof(int));
 }
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_class, machine_class, MachineClass);
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index b5f8f5c..5717a15 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -53,11 +53,7 @@ static int property_get_ether_addrs(
                         return r;
         }
 
-        r = sd_bus_message_close_container(reply);
-        if (r < 0)
-                return r;
-
-        return 1;
+        return sd_bus_message_close_container(reply);
 }
 
 const sd_bus_vtable network_vtable[] = {

commit 318b0fd7afe42b35f150eceebe54b95309037b39
Author: Dimitri John Ledkov <dimitri.j.ledkov at intel.com>
Date:   Wed Jul 8 12:37:47 2015 +0100

    automake: Do not install developer files on end-user systems.
    
    autogen.sh, .dir-locals.el, .vimrc, .ycm_extra_conf.py, .travis.yml,
    .mailmap files are only useful with the source tree, for the
    developers. Do not install these files as documentation on the
    end-user systems, but keep them distributed with the tarball.

diff --git a/Makefile.am b/Makefile.am
index 19a3706..603a479 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -647,7 +647,9 @@ dist_doc_DATA = \
 	DISTRO_PORTING \
 	src/libsystemd/sd-bus/PORTING-DBUS1 \
 	src/libsystemd/sd-bus/DIFFERENCES \
-	src/libsystemd/sd-bus/GVARIANT-SERIALIZATION \
+	src/libsystemd/sd-bus/GVARIANT-SERIALIZATION
+
+EXTRA_DIST += \
 	autogen.sh \
 	.dir-locals.el \
 	.vimrc \

commit 0b1b17d3256c409254b114d63b4ed2308c10996d
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Jul 8 13:52:48 2015 +0200

    resolved: fix marshalling of RRSIG records
    
    The key tag is 16, not 8 bits.

diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index bb74b18..47cc975 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -691,7 +691,7 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
                 if (r < 0)
                         goto fail;
 
-                r = dns_packet_append_uint8(p, rr->rrsig.key_tag, NULL);
+                r = dns_packet_append_uint16(p, rr->rrsig.key_tag, NULL);
                 if (r < 0)
                         goto fail;
 

commit 9e19c04f3a4e03e37dc89b63c1ae9b0a7c611810
Author: Daniel Mack <daniel at zonque.org>
Date:   Tue Jul 7 17:21:03 2015 -0400

    journal-gatewayd: fix tmpfile logic
    
    "rw" is not a valid mode string for f*open(). This got broken in
    cc02a7b33049 ("journal-gatewayd: factor out opening of temp
    file").

diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index d9450ae..9a09f40 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -132,7 +132,7 @@ static int request_meta_ensure_tmp(RequestMeta *m) {
                 if (fd < 0)
                         return fd;
 
-                m->tmp = fdopen(fd, "rw");
+                m->tmp = fdopen(fd, "w+");
                 if (!m->tmp) {
                         safe_close(fd);
                         return -errno;

commit e8216945a97bc2a2b04bc286e67ab5bba313b83e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jul 7 20:35:45 2015 +0200

    man: update and extend the various sd_bus_message_append_*() man pages
    
    Some calls changed their signature since the man pages were written.
    Also extend on a number of details.

diff --git a/man/sd_bus_message_append.xml b/man/sd_bus_message_append.xml
index 7a4bfa4..0ee849d 100644
--- a/man/sd_bus_message_append.xml
+++ b/man/sd_bus_message_append.xml
@@ -46,7 +46,8 @@
   <refnamediv>
     <refname>sd_bus_message_append</refname>
 
-    <refpurpose>Attach parts of message based on a format string</refpurpose>
+    <refpurpose>Attach fields to a D-Bus message based on a type
+    string</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
@@ -65,17 +66,20 @@
   <refsect1>
     <title>Description</title>
 
-    <para>The <function>sd_bus_message_append</function> function appends
-    a sequence of items to message <parameter>m</parameter>. The
-    format string <parameter>types</parameter> describes the types of
-    arguments that follow.</para>
+    <para>The <function>sd_bus_message_append()</function> function
+    appends a sequence of fields to the D-Bus message object
+    <parameter>m</parameter>. The type string
+    <parameter>types</parameter> describes the types of the field
+    arguments that follow. For each type specified in the type string
+    one or more arguments need to be specified, in the same order as
+    declared in the type string.</para>
 
-    <para>The format string is composed of the elements shown in the
+    <para>The type string is composed of the elements shown in the
     table below. It contains zero or more single "complete types".
     Each complete type may be one of the basic types or a fully
-    described container type. A container type may be a structure, a
-    variant type code, an array with its element type, or a dictionary
-    with its entry type. The format string is
+    described container type. A container type may be a structure with
+    the contained types, a variant, an array with its element type, or
+    a dictionary entry with the contained types. The type string is
     <constant>NUL</constant>-terminated.</para>
 
     <para>In case of a basic type, one argument of the corresponding
@@ -88,27 +92,32 @@
     rules as if they were not nested.</para>
 
     <para>A variant is denoted by <literal>v</literal>. Corresponding
-    arguments must include a format string denoting a complete type,
+    arguments must begin with a type string denoting a complete type,
     and following that, arguments corresponding to the specified type.
     </para>
 
     <para>An array is denoted by <literal>a</literal> followed by a
-    complete type. Corresponding arguments must include the size of
-    the array, and then repeated this number of times, arguments
-    corresponding to the nested type.</para>
+    complete type. Corresponding arguments must begin with the number of
+    entries in the array, followed by the entries themselves,
+    matching the element type of the array.</para>
 
     <para>A dictionary is an array of dictionary entries, denoted by
     <literal>a</literal> followed by a pair of complete types between
     <literal>{</literal> and <literal>}</literal>. The first of those
-    types must be a basic type. Corresponding arguments must include
-    the size of the dictionary, and then repeated this number of
-    times, arguments corresponding to each of the two nested
-    types.</para>
+    types must be a basic type. Corresponding arguments must begin
+    with the number of dictionary entries, followed by a pair of
+    values for each entry matching the element type of
+    the dictionary entries.</para>
+
+    <para>For further details on the D-Bus type system, please consult
+    the <ulink
+    url="http://dbus.freedesktop.org/doc/dbus-specification.html#type-system">D-Bus
+    Specification</ulink>.</para>
 
     <table>
-      <title>Item format specifiers</title>
+      <title>Item type specifiers</title>
 
-      <tgroup cols='4'>
+      <tgroup cols='5'>
         <xi:include href="sd_bus_message_append_basic.xml" xpointer="xpointer(//table[@id='format-specifiers'])//colspec" />
         <xi:include href="sd_bus_message_append_basic.xml" xpointer="xpointer(//table[@id='format-specifiers']//thead)" />
 
@@ -120,6 +129,7 @@
             <entry><constant>SD_BUS_TYPE_ARRAY</constant></entry>
             <entry>array</entry>
             <entry>determined by array type and size</entry>
+            <entry>int, followed by array contents</entry>
           </row>
 
           <row>
@@ -127,6 +137,7 @@
             <entry><constant>SD_BUS_TYPE_VARIANT</constant></entry>
             <entry>variant</entry>
             <entry>determined by the type argument</entry>
+            <entry>signature string, followed by variant contents</entry>
           </row>
 
           <row>
@@ -134,6 +145,7 @@
             <entry><constant>SD_BUS_TYPE_STRUCT_BEGIN</constant></entry>
             <entry>array start</entry>
             <entry morerows="1">determined by the nested types</entry>
+            <entry morerows="1">structure contents</entry>
           </row>
           <row>
             <entry><literal>)</literal></entry>
@@ -146,6 +158,7 @@
             <entry><constant>SD_BUS_TYPE_DICT_ENTRY_BEGIN</constant></entry>
             <entry>dictionary entry start</entry>
             <entry morerows="1">determined by the nested types</entry>
+            <entry morerows="1">dictionary contents</entry>
           </row>
           <row>
             <entry><literal>}</literal></entry>
@@ -155,10 +168,11 @@
        </tbody>
       </tgroup>
     </table>
+
   </refsect1>
 
   <refsect1>
-    <title>Types string grammar</title>
+    <title>Types String Grammar</title>
 
     <programlisting>types ::= complete_type*
 complete_type ::= basic_type | variant | structure | array | dictionary
@@ -194,7 +208,7 @@ uint32_t t = 7;
 double d = 8.0;
 sd_bus_message_append(m, "ynqiuxtd", y, n, q, i, u, x, t, d);</programlisting>
 
-     <para>Append a structure composed of string and a D-Bus path:</para>
+     <para>Append a structure composed of a string and a D-Bus path:</para>
 
      <programlisting>sd_bus_message_append(m, "(so)", "a string", "/a/path");
 </programlisting>
@@ -242,12 +256,8 @@ sd_bus_message_append(m, "ynqiuxtd", y, n, q, i, u, x, t, d);</programlisting>
     <para>
       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry project='die-net'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+      <citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>sd_bus_message_append_array</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     </para>
   </refsect1>
 
diff --git a/man/sd_bus_message_append_array.xml b/man/sd_bus_message_append_array.xml
index c2adc6f..034466b 100644
--- a/man/sd_bus_message_append_array.xml
+++ b/man/sd_bus_message_append_array.xml
@@ -49,7 +49,8 @@
     <refname>sd_bus_message_append_array_iovec</refname>
     <refname>sd_bus_message_append_array_space</refname>
 
-    <refpurpose>Attach an array of items to a message</refpurpose>
+    <refpurpose>Appaned an array of fields to a D-Bus
+    message</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
@@ -69,6 +70,8 @@
         <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
         <paramdef>char <parameter>type</parameter></paramdef>
         <paramdef>int <parameter>memfd</parameter></paramdef>
+        <paramdef>uint64_t <parameter>offset</parameter></paramdef>
+        <paramdef>uint64_t <parameter>size</parameter></paramdef>
       </funcprototype>
 
       <funcprototype>
@@ -83,7 +86,7 @@
         <funcdef>int sd_bus_message_append_array_space</funcdef>
         <paramdef>char <parameter>type</parameter></paramdef>
         <paramdef>size_t <parameter>size</parameter></paramdef>
-        <paramdef>char void **<parameter>ptr</parameter></paramdef>
+        <paramdef>void **<parameter>ptr</parameter></paramdef>
       </funcprototype>
     </funcsynopsis>
   </refsynopsisdiv>
@@ -91,18 +94,19 @@
   <refsect1>
     <title>Description</title>
 
-    <para>The <function>sd_bus_message_append_array</function> functionc
-    appends items to message <parameter>m</parameter> as the single
-    array. A container will be opened, items appended, and the
-    container closed. Parameter <parameter>type</parameter> determines
-    how pointer <parameter>p</parameter> is interpreted.
+    <para>The <function>sd_bus_message_append_array()</function>
+    function appends an array to a D-Bus message
+    <parameter>m</parameter>. A container will be opened, the array
+    contents appended, and the container closed. The parameter
+    <parameter>type</parameter> determines how the pointer
+    <parameter>p</parameter> is interpreted.
     <parameter>type</parameter> must be one of the "trivial" types
     <literal>y</literal>, <literal>n</literal>, <literal>q</literal>,
     <literal>i</literal>, <literal>u</literal>, <literal>x</literal>,
     <literal>t</literal>, <literal>d</literal> (but not
-    <literal>b</literal>), as defined by the
-    <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic Types</ulink>
-    section of the D-Bus specification, and listed in
+    <literal>b</literal>), as defined by the <ulink
+    url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
+    Types</ulink> section of the D-Bus specification, and listed in
     <citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
     Pointer <parameter>p</parameter> must point to an array of size
     <parameter>size</parameter> bytes containing items of the
@@ -110,50 +114,68 @@
     multiple of the size of the type <parameter>type</parameter>. As a
     special case, <parameter>p</parameter> may be
     <constant>NULL</constant>, if <parameter>size</parameter> is 0.
-    </para>
-
-    <para>The memory pointed at by <parameter>p</parameter> is copied
-    into the memory area containing the message and may be changed
-    after this call.</para>
-
-    <para>The
-    <function>sd_bus_message_append_array_memfd</function> function appends
-    items to message <parameter>m</parameter>, similarly to
-    <function>sd_bus_message_append_array</function>. Contents of the
-    memory file descriptor <parameter>memfd</parameter> are used as
-    the contents of the array. Their size must be a multiple of the
-    size of the type <parameter>type</parameter>.</para>
-
-    <para>The descriptor specified with <parameter>memfd</parameter>
-    will be sealed and cannot be modified after this call.</para>
-
-    <para>The
-    <function>sd_bus_message_append_array_iovec</function> function appends
-    items to message <parameter>m</parameter>, similarly to
-    <function>sd_bus_message_append_array</function>. Contents of the
-    iovec <parameter>iov</parameter> are used as the contents of the
-    array. The total size of <parameter>iov</parameter> payload (the
-    sum of <structfield>iov_len</structfield> fields) must be a multiple
-    of the size of the type <parameter>type</parameter>.</para>
-
-    <para>The <parameter>iov</parameter> argument must point to
-    <parameter>n</parameter> <structname>struct iovec</structname>
-    structures. Each structure may have the
-    <structname>iov_base</structname> field set, in which case the
-    memory pointed to will be copied into the message, or unset, in
-    which case a block of zeros of length
+    The memory pointed to by <parameter>p</parameter> is copied into
+    the memory area containing the message and stays in possession of
+    the caller. The caller may hence freely change the data after this
+    call without affecting the message the array was appended
+    to.</para>
+
+    <para>The <function>sd_bus_message_append_array_memfd()</function>
+    function appends an array of a trivial type to message
+    <parameter>m</parameter>, similar to
+    <function>sd_bus_message_append_array()</function>. The contents
+    of the memory file descriptor <parameter>memfd</parameter>
+    starting at the specified offset and and of the specified size is
+    used as the contents of the array. The offset and size must be a
+    multiple of the size of the type
+    <parameter>type</parameter>. However, as a special exception, if
+    the offset is specified as zero and the size specified as
+    UINT64_MAX the full memory file descriptor contents is used. The
+    memory file descriptor is sealed by this call if it hasn't been
+    sealed yet, and cannot be modified a after this call. See
+    <citerefentry
+    project='man-pages'><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+    for details about memory file descriptors. Appending arrays with
+    memory file descriptors enables efficient zero-copy data transfer,
+    as the memory file descriptor may be passed as-is to the
+    destination, without copying the memory in it to the destination
+    process. Not all protocol transports support passing memory file
+    descriptors between participants, in which case this call will
+    automatically fall back to copying. Also, as memory file
+    descriptor passing is inefficient for smaller amounts of data
+    copying might still be enforced even where memory file descriptor
+    passing is supported.</para>
+
+    <para>The <function>sd_bus_message_append_array_iovec()</function>
+    function appends an array of a trivial type to the message
+    <parameter>m</parameter>, similar to
+    <function>sd_bus_message_append_array()</function>. Contents of
+    the IO vector array <parameter>iov</parameter> are used as the
+    contents of the array. The total size of
+    <parameter>iov</parameter> payload (the sum of
+    <structfield>iov_len</structfield> fields) must be a multiple of
+    the size of the type <parameter>type</parameter>. The
+    <parameter>iov</parameter> argument must point to
+    <parameter>n</parameter> IO vector structures. Each structure may
+    have the <structname>iov_base</structname> field set, in which
+    case the memory pointed to will be copied into the message, or
+    unset (set to zero), in which case a block of zeros of length
     <structname>iov_len</structname> bytes will be inserted. The
     memory pointed at by <parameter>iov</parameter> may be changed
     after this call.</para>
 
-    <para>The
-    <function>sd_bus_message_append_array_space</function> function appends
-    space for an array of items to message <parameter>m</parameter>.
-    It behaves the same as
-    <function>sd_bus_message_append_array</function>, but instead
-    of copying items to the message, it returns a pointer to the
-    destination area to the caller in pointer <parameter>p</parameter>.
-    </para>
+    <para>The <function>sd_bus_message_append_array_space()</function>
+    function appends space for an array of a trivial type to message
+    <parameter>m</parameter>.  It behaves the same as
+    <function>sd_bus_message_append_array()</function>, but instead of
+    copying items to the message, it returns a pointer to the
+    destination area to the caller in pointer
+    <parameter>p</parameter>. The caller should subsequently write the
+    array contents to this memory. Modifications of the memory
+    pointed to should only occur until the next operation on the bus
+    message is invoked, most imporantly the memory should not be
+    altered anymore when another field has been added to the message
+    or the message has been sealed.</para>
   </refsect1>
 
   <refsect1>
@@ -183,6 +205,7 @@
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd_bus_message_append_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      <citerefentry project='man-pages'><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
       <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html">The D-Bus specification</ulink>
     </para>
   </refsect1>
diff --git a/man/sd_bus_message_append_basic.xml b/man/sd_bus_message_append_basic.xml
index 91eaf87..276953a 100644
--- a/man/sd_bus_message_append_basic.xml
+++ b/man/sd_bus_message_append_basic.xml
@@ -45,7 +45,7 @@
   <refnamediv>
     <refname>sd_bus_message_append_basic</refname>
 
-    <refpurpose>Attach a single part to a message</refpurpose>
+    <refpurpose>Attach a single field to a message</refpurpose>
   </refnamediv>
 
   <refsynopsisdiv>
@@ -56,7 +56,7 @@
         <funcdef>int sd_bus_message_append_basic</funcdef>
         <paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
         <paramdef>char <parameter>type</parameter></paramdef>
-        <paramdef>char void *<parameter>p</parameter></paramdef>
+        <paramdef>const void *<parameter>p</parameter></paramdef>
       </funcprototype>
     </funcsynopsis>
   </refsynopsisdiv>
@@ -64,31 +64,33 @@
   <refsect1>
     <title>Description</title>
 
-    <para><function>sd_bus_message_append_basic</function> appends a
-    single item to the message <parameter>m</parameter>. Parameter
-    <parameter>type</parameter> determines how pointer
+    <para><function>sd_bus_message_append_basic()</function> appends a
+    single field to the message <parameter>m</parameter>. The
+    parameter <parameter>type</parameter> determines how the pointer
     <parameter>p</parameter> is interpreted.
-    <parameter>type</parameter> must be one of the basic types
-    as defined by the
-
-    <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic Types</ulink>
-    section of the D-Bus specification, and listed in the table below.
+    <parameter>type</parameter> must be one of the basic types as
+    defined by the <ulink
+    url="http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types">Basic
+    Types</ulink> section of the D-Bus specification, and listed in
+    the table below.
     </para>
 
     <table id='format-specifiers'>
-      <title>Item format specifiers</title>
+      <title>Item type specifiers</title>
 
-      <tgroup cols='4'>
+      <tgroup cols='5'>
         <colspec colname='specifier' />
         <colspec colname='constant' />
         <colspec colname='description' />
         <colspec colname='size' />
+        <colspec colname='ctype' />
         <thead>
           <row>
             <entry>Specifier</entry>
             <entry>Constant</entry>
             <entry>Description</entry>
             <entry>Size</entry>
+            <entry>Expected C Type</entry>
           </row>
         </thead>
         <tbody>
@@ -97,6 +99,7 @@
             <entry><constant>SD_BUS_TYPE_BYTE</constant></entry>
             <entry>unsigned integer</entry>
             <entry>1 byte</entry>
+            <entry>uint8_t</entry>
           </row>
 
           <row>
@@ -104,6 +107,7 @@
             <entry><constant>SD_BUS_TYPE_BOOLEAN</constant></entry>
             <entry>boolean</entry>
             <entry>4 bytes</entry>
+            <entry>int</entry>
           </row>
 
           <row>
@@ -111,6 +115,7 @@
             <entry><constant>SD_BUS_TYPE_INT16</constant></entry>
             <entry>signed integer</entry>
             <entry>2 bytes</entry>
+            <entry>int16_t</entry>
           </row>
 
           <row>
@@ -118,6 +123,7 @@
             <entry><constant>SD_BUS_TYPE_UINT16</constant></entry>
             <entry>unsigned integer</entry>
             <entry>2 bytes</entry>
+            <entry>uint16_t</entry>
           </row>
 
           <row>
@@ -125,6 +131,7 @@
             <entry><constant>SD_BUS_TYPE_INT32</constant></entry>
             <entry>signed integer</entry>
             <entry>4 bytes</entry>
+            <entry>int32_t</entry>
           </row>
 
           <row>
@@ -132,6 +139,7 @@
             <entry><constant>SD_BUS_TYPE_UINT32</constant></entry>
             <entry>unsigned integer</entry>
             <entry>4 bytes</entry>
+            <entry>uint32_t</entry>
           </row>
 
           <row>
@@ -139,6 +147,7 @@
             <entry><constant>SD_BUS_TYPE_INT64</constant></entry>
             <entry>signed integer</entry>
             <entry>8 bytes</entry>
+            <entry>int64_t</entry>
           </row>
 
           <row>
@@ -146,6 +155,7 @@
             <entry><constant>SD_BUS_TYPE_UINT64</constant></entry>
             <entry>unsigned integer</entry>
             <entry>8 bytes</entry>
+            <entry>uint64_t</entry>
           </row>
 
           <row>
@@ -153,6 +163,7 @@
             <entry><constant>SD_BUS_TYPE_DOUBLE</constant></entry>
             <entry>floating-point</entry>
             <entry>8 bytes</entry>
+            <entry>double</entry>
           </row>
 
           <row>
@@ -160,6 +171,7 @@
             <entry><constant>SD_BUS_TYPE_STRING</constant></entry>
             <entry>Unicode string</entry>
             <entry>variable</entry>
+            <entry>char[]</entry>
           </row>
 
           <row>
@@ -167,6 +179,7 @@
             <entry><constant>SD_BUS_TYPE_OBJECT_PATH</constant></entry>
             <entry>object path</entry>
             <entry>variable</entry>
+            <entry>char[]</entry>
           </row>
 
           <row>
@@ -174,6 +187,7 @@
             <entry><constant>SD_BUS_TYPE_SIGNATURE</constant></entry>
             <entry>signature</entry>
             <entry>variable</entry>
+            <entry>char[]</entry>
           </row>
 
           <row>
@@ -181,16 +195,19 @@
             <entry><constant>SD_BUS_TYPE_UNIX_FD</constant></entry>
             <entry>UNIX file descriptor</entry>
             <entry>4 bytes</entry>
+            <entry>int</entry>
           </row>
        </tbody>
       </tgroup>
     </table>
 
-    <para>The value of the parameter is copied into the memory area
-    containing the message and may be changed after this call. If
-    <parameter>type</parameter> is <literal>h</literal> (UNIX file
-    descriptor), it is always "consumed" by this call, and either
-    successfully appended to the message or closed.</para>
+    <para>The value of the parameter is copied into a memory area held
+    by the message object, stays in the possession of the caller and
+    may hence be freely changed after this call without affecting the
+    bus message it has been added to. If <parameter>type</parameter>
+    is <literal>h</literal> (UNIX file descriptor), the descriptor is
+    duplicated by this call and the passed descriptor stays in
+    possession of the caller.</para>
 
     <para>For types <literal>s</literal>, <literal>o</literal>, and
     <literal>g</literal>, the parameter <parameter>p</parameter> is

commit ad118bda159d3f9c27c5a15ace54cf808a6e8788
Author: Daniel Mack <daniel at zonque.org>
Date:   Mon Jul 6 19:27:20 2015 -0400

    tree-wide: fix write_string_file() user that should not create files
    
    The latest consolidation cleanup of write_string_file() revealed some users
    of that helper which should have used write_string_file_no_create() in the
    past but didn't. Basically, all existing users that write to files in /sys
    and /proc should not expect to write to a file which is not yet existant.

diff --git a/src/basic/smack-util.c b/src/basic/smack-util.c
index 0c3697b..047aa29 100644
--- a/src/basic/smack-util.c
+++ b/src/basic/smack-util.c
@@ -139,7 +139,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
                 return 0;
 
         p = procfs_file_alloca(pid, "attr/current");
-        r = write_string_file(p, label, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(p, label, 0);
         if (r < 0)
                 return r;
 #endif
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 24eb410..1e216f5 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
                 }
 
                 /* Flush out all rules */
-                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
 
                 STRV_FOREACH(f, files) {
                         k = apply_file(*f, true);
diff --git a/src/core/execute.c b/src/core/execute.c
index 61e7304..21721dc 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1446,7 +1446,7 @@ static int exec_child(
                  * shouldn't trip up over that. */
 
                 sprintf(t, "%i", context->oom_score_adjust);
-                r = write_string_file("/proc/self/oom_score_adj", t, WRITE_STRING_FILE_CREATE);
+                r = write_string_file("/proc/self/oom_score_adj", t, 0);
                 if (r == -EPERM || r == -EACCES) {
                         log_open();
                         log_unit_debug_errno(unit, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index c7f4d02..d749eb4 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -2508,7 +2508,7 @@ static int reset_audit_loginuid(void) {
         if (streq(p, "4294967295"))
                 return 0;
 
-        r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_CREATE);
+        r = write_string_file("/proc/self/loginuid", "4294967295", 0);
         if (r < 0) {
                 log_error_errno(r,
                                 "Failed to reset audit login UID. This probably means that your kernel is too\n"
@@ -4448,13 +4448,13 @@ static int setup_uid_map(pid_t pid) {
 
         xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
         xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, arg_uid_shift, arg_uid_range);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write UID map: %m");
 
         /* We always assign the same UID and GID ranges */
         xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
-        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
+        r = write_string_file(uid_map, line, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write GID map: %m");
 
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c
index 232a005..1de0b94 100644
--- a/src/shared/sysctl-util.c
+++ b/src/shared/sysctl-util.c
@@ -66,7 +66,7 @@ int sysctl_write(const char *property, const char *value) {
         log_debug("Setting '%s' to '%s'", property, value);
 
         p = strjoina("/proc/sys/", property);
-        return write_string_file(p, value, WRITE_STRING_FILE_CREATE);
+        return write_string_file(p, value, 0);
 }
 
 int sysctl_read(const char *property, char **content) {
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 8a31089..0661f7b 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -398,7 +398,7 @@ static void worker_spawn(Manager *manager, struct event *event) {
                 prctl(PR_SET_PDEATHSIG, SIGTERM);
 
                 /* reset OOM score, we only protect the main daemon */
-                write_string_file("/proc/self/oom_score_adj", "0", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/self/oom_score_adj", "0", 0);
 
                 for (;;) {
                         struct udev_event *udev_event;
@@ -1747,7 +1747,7 @@ int main(int argc, char *argv[]) {
 
                 setsid();
 
-                write_string_file("/proc/self/oom_score_adj", "-1000", WRITE_STRING_FILE_CREATE);
+                write_string_file("/proc/self/oom_score_adj", "-1000", 0);
         }
 
         r = run(fd_ctrl, fd_uevent, cgroup);
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 4b21175..7bdc158 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -56,7 +56,7 @@ static int disable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", WRITE_STRING_FILE_CREATE);
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", 0);
         if (k < 0)
                 r = k;
 
@@ -89,7 +89,7 @@ static int enable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", WRITE_STRING_FILE_CREATE);
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", 0);
         if (k < 0)
                 r = k;
 

commit 4c1fc3e404d648c70bd2f50ac50aeac6ece8872e
Author: Daniel Mack <daniel at zonque.org>
Date:   Mon Jul 6 19:19:25 2015 -0400

    fileio: consolidate write_string_file*()
    
    Merge write_string_file(), write_string_file_no_create() and
    write_string_file_atomic() into write_string_file() and provide a flags mask
    that allows combinations of atomic writing, newline appending and automatic
    file creation. Change all users accordingly.

diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index c79ad65..c8961de 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -415,7 +415,7 @@ int main(int argc, char *argv[]) {
                         return EXIT_FAILURE;
                 }
 
-                r = write_string_file(saved, value);
+                r = write_string_file(saved, value, WRITE_STRING_FILE_CREATE);
                 if (r < 0) {
                         log_error_errno(r, "Failed to write %s: %m", saved);
                         return EXIT_FAILURE;
diff --git a/src/basic/capability.c b/src/basic/capability.c
index 58f00e6..8dbe4da 100644
--- a/src/basic/capability.c
+++ b/src/basic/capability.c
@@ -204,7 +204,7 @@ static int drop_from_file(const char *fn, uint64_t drop) {
         if (asprintf(&p, "%u %u", lo, hi) < 0)
                 return -ENOMEM;
 
-        r = write_string_file(fn, p);
+        r = write_string_file(fn, p, WRITE_STRING_FILE_CREATE);
         free(p);
 
         return r;
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 439c551..34a3060 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -646,7 +646,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
 
         snprintf(c, sizeof(c), PID_FMT"\n", pid);
 
-        return write_string_file_no_create(fs, c);
+        return write_string_file(fs, c, 0);
 }
 
 int cg_attach_fallback(const char *controller, const char *path, pid_t pid) {
@@ -820,7 +820,7 @@ int cg_install_release_agent(const char *controller, const char *agent) {
 
         sc = strstrip(contents);
         if (sc[0] == 0) {
-                r = write_string_file_no_create(fs, agent);
+                r = write_string_file(fs, agent, 0);
                 if (r < 0)
                         return r;
         } else if (!streq(sc, agent))
@@ -840,7 +840,7 @@ int cg_install_release_agent(const char *controller, const char *agent) {
 
         sc = strstrip(contents);
         if (streq(sc, "0")) {
-                r = write_string_file_no_create(fs, "1");
+                r = write_string_file(fs, "1", 0);
                 if (r < 0)
                         return r;
 
@@ -861,7 +861,7 @@ int cg_uninstall_release_agent(const char *controller) {
         if (r < 0)
                 return r;
 
-        r = write_string_file_no_create(fs, "0");
+        r = write_string_file(fs, "0", 0);
         if (r < 0)
                 return r;
 
@@ -872,7 +872,7 @@ int cg_uninstall_release_agent(const char *controller) {
         if (r < 0)
                 return r;
 
-        r = write_string_file_no_create(fs, "");
+        r = write_string_file(fs, "", 0);
         if (r < 0)
                 return r;
 
@@ -1708,7 +1708,7 @@ int cg_set_attribute(const char *controller, const char *path, const char *attri
         if (r < 0)
                 return r;
 
-        return write_string_file_no_create(p, value);
+        return write_string_file(p, value, 0);
 }
 
 int cg_get_attribute(const char *controller, const char *path, const char *attribute, char **ret) {
diff --git a/src/basic/fileio-label.c b/src/basic/fileio-label.c
index bec988c..f596f1d 100644
--- a/src/basic/fileio-label.c
+++ b/src/basic/fileio-label.c
@@ -31,7 +31,7 @@ int write_string_file_atomic_label(const char *fn, const char *line) {
         if (r < 0)
                 return r;
 
-        r = write_string_file_atomic(fn, line);
+        r = write_string_file(fn, line, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
 
         mac_selinux_create_file_clear();
 
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 82b40aa..d592bf5 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -45,42 +45,7 @@ int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
         return 0;
 }
 
-int write_string_file(const char *fn, const char *line) {
-        _cleanup_fclose_ FILE *f = NULL;
-
-        assert(fn);
-        assert(line);
-
-        f = fopen(fn, "we");
-        if (!f)
-                return -errno;
-
-        return write_string_stream(f, line, true);
-}
-
-int write_string_file_no_create(const char *fn, const char *line) {
-        _cleanup_fclose_ FILE *f = NULL;
-        int fd;
-
-        assert(fn);
-        assert(line);
-
-        /* We manually build our own version of fopen(..., "we") that
-         * works without O_CREAT */
-        fd = open(fn, O_WRONLY|O_CLOEXEC|O_NOCTTY);
-        if (fd < 0)
-                return -errno;
-
-        f = fdopen(fd, "we");
-        if (!f) {
-                safe_close(fd);
-                return -errno;
-        }
-
-        return write_string_stream(f, line, true);
-}
-
-int write_string_file_atomic(const char *fn, const char *line) {
+static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) {
         _cleanup_fclose_ FILE *f = NULL;
         _cleanup_free_ char *p = NULL;
         int r;
@@ -94,7 +59,7 @@ int write_string_file_atomic(const char *fn, const char *line) {
 
         fchmod_umask(fileno(f), 0644);
 
-        r = write_string_stream(f, line, true);
+        r = write_string_stream(f, line, enforce_newline);
         if (r >= 0) {
                 if (rename(p, fn) < 0)
                         r = -errno;
@@ -106,6 +71,41 @@ int write_string_file_atomic(const char *fn, const char *line) {
         return r;
 }
 
+int write_string_file(const char *fn, const char *line, WriteStringFileFlags flags) {
+        _cleanup_fclose_ FILE *f = NULL;
+
+        assert(fn);
+        assert(line);
+
+        if (flags & WRITE_STRING_FILE_ATOMIC) {
+                assert(flags & WRITE_STRING_FILE_CREATE);
+
+                return write_string_file_atomic(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE));
+        }
+
+        if (flags & WRITE_STRING_FILE_CREATE) {
+                f = fopen(fn, "we");
+                if (!f)
+                        return -errno;
+        } else {
+                int fd;
+
+                /* We manually build our own version of fopen(..., "we") that
+                 * works without O_CREAT */
+                fd = open(fn, O_WRONLY|O_CLOEXEC|O_NOCTTY);
+                if (fd < 0)
+                        return -errno;
+
+                f = fdopen(fd, "we");
+                if (!f) {
+                        safe_close(fd);
+                        return -errno;
+                }
+        }
+
+        return write_string_stream(f, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE));
+}
+
 int read_one_line_file(const char *fn, char **line) {
         _cleanup_fclose_ FILE *f = NULL;
         char t[LINE_MAX], *c;
diff --git a/src/basic/fileio.h b/src/basic/fileio.h
index 989b904..2e8148f 100644
--- a/src/basic/fileio.h
+++ b/src/basic/fileio.h
@@ -25,10 +25,14 @@
 
 #include "macro.h"
 
+typedef enum {
+        WRITE_STRING_FILE_CREATE = 1,
+        WRITE_STRING_FILE_ATOMIC = 2,
+        WRITE_STRING_FILE_AVOID_NEWLINE = 4,
+} WriteStringFileFlags;
+
 int write_string_stream(FILE *f, const char *line, bool enforce_newline);
-int write_string_file(const char *fn, const char *line);
-int write_string_file_no_create(const char *fn, const char *line);
-int write_string_file_atomic(const char *fn, const char *line);
+int write_string_file(const char *fn, const char *line, WriteStringFileFlags flags);
 
 int read_one_line_file(const char *fn, char **line);
 int read_full_file(const char *fn, char **contents, size_t *size);
diff --git a/src/basic/smack-util.c b/src/basic/smack-util.c
index 2e24b1e..0c3697b 100644
--- a/src/basic/smack-util.c
+++ b/src/basic/smack-util.c
@@ -139,7 +139,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
                 return 0;
 
         p = procfs_file_alloca(pid, "attr/current");
-        r = write_string_file(p, label);
+        r = write_string_file(p, label, WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return r;
 #endif
diff --git a/src/basic/util.c b/src/basic/util.c
index aa912bd..e4e302a 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -4716,7 +4716,7 @@ int update_reboot_param_file(const char *param) {
 
         if (param) {
 
-                r = write_string_file(REBOOT_PARAM_FILE, param);
+                r = write_string_file(REBOOT_PARAM_FILE, param, WRITE_STRING_FILE_CREATE);
                 if (r < 0)
                         log_error("Failed to write reboot param to "
                                   REBOOT_PARAM_FILE": %s", strerror(-r));
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 6028ed6..24eb410 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -53,7 +53,7 @@ static int delete_rule(const char *rule) {
         if (!fn)
                 return log_oom();
 
-        return write_string_file(fn, "-1");
+        return write_string_file(fn, "-1", 0);
 }
 
 static int apply_rule(const char *rule) {
@@ -61,7 +61,7 @@ static int apply_rule(const char *rule) {
 
         delete_rule(rule);
 
-        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule);
+        r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to add binary format: %m");
 
@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
                 }
 
                 /* Flush out all rules */
-                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1");
+                write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_CREATE);
 
                 STRV_FOREACH(f, files) {
                         k = apply_file(*f, true);
diff --git a/src/core/execute.c b/src/core/execute.c
index c92db51..61e7304 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1446,7 +1446,7 @@ static int exec_child(
                  * shouldn't trip up over that. */
 
                 sprintf(t, "%i", context->oom_score_adjust);
-                r = write_string_file("/proc/self/oom_score_adj", t);
+                r = write_string_file("/proc/self/oom_score_adj", t, WRITE_STRING_FILE_CREATE);
                 if (r == -EPERM || r == -EACCES) {
                         log_open();
                         log_unit_debug_errno(unit, r, "Failed to adjust OOM setting, assuming containerized execution, ignoring: %m");
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index b3d2284..8e26362 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -260,7 +260,7 @@ int machine_id_setup(const char *root) {
          * /run/machine-id as a replacement */
 
         RUN_WITH_UMASK(0022) {
-                r = write_string_file(run_machine_id, id);
+                r = write_string_file(run_machine_id, id, WRITE_STRING_FILE_CREATE);
         }
         if (r < 0) {
                 (void) unlink(run_machine_id);
diff --git a/src/core/main.c b/src/core/main.c
index 523f0ce..c412457 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1203,7 +1203,7 @@ static int write_container_id(void) {
         if (isempty(c))
                 return 0;
 
-        return write_string_file("/run/systemd/container", c);
+        return write_string_file("/run/systemd/container", c, WRITE_STRING_FILE_CREATE);
 }
 
 int main(int argc, char *argv[]) {
diff --git a/src/core/smack-setup.c b/src/core/smack-setup.c
index ddb02a1..cbe7d0b 100644
--- a/src/core/smack-setup.c
+++ b/src/core/smack-setup.c
@@ -221,7 +221,7 @@ int mac_smack_setup(bool *loaded_policy) {
         }
 
 #ifdef SMACK_RUN_LABEL
-        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL);
+        r = write_string_file("/proc/self/attr/current", SMACK_RUN_LABEL, 0);
         if (r)
                 log_warning("Failed to set SMACK label \"%s\" on self: %s",
                             SMACK_RUN_LABEL, strerror(-r));
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index cda96d4..3805b29 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -415,7 +415,7 @@ static int process_hostname(void) {
                 return 0;
 
         mkdir_parents(etc_hostname, 0755);
-        r = write_string_file(etc_hostname, arg_hostname);
+        r = write_string_file(etc_hostname, arg_hostname, WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return log_error_errno(r, "Failed to write %s: %m", etc_hostname);
 
@@ -436,7 +436,7 @@ static int process_machine_id(void) {
                 return 0;
 
         mkdir_parents(etc_machine_id, 0755);
-        r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id));
+        r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id), WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return log_error_errno(r, "Failed to write machine id: %m");
 
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index b46e160..da5f3b6 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -183,7 +183,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
         r = write_string_file(p,
                         "# Automatically generated by systemd-gpt-auto-generator\n\n"
                         "[Unit]\n"
-                        "JobTimeoutSec=0\n"); /* the binary handles timeouts anyway */
+                        "JobTimeoutSec=0\n",
+                        WRITE_STRING_FILE_CREATE); /* the binary handles timeouts anyway */
         if (r < 0)
                 return log_error_errno(r, "Failed to write device drop-in: %m");
 
diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c
index 43aac61..1f3b169 100644
--- a/src/hibernate-resume/hibernate-resume.c
+++ b/src/hibernate-resume/hibernate-resume.c
@@ -65,7 +65,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        r = write_string_file("/sys/power/resume", major_minor);
+        r = write_string_file("/sys/power/resume", major_minor, WRITE_STRING_FILE_CREATE);
         if (r < 0) {
                 log_error_errno(r, "Failed to write '%s' to /sys/power/resume: %m", major_minor);
                 return EXIT_FAILURE;
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 659ce18..b56a61c 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1196,7 +1196,7 @@ static int trigger_device(Manager *m, struct udev_device *d) {
                 if (!t)
                         return -ENOMEM;
 
-                write_string_file(t, "change");
+                write_string_file(t, "change", WRITE_STRING_FILE_CREATE);
         }
 
         return 0;
@@ -1795,7 +1795,7 @@ static int nologin_timeout_handler(
 
         log_info("Creating /run/nologin, blocking further logins...");
 
-        r = write_string_file_atomic("/run/nologin", "System is going down.");
+        r = write_string_file("/run/nologin", "System is going down.", WRITE_STRING_FILE_ATOMIC);
         if (r < 0)
                 log_error_errno(r, "Failed to create /run/nologin: %m");
         else
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 5607cf4..9550e89 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1495,7 +1495,7 @@ static int link_set_ipv4_forward(Link *link) {
         p = strjoina("/proc/sys/net/ipv4/conf/", link->ifname, "/forwarding");
         v = one_zero(link_ipv4_forward_enabled(link));
 
-        r = write_string_file_no_create(p, v);
+        r = write_string_file(p, v, 0);
         if (r < 0) {
                 /* If the right value is set anyway, don't complain */
                 if (verify_one_line_file(p, v) > 0)
@@ -1524,7 +1524,7 @@ static int link_set_ipv6_forward(Link *link) {
         p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/forwarding");
         v = one_zero(link_ipv6_forward_enabled(link));
 
-        r = write_string_file_no_create(p, v);
+        r = write_string_file(p, v, 0);
         if (r < 0) {
                 /* If the right value is set anyway, don't complain */
                 if (verify_one_line_file(p, v) > 0)
@@ -1553,7 +1553,7 @@ static int link_set_ipv6_privacy_extensions(Link *link) {
         p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/use_tempaddr");
         xsprintf(buf, "%u", link->network->ipv6_privacy_extensions);
 
-        r = write_string_file_no_create(p, buf);
+        r = write_string_file(p, buf, 0);
         if (r < 0) {
                 /* If the right value is set anyway, don't complain */
                 if (verify_one_line_file(p, buf) > 0)
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index ab9fbaf..c7f4d02 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1703,7 +1703,7 @@ static int setup_boot_id(const char *dest) {
 
         id128_format_as_uuid(rnd, as_uuid);
 
-        r = write_string_file(from, as_uuid);
+        r = write_string_file(from, as_uuid, WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return log_error_errno(r, "Failed to write boot id: %m");
 
@@ -2508,7 +2508,7 @@ static int reset_audit_loginuid(void) {
         if (streq(p, "4294967295"))
                 return 0;
 
-        r = write_string_file("/proc/self/loginuid", "4294967295");
+        r = write_string_file("/proc/self/loginuid", "4294967295", WRITE_STRING_FILE_CREATE);
         if (r < 0) {
                 log_error_errno(r,
                                 "Failed to reset audit login UID. This probably means that your kernel is too\n"
@@ -4448,13 +4448,13 @@ static int setup_uid_map(pid_t pid) {
 
         xsprintf(uid_map, "/proc/" PID_FMT "/uid_map", pid);
         xsprintf(line, UID_FMT " " UID_FMT " " UID_FMT "\n", 0, arg_uid_shift, arg_uid_range);
-        r = write_string_file(uid_map, line);
+        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return log_error_errno(r, "Failed to write UID map: %m");
 
         /* We always assign the same UID and GID ranges */
         xsprintf(uid_map, "/proc/" PID_FMT "/gid_map", pid);
-        r = write_string_file(uid_map, line);
+        r = write_string_file(uid_map, line, WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 return log_error_errno(r, "Failed to write GID map: %m");
 
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index 5a90c77..904dec6 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
                         return EXIT_SUCCESS;
                 }
 
-                r = write_string_file(saved, value);
+                r = write_string_file(saved, value, WRITE_STRING_FILE_CREATE);
                 if (r < 0) {
                         log_error_errno(r, "Failed to write %s: %m", saved);
                         return EXIT_FAILURE;
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c
index 55f4e48..232a005 100644
--- a/src/shared/sysctl-util.c
+++ b/src/shared/sysctl-util.c
@@ -66,7 +66,7 @@ int sysctl_write(const char *property, const char *value) {
         log_debug("Setting '%s' to '%s'", property, value);
 
         p = strjoina("/proc/sys/", property);
-        return write_string_file(p, value);
+        return write_string_file(p, value, WRITE_STRING_FILE_CREATE);
 }
 
 int sysctl_read(const char *property, char **content) {
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 2be63b4..2b23101 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -42,7 +42,7 @@ static int write_mode(char **modes) {
         STRV_FOREACH(mode, modes) {
                 int k;
 
-                k = write_string_file("/sys/power/disk", *mode);
+                k = write_string_file("/sys/power/disk", *mode, 0);
                 if (k == 0)
                         return 0;
 
diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c
index 838ffcb..e4771c9 100644
--- a/src/test/test-btrfs.c
+++ b/src/test/test-btrfs.c
@@ -68,7 +68,7 @@ int main(int argc, char *argv[]) {
         if (r < 0)
                 log_error_errno(r, "Failed to make subvolume: %m");
 
-        r = write_string_file("/xxxtest/afile", "ljsadhfljasdkfhlkjdsfha");
+        r = write_string_file("/xxxtest/afile", "ljsadhfljasdkfhlkjdsfha", WRITE_STRING_FILE_CREATE);
         if (r < 0)
                 log_error_errno(r, "Failed to write file: %m");
 
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index b1385b8..b73c958 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -43,7 +43,7 @@ static void test_copy_file(void) {
         assert_se(fd >= 0);
         close(fd);
 
-        assert_se(write_string_file(fn, "foo bar bar bar foo") == 0);
+        assert_se(write_string_file(fn, "foo bar bar bar foo", WRITE_STRING_FILE_CREATE) == 0);
 
         assert_se(copy_file(fn, fn_copy, 0, 0644, 0) == 0);
 
@@ -67,7 +67,7 @@ static void test_copy_file_fd(void) {
         out_fd = mkostemp_safe(out_fn, O_RDWR);
         assert_se(out_fd >= 0);
 
-        assert_se(write_string_file(in_fn, text) == 0);
+        assert_se(write_string_file(in_fn, text, WRITE_STRING_FILE_CREATE) == 0);
         assert_se(copy_file_fd("/a/file/which/does/not/exist/i/guess", out_fd, true) < 0);
         assert_se(copy_file_fd(in_fn, out_fd, true) >= 0);
         assert_se(lseek(out_fd, SEEK_SET, 0) == 0);
@@ -94,7 +94,7 @@ static void test_copy_tree(void) {
                 char *f = strjoina(original_dir, *p);
 
                 assert_se(mkdir_parents(f, 0755) >= 0);
-                assert_se(write_string_file(f, "file") == 0);
+                assert_se(write_string_file(f, "file", WRITE_STRING_FILE_CREATE) == 0);
         }
 
         STRV_FOREACH_PAIR(link, p, links) {
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 725c2fa..be3a879 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -334,7 +334,7 @@ static void test_write_string_file(void) {
         fd = mkostemp_safe(fn, O_RDWR);
         assert_se(fd >= 0);
 
-        assert_se(write_string_file(fn, "boohoo") == 0);
+        assert_se(write_string_file(fn, "boohoo", WRITE_STRING_FILE_CREATE) == 0);
 
         assert_se(read(fd, buf, sizeof(buf)) == 7);
         assert_se(streq(buf, "boohoo\n"));
@@ -350,8 +350,8 @@ static void test_write_string_file_no_create(void) {
         fd = mkostemp_safe(fn, O_RDWR);
         assert_se(fd >= 0);
 
-        assert_se(write_string_file_no_create("/a/file/which/does/not/exists/i/guess", "boohoo") < 0);
-        assert_se(write_string_file_no_create(fn, "boohoo") == 0);
+        assert_se(write_string_file("/a/file/which/does/not/exists/i/guess", "boohoo", 0) < 0);
+        assert_se(write_string_file(fn, "boohoo", 0) == 0);
 
         assert_se(read(fd, buf, sizeof(buf)) == strlen("boohoo\n"));
         assert_se(streq(buf, "boohoo\n"));
@@ -377,8 +377,8 @@ static void test_load_env_file_pairs(void) {
                         "ANSI_COLOR=\"0;36\"\n"
                         "HOME_URL=\"https://www.archlinux.org/\"\n"
                         "SUPPORT_URL=\"https://bbs.archlinux.org/\"\n"
-                        "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n"
-                        );
+                        "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n",
+                        WRITE_STRING_FILE_CREATE);
         assert_se(r == 0);
 
         f = fdopen(fd, "r");
diff --git a/src/test/test-util.c b/src/test/test-util.c
index ad9ea3b..9fbfece 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -565,14 +565,14 @@ static void test_read_hostname_config(void) {
         close(fd);
 
         /* simple hostname */
-        write_string_file(path, "foo");
+        write_string_file(path, "foo", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(streq(hostname, "foo"));
         free(hostname);
         hostname = NULL;
 
         /* with comment */
-        write_string_file(path, "# comment\nfoo");
+        write_string_file(path, "# comment\nfoo", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foo"));
@@ -580,7 +580,7 @@ static void test_read_hostname_config(void) {
         hostname = NULL;
 
         /* with comment and extra whitespace */
-        write_string_file(path, "# comment\n\n foo ");
+        write_string_file(path, "# comment\n\n foo ", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foo"));
@@ -588,7 +588,7 @@ static void test_read_hostname_config(void) {
         hostname = NULL;
 
         /* cleans up name */
-        write_string_file(path, "!foo/bar.com");
+        write_string_file(path, "!foo/bar.com", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foobar.com"));
@@ -597,7 +597,7 @@ static void test_read_hostname_config(void) {
 
         /* no value set */
         hostname = (char*) 0x1234;
-        write_string_file(path, "# nothing here\n");
+        write_string_file(path, "# nothing here\n", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == -ENOENT);
         assert_se(hostname == (char*) 0x1234);  /* does not touch argument on error */
 
@@ -1191,11 +1191,11 @@ static void test_execute_directory(void) {
         masked = strjoina(template_lo, "/masked");
         mask = strjoina(template_hi, "/masked");
 
-        assert_se(write_string_file(name, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works") == 0);
-        assert_se(write_string_file(name2, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works2") == 0);
-        assert_se(write_string_file(overridden, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed") == 0);
-        assert_se(write_string_file(override, "#!/bin/sh\necho 'Executing '$0") == 0);
-        assert_se(write_string_file(masked, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed") == 0);
+        assert_se(write_string_file(name, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works", WRITE_STRING_FILE_CREATE) == 0);
+        assert_se(write_string_file(name2, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works2", WRITE_STRING_FILE_CREATE) == 0);
+        assert_se(write_string_file(overridden, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed", WRITE_STRING_FILE_CREATE) == 0);
+        assert_se(write_string_file(override, "#!/bin/sh\necho 'Executing '$0", WRITE_STRING_FILE_CREATE) == 0);
+        assert_se(write_string_file(masked, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed", WRITE_STRING_FILE_CREATE) == 0);
         assert_se(symlink("/dev/null", mask) == 0);
         assert_se(chmod(name, 0755) == 0);
         assert_se(chmod(name2, 0755) == 0);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index e27fb1f..8a31089 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -398,7 +398,7 @@ static void worker_spawn(Manager *manager, struct event *event) {
                 prctl(PR_SET_PDEATHSIG, SIGTERM);
 
                 /* reset OOM score, we only protect the main daemon */
-                write_string_file("/proc/self/oom_score_adj", "0");
+                write_string_file("/proc/self/oom_score_adj", "0", WRITE_STRING_FILE_CREATE);
 
                 for (;;) {
                         struct udev_event *udev_event;
@@ -1091,7 +1091,7 @@ static int synthesize_change(struct udev_device *dev) {
                  */
                 log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
                 strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
-                write_string_file(filename, "change");
+                write_string_file(filename, "change", WRITE_STRING_FILE_CREATE);
 
                 udev_list_entry_foreach(item, udev_enumerate_get_list_entry(e)) {
                         _cleanup_udev_device_unref_ struct udev_device *d = NULL;
@@ -1106,7 +1106,7 @@ static int synthesize_change(struct udev_device *dev) {
                         log_debug("device %s closed, synthesising partition '%s' 'change'",
                                   udev_device_get_devnode(dev), udev_device_get_devnode(d));
                         strscpyl(filename, sizeof(filename), udev_device_get_syspath(d), "/uevent", NULL);
-                        write_string_file(filename, "change");
+                        write_string_file(filename, "change", WRITE_STRING_FILE_CREATE);
                 }
 
                 return 0;
@@ -1114,7 +1114,7 @@ static int synthesize_change(struct udev_device *dev) {
 
         log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
         strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
-        write_string_file(filename, "change");
+        write_string_file(filename, "change", WRITE_STRING_FILE_CREATE);
 
         return 0;
 }
@@ -1747,7 +1747,7 @@ int main(int argc, char *argv[]) {
 
                 setsid();
 
-                write_string_file("/proc/self/oom_score_adj", "-1000");
+                write_string_file("/proc/self/oom_score_adj", "-1000", WRITE_STRING_FILE_CREATE);
         }
 
         r = run(fd_ctrl, fd_uevent, cgroup);
diff --git a/src/user-sessions/user-sessions.c b/src/user-sessions/user-sessions.c
index 1c31769..ddeb310 100644
--- a/src/user-sessions/user-sessions.c
+++ b/src/user-sessions/user-sessions.c
@@ -65,7 +65,7 @@ int main(int argc, char*argv[]) {
         } else if (streq(argv[1], "stop")) {
                 int r;
 
-                r = write_string_file_atomic("/run/nologin", "System is going down.");
+                r = write_string_file("/run/nologin", "System is going down.", WRITE_STRING_FILE_ATOMIC);
                 if (r < 0) {
                         log_error_errno(r, "Failed to create /run/nologin: %m");
                         return EXIT_FAILURE;
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index f7728dc..4b21175 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -56,7 +56,7 @@ static int disable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0");
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "0", WRITE_STRING_FILE_CREATE);
         if (k < 0)
                 r = k;
 
@@ -89,7 +89,7 @@ static int enable_utf8(int fd) {
         if (k < 0)
                 r = k;
 
-        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1");
+        k = write_string_file("/sys/module/vt/parameters/default_utf8", "1", WRITE_STRING_FILE_CREATE);
         if (k < 0)
                 r = k;
 

commit 40beecdb6d1c73e5acb62ebac2ccbfd7891f2418
Author: Daniel Mack <daniel at zonque.org>
Date:   Mon Jul 6 17:31:44 2015 -0400

    fileio: add 'enforce_newline' argument to write_string_stream()
    
    Add a flag to control whether write_string_stream() should always enforce a
    trailing newline character in the file.

diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index 00fb6f8..82b40aa 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -27,14 +27,14 @@
 #include "ctype.h"
 #include "fileio.h"
 
-int write_string_stream(FILE *f, const char *line) {
+int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
         assert(f);
         assert(line);
 
         errno = 0;
 
         fputs(line, f);
-        if (!endswith(line, "\n"))
+        if (enforce_newline && !endswith(line, "\n"))
                 fputc('\n', f);
 
         fflush(f);
@@ -55,7 +55,7 @@ int write_string_file(const char *fn, const char *line) {
         if (!f)
                 return -errno;
 
-        return write_string_stream(f, line);
+        return write_string_stream(f, line, true);
 }
 
 int write_string_file_no_create(const char *fn, const char *line) {
@@ -77,7 +77,7 @@ int write_string_file_no_create(const char *fn, const char *line) {
                 return -errno;
         }
 
-        return write_string_stream(f, line);
+        return write_string_stream(f, line, true);
 }
 
 int write_string_file_atomic(const char *fn, const char *line) {
@@ -94,7 +94,7 @@ int write_string_file_atomic(const char *fn, const char *line) {
 
         fchmod_umask(fileno(f), 0644);
 
-        r = write_string_stream(f, line);
+        r = write_string_stream(f, line, true);
         if (r >= 0) {
                 if (rename(p, fn) < 0)
                         r = -errno;
diff --git a/src/basic/fileio.h b/src/basic/fileio.h
index 91d4a0d..989b904 100644
--- a/src/basic/fileio.h
+++ b/src/basic/fileio.h
@@ -25,7 +25,7 @@
 
 #include "macro.h"
 
-int write_string_stream(FILE *f, const char *line);
+int write_string_stream(FILE *f, const char *line, bool enforce_newline);
 int write_string_file(const char *fn, const char *line);
 int write_string_file_no_create(const char *fn, const char *line);
 int write_string_file_atomic(const char *fn, const char *line);
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index eee6bc8..2be63b4 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -65,7 +65,7 @@ static int write_state(FILE **f, char **states) {
         STRV_FOREACH(state, states) {
                 int k;
 
-                k = write_string_stream(*f, *state);
+                k = write_string_stream(*f, *state, true);
                 if (k == 0)
                         return 0;
                 log_debug_errno(k, "Failed to write '%s' to /sys/power/state: %m",
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 4c31b77..725c2fa 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -302,17 +302,27 @@ static void test_write_string_stream(void) {
 
         f = fdopen(fd, "r");
         assert_se(f);
-        assert_se(write_string_stream(f, "boohoo") < 0);
+        assert_se(write_string_stream(f, "boohoo", true) < 0);
 
         f = freopen(fn, "r+", f);
         assert_se(f);
 
-        assert_se(write_string_stream(f, "boohoo") == 0);
+        assert_se(write_string_stream(f, "boohoo", true) == 0);
         rewind(f);
 
         assert_se(fgets(buf, sizeof(buf), f));
         assert_se(streq(buf, "boohoo\n"));
 
+        f = freopen(fn, "w+", f);
+        assert_se(f);
+
+        assert_se(write_string_stream(f, "boohoo", false) == 0);
+        rewind(f);
+
+        assert_se(fgets(buf, sizeof(buf), f));
+        printf(">%s<", buf);
+        assert_se(streq(buf, "boohoo"));
+
         unlink(fn);
 }
 



More information about the systemd-commits mailing list