[systemd-commits] 14 commits - configure.ac .gitignore Makefile.am src/bus-proxyd src/core src/libsystemd-bus src/libsystemd-rtnl src/network src/shared

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Thu Jan 2 16:52:19 PST 2014


 .gitignore                            |    1 
 Makefile.am                           |    4 +
 configure.ac                          |   14 ++++-
 src/bus-proxyd/bus-proxyd.c           |   32 ++++--------
 src/core/automount.c                  |    4 -
 src/core/dbus-cgroup.c                |    5 -
 src/core/dbus-execute.c               |   11 +---
 src/core/dbus-manager.c               |    2 
 src/core/execute.c                    |   83 ++++++++++++++------------------
 src/core/job.c                        |    4 -
 src/core/killall.c                    |    4 -
 src/core/main.c                       |    6 +-
 src/core/manager.c                    |   38 ++++++++-------
 src/core/mount.c                      |    6 +-
 src/core/service.c                    |   81 ++++++++++++++++----------------
 src/libsystemd-bus/bus-creds.c        |    2 
 src/libsystemd-bus/bus-dump.c         |    7 +-
 src/libsystemd-bus/bus-util.c         |    4 -
 src/libsystemd-bus/sd-bus.c           |   14 +----
 src/libsystemd-bus/test-bus-cleanup.c |   80 +++++++++++++++++++++++++++++++
 src/libsystemd-rtnl/rtnl-message.c    |   86 ++++++++++++++++------------------
 src/network/networkd-network.c        |   11 ++--
 src/shared/capability.c               |   24 ++-------
 src/shared/capability.h               |   12 ++++
 src/shared/def.h                      |   12 ++++
 src/shared/time-util.h                |    3 +
 src/shared/util.h                     |   18 ++++++-
 27 files changed, 338 insertions(+), 230 deletions(-)

New commits:
commit 477e73b5312094f2d34de8e40ccbe61e6d4d81e9
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jan 2 19:49:49 2014 -0500

    networkd: fix memory leak in error path

diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 9533aff..3cbc9ab 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -24,6 +24,7 @@
 #include "path-util.h"
 #include "conf-files.h"
 #include "conf-parser.h"
