_dbus_spawn_async_with_babysitter: correct documentation

env is used as you'd expect now.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
dbus-spawn: correct a comment that falsely claimed thread-safety

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
Correctly set number of arguments already handled

At privous, which increments the number of arguments already handled in
the last of loop, however, if there is any invalid argument, then it
will "goto out" and the number of arguments already handled is now
incorrect.

A following patch will use the number of arguments already handled as a
loop terminate condition, so it's good to fix it before.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Fix memory or unix fd may leak in dbus_message_iter_get_args_valist

This is an aged bug since 2009, so let's fix it. Say if a previous
parsing for unix fd or array of string successfully but then a later
element parsing fail, then the unix fd or array of string leaked.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Test: add test cases for message parsing

Add test cases for testing:
  * If more arguments than requested are present, the requested
    arguments are returned and the extra arguments are ignored.
  * If arguments parse failed, ensure we didn't leak any memory or unix
    fd

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259
[added a check for fd leaks around verify_test_message_args_ignored() -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Use SIGHUP without check in UNIX environment

As Simon's comment
  https://bugs.freedesktop.org/show_bug.cgi?id=66068#c8
we can do this in UNIX environment.

Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus-spawn: draw a diagram

There are enough pipes, fds and processes here that it's important to
keep track of them.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859
transaction_free: factor out

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859
Reviewed-by: Chengwei Yang
[removed unused variable based on review -smcv]
Remove unnecessary dbus_setenv()

DBUS_ACTIVATION_ADDRESS changed to DBUS_STARTER_ADDRESS and
DBUS_ACTIVATION_BUS_TYPE changed to DBUS_STARTER_BUS_TYPE since 2005 by
this commit - 8873c90

So the dbus_setenv() which used to unset the above two wrong environment
variables has no effect in fact. And giving that setenv(3) and putenv(3)
are not threadsafe, so it's better to remove them.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68308
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Acked-by: Colin Walters <walters@verbum.org>
Update configurable elements for dbus-daemon manual

Update three configurable elements for dbus-daemon manual, <syslog>,
<pidfile> and <allow_anonymous>, all of them are undocumented so far.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69125
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
DBusBabysitter: change executable to log_name

DBusBabysitter->executable is defined as executable name to use in error
messages. However, if servicehelper used, then the executable name is
servicehelper. It's not much help because we couldn't figure out which
service we're trying to activated if error happens.

In the following patch, we'll use service name to be activated as the
child log identifier and add a parameter to
_dbus_spawn_async_with_babysitter() to pass the log identifier.  Since
this is not the case in test, so executable changed to log_name.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Handle activated child stdout/stderr correctly in systemd environment

In systemd environment, dbus-daemon will run as no-fork mode since this
is the recommended practice of systemd.

In that scenario, child activated by dbus-daemon will inherit
dbus-daemon standard streams, includes stdin/stdout/stderr. stdin will
be redirected to /dev/null by systemd and stdout/stderr will be catched
by systemd log subsystem. Since the child inherit stdout/stderr from
dbus-daemon, so from systemd journal log, the child log output will be
identified with dbus-daemon identifier. So it's a little confusing.

This patch redirects the child stdout/stderr to systemd journal stream,
and with its owned service name as identifier. However, thing not fixed
perfectly due to the socket ucred of the child is owned by dbus-daemon,
so the pid isn't the real pid of the chile.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Add comments describing how "compile with journald, run without" works
Close unused inherited file descriptor

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
1.6.18
Start on 1.6.20
Merge branch 'dbus-1.6'

Conflicts:
	NEWS
	configure.ac
Revert "start dbus-specification 0.23"

This reverts commit c8bc5f24b721bc03679c44669cf5e655c1e99b5f.
Nothing changed since 0.22.
bus/selinux: Fix previous commit for CAP_AUDIT_WRITE retention

As soon as capng_clear() is called, we won't appear to have
CAP_AUDIT_WRITE.  Fix this by checking for it before resetting the
libcap state.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49062
Tested-by: Laurent Bigonville <bigon@debian.org>
Reviewed-by: Laurent Bigonville <bigon@debian.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Lennart Poettering <lennart@poettering.net>
1.7.8