+#include "util.h"
 
 static int network_load_one(Manager *manager, const char *filename) {
         _cleanup_network_free_ Network *network = NULL;
@@ -77,7 +78,8 @@ static int network_load_one(Manager *manager, const char *filename) {
 
 int network_load(Manager *manager) {
         Network *network;
-        char **files, **f;
+        _cleanup_strv_free_ char **files = NULL;
+        char **f;
         int r;
 
         assert(manager);
@@ -97,8 +99,6 @@ int network_load(Manager *manager) {
                         return r;
         }
 
-        strv_free(files);
-
         return 0;
 }
 

commit 7384fa923e1ba403454903133b33f559b735fe75
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jan 2 19:49:43 2014 -0500

    networkd: do not deference null pointer in cleanup

diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index e0e3878..9533aff 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -109,6 +109,8 @@ void network_free(Network *network) {
         if (!network)
                 return;
 
+        assert(network->manager);
+
         free(network->filename);
 
         free(network->match_mac);
@@ -128,7 +130,8 @@ void network_free(Network *network) {
         hashmap_free(network->addresses_by_section);
         hashmap_free(network->routes_by_section);
 
-        LIST_REMOVE(networks, network->manager->networks, network);
+        if (network->manager->networks)
+                LIST_REMOVE(networks, network->manager->networks, network);
 
         free(network);
 }

commit d4c636603a2c7594faa66f9c3e6c75f5ccb5c3e4
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jan 2 19:49:33 2014 -0500

    core: fix gcc unused variable warning

diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 5a998e3..6abd599 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1405,7 +1405,9 @@ static int method_enable_unit_files_generic(
                 sd_bus_error *error) {
 
         _cleanup_strv_free_ char **l = NULL;
+#ifdef HAVE_SELINUX
         char **i;
+#endif
         UnitFileChange *changes = NULL;
         unsigned n_changes = 0;
         UnitFileScope scope;

commit 0349c608c839e728e15a37b2317c3f332c8a2a36
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 31 22:45:45 2013 -0500

    bus: fix memleak in sd_bus_creds_new_from_pid

diff --git a/src/libsystemd-bus/bus-creds.c b/src/libsystemd-bus/bus-creds.c
index b2cf687..5575f73 100644
--- a/src/libsystemd-bus/bus-creds.c
+++ b/src/libsystemd-bus/bus-creds.c
@@ -140,7 +140,7 @@ _public_ int sd_bus_creds_new_from_pid(pid_t pid, uint64_t mask, sd_bus_creds **
 
         r = bus_creds_add_more(c, mask, pid, 0);
         if (r < 0) {
-                free(c);
+                sd_bus_creds_unref(c);
                 return r;
         }
 

commit 5ce70e5bcd62e89b52485961c3699312ee4a7e0e
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 31 22:35:54 2013 -0500

    Introduce cleanup functions for cap_free
    
    Unfortunately a different cleanup function is necessary per type,
    because cap_t** and char** are incompatible with void**.

diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index b79a456..4e95297 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -29,6 +29,7 @@
 #include "fileio.h"
 #include "execute.h"
 #include "dbus-execute.h"
+#include "capability.h"
 
 BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_exec_output, exec_output, ExecOutput);
 
@@ -319,9 +320,8 @@ static int property_get_capabilities(
                 sd_bus_error *error) {
 
         ExecContext *c = userdata;
-        char *t = NULL;
+        _cleanup_cap_free_charp_ char *t = NULL;
         const char *s;
-        int r;
 
         assert(bus);
         assert(reply);
@@ -335,12 +335,7 @@ static int property_get_capabilities(
         if (!s)
                 return -ENOMEM;
 
-        r = sd_bus_message_append(reply, "s", s);
-
-        if (t)
-                cap_free(t);
-
-        return r;
+        return sd_bus_message_append(reply, "s", s);
 }
 
 static int property_get_syscall_filter(
diff --git a/src/core/execute.c b/src/core/execute.c
index 39c0fed..4317afa 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -650,14 +650,13 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
 }
 
 static int enforce_user(const ExecContext *context, uid_t uid) {
-        int r;
         assert(context);
 
         /* Sets (but doesn't lookup) the uid and make sure we keep the
          * capabilities while doing so. */
 
         if (context->capabilities) {
-                cap_t d;
+                _cleanup_cap_free_ cap_t d = NULL;
                 static const cap_value_t bits[] = {
                         CAP_SETUID,   /* Necessary so that we can run setresuid() below */
                         CAP_SETPCAP   /* Necessary so that we can set PR_SET_SECUREBITS later on */
@@ -677,23 +676,16 @@ static int enforce_user(const ExecContext *context, uid_t uid) {
                 /* Second step: set the capabilities. This will reduce
                  * the capabilities to the minimum we need. */
 
-                if (!(d = cap_dup(context->capabilities)))
+                d = cap_dup(context->capabilities);
+                if (!d)
                         return -errno;
 
                 if (cap_set_flag(d, CAP_EFFECTIVE, ELEMENTSOF(bits), bits, CAP_SET) < 0 ||
-                    cap_set_flag(d, CAP_PERMITTED, ELEMENTSOF(bits), bits, CAP_SET) < 0) {
-                        r = -errno;
-                        cap_free(d);
-                        return r;
-                }
-
-                if (cap_set_proc(d) < 0) {
-                        r = -errno;
-                        cap_free(d);
-                        return r;
-                }
+                    cap_set_flag(d, CAP_PERMITTED, ELEMENTSOF(bits), bits, CAP_SET) < 0)
+                        return -errno;
 
-                cap_free(d);
+                if (cap_set_proc(d) < 0)
+                        return -errno;
         }
 
         /* Third step: actually set the uids */
@@ -2000,37 +1992,37 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
                         prefix, yes_no(c->tty_vhangup),
                         prefix, yes_no(c->tty_vt_disallocate));
 
-        if (c->std_output == EXEC_OUTPUT_SYSLOG || c->std_output == EXEC_OUTPUT_KMSG || c->std_output == EXEC_OUTPUT_JOURNAL ||
-            c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE ||
-            c->std_error == EXEC_OUTPUT_SYSLOG || c->std_error == EXEC_OUTPUT_KMSG || c->std_error == EXEC_OUTPUT_JOURNAL ||
-            c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE || c->std_error == EXEC_OUTPUT_JOURNAL_AND_CONSOLE) {
-                char *fac_str, *lvl_str;
-                int r;
+        if (c->std_output == EXEC_OUTPUT_SYSLOG ||
+            c->std_output == EXEC_OUTPUT_KMSG ||
+            c->std_output == EXEC_OUTPUT_JOURNAL ||
+            c->std_output == EXEC_OUTPUT_SYSLOG_AND_CONSOLE ||
+            c->std_output == EXEC_OUTPUT_KMSG_AND_CONSOLE ||
+            c->std_output == EXEC_OUTPUT_JOURNAL_AND_CONSOLE ||
+            c->std_error == EXEC_OUTPUT_SYSLOG ||
+            c->std_error == EXEC_OUTPUT_KMSG ||
+            c->std_error == EXEC_OUTPUT_JOURNAL ||
+            c->std_error == EXEC_OUTPUT_SYSLOG_AND_CONSOLE ||
+            c->std_error == EXEC_OUTPUT_KMSG_AND_CONSOLE ||
+            c->std_error == EXEC_OUTPUT_JOURNAL_AND_CONSOLE) {
 
-                r = log_facility_unshifted_to_string_alloc(c->syslog_priority >> 3, &fac_str);
-                if (r < 0)
-                        fac_str = NULL;
+                _cleanup_free_ char *fac_str = NULL, *lvl_str = NULL;
 
-                r = log_level_to_string_alloc(LOG_PRI(c->syslog_priority), &lvl_str);
-                if (r < 0)
-                        lvl_str = NULL;
+                log_facility_unshifted_to_string_alloc(c->syslog_priority >> 3, &fac_str);
+                log_level_to_string_alloc(LOG_PRI(c->syslog_priority), &lvl_str);
 
                 fprintf(f,
                         "%sSyslogFacility: %s\n"
                         "%sSyslogLevel: %s\n",
                         prefix, strna(fac_str),
                         prefix, strna(lvl_str));
-                free(lvl_str);
-                free(fac_str);
         }
 
         if (c->capabilities) {
-                char *t;
-                if ((t = cap_to_text(c->capabilities, NULL))) {
-                        fprintf(f, "%sCapabilities: %s\n",
-                                prefix, t);
-                        cap_free(t);
-                }
+                _cleanup_cap_free_charp_ char *t;
+
+                t = cap_to_text(c->capabilities, NULL);
+                if (t)
+                        fprintf(f, "%sCapabilities: %s\n", prefix, t);
         }
 
         if (c->secure_bits)
@@ -2049,12 +2041,11 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
 
                 for (l = 0; l <= cap_last_cap(); l++)
                         if (!(c->capability_bounding_set_drop & ((uint64_t) 1ULL << (uint64_t) l))) {
-                                char *t;
+                                _cleanup_cap_free_charp_ char *t;
 
-                                if ((t = cap_to_name(l))) {
+                                t = cap_to_name(l);
+                                if (t)
                                         fprintf(f, " %s", t);
-                                        cap_free(t);
-                                }
                         }
 
                 fputs("\n", f);
diff --git a/src/libsystemd-bus/bus-dump.c b/src/libsystemd-bus/bus-dump.c
index df7cf68..78e7597 100644
--- a/src/libsystemd-bus/bus-dump.c
+++ b/src/libsystemd-bus/bus-dump.c
@@ -19,8 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <sys/capability.h>
-
 #include "util.h"
 #include "capability.h"
 #include "strv.h"
@@ -281,12 +279,15 @@ static void dump_capabilities(
 
         for (;;) {
                 if (r > 0) {
+                        _cleanup_cap_free_charp_ char *t;
+
                         if (n > 0)
                                 fputc(' ', f);
                         if (n % 4 == 3)
                                 fputs("\n          ", f);
 
-                        fputs(cap_to_name(i), f);
+                        t = cap_to_name(i);
+                        fprintf(f, "%s", t);
                         n++;
                 }
 
diff --git a/src/shared/capability.c b/src/shared/capability.c
index 72c671c..f8ee1c6 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -37,21 +37,17 @@
 #include "fileio.h"
 
 int have_effective_cap(int value) {
-        cap_t cap;
+        _cleanup_cap_free_ cap_t cap;
         cap_flag_value_t fv;
-        int r;
 
         cap = cap_get_proc();
         if (!cap)
                 return -errno;
 
         if (cap_get_flag(cap, value, CAP_EFFECTIVE, &fv) < 0)
-                r = -errno;
+                return -errno;
         else
-                r = fv == CAP_SET;
-
-        cap_free(cap);
-        return r;
+                return fv == CAP_SET;
 }
 
 unsigned long cap_last_cap(void) {
@@ -89,7 +85,7 @@ unsigned long cap_last_cap(void) {
 
 int capability_bounding_set_drop(uint64_t drop, bool right_now) {
         unsigned long i;
-        cap_t after_cap = NULL, temp_cap = NULL;
+        _cleanup_cap_free_ cap_t after_cap = NULL, temp_cap = NULL;
         cap_flag_value_t fv;
         int r;
 
@@ -102,10 +98,8 @@ int capability_bounding_set_drop(uint64_t drop, bool right_now) {
         if (!after_cap)
                 return -errno;
 
-        if (cap_get_flag(after_cap, CAP_SETPCAP, CAP_EFFECTIVE, &fv) < 0) {
-                cap_free(after_cap);
+        if (cap_get_flag(after_cap, CAP_SETPCAP, CAP_EFFECTIVE, &fv) < 0)
                 return -errno;
-        }
 
         if (fv != CAP_SET) {
                 static const cap_value_t v = CAP_SETPCAP;
@@ -162,13 +156,7 @@ int capability_bounding_set_drop(uint64_t drop, bool right_now) {
         r = 0;
 
 finish:
-        if (temp_cap)
-                cap_free(temp_cap);
-
-        if (after_cap) {
-                cap_set_proc(after_cap);
-                cap_free(after_cap);
-        }
+        cap_set_proc(after_cap);
 
         return r;
 }
diff --git a/src/shared/capability.h b/src/shared/capability.h
index 59469e5..64f8641 100644
--- a/src/shared/capability.h
+++ b/src/shared/capability.h
@@ -23,8 +23,20 @@
 
 #include <inttypes.h>
 #include <stdbool.h>
+#include <sys/capability.h>
+
+#include "util.h"
 
 unsigned long cap_last_cap(void);
 int have_effective_cap(int value);
 int capability_bounding_set_drop(uint64_t drop, bool right_now);
 int capability_bounding_set_drop_usermode(uint64_t drop);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
+#define _cleanup_cap_free_ _cleanup_(cap_freep)
+
+static inline void cap_free_charpp(char **p) {
+        if (*p)
+                cap_free(*p);
+}
+#define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp)

commit ac6b760ceedd4b21921b6a682cf1479af3d3024f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 31 20:20:17 2013 -0500

    build-sys: add --disable-dbus autoconf option

diff --git a/configure.ac b/configure.ac
index 4cb2a53..d8a9356 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,8 +247,14 @@ AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/
 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
 
 # ------------------------------------------------------------------------------
-PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2], have_dbus=yes, have_dbus=no])
-AS_IF([test "$have_dbus" = "yes"], [ AC_DEFINE(HAVE_DBUS, [1], [Define if dbus-1 is available]) ])
+have_dbus=no
+AC_ARG_ENABLE(dbus, AS_HELP_STRING([--disable-dbus], [disable usage of dbus-1 in tests]))
+AS_IF(["x$enable_dbus" != "xno"], [
+        PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2],
+                [AC_DEFINE(HAVE_DBUS, 1, [Define if dbus-1 library is available]) have_dbus=yes],
+                [have_dbus=no])
+        AS_IF([test "x$have_dbus" = "xno" -a "x$enable_dbus" = "xyes"],
+                [AC_MSG_ERROR([*** dbus-1 support requested but libraries not found])])])
 AM_CONDITIONAL(HAVE_DBUS, [test "$have_dbus" = "yes"])
 
 # ------------------------------------------------------------------------------
@@ -1097,6 +1103,7 @@ AC_MSG_RESULT([
         efi:                     ${have_efi}
         kmod:                    ${have_kmod}
         blkid:                   ${have_blkid}
+        dbus:                    ${have_dbus}
         nss-myhostname:          ${have_myhostname}
         gudev:                   ${enable_gudev}
         gintrospection:          ${enable_introspection}

commit a0846368c808fb8b73b84d40472717cfd83ca4d7
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 31 20:19:58 2013 -0500

    build-sys: make valgrind-tests target output nicer

diff --git a/Makefile.am b/Makefile.am
index 44b6917..069583c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4902,8 +4902,10 @@ install-tree: all
 # exclude the one perl script we have in there
 valgrind-tests: $(TESTS)
 	$(AM_V_GEN)for f in $(filter-out %.pl, $^); do \
+		if file $$f | grep -q shell; then \
+		echo -e "$${x}Skipping non-binary $$f"; else \
 		echo -e "$${x}Running $$f"; \
-	        libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=4194400 --error-exitcode=55 $(builddir)/$$f ; \
+	        libtool --mode=execute valgrind -q --leak-check=full --max-stackframe=4194400 --error-exitcode=55 $(builddir)/$$f ; fi; \
 		x="\n\n"; \
 	done
 

commit 4ebe732c0cdcd9431a5095140bc4189f86508725
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Tue Dec 31 12:56:59 2013 -0500

    rtnl: fix memory corruptions after realloc
    
    struct sd_rtnl_message would keep two additional pointers into the hdr
    field. Every time hdr was realloced, those pointers should be adjusted,
    but weren't. It seems less error-prone to keep offsets instead.

diff --git a/src/libsystemd-rtnl/rtnl-message.c b/src/libsystemd-rtnl/rtnl-message.c
index 24f2e6f..517df61 100644
--- a/src/libsystemd-rtnl/rtnl-message.c
+++ b/src/libsystemd-rtnl/rtnl-message.c
@@ -35,14 +35,16 @@ struct sd_rtnl_message {
         RefCount n_ref;
 
         struct nlmsghdr *hdr;
-
-        struct rtattr *current_container;
-
-        struct rtattr *next_rta;
+        size_t container_offset; /* offset from hdr to container start */
+        size_t next_rta_offset; /* offset from hdr to next rta */
 
         bool sealed:1;
 };
 
+#define CURRENT_CONTAINER(m) ((m)->container_offset ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offset) : NULL)
+#define NEXT_RTA(m) ((struct rtattr*)((uint8_t*)(m)->hdr + (m)->next_rta_offset))
+#define UPDATE_RTA(m, new) (m)->next_rta_offset = (uint8_t*)(new) - (uint8_t*)(m)->hdr;
+
 static int message_new(sd_rtnl_message **ret, size_t initial_size) {
         sd_rtnl_message *m;
 
@@ -154,7 +156,7 @@ int sd_rtnl_message_route_new(uint16_t nlmsg_type, unsigned char rtm_family,
 
         rtm = NLMSG_DATA((*ret)->hdr);
 
-        (*ret)->next_rta = RTM_RTA(rtm);
+        UPDATE_RTA(*ret, RTM_RTA(rtm));
 
         rtm->rtm_family = rtm_family;
         rtm->rtm_scope = RT_SCOPE_UNIVERSE;
@@ -208,7 +210,7 @@ int sd_rtnl_message_link_new(uint16_t nlmsg_type, int index, sd_rtnl_message **r
         ifi->ifi_index = index;
         ifi->ifi_change = 0xffffffff;
 
-        (*ret)->next_rta = IFLA_RTA(ifi);
+        UPDATE_RTA(*ret, IFLA_RTA(ifi));
 
         return 0;
 }
@@ -236,7 +238,7 @@ int sd_rtnl_message_addr_new(uint16_t nlmsg_type, int index, unsigned char famil
         ifa->ifa_scope = scope;
         ifa->ifa_index = index;
 
-        (*ret)->next_rta = IFA_RTA(ifa);
+        UPDATE_RTA(*ret, IFA_RTA(ifa));
 
         return 0;
 }
@@ -296,8 +298,8 @@ int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags) {
         return 0;
 }
 
-/* If successful the updated message will be correctly aligned, if unsuccessful the old message is
-   untouched */
+/* If successful the updated message will be correctly aligned, if
+   unsuccessful the old message is untouched. */
 static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data, size_t data_length) {
         uint32_t rta_length, message_length;
         struct nlmsghdr *new_hdr;
@@ -311,48 +313,42 @@ static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data,
 
         /* get the size of the new rta attribute (with padding at the end) */
         rta_length = RTA_LENGTH(data_length);
-        /* get the new message size (with padding at the end)
-         */
+
+        /* get the new message size (with padding at the end) */
         message_length = m->hdr->nlmsg_len + RTA_ALIGN(rta_length);
 
         /* realloc to fit the new attribute */
         new_hdr = realloc(m->hdr, message_length);
         if (!new_hdr)
                 return -ENOMEM;
-        /* update the location of the next rta for reading */
-        m->next_rta = (struct rtattr *) ((uint8_t *) m->next_rta +
-                                         ((uint8_t *) new_hdr -
-                                          (uint8_t *) m->hdr));
         m->hdr = new_hdr;
 
         /* get pointer to the attribute we are about to add */
         rta = (struct rtattr *) ((uint8_t *) m->hdr + m->hdr->nlmsg_len);
-        /* update message size */
-        m->hdr->nlmsg_len = message_length;
 
-        /* we are inside a container, extend it */
-        if (m->current_container)
-                m->current_container->rta_len = (uint8_t *) m->hdr +
-                                                m->hdr->nlmsg_len -
-                                                (uint8_t *) m->current_container;
+        /* if we are inside a container, extend it */
+        if (CURRENT_CONTAINER(m))
+                CURRENT_CONTAINER(m)->rta_len += message_length - m->hdr->nlmsg_len;
 
         /* fill in the attribute */
         rta->rta_type = type;
         rta->rta_len = rta_length;
         if (!data) {
-                /* this is a container, set pointer */
-                m->current_container = rta;
+                /* this is the start of a new container */
+                m->container_offset = m->hdr->nlmsg_len;
         } else {
                 /* we don't deal with the case where the user lies about the type
                  * and gives us too little data (so don't do that)
                 */
                 padding = mempcpy(RTA_DATA(rta), data, data_length);
                 /* make sure also the padding at the end of the message is initialized */
-                memset(padding, '\0', (uint8_t *) m->hdr +
-                                      m->hdr->nlmsg_len -
-                                      (uint8_t *) padding);
+                memzero(padding,
+                        (uint8_t *) m->hdr + message_length - (uint8_t *) padding);
         }
 
+        /* update message size */
+        m->hdr->nlmsg_len = message_length;
+
         return 0;
 }
 
@@ -373,8 +369,8 @@ int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const
                 case RTM_SETLINK:
                 case RTM_GETLINK:
                 case RTM_DELLINK:
-                        if (m->current_container) {
-                                if (m->current_container->rta_type != IFLA_LINKINFO ||
+                        if (CURRENT_CONTAINER(m)) {
+                                if (CURRENT_CONTAINER(m)->rta_type != IFLA_LINKINFO ||
                                     type != IFLA_INFO_KIND)
                                         return -ENOTSUP;
                         } else {
@@ -612,7 +608,7 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
         uint16_t rtm_type;
 
         assert_return(m, -EINVAL);
-        assert_return(!m->current_container, -EINVAL);
+        assert_return(!CURRENT_CONTAINER(m), -EINVAL);
 
         sd_rtnl_message_get_type(m, &rtm_type);
 
@@ -629,9 +625,9 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
 
 int sd_rtnl_message_close_container(sd_rtnl_message *m) {
         assert_return(m, -EINVAL);
-        assert_return(m->current_container, -EINVAL);
+        assert_return(CURRENT_CONTAINER(m), -EINVAL);
 
-        m->current_container = NULL;
+        m->container_offset = 0;
 
         return 0;
 }
@@ -642,13 +638,13 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data)
         int r;
 
         assert(m);
-        assert(m->next_rta);
+        assert(m->next_rta_offset);
         assert(type);
         assert(data);
 
-        remaining_size = (uint8_t *) m->hdr + m->hdr->nlmsg_len - (uint8_t *) m->next_rta;
+        remaining_size = m->hdr->nlmsg_len - m->next_rta_offset;
 
-        if (!RTA_OK(m->next_rta, remaining_size))
+        if (!RTA_OK(NEXT_RTA(m), remaining_size))
                 return 0;
 
         /* make sure we don't try to read a container
@@ -658,13 +654,13 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data)
                 return r;
 
         if (message_type_is_link(rtm_type) &&
-            m->next_rta->rta_type == IFLA_LINKINFO)
+            NEXT_RTA(m)->rta_type == IFLA_LINKINFO)
                return -EINVAL;
 
-        *data = RTA_DATA(m->next_rta);
-        *type = m->next_rta->rta_type;
+        *data = RTA_DATA(NEXT_RTA(m));
+        *type = NEXT_RTA(m)->rta_type;
 
-        m->next_rta = RTA_NEXT(m->next_rta, remaining_size);
+        UPDATE_RTA(m, RTA_NEXT(NEXT_RTA(m), remaining_size));
 
         return 1;
 }
@@ -811,7 +807,7 @@ int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret) {
                                         k = -EIO;
                                 else {
                                         ifi = NLMSG_DATA(m->hdr);
-                                        m->next_rta = IFLA_RTA(ifi);
+                                        UPDATE_RTA(m, IFLA_RTA(ifi));
                                 }
                                 break;
                         case RTM_NEWADDR:
@@ -821,7 +817,7 @@ int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret) {
                                         k = -EIO;
                                 else {
                                         ifa = NLMSG_DATA(m->hdr);
-                                        m->next_rta = IFA_RTA(ifa);
+                                        UPDATE_RTA(m, IFA_RTA(ifa));
                                 }
                                 break;
                         case RTM_NEWROUTE:
@@ -831,7 +827,7 @@ int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret) {
                                         k = -EIO;
                                 else {
                                         rtm = NLMSG_DATA(m->hdr);
-                                        m->next_rta = RTM_RTA(rtm);
+                                        UPDATE_RTA(m, RTM_RTA(rtm));
                                 }
                                 break;
                         case NLMSG_NOOP:
@@ -866,22 +862,22 @@ int sd_rtnl_message_rewind(sd_rtnl_message *m) {
                 case RTM_GETLINK:
                 case RTM_DELLINK:
                         ifi = NLMSG_DATA(m->hdr);
+                        UPDATE_RTA(m, IFLA_RTA(ifi));
 
-                        m->next_rta = IFLA_RTA(ifi);
                         break;
                 case RTM_NEWADDR:
                 case RTM_GETADDR:
                 case RTM_DELADDR:
                         ifa = NLMSG_DATA(m->hdr);
+                        UPDATE_RTA(m, IFA_RTA(ifa));
 
-                        m->next_rta = IFA_RTA(ifa);
                         break;
                 case RTM_NEWROUTE:
                 case RTM_GETROUTE:
                 case RTM_DELROUTE:
                         rtm = NLMSG_DATA(m->hdr);
+                        UPDATE_RTA(m, RTM_RTA(rtm));
 
-                        m->next_rta = RTM_RTA(rtm);
                         break;
                 default:
                         return -ENOTSUP;

commit 6ee4f99042a289d0afecc11d322f0addd483c093
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Dec 30 23:13:38 2013 -0500

    bus: break reference cycle between bus and messages
    
    Because messages in the read and write queues hold a reference on the
    bus, and the bus holds a reference on each of them, we would never
    free the bus if the read or write queues were not empty. Explicitly
    substract the number of messages in those queue from the bus reference
    count when deciding whether to free or not.
    
    A simple test which creates and unrefs simple objects is added.

diff --git a/src/libsystemd-bus/test-bus-cleanup.c b/src/libsystemd-bus/test-bus-cleanup.c
new file mode 100644
index 0000000..d8ddb84
--- /dev/null
+++ b/src/libsystemd-bus/test-bus-cleanup.c
@@ -0,0 +1,80 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Zbigniew Jędrzejewski-Szmek
+
+  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/>.
+***/
+
+#include <stdio.h>
+
+#include "sd-bus.h"
+#include "bus-util.h"
+#include "bus-internal.h"
+#include "bus-message.h"
+#include "refcnt.h"
+
+static void test_bus_new(void) {
+        _cleanup_bus_unref_ sd_bus *bus = NULL;
+
+        assert_se(sd_bus_new(&bus) == 0);
+        printf("after new: refcount %u\n", REFCNT_GET(bus->n_ref));
+}
+
+static void test_bus_open(void) {
+        _cleanup_bus_unref_ sd_bus *bus = NULL;
+
+        assert_se(sd_bus_open_system(&bus) >= 0);
+        printf("after open: refcount %u\n", REFCNT_GET(bus->n_ref));
+}
+
+static void test_bus_new_method_call(void) {
+        sd_bus *bus = NULL;
+        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+
+        assert_se(sd_bus_open_system(&bus) >= 0);
+
+        assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path", "an.interface.name", "AMethodName", &m) >= 0);
+
+        printf("after message_new_method_call: refcount %u\n", REFCNT_GET(bus->n_ref));
+
+        sd_bus_unref(bus);
+        printf("after bus_unref: refcount %u\n", m->n_ref);
+}
+
+static void test_bus_new_signal(void) {
+        sd_bus *bus = NULL;
+        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
+
+        assert_se(sd_bus_open_system(&bus) >= 0);
+
+        assert_se(sd_bus_message_new_signal(bus, "/an/object/path", "an.interface.name", "Name", &m) >= 0);
+
+        printf("after message_new_signal: refcount %u\n", REFCNT_GET(bus->n_ref));
+
+        sd_bus_unref(bus);
+        printf("after bus_unref: refcount %u\n", m->n_ref);
+}
+
+int main(int argc, char **argv) {
+        log_parse_environment();
+        log_open();
+
+        test_bus_new();
+        test_bus_open();
+        test_bus_new_method_call();
+        test_bus_new_signal();
+}

commit ccd06097c79218f7d5ea4c21721bbcbc7c467dca
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Dec 30 17:22:26 2013 -0500

    Use format patterns for usec_t, pid_t, nsec_t, usec_t
    
    It is nicer to predefine patterns using configure time check instead of
    using casts everywhere.
    
    Since we do not need to use any flags, include "%" in the format instead
    of excluding it like PRI* macros.

diff --git a/.gitignore b/.gitignore
index 4799bad..0cd13a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@
 /test-bus-creds
 /test-bus-error
 /test-bus-gvariant
+/test-bus-cleanup
 /test-bus-introspect
 /test-bus-kernel
 /test-bus-kernel-benchmark
diff --git a/configure.ac b/configure.ac
index 5e30af3..4cb2a53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -178,6 +178,9 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
         -Wl,-z,now])
 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $address_sanitizer_ldflags")
 
+AC_CHECK_SIZEOF(pid_t)
+AC_CHECK_SIZEOF(uid_t)
+
 # ------------------------------------------------------------------------------
 # we use python to build the man page index, and for systemd-python
 have_python=no
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 28e8b44..a14d7c8 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -157,9 +157,9 @@ static int rename_service(sd_bus *a, sd_bus *b) {
 
         /* The status string gets the full command line ... */
         sd_notifyf(false,
-                   "STATUS=Processing requests from client PID %lu (%s); UID %lu (%s)",
-                   (unsigned long) pid, p,
-                   (unsigned long) uid, name);
+                   "STATUS=Processing requests from client PID "PID_FMT" (%s); UID "UID_FMT" (%s)",
+                   pid, p,
+                   uid, name);
 
         /* ... and the argv line only the short comm */
         if (arg_command_line_buffer) {
@@ -167,17 +167,17 @@ static int rename_service(sd_bus *a, sd_bus *b) {
 
                 m = strlen(arg_command_line_buffer);
                 w = snprintf(arg_command_line_buffer, m,
-                             "[PID %lu/%s; UID %lu/%s]",
-                             (unsigned long) pid, comm,
-                             (unsigned long) uid, name);
+                             "[PID "PID_FMT"/%s; UID "UID_FMT"/%s]",
+                             pid, comm,
+                             uid, name);
 
                 if (m > w)
                         memset(arg_command_line_buffer + w, 0, m - w);
         }
 
-        log_debug("Running on behalf of PID %lu (%s), UID %lu (%s), %s",
-                  (unsigned long) pid, p,
-                  (unsigned long) uid, name,
+        log_debug("Running on behalf of PID "PID_FMT" (%s), UID "UID_FMT" (%s), %s",
+                  pid, p,
+                  uid, name,
                   a->unique_name);
                 ;
         return 0;
diff --git a/src/core/automount.c b/src/core/automount.c
index c44521c..f500850 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -774,8 +774,8 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
 
                         get_process_comm(packet.v5_packet.pid, &p);
                         log_info_unit(UNIT(a)->id,
-                                       "Got automount request for %s, triggered by %lu (%s)",
-                                       a->where, (unsigned long) packet.v5_packet.pid, strna(p));
+                                       "Got automount request for %s, triggered by "PID_FMT" (%s)",
+                                       a->where, packet.v5_packet.pid, strna(p));
                 } else
                         log_debug_unit(UNIT(a)->id, "Got direct mount request on %s", a->where);
 
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 861bb16..792f37e 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -321,10 +321,9 @@ int bus_cgroup_set_property(
                 if (r < 0)
                         return r;
 
-                while (( r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
-                        unsigned long ul;
+                while ((r = sd_bus_message_read(message, "(st)", &path, &u64)) > 0) {
+                        unsigned long ul = u64;
 
-                        ul = (unsigned long) u64;
                         if (ul < 10 || ul > 1000)
                                 return sd_bus_error_set_errnof(error, EINVAL, "BlockIODeviceWeight out of range");
 
diff --git a/src/core/execute.c b/src/core/execute.c
index 7f93c0c..39c0fed 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1038,7 +1038,7 @@ static int build_environment(
                 return -ENOMEM;
 
         if (n_fds > 0) {
-                if (asprintf(&x, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0)
+                if (asprintf(&x, "LISTEN_PID="PID_FMT, getpid()) < 0)
                         return -ENOMEM;
                 our_env[n_env++] = x;
 
@@ -1048,7 +1048,7 @@ static int build_environment(
         }
 
         if (watchdog_usec > 0) {
-                if (asprintf(&x, "WATCHDOG_PID=%lu", (unsigned long) getpid()) < 0)
+                if (asprintf(&x, "WATCHDOG_PID="PID_FMT, getpid()) < 0)
                         return -ENOMEM;
                 our_env[n_env++] = x;
 
@@ -1636,8 +1636,8 @@ int exec_spawn(ExecCommand *command,
 
         log_struct_unit(LOG_DEBUG,
                         unit_id,
-                        "MESSAGE=Forked %s as %lu",
-                        command->path, (unsigned long) pid,
+                        "MESSAGE=Forked %s as "PID_FMT,
+                        command->path, pid,
                         NULL);
 
         /* We add the new process to the cgroup both in the child (so
@@ -1979,7 +1979,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
         }
 
         if (c->timer_slack_nsec != (nsec_t) -1)
-                fprintf(f, "%sTimerSlackNSec: %lu\n", prefix, (unsigned long)c->timer_slack_nsec);
+                fprintf(f, "%sTimerSlackNSec: "NSEC_FMT "\n", prefix, c->timer_slack_nsec);
 
         fprintf(f,
                 "%sStandardInput: %s\n"
@@ -2139,8 +2139,8 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
                 return;
 
         fprintf(f,
-                "%sPID: %lu\n",
-                prefix, (unsigned long) s->pid);
+                "%sPID: "PID_FMT"\n",
+                prefix, s->pid);
 
         if (s->start_timestamp.realtime > 0)
                 fprintf(f,
diff --git a/src/core/job.c b/src/core/job.c
index 491c73d..7faa8da 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -906,7 +906,7 @@ char *job_dbus_path(Job *j) {
 
         assert(j);
 
-        if (asprintf(&p, "/org/freedesktop/systemd1/job/%lu", (unsigned long) j->id) < 0)
+        if (asprintf(&p, "/org/freedesktop/systemd1/job/%"PRIu32, j->id) < 0)
                 return NULL;
 
         return p;
@@ -922,7 +922,7 @@ int job_serialize(Job *j, FILE *f, FDSet *fds) {
         fprintf(f, "job-ignore-order=%s\n", yes_no(j->ignore_order));
 
         if (j->begin_usec > 0)
-                fprintf(f, "job-begin=%llu\n", (unsigned long long) j->begin_usec);
+                fprintf(f, "job-begin="USEC_FMT"\n", j->begin_usec);
 
         bus_client_track_serialize(j->manager, f, j->subscribed);
 
diff --git a/src/core/killall.c b/src/core/killall.c
index ea9bfa1..7664775 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -170,12 +170,12 @@ static int killall(int sig, Set *pids, bool send_sighup) {
                         _cleanup_free_ char *s;
 
                         get_process_comm(pid, &s);
-                        log_notice("Sending SIGKILL to PID %lu (%s).", (unsigned long) pid, strna(s));
+                        log_notice("Sending SIGKILL to PID "PID_FMT" (%s).", pid, strna(s));
                 }
 
                 if (kill(pid, sig) >= 0) {
                         if (pids)
-                                set_put(pids, ULONG_TO_PTR((unsigned long) pid));
+                                set_put(pids, ULONG_TO_PTR(pid));
                 } else if (errno != ENOENT)
                         log_warning("Could not kill %d: %m", pid);
 
diff --git a/src/core/main.c b/src/core/main.c
index 064445d..d052c8d 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -166,7 +166,7 @@ noreturn static void crash(int sig) {
                         else if (status.si_code != CLD_DUMPED)
                                 log_error("Caught <%s>, core dump failed.", signal_to_string(sig));
                         else
-                                log_error("Caught <%s>, dumped core as pid %lu.", signal_to_string(sig), (unsigned long) pid);
+                                log_error("Caught <%s>, dumped core as pid "PID_FMT".", signal_to_string(sig), pid);
                 }
         }
 
@@ -197,7 +197,7 @@ noreturn static void crash(int sig) {
                         _exit(1);
                 }
 
-                log_info("Successfully spawned crash shell as pid %lu.", (unsigned long) pid);
+                log_info("Successfully spawned crash shell as pid "PID_FMT".", pid);
         }
 
         log_info("Freezing execution.");
@@ -1865,7 +1865,7 @@ finish:
                         watchdog_close(false);
 
                         /* Tell the binary how often to ping */
-                        snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog);
+                        snprintf(e, sizeof(e), "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog);
                         char_array_0(e);
 
                         env_block = strv_append(environ, e);
diff --git a/src/core/manager.c b/src/core/manager.c
index ea8887a..22a3e3e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1334,7 +1334,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
                 if (!u) {
                         u = manager_get_unit_by_pid(m, ucred->pid);
                         if (!u) {
-                                log_warning("Cannot find unit for notify message of PID %lu.", (unsigned long) ucred->pid);
+                                log_warning("Cannot find unit for notify message of PID "PID_FMT".", ucred->pid);
                                 continue;
                         }
                 }
@@ -1382,7 +1382,7 @@ static int manager_dispatch_sigchld(Manager *m) {
                         _cleanup_free_ char *name = NULL;
 
                         get_process_comm(si.si_pid, &name);
-                        log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name));
+                        log_debug("Got SIGCHLD for process "PID_FMT" (%s)", si.si_pid, strna(name));
                 }
 
                 /* And now figure out the unit this belongs to */
@@ -1470,9 +1470,9 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                         log_full(sfsi.ssi_signo == SIGCHLD ||
                                  (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
                                  ? LOG_DEBUG : LOG_INFO,
-                                 "Received SIG%s from PID %lu (%s).",
+                                 "Received SIG%s from PID "PID_FMT" (%s).",
                                  signal_to_string(sfsi.ssi_signo),
-                                 (unsigned long) sfsi.ssi_pid, strna(p));
+                                 sfsi.ssi_pid, strna(p));
                 } else
                         log_full(sfsi.ssi_signo == SIGCHLD ||
                                  (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
@@ -1974,9 +1974,9 @@ int manager_open_serialization(Manager *m, FILE **_f) {
         assert(_f);
 
         if (m->running_as == SYSTEMD_SYSTEM)
-                asprintf(&path, "/run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
+                asprintf(&path, "/run/systemd/dump-"PID_FMT"-XXXXXX", getpid());
         else
-                asprintf(&path, "/tmp/systemd-dump-%lu-XXXXXX", (unsigned long) getpid());
+                asprintf(&path, "/tmp/systemd-dump-"PID_FMT"-XXXXXX", getpid());
 
         if (!path)
                 return -ENOMEM;
@@ -2454,9 +2454,9 @@ void manager_check_finished(Manager *m) {
                         if (!log_on_console())
                                 log_struct(LOG_INFO,
                                            MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                           "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
-                                           "INITRD_USEC=%llu", (unsigned long long) initrd_usec,
-                                           "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                           "KERNEL_USEC="USEC_FMT, kernel_usec,
+                                           "INITRD_USEC="USEC_FMT, initrd_usec,
+                                           "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                            "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.",
                                            format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
                                            format_timespan(initrd, sizeof(initrd), initrd_usec, USEC_PER_MSEC),
@@ -2470,8 +2470,8 @@ void manager_check_finished(Manager *m) {
                         if (!log_on_console())
                                 log_struct(LOG_INFO,
                                            MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                           "KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
-                                           "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                           "KERNEL_USEC="USEC_FMT, kernel_usec,
+                                           "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                            "MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
                                            format_timespan(kernel, sizeof(kernel), kernel_usec, USEC_PER_MSEC),
                                            format_timespan(userspace, sizeof(userspace), userspace_usec, USEC_PER_MSEC),
@@ -2485,7 +2485,7 @@ void manager_check_finished(Manager *m) {
                 if (!log_on_console())
                         log_struct(LOG_INFO,
                                    MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
-                                   "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
+                                   "USERSPACE_USEC="USEC_FMT, userspace_usec,
                                    "MESSAGE=Startup finished in %s.",
                                    format_timespan(sum, sizeof(sum), total_usec, USEC_PER_MSEC),
                                    NULL);
diff --git a/src/core/mount.c b/src/core/mount.c
index 09efa1b..41185c0 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -750,8 +750,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (m->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %lu\n",
-                        prefix, (unsigned long) m->control_pid);
+                        "%sControl PID: "PID_FMT"\n",
+                        prefix, m->control_pid);
 
         exec_context_dump(&m->exec_context, f, prefix);
         kill_context_dump(&m->kill_context, f, prefix);
@@ -1093,7 +1093,7 @@ static int mount_serialize(Unit *u, FILE *f, FDSet *fds) {
         unit_serialize_item(u, f, "reload-result", mount_result_to_string(m->reload_result));
 
         if (m->control_pid > 0)
-                unit_serialize_item_format(u, f, "control-pid", "%lu", (unsigned long) m->control_pid);
+                unit_serialize_item_format(u, f, "control-pid", PID_FMT, m->control_pid);
 
         if (m->control_command_id >= 0)
                 unit_serialize_item(u, f, "control-command", mount_exec_command_to_string(m->control_command_id));
diff --git a/src/core/service.c b/src/core/service.c
index ea47a5e..6fbde2b 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -210,8 +210,8 @@ static int service_set_main_pid(Service *s, pid_t pid) {
 
         if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
                 log_warning_unit(UNIT(s)->id,
-                                 "%s: Supervising process %lu which is not our child. We'll most likely not notice when it exits.",
-                                 UNIT(s)->id, (unsigned long) pid);
+                                 "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.",
+                                 UNIT(s)->id, pid);
 
                 s->main_pid_alien = true;
         } else
@@ -1309,15 +1309,15 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %lu\n",
-                        prefix, (unsigned long) s->control_pid);
+                        "%sControl PID: "PID_FMT"\n",
+                        prefix, s->control_pid);
 
         if (s->main_pid > 0)
                 fprintf(f,
-                        "%sMain PID: %lu\n"
+                        "%sMain PID: "PID_FMT"\n"
                         "%sMain PID Known: %s\n"
                         "%sMain PID Alien: %s\n",
-                        prefix, (unsigned long) s->main_pid,
+                        prefix, s->main_pid,
                         prefix, yes_no(s->main_pid_known),
                         prefix, yes_no(s->main_pid_alien));
 
@@ -1401,8 +1401,8 @@ static int service_load_pid_file(Service *s, bool may_warn) {
         if (kill(pid, 0) < 0 && errno != EPERM) {
                 if (may_warn)
                         log_info_unit(UNIT(s)->id,
-                                      "PID %lu read from file %s does not exist.",
-                                      (unsigned long) pid, s->pid_file);
+                                      "PID "PID_FMT" read from file %s does not exist.",
+                                      pid, s->pid_file);
                 return -ESRCH;
         }
 
@@ -1411,13 +1411,13 @@ static int service_load_pid_file(Service *s, bool may_warn) {
                         return 0;
 
                 log_debug_unit(UNIT(s)->id,
-                               "Main PID changing: %lu -> %lu",
-                               (unsigned long) s->main_pid, (unsigned long) pid);
+                               "Main PID changing: "PID_FMT" -> "PID_FMT,
+                               s->main_pid, pid);
                 service_unwatch_main_pid(s);
                 s->main_pid_known = false;
         } else
                 log_debug_unit(UNIT(s)->id,
-                               "Main PID loaded: %lu", (unsigned long) pid);
+                               "Main PID loaded: "PID_FMT, pid);
 
         r = service_set_main_pid(s, pid);
         if (r < 0)
@@ -1427,8 +1427,8 @@ static int service_load_pid_file(Service *s, bool may_warn) {
         if (r < 0) {
                 /* FIXME: we need to do something here */
                 log_warning_unit(UNIT(s)->id,
-                                 "Failed to watch PID %lu from service %s",
-                                 (unsigned long) pid, UNIT(s)->id);
+                                 "Failed to watch PID "PID_FMT" from service %s",
+                                 pid, UNIT(s)->id);
                 return r;
         }
 
@@ -1456,7 +1456,7 @@ static int service_search_main_pid(Service *s) {
                 return -ENOENT;
 
         log_debug_unit(UNIT(s)->id,
-                       "Main PID guessed: %lu", (unsigned long) pid);
+                       "Main PID guessed: "PID_FMT, pid);
         r = service_set_main_pid(s, pid);
         if (r < 0)
                 return r;
@@ -1465,8 +1465,8 @@ static int service_search_main_pid(Service *s) {
         if (r < 0)
                 /* FIXME: we need to do something here */
                 log_warning_unit(UNIT(s)->id,
-                                 "Failed to watch PID %lu from service %s",
-                                 (unsigned long) pid, UNIT(s)->id);
+                                 "Failed to watch PID "PID_FMT" from service %s",
+                                 pid, UNIT(s)->id);
                 return r;
 
         return 0;
@@ -1763,13 +1763,13 @@ static int service_spawn(
                 }
 
         if (s->main_pid > 0)
-                if (asprintf(our_env + n_env++, "MAINPID=%lu", (unsigned long) s->main_pid) < 0) {
+                if (asprintf(our_env + n_env++, "MAINPID="PID_FMT, s->main_pid) < 0) {
                         r = -ENOMEM;
                         goto fail;
                 }
 
         if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM)
-                if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) {
+                if (asprintf(our_env + n_env++, "MANAGERPID="PID_FMT, getpid()) < 0) {
                         r = -ENOMEM;
                         goto fail;
                 }
@@ -2562,11 +2562,11 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
         unit_serialize_item(u, f, "reload-result", service_result_to_string(s->reload_result));
 
         if (s->control_pid > 0)
-                unit_serialize_item_format(u, f, "control-pid", "%lu",
-                                           (unsigned long) s->control_pid);
+                unit_serialize_item_format(u, f, "control-pid", PID_FMT,
+                                           s->control_pid);
 
         if (s->main_pid_known && s->main_pid > 0)
-                unit_serialize_item_format(u, f, "main-pid", "%lu", (unsigned long) s->main_pid);
+                unit_serialize_item_format(u, f, "main-pid", PID_FMT, s->main_pid);
 
         unit_serialize_item(u, f, "main-pid-known", yes_no(s->main_pid_known));
 
@@ -2590,8 +2590,8 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) {
         }
 
         if (s->main_exec_status.pid > 0) {
-                unit_serialize_item_format(u, f, "main-exec-status-pid", "%lu",
-                                           (unsigned long) s->main_exec_status.pid);
+                unit_serialize_item_format(u, f, "main-exec-status-pid", PID_FMT,
+                                           s->main_exec_status.pid);
                 dual_timestamp_serialize(f, "main-exec-status-start",
                                          &s->main_exec_status.start_timestamp);
                 dual_timestamp_serialize(f, "main-exec-status-exit",
@@ -3343,20 +3343,20 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
 
         assert(u);
 
-        log_debug_unit(u->id, "%s: Got notification message from PID %lu (%s...)",
-                       u->id, (unsigned long) pid, tags && *tags ? tags[0] : "(empty)");
+        log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s...)",
+                       u->id, pid, tags && *tags ? tags[0] : "(empty)");
 
         if (s->notify_access == NOTIFY_NONE) {
                 log_warning_unit(u->id,
-                                 "%s: Got notification message from PID %lu, but reception is disabled.",
-                                 u->id, (unsigned long) pid);
+                                 "%s: Got notification message from PID "PID_FMT", but reception is disabled.",
+                                 u->id, pid);
                 return;
         }
 
         if (s->notify_access == NOTIFY_MAIN && s->main_pid != 0 && pid != s->main_pid) {
                 log_warning_unit(u->id,
-                                 "%s: Got notification message from PID %lu, but reception only permitted for PID %lu",
-                                 u->id, (unsigned long) pid, (unsigned long) s->main_pid);
+                                 "%s: Got notification message from PID "PID_FMT", but reception only permitted for PID "PID_FMT,
+                                 u->id, pid, s->main_pid);
                 return;
         }
 
diff --git a/src/shared/time-util.h b/src/shared/time-util.h
index 913821a..96f2ec8 100644
--- a/src/shared/time-util.h
+++ b/src/shared/time-util.h
@@ -27,6 +27,9 @@
 typedef uint64_t usec_t;
 typedef uint64_t nsec_t;
 
+#define NSEC_FMT "%" PRIu64
+#define USEC_FMT "%" PRIu64
+
 #include "macro.h"
 
 typedef struct dual_timestamp {
diff --git a/src/shared/util.h b/src/shared/util.h
index f6d2ced..d9720d0 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -42,6 +42,22 @@
 #include <mntent.h>
 #include <sys/socket.h>
 
+#if SIZEOF_PID_T == 4
+#  define PID_FMT "%" PRIu32
+#elif SIZEOF_PID_T == 2
+#  define PID_FMT "%" PRIu16
+#else
+#  error Unknown pid_t size
+#endif
+
+#if SIZEOF_UID_T == 4
+#  define UID_FMT "%" PRIu32
+#elif SIZEOF_UID_T == 2
+#  define UID_FMT "%" PRIu16
+#else
+#  error Unknown uid_t size
+#endif
+
 #include "macro.h"
 #include "time-util.h"
 
@@ -763,7 +779,7 @@ int unlink_noerrno(const char *path);
                 pid_t _pid_ = (pid);                                    \
                 char *_r_;                                              \
                 _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
-                sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \
+                sprintf(_r_, "/proc/"PID_FMT"/" field, _pid_); \
                 _r_;                                                    \
         })
 

commit ab9001a1e3dc6e60d0cdf53363dc5d18dcc382fd
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Dec 30 16:12:46 2013 -0500

    Move bus path definitions to def.h

diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index fa52a38..28e8b44 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -40,17 +40,9 @@
 #include "bus-util.h"
 #include "build.h"
 #include "strv.h"
+#include "def.h"
 
-#define UNIX_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
-#define KERNEL_BUS_PATH "kernel:path=/dev/kdbus/0-system/bus"
-
-#ifdef ENABLE_KDBUS
-#  define DEFAULT_BUS_PATH KERNEL_BUS_PATH ";" UNIX_BUS_PATH
-#else
-#  define DEFAULT_BUS_PATH UNIX_BUS_PATH
-#endif
-
-static const char *arg_address = DEFAULT_BUS_PATH;
+static const char *arg_address = DEFAULT_SYSTEM_BUS_PATH;
 static char *arg_command_line_buffer = NULL;
 
 static int help(void) {
@@ -60,7 +52,7 @@ static int help(void) {
                "  -h --help              Show this help\n"
                "     --version           Show package version\n"
                "     --address=ADDRESS   Connect to the bus specified by ADDRESS\n"
-               "                         (default: " DEFAULT_BUS_PATH ")\n",
+               "                         (default: " DEFAULT_SYSTEM_BUS_PATH ")\n",
                program_invocation_short_name);
 
         return 0;
diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index f96c293..425f63a 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -483,7 +483,7 @@ int bus_open_system_systemd(sd_bus **_bus) {
         if (r < 0)
                 return r;
 
-        r = sd_bus_set_address(bus, "kernel:path=/dev/kdbus/0-system/bus");
+        r = sd_bus_set_address(bus, KERNEL_SYSTEM_BUS_PATH);
         if (r < 0)
                 return r;
 
@@ -536,7 +536,7 @@ int bus_open_user_systemd(sd_bus **_bus) {
         if (r < 0)
                 return r;
 
-        if (asprintf(&bus->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid()) < 0)
+        if (asprintf(&bus->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()) < 0)
                 return -ENOMEM;
 
         bus->bus_client = true;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 44ab071..61dc0e5 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -34,6 +34,7 @@
 #include "strv.h"
 #include "set.h"
 #include "missing.h"
+#include "def.h"
 
 #include "sd-bus.h"
 #include "bus-internal.h"
@@ -1047,12 +1048,7 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
         if (e)
                 r = sd_bus_set_address(b, e);
         else
-#ifdef ENABLE_KDBUS
-                r = sd_bus_set_address(b, "kernel:path=/dev/kdbus/0-system/bus;unix:path=/run/dbus/system_bus_socket");
-#else
-                r = sd_bus_set_address(b, "unix:path=/run/dbus/system_bus_socket");
-#endif
-
+                r = sd_bus_set_address(b, DEFAULT_SYSTEM_BUS_PATH);
         if (r < 0)
                 goto fail;
 
@@ -1103,13 +1099,13 @@ _public_ int sd_bus_open_user(sd_bus **ret) {
                         }
 
 #ifdef ENABLE_KDBUS
-                        asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus", (unsigned long) getuid(), ee);
+                        asprintf(&b->address, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT, (unsigned long) getuid(), ee);
 #else
-                        b->address = strjoin("unix:path=", ee, "/bus", NULL);
+                        asprintf(&b->address, UNIX_USER_BUS_FMT, (unsigned long) getuid());
 #endif
                 } else {
 #ifdef ENABLE_KDBUS
-                        asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid());
+                        asprintf(&b->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid());
 #else
                         return -ECONNREFUSED;
 #endif
diff --git a/src/shared/def.h b/src/shared/def.h
index d196af7..ac325bf 100644
--- a/src/shared/def.h
+++ b/src/shared/def.h
@@ -59,3 +59,15 @@
         "/usr/share/kbd/keymaps/\0"             \
         "/usr/lib/kbd/keymaps/\0"
 #endif
+
+#define UNIX_SYSTEM_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
+#define KERNEL_SYSTEM_BUS_PATH "kernel:path=/dev/kdbus/0-system/bus"
+
+#ifdef ENABLE_KDBUS
+#  define DEFAULT_SYSTEM_BUS_PATH KERNEL_SYSTEM_BUS_PATH ";" UNIX_SYSTEM_BUS_PATH
+#else
+#  define DEFAULT_SYSTEM_BUS_PATH UNIX_SYSTEM_BUS_PATH
+#endif
+
+#define UNIX_USER_BUS_FMT "unix:path=%s/bus"
+#define KERNEL_USER_BUS_FMT "kernel:path=/dev/kdbus/%lu-user/bus"

commit da13d4d20f8ca12e86863abbae5ed47bca936828
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Dec 30 11:21:56 2013 -0500

    core/service: check if mainpid matches only if it is set
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1047304

diff --git a/src/core/service.c b/src/core/service.c
index eb9cd23..ea47a5e 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3343,6 +3343,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
 
         assert(u);
 
+        log_debug_unit(u->id, "%s: Got notification message from PID %lu (%s...)",
+                       u->id, (unsigned long) pid, tags && *tags ? tags[0] : "(empty)");
+
         if (s->notify_access == NOTIFY_NONE) {
                 log_warning_unit(u->id,
                                  "%s: Got notification message from PID %lu, but reception is disabled.",
@@ -3350,15 +3353,13 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
                 return;
         }
 
-        if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) {
+        if (s->notify_access == NOTIFY_MAIN && s->main_pid != 0 && pid != s->main_pid) {
                 log_warning_unit(u->id,
                                  "%s: Got notification message from PID %lu, but reception only permitted for PID %lu",
                                  u->id, (unsigned long) pid, (unsigned long) s->main_pid);
                 return;
         }
 
-        log_debug_unit(u->id, "%s: Got message", u->id);
-
         /* Interpret MAINPID= */
         if ((e = strv_find_prefix(tags, "MAINPID=")) &&
             (s->state == SERVICE_START ||

commit a9244623f785f504f799407b0228dea9655e24cb
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Dec 27 22:12:38 2013 -0500

    core/manager: print info about interesting signals
    
    Information about signals which are not routinely received by systemd
    are printed at info level. This should make it easier to see what is
    happening in the system.

diff --git a/src/core/manager.c b/src/core/manager.c
index f69ae07..ea8887a 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1463,16 +1463,22 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
                 }
 
                 if (sfsi.ssi_pid > 0) {
-                        char *p = NULL;
+                        _cleanup_free_ char *p = NULL;
 
                         get_process_comm(sfsi.ssi_pid, &p);
 
-                        log_debug("Received SIG%s from PID %lu (%s).",
-                                  signal_to_string(sfsi.ssi_signo),
-                                  (unsigned long) sfsi.ssi_pid, strna(p));
-                        free(p);
+                        log_full(sfsi.ssi_signo == SIGCHLD ||
+                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                 ? LOG_DEBUG : LOG_INFO,
+                                 "Received SIG%s from PID %lu (%s).",
+                                 signal_to_string(sfsi.ssi_signo),
+                                 (unsigned long) sfsi.ssi_pid, strna(p));
                 } else
-                        log_debug("Received SIG%s.", signal_to_string(sfsi.ssi_signo));
+                        log_full(sfsi.ssi_signo == SIGCHLD ||
+                                 (sfsi.ssi_signo == SIGTERM && m->running_as == SYSTEMD_USER)
+                                 ? LOG_DEBUG : LOG_INFO,
+                                 "Received SIG%s.",
+                                 signal_to_string(sfsi.ssi_signo));
 
                 switch (sfsi.ssi_signo) {
 

commit 41aef6fc747a3b5b8bf47faa468881be16509c66
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Dec 27 20:03:27 2013 -0500

    core/service: tweak messages on operation timeouts

diff --git a/src/core/service.c b/src/core/service.c
index 8097e26..eb9cd23 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3181,19 +3181,21 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
         case SERVICE_START_PRE:
         case SERVICE_START:
                 log_warning_unit(UNIT(s)->id,
-                                 "%s operation timed out. Terminating.", UNIT(s)->id);
+                                 "%s %s operation timed out. Terminating.",
+                                 UNIT(s)->id,
+                                 s->state == SERVICE_START ? "start" : "start-pre");
                 service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
                 break;
 
         case SERVICE_START_POST:
                 log_warning_unit(UNIT(s)->id,
-                                 "%s operation timed out. Stopping.", UNIT(s)->id);
+                                 "%s start-post operation timed out. Stopping.", UNIT(s)->id);
                 service_enter_stop(s, SERVICE_FAILURE_TIMEOUT);
                 break;
 
         case SERVICE_RELOAD:
                 log_warning_unit(UNIT(s)->id,
-                                 "%s operation timed out. Stopping.", UNIT(s)->id);
+                                 "%s reload operation timed out. Stopping.", UNIT(s)->id);
                 s->reload_result = SERVICE_FAILURE_TIMEOUT;
                 service_enter_running(s, SERVICE_SUCCESS);
                 break;
@@ -3207,11 +3209,11 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
         case SERVICE_STOP_SIGTERM:
                 if (s->kill_context.send_sigkill) {
                         log_warning_unit(UNIT(s)->id,
-                                         "%s stopping timed out. Killing.", UNIT(s)->id);
+                                         "%s stop-sigterm timed out. Killing.", UNIT(s)->id);
                         service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_FAILURE_TIMEOUT);
                 } else {
                         log_warning_unit(UNIT(s)->id,
-                                         "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id);
+                                         "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id);
                         service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT);
                 }
 
@@ -3229,18 +3231,18 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
 
         case SERVICE_STOP_POST:
                 log_warning_unit(UNIT(s)->id,
-                                 "%s stopping timed out (2). Terminating.", UNIT(s)->id);
+                                 "%s stop-post timed out. Terminating.", UNIT(s)->id);
                 service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
                 break;
 
         case SERVICE_FINAL_SIGTERM:
                 if (s->kill_context.send_sigkill) {
                         log_warning_unit(UNIT(s)->id,
-                                         "%s stopping timed out (2). Killing.", UNIT(s)->id);
+                                         "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id);
                         service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_TIMEOUT);
                 } else {
                         log_warning_unit(UNIT(s)->id,
-                                         "%s stopping timed out (2). Skipping SIGKILL. Entering failed mode.",
+                                         "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.",
                                          UNIT(s)->id);
                         service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, false);
                 }
@@ -3249,7 +3251,7 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
 
         case SERVICE_FINAL_SIGKILL:
                 log_warning_unit(UNIT(s)->id,
-                                 "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id);
+                                 "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id);
                 service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, true);
                 break;
 



More information about the systemd-commits mailing list