[systemd-commits] 7 commits - fixme src/automount.c src/device.c src/execute.c src/initctl.c src/log.c src/logger.c src/main.c src/manager.c src/mount.c src/path.c src/service.c src/snapshot.c src/socket.c src/swap.c src/systemctl.c src/target.c src/timer.c src/unit.h src/util.c

Lennart Poettering lennart at kemper.freedesktop.org
Sat Jun 19 07:59:15 PDT 2010


 fixme           |    2 -
 src/automount.c |   18 +++++------
 src/device.c    |    2 -
 src/execute.c   |    8 ++---
 src/initctl.c   |   16 ++++++++--
 src/log.c       |    4 +-
 src/logger.c    |   16 ++++++++--
 src/main.c      |    4 +-
 src/manager.c   |   16 +++++-----
 src/mount.c     |   29 ++++++++++--------
 src/path.c      |    4 +-
 src/service.c   |   87 +++++++++++++++++++++++++++++---------------------------
 src/snapshot.c  |    2 -
 src/socket.c    |   33 ++++++++++++---------
 src/swap.c      |    6 +--
 src/systemctl.c |   63 +++++++++++++++++++++++++++++++++++++---
 src/target.c    |    2 -
 src/timer.c     |    4 +-
 src/unit.h      |    4 +-
 src/util.c      |   10 +++---
 20 files changed, 208 insertions(+), 122 deletions(-)

New commits:
commit f1c5860be7b89e784fbba1624127a843b62c7b98
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:58:59 2010 +0200

    systemctl: make upstart glue code talk to upstart via private abstarct bus and verify its UID owner

diff --git a/src/systemctl.c b/src/systemctl.c
index 429d6a7..18b32bc 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -29,6 +29,7 @@
 #include <termios.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <sys/socket.h>
 
 #include <dbus/dbus.h>
 
@@ -103,6 +104,32 @@ static int bus_iter_get_basic_and_next(DBusMessageIter *iter, int type, void *da
         return 0;
 }
 
+static int bus_check_peercred(DBusConnection *c) {
+        int fd;
+        struct ucred ucred;
+        socklen_t l;
+
+        assert(c);
+
+        assert_se(dbus_connection_get_unix_fd(c, &fd));
+
+        l = sizeof(struct ucred);
+        if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0) {
+                log_error("SO_PEERCRED failed: %m");
+                return -errno;
+        }
+
+        if (l != sizeof(struct ucred)) {
+                log_error("SO_PEERCRED returned wrong size.");
+                return -E2BIG;
+        }
+
+        if (ucred.uid != 0)
+                return -EPERM;
+
+        return 1;
+}
+
 static int columns(void) {
         static int parsed_columns = 0;
         const char *e;
@@ -1931,7 +1958,7 @@ static int action_to_runlevel(void) {
         return table[arg_action];
 }
 
-static int talk_upstart(DBusConnection *bus) {
+static int talk_upstart(void) {
         DBusMessage *m = NULL, *reply = NULL;
         DBusError error;
         int previous, rl, r;
@@ -1942,6 +1969,7 @@ static int talk_upstart(DBusConnection *bus) {
         const char *emit = "runlevel";
         dbus_bool_t b_false = FALSE;
         DBusMessageIter iter, sub;
+        DBusConnection *bus;
 
         dbus_error_init(&error);
 
@@ -1951,6 +1979,22 @@ static int talk_upstart(DBusConnection *bus) {
         if (utmp_get_runlevel(&previous, NULL) < 0)
                 previous = 'N';
 
+        if (!(bus = dbus_connection_open("unix:abstract=/com/ubuntu/upstart", &error))) {
+                if (dbus_error_has_name(&error, DBUS_ERROR_NO_SERVER)) {
+                        r = 0;
+                        goto finish;
+                }
+
+                log_error("Failed to connect to Upstart bus: %s", error.message);
+                r = -EIO;
+                goto finish;
+        }
+
+        if ((r = bus_check_peercred(bus)) < 0) {
+                log_error("Failed to verify owner of bus.");
+                goto finish;
+        }
+
         if (!(m = dbus_message_new_method_call(
                               "com.ubuntu.Upstart",
                               "/com/ubuntu/Upstart",
@@ -1958,7 +2002,8 @@ static int talk_upstart(DBusConnection *bus) {
                               "EmitEvent"))) {
 
                 log_error("Could not allocate message.");
-                return -ENOMEM;
+                r = -ENOMEM;
+                goto finish;
         }
 
         dbus_message_iter_init_append(m, &iter);
@@ -1998,6 +2043,9 @@ finish:
         if (reply)
                 dbus_message_unref(reply);
 
+        if (bus)
+                dbus_connection_unref(bus);
+
         dbus_error_free(&error);
 
         return r;
@@ -2165,7 +2213,7 @@ static int start_with_fallback(DBusConnection *bus) {
 
                 /* Hmm, talking to systemd via D-Bus didn't work. Then
                  * let's try to talk to Upstart via D-Bus. */
-                if ((r = talk_upstart(bus)) > 0)
+                if ((r = talk_upstart()) > 0)
                         return 0;
         }
 
@@ -2262,9 +2310,14 @@ int main(int argc, char*argv[]) {
         }
 
         /* If we are root, then let's not go via the bus */
-        if (geteuid() == 0 && !arg_session)
+        if (geteuid() == 0 && !arg_session) {
                 bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", &error);
-        else
+
+                if (bus && bus_check_peercred(bus) < 0) {
+                        log_error("Failed to verify owner of bus.");
+                        goto finish;
+                }
+        } else
                 bus = dbus_bus_get(arg_session ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
 
         if (bus)
commit 4d0e5dbd52291ae49740adb006bfc2595b953ec5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:57:54 2010 +0200

    service: require KillMode=control-group when PAM is enabled

diff --git a/src/mount.c b/src/mount.c
index e398420..081e92c 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -303,6 +303,11 @@ static int mount_verify(Mount *m) {
                 return -EBADMSG;
         }
 
+        if (m->exec_context.pam_name && m->kill_mode != KILL_CONTROL_GROUP) {
+                log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", m->meta.id);
+                return -EINVAL;
+        }
+
         return 0;
 }
 
diff --git a/src/service.c b/src/service.c
index ba60b8f..aff3551 100644
--- a/src/service.c
+++ b/src/service.c
@@ -817,7 +817,12 @@ static int service_verify(Service *s) {
         }
 
         if (s->type == SERVICE_DBUS && !s->bus_name) {
-                log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->meta.id);
+                log_error("%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", s->meta.id);
+                return -EINVAL;
+        }
+
+        if (s->exec_context.pam_name && s->kill_mode != KILL_CONTROL_GROUP) {
+                log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
                 return -EINVAL;
         }
 
diff --git a/src/socket.c b/src/socket.c
index ccbe432..7a8624c 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -153,7 +153,12 @@ static int socket_verify(Socket *s) {
         }
 
         if (s->accept && s->max_connections <= 0) {
-                log_error("%s's MaxConnection setting too small. Refusing.", UNIT(s)->meta.id);
+                log_error("%s's MaxConnection setting too small. Refusing.", s->meta.id);
+                return -EINVAL;
+        }
+
+        if (s->exec_context.pam_name && s->kill_mode != KILL_CONTROL_GROUP) {
+                log_error("%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", s->meta.id);
                 return -EINVAL;
         }
 
commit 399ab2b1ac07be5afa9708b3280d4e1a4cceb5b8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:57:29 2010 +0200

    unit: make unit casts typesafe

diff --git a/src/manager.c b/src/manager.c
index da42d7d..554dd8e 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -271,7 +271,7 @@ static unsigned manager_dispatch_cleanup_queue(Manager *m) {
         while ((meta = m->cleanup_queue)) {
                 assert(meta->in_cleanup_queue);
 
-                unit_free(UNIT(meta));
+                unit_free((Unit*) meta);
                 n++;
         }
 
@@ -361,7 +361,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
         while ((meta = m->gc_queue)) {
                 assert(meta->in_gc_queue);
 
-                unit_gc_sweep(UNIT(meta), gc_marker);
+                unit_gc_sweep((Unit*) meta, gc_marker);
 
                 LIST_REMOVE(Meta, gc_queue, m->gc_queue, meta);
                 meta->in_gc_queue = false;
@@ -372,7 +372,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
                     meta->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
                         log_debug("Collecting %s", meta->id);
                         meta->gc_marker = gc_marker + GC_OFFSET_BAD;
-                        unit_add_to_cleanup_queue(UNIT(meta));
+                        unit_add_to_cleanup_queue((Unit*) meta);
                 }
         }
 
@@ -1439,7 +1439,7 @@ unsigned manager_dispatch_load_queue(Manager *m) {
         while ((meta = m->load_queue)) {
                 assert(meta->in_load_queue);
 
-                unit_load(UNIT(meta));
+                unit_load((Unit*) meta);
                 n++;
         }
 
@@ -1585,7 +1585,7 @@ unsigned manager_dispatch_dbus_queue(Manager *m) {
         while ((meta = m->dbus_unit_queue)) {
                 assert(meta->in_dbus_queue);
 
-                bus_unit_send_change_signal(UNIT(meta));
+                bus_unit_send_change_signal((Unit*) meta);
                 n++;
         }
 
diff --git a/src/unit.h b/src/unit.h
index c5be858..fb158d5 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -336,14 +336,14 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
 /* For casting a unit into the various unit types */
 #define DEFINE_CAST(UPPERCASE, MixedCase)                               \
         static inline MixedCase* UPPERCASE(Unit *u) {                   \
-                if (!u || u->meta.type != UNIT_##UPPERCASE)             \
+                if (_unlikely_(!u || u->meta.type != UNIT_##UPPERCASE)) \
                         return NULL;                                    \
                                                                         \
                 return (MixedCase*) u;                                  \
         }
 
 /* For casting the various unit types into a unit */
-#define UNIT(u) ((Unit*) (u))
+#define UNIT(u) ((Unit*) (&(u)->meta))
 
 DEFINE_CAST(SOCKET, Socket);
 DEFINE_CAST(TIMER, Timer);
commit 0ca3f374f9d7c166ac5b391ec7208f6de7274e7f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:56:57 2010 +0200

    initctl: add some checks before starting up

diff --git a/src/initctl.c b/src/initctl.c
index b6bcaf9..3de7fcd 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -336,6 +336,16 @@ int main(int argc, char *argv[]) {
         Server server;
         int r = 3, n;
 
+        if (getppid() != 1) {
+                log_error("This program should be invoked by init only.");
+                return 1;
+        }
+
+        if (argc > 1) {
+                log_error("This program does not take arguments.");
+                return 1;
+        }
+
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
diff --git a/src/logger.c b/src/logger.c
index 66f6f8c..cc394df 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -535,6 +535,16 @@ int main(int argc, char *argv[]) {
         Server server;
         int r = 3, n;
 
+        if (getppid() != 1) {
+                log_error("This program should be invoked by init only.");
+                return 1;
+        }
+
+        if (argc > 1) {
+                log_error("This program does not take arguments.");
+                return 1;
+        }
+
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
commit f5a3628cc7aa132bb0ee6be48f3cedc2d8838046
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:56:26 2010 +0200

    initctl: talk to systemd via the abstract private bus

diff --git a/src/initctl.c b/src/initctl.c
index def621d..b6bcaf9 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -296,7 +296,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 s->n_fifos ++;
         }
 
-        if (!(s->bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
+        if (!(s->bus = dbus_connection_open("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
                 log_error("Failed to get D-Bus connection: %s", error.message);
                 goto fail;
         }
commit 4cd1fbcc0648a289e9bf9d9047621bbdf7ec0ece
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 16:55:49 2010 +0200

    unit: get rid of various unnecessary casts

diff --git a/src/automount.c b/src/automount.c
index 262a47d..75c1053 100644
--- a/src/automount.c
+++ b/src/automount.c
@@ -87,8 +87,8 @@ static void unmount_autofs(Automount *a) {
         /* If we reload/reexecute things we keep the mount point
          * around */
         if (a->where &&
-            (UNIT(a)->meta.manager->exit_code != MANAGER_RELOAD &&
-             UNIT(a)->meta.manager->exit_code != MANAGER_REEXECUTE))
+            (a->meta.manager->exit_code != MANAGER_RELOAD &&
+             a->meta.manager->exit_code != MANAGER_REEXECUTE))
                 repeat_unmout(a->where);
 }
 
@@ -150,7 +150,7 @@ static int automount_verify(Automount *a) {
         char *e;
         assert(a);
 
-        if (UNIT(a)->meta.load_state != UNIT_LOADED)
+        if (a->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (!(e = unit_name_from_path(a->where, ".automount")))
@@ -160,7 +160,7 @@ static int automount_verify(Automount *a) {
         free(e);
 
         if (!b) {
-                log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->meta.id);
+                log_error("%s's Where setting doesn't match unit name. Refusing.", a->meta.id);
                 return -EINVAL;
         }
 
@@ -212,7 +212,7 @@ static void automount_set_state(Automount *a, AutomountState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(a)->meta.id,
+                          a->meta.id,
                           automount_state_to_string(old_state),
                           automount_state_to_string(state));
 
@@ -403,7 +403,7 @@ int automount_send_ready(Automount *a, int status) {
         if (set_isempty(a->tokens))
                 return 0;
 
-        if ((ioctl_fd = open_ioctl_fd(UNIT(a)->meta.manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
+        if ((ioctl_fd = open_ioctl_fd(a->meta.manager->dev_autofs_fd, a->where, a->dev_id)) < 0) {
                 r = ioctl_fd;
                 goto fail;
         }
@@ -422,7 +422,7 @@ int automount_send_ready(Automount *a, int status) {
                  * if you pass a positive status code here, the kernel will
                  * freeze! Yay! */
 
-                if ((k = autofs_send_ready(UNIT(a)->meta.manager->dev_autofs_fd,
+                if ((k = autofs_send_ready(a->meta.manager->dev_autofs_fd,
                                            ioctl_fd,
                                            token,
                                            status)) < 0)
@@ -452,7 +452,7 @@ static void automount_enter_waiting(Automount *a) {
         if (a->tokens)
                 set_clear(a->tokens);
 
-        if ((dev_autofs_fd = open_dev_autofs(UNIT(a)->meta.manager)) < 0) {
+        if ((dev_autofs_fd = open_dev_autofs(a->meta.manager)) < 0) {
                 r = dev_autofs_fd;
                 goto fail;
         }
@@ -545,7 +545,7 @@ static void automount_enter_runnning(Automount *a) {
 
         if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
                 log_info("%s's automount point already active?", a->meta.id);
-        else if ((r = manager_add_job(UNIT(a)->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, NULL)) < 0) {
+        else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, NULL)) < 0) {
                 log_warning("%s failed to queue mount startup job: %s", a->meta.id, strerror(-r));
                 goto fail;
         }
diff --git a/src/device.c b/src/device.c
index adc6cc1..a0349c4 100644
--- a/src/device.c
+++ b/src/device.c
@@ -53,7 +53,7 @@ static void device_set_state(Device *d, DeviceState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(d)->meta.id,
+                          d->meta.id,
                           device_state_to_string(old_state),
                           device_state_to_string(state));
 
diff --git a/src/mount.c b/src/mount.c
index b49c64a..e398420 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -251,7 +251,7 @@ static int mount_add_target_links(Mount *m) {
         else
                 target = SPECIAL_LOCAL_FS_TARGET;
 
-        if ((r = manager_load_unit(UNIT(m)->meta.manager, target, NULL, &tu)) < 0)
+        if ((r = manager_load_unit(m->meta.manager, target, NULL, &tu)) < 0)
                 return r;
 
         if (automount && m->meta.manager->running_as == MANAGER_SYSTEM) {
@@ -294,12 +294,12 @@ static int mount_verify(Mount *m) {
         free(e);
 
         if (!b) {
-                log_error("%s's Where setting doesn't match unit name. Refusing.", UNIT(m)->meta.id);
+                log_error("%s's Where setting doesn't match unit name. Refusing.", m->meta.id);
                 return -EINVAL;
         }
 
         if (m->meta.fragment_path && !m->parameters_fragment.what) {
-                log_error("%s's What setting is missing. Refusing.", UNIT(m)->meta.id);
+                log_error("%s's What setting is missing. Refusing.", m->meta.id);
                 return -EBADMSG;
         }
 
@@ -420,7 +420,7 @@ static void mount_set_state(Mount *m, MountState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(m)->meta.id,
+                          m->meta.id,
                           mount_state_to_string(old_state),
                           mount_state_to_string(state));
 
@@ -529,8 +529,8 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
                             m->meta.manager->environment,
                             true,
                             true,
-                            UNIT(m)->meta.manager->confirm_spawn,
-                            UNIT(m)->meta.cgroup_bondings,
+                            m->meta.manager->confirm_spawn,
+                            m->meta.cgroup_bondings,
                             &pid)) < 0)
                 goto fail;
 
@@ -582,7 +582,7 @@ static void mount_enter_signal(Mount *m, MountState state, bool success) {
 
                 if (m->kill_mode == KILL_CONTROL_GROUP) {
 
-                        if ((r = cgroup_bonding_kill_list(UNIT(m)->meta.cgroup_bondings, sig)) < 0) {
+                        if ((r = cgroup_bonding_kill_list(m->meta.cgroup_bondings, sig)) < 0) {
                                 if (r != -EAGAIN && r != -ESRCH)
                                         goto fail;
                         } else
@@ -609,7 +609,7 @@ static void mount_enter_signal(Mount *m, MountState state, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to kill processes: %s", UNIT(m)->meta.id, strerror(-r));
+        log_warning("%s failed to kill processes: %s", m->meta.id, strerror(-r));
 
         if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
                 mount_enter_mounted(m, false);
@@ -645,7 +645,7 @@ static void mount_enter_unmounting(Mount *m, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run 'umount' task: %s", UNIT(m)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'umount' task: %s", m->meta.id, strerror(-r));
         mount_enter_mounted(m, false);
 }
 
@@ -688,7 +688,7 @@ static void mount_enter_mounting(Mount *m) {
         return;
 
 fail:
-        log_warning("%s failed to run 'mount' task: %s", UNIT(m)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'mount' task: %s", m->meta.id, strerror(-r));
         mount_enter_dead(m, false);
 }
 
diff --git a/src/path.c b/src/path.c
index 8a940d0..24545ba 100644
--- a/src/path.c
+++ b/src/path.c
@@ -91,7 +91,7 @@ static int path_add_mount_links(Path *p) {
 static int path_verify(Path *p) {
         assert(p);
 
-        if (UNIT(p)->meta.load_state != UNIT_LOADED)
+        if (p->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (!p->specs) {
@@ -297,7 +297,7 @@ static void path_enter_running(Path *p) {
         int r;
         assert(p);
 
-        if ((r = manager_add_job(UNIT(p)->meta.manager, JOB_START, p->unit, JOB_REPLACE, true, NULL)) < 0)
+        if ((r = manager_add_job(p->meta.manager, JOB_START, p->unit, JOB_REPLACE, true, NULL)) < 0)
                 goto fail;
 
         path_set_state(p, PATH_RUNNING);
diff --git a/src/service.c b/src/service.c
index 9873201..ba60b8f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -279,7 +279,7 @@ static int sysv_fix_order(Service *s) {
         /* For each pair of services where at least one lacks a LSB
          * header, we use the start priority value to order things. */
 
-        LIST_FOREACH(units_per_type, other, UNIT(s)->meta.manager->units_per_type[UNIT_SERVICE]) {
+        LIST_FOREACH(units_per_type, other, s->meta.manager->units_per_type[UNIT_SERVICE]) {
                 Service *t;
                 UnitDependency d;
 
@@ -711,7 +711,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
             endswith(name, ".sh.service"))
                 return -ENOENT;
 
-        STRV_FOREACH(p, UNIT(s)->meta.manager->lookup_paths.sysvinit_path) {
+        STRV_FOREACH(p, s->meta.manager->lookup_paths.sysvinit_path) {
                 char *path;
                 int r;
 
@@ -723,7 +723,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
                 r = service_load_sysv_path(s, path);
 
-                if (r >= 0 && UNIT(s)->meta.load_state == UNIT_STUB) {
+                if (r >= 0 && s->meta.load_state == UNIT_STUB) {
                         /* Try Debian style xxx.sh source'able init scripts */
                         strcat(path, ".sh");
                         r = service_load_sysv_path(s, path);
@@ -731,7 +731,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
                 free(path);
 
-                if (r >= 0 && UNIT(s)->meta.load_state == UNIT_STUB) {
+                if (r >= 0 && s->meta.load_state == UNIT_STUB) {
                         /* Try SUSE style boot.xxx init scripts */
 
                         if (asprintf(&path, "%s/boot.%s", *p, name) < 0)
@@ -745,7 +745,7 @@ static int service_load_sysv_name(Service *s, const char *name) {
                 if (r < 0)
                         return r;
 
-                if ((UNIT(s)->meta.load_state != UNIT_STUB))
+                if ((s->meta.load_state != UNIT_STUB))
                         break;
         }
 
@@ -762,22 +762,22 @@ static int service_load_sysv(Service *s) {
         /* Load service data from SysV init scripts, preferably with
          * LSB headers ... */
 
-        if (strv_isempty(UNIT(s)->meta.manager->lookup_paths.sysvinit_path))
+        if (strv_isempty(s->meta.manager->lookup_paths.sysvinit_path))
                 return 0;
 
-        if ((t = UNIT(s)->meta.id))
+        if ((t = s->meta.id))
                 if ((r = service_load_sysv_name(s, t)) < 0)
                         return r;
 
-        if (UNIT(s)->meta.load_state == UNIT_STUB)
-                SET_FOREACH(t, UNIT(s)->meta.names, i) {
-                        if (t == UNIT(s)->meta.id)
+        if (s->meta.load_state == UNIT_STUB)
+                SET_FOREACH(t, s->meta.names, i) {
+                        if (t == s->meta.id)
                                 continue;
 
                         if ((r == service_load_sysv_name(s, t)) < 0)
                                 return r;
 
-                        if (UNIT(s)->meta.load_state != UNIT_STUB)
+                        if (s->meta.load_state != UNIT_STUB)
                                 break;
                 }
 
@@ -803,16 +803,16 @@ static int service_add_bus_name(Service *s) {
 static int service_verify(Service *s) {
         assert(s);
 
-        if (UNIT(s)->meta.load_state != UNIT_LOADED)
+        if (s->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (!s->exec_command[SERVICE_EXEC_START]) {
-                log_error("%s lacks ExecStart setting. Refusing.", UNIT(s)->meta.id);
+                log_error("%s lacks ExecStart setting. Refusing.", s->meta.id);
                 return -EINVAL;
         }
 
         if (s->exec_command[SERVICE_EXEC_START]->command_next) {
-                log_error("%s has more than one ExecStart setting. Refusing.", UNIT(s)->meta.id);
+                log_error("%s has more than one ExecStart setting. Refusing.", s->meta.id);
                 return -EINVAL;
         }
 
@@ -1019,7 +1019,7 @@ static int service_get_sockets(Service *s, Set **_set) {
         if (!(set = set_new(NULL, NULL)))
                 return -ENOMEM;
 
-        SET_FOREACH(t, UNIT(s)->meta.names, i) {
+        SET_FOREACH(t, s->meta.names, i) {
                 char *k;
                 Unit *p;
 
@@ -1031,7 +1031,7 @@ static int service_get_sockets(Service *s, Set **_set) {
                         goto fail;
                 }
 
-                p = manager_get_unit(UNIT(s)->meta.manager, k);
+                p = manager_get_unit(s->meta.manager, k);
                 free(k);
 
                 if (!p)
@@ -1138,13 +1138,13 @@ static void service_set_state(Service *s, ServiceState state) {
             state != SERVICE_STOP_POST &&
             state != SERVICE_FINAL_SIGTERM &&
             state != SERVICE_FINAL_SIGKILL &&
-            !(state == SERVICE_DEAD && UNIT(s)->meta.job)) {
+            !(state == SERVICE_DEAD && s->meta.job)) {
                 service_close_socket_fd(s);
                 service_connection_unref(s);
         }
 
         if (old_state != state)
-                log_debug("%s changed %s -> %s", UNIT(s)->meta.id, service_state_to_string(old_state), service_state_to_string(state));
+                log_debug("%s changed %s -> %s", s->meta.id, service_state_to_string(old_state), service_state_to_string(state));
 
         unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state]);
 }
@@ -1351,8 +1351,8 @@ static int service_spawn(
                        env,
                        apply_permissions,
                        apply_chroot,
-                       UNIT(s)->meta.manager->confirm_spawn,
-                       UNIT(s)->meta.cgroup_bondings,
+                       s->meta.manager->confirm_spawn,
+                       s->meta.cgroup_bondings,
                        &pid);
 
         strv_free(argv);
@@ -1416,7 +1416,7 @@ static int cgroup_good(Service *s) {
 
         assert(s);
 
-        if ((r = cgroup_bonding_is_empty_list(UNIT(s)->meta.cgroup_bondings)) < 0)
+        if ((r = cgroup_bonding_is_empty_list(s->meta.cgroup_bondings)) < 0)
                 return r;
 
         return !r;
@@ -1444,7 +1444,7 @@ static void service_enter_dead(Service *s, bool success, bool allow_restart) {
         return;
 
 fail:
-        log_warning("%s failed to run install restart timer: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run install restart timer: %s", s->meta.id, strerror(-r));
         service_enter_dead(s, false, false);
 }
 
@@ -1479,7 +1479,7 @@ static void service_enter_stop_post(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run 'stop-post' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'stop-post' task: %s", s->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
 }
 
@@ -1497,7 +1497,7 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
 
                 if (s->kill_mode == KILL_CONTROL_GROUP) {
 
-                        if ((r = cgroup_bonding_kill_list(UNIT(s)->meta.cgroup_bondings, sig)) < 0) {
+                        if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig)) < 0) {
                                 if (r != -EAGAIN && r != -ESRCH)
                                         goto fail;
                         } else
@@ -1540,7 +1540,7 @@ static void service_enter_signal(Service *s, ServiceState state, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to kill processes: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to kill processes: %s", s->meta.id, strerror(-r));
 
         if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL)
                 service_enter_stop_post(s, false);
@@ -1577,7 +1577,7 @@ static void service_enter_stop(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run 'stop' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'stop' task: %s", s->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_STOP_SIGTERM, false);
 }
 
@@ -1622,7 +1622,7 @@ static void service_enter_start_post(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run 'start-post' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start-post' task: %s", s->meta.id, strerror(-r));
         service_enter_stop(s, false);
 }
 
@@ -1687,7 +1687,7 @@ static void service_enter_start(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run 'start' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start' task: %s", s->meta.id, strerror(-r));
         service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
 }
 
@@ -1717,7 +1717,7 @@ static void service_enter_start_pre(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run 'start-pre' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'start-pre' task: %s", s->meta.id, strerror(-r));
         service_enter_dead(s, false, true);
 }
 
@@ -1727,15 +1727,15 @@ static void service_enter_restart(Service *s) {
 
         service_enter_dead(s, true, false);
 
-        if ((r = manager_add_job(UNIT(s)->meta.manager, JOB_START, UNIT(s), JOB_FAIL, false, NULL)) < 0)
+        if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(s), JOB_FAIL, false, NULL)) < 0)
                 goto fail;
 
-        log_debug("%s scheduled restart job.", UNIT(s)->meta.id);
+        log_debug("%s scheduled restart job.", s->meta.id);
         return;
 
 fail:
 
-        log_warning("%s failed to schedule restart job: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to schedule restart job: %s", s->meta.id, strerror(-r));
         service_enter_dead(s, false, false);
 }
 
@@ -1765,7 +1765,7 @@ static void service_enter_reload(Service *s) {
         return;
 
 fail:
-        log_warning("%s failed to run 'reload' task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run 'reload' task: %s", s->meta.id, strerror(-r));
         service_enter_stop(s, false);
 }
 
@@ -1796,7 +1796,7 @@ static void service_run_next(Service *s, bool success) {
         return;
 
 fail:
-        log_warning("%s failed to run next task: %s", UNIT(s)->meta.id, strerror(-r));
+        log_warning("%s failed to run next task: %s", s->meta.id, strerror(-r));
 
         if (s->state == SERVICE_START_PRE)
                 service_enter_signal(s, SERVICE_FINAL_SIGTERM, false);
@@ -2167,7 +2167,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                                          * executed. */
 
                                         if ((r = service_load_pid_file(s)) < 0)
-                                                log_warning("%s: failed to load PID file %s: %s", UNIT(s)->meta.id, s->pid_file, strerror(-r));
+                                                log_warning("%s: failed to load PID file %s: %s", s->meta.id, s->pid_file, strerror(-r));
                                 }
 
                                 /* Fall through */
@@ -2572,7 +2572,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock) {
          * service for a stream socket and the socket needs to be
          * configured. */
 
-        if (UNIT(s)->meta.load_state != UNIT_LOADED)
+        if (s->meta.load_state != UNIT_LOADED)
                 return -EINVAL;
 
         if (s->socket_fd >= 0)
diff --git a/src/snapshot.c b/src/snapshot.c
index 513bf66..ea3894b 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -40,7 +40,7 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(s)->meta.id,
+                          s->meta.id,
                           snapshot_state_to_string(old_state),
                           snapshot_state_to_string(state));
 
diff --git a/src/socket.c b/src/socket.c
index 751d8aa..ccbe432 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -144,11 +144,11 @@ static bool have_non_accept_socket(Socket *s) {
 static int socket_verify(Socket *s) {
         assert(s);
 
-        if (UNIT(s)->meta.load_state != UNIT_LOADED)
+        if (s->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (!s->ports) {
-                log_error("%s lacks Listen setting. Refusing.", UNIT(s)->meta.id);
+                log_error("%s lacks Listen setting. Refusing.", s->meta.id);
                 return -EINVAL;
         }
 
@@ -699,8 +699,8 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
                        s->meta.manager->environment,
                        true,
                        true,
-                       UNIT(s)->meta.manager->confirm_spawn,
-                       UNIT(s)->meta.cgroup_bondings,
+                       s->meta.manager->confirm_spawn,
+                       s->meta.cgroup_bondings,
                        &pid);
 
         strv_free(argv);
@@ -772,7 +772,7 @@ static void socket_enter_signal(Socket *s, SocketState state, bool success) {
 
                 if (s->kill_mode == KILL_CONTROL_GROUP) {
 
-                        if ((r = cgroup_bonding_kill_list(UNIT(s)->meta.cgroup_bondings, sig)) < 0) {
+                        if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig)) < 0) {
                                 if (r != -EAGAIN && r != -ESRCH)
                                         goto fail;
                         } else
@@ -907,7 +907,7 @@ static void socket_enter_running(Socket *s, int cfd) {
         assert(s);
 
         if (cfd < 0) {
-                if ((r = manager_add_job(UNIT(s)->meta.manager, JOB_START, UNIT(s->service), JOB_REPLACE, true, NULL)) < 0)
+                if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(s->service), JOB_REPLACE, true, NULL)) < 0)
                         goto fail;
 
                 socket_set_state(s, SOCKET_RUNNING);
@@ -924,7 +924,7 @@ static void socket_enter_running(Socket *s, int cfd) {
                 if ((r = instance_from_socket(cfd, s->n_accepted++, &instance)) < 0)
                         goto fail;
 
-                if (!(prefix = unit_name_to_prefix(UNIT(s)->meta.id))) {
+                if (!(prefix = unit_name_to_prefix(s->meta.id))) {
                         free(instance);
                         r = -ENOMEM;
                         goto fail;
@@ -939,7 +939,7 @@ static void socket_enter_running(Socket *s, int cfd) {
                         goto fail;
                 }
 
-                r = manager_load_unit(UNIT(s)->meta.manager, name, NULL, &u);
+                r = manager_load_unit(s->meta.manager, name, NULL, &u);
                 free(name);
 
                 if (r < 0)
diff --git a/src/swap.c b/src/swap.c
index 501a1d9..663c568 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -127,7 +127,7 @@ static int swap_verify(Swap *s) {
         bool b;
         char *e;
 
-        if (UNIT(s)->meta.load_state != UNIT_LOADED)
+        if (s->meta.load_state != UNIT_LOADED)
                   return 0;
 
         if (!(e = unit_name_from_path(s->what, ".swap")))
@@ -137,7 +137,7 @@ static int swap_verify(Swap *s) {
         free(e);
 
         if (!b) {
-                log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", UNIT(s)->meta.id);
+                log_error("%s: Value of \"What\" and unit name do not match, not loading.\n", s->meta.id);
                 return -EINVAL;
         }
 
@@ -320,7 +320,7 @@ static void swap_set_state(Swap *s, SwapState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(s)->meta.id,
+                          s->meta.id,
                           swap_state_to_string(old_state),
                           swap_state_to_string(state));
 
diff --git a/src/target.c b/src/target.c
index d3f3748..fba9956 100644
--- a/src/target.c
+++ b/src/target.c
@@ -43,7 +43,7 @@ static void target_set_state(Target *t, TargetState state) {
 
         if (state != old_state)
                 log_debug("%s changed %s -> %s",
-                          UNIT(t)->meta.id,
+                          t->meta.id,
                           target_state_to_string(old_state),
                           target_state_to_string(state));
 
diff --git a/src/timer.c b/src/timer.c
index 7bf2d10..ead8ab9 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -60,7 +60,7 @@ static void timer_done(Unit *u) {
 static int timer_verify(Timer *t) {
         assert(t);
 
-        if (UNIT(t)->meta.load_state != UNIT_LOADED)
+        if (t->meta.load_state != UNIT_LOADED)
                 return 0;
 
         if (!t->values) {
@@ -258,7 +258,7 @@ static void timer_enter_running(Timer *t) {
         int r;
         assert(t);
 
-        if ((r = manager_add_job(UNIT(t)->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, NULL)) < 0)
+        if ((r = manager_add_job(t->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, NULL)) < 0)
                 goto fail;
 
         timer_set_state(t, TIMER_RUNNING);
commit bb00e604097fba830af1dc078d78aff278dfcd37
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jun 19 04:35:52 2010 +0200

    don't use 'long long' unless we have a really good reason to

diff --git a/fixme b/fixme
index a366ea8..9152a25 100644
--- a/fixme
+++ b/fixme
@@ -18,8 +18,6 @@
 
 * "disabled" load state?
 
-* uid are 32bit
-
 * %m in printf() instead of strerror();
 
 * gc: don't reap broken services
diff --git a/src/execute.c b/src/execute.c
index 28baeed..d5bb8d3 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -1213,7 +1213,7 @@ int exec_spawn(ExecCommand *command,
                 }
 
                 if (n_fds > 0)
-                        if (asprintf(our_env + n_env++, "LISTEN_PID=%llu", (unsigned long long) getpid()) < 0 ||
+                        if (asprintf(our_env + n_env++, "LISTEN_PID=%lu", (unsigned long) getpid()) < 0 ||
                             asprintf(our_env + n_env++, "LISTEN_FDS=%u", n_fds) < 0) {
                                 r = EXIT_MEMORY;
                                 goto fail;
@@ -1270,7 +1270,7 @@ int exec_spawn(ExecCommand *command,
         if (cgroup_bondings)
                 cgroup_bonding_install_list(cgroup_bondings, pid);
 
-        log_debug("Forked %s as %llu", command->path, (unsigned long long) pid);
+        log_debug("Forked %s as %lu", command->path, (unsigned long) pid);
 
         command->exec_status.pid = pid;
         command->exec_status.start_timestamp = now(CLOCK_REALTIME);
@@ -1572,8 +1572,8 @@ void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
                 return;
 
         fprintf(f,
-                "%sPID: %llu\n",
-                prefix, (unsigned long long) s->pid);
+                "%sPID: %lu\n",
+                prefix, (unsigned long) s->pid);
 
         if (s->start_timestamp > 0)
                 fprintf(f,
diff --git a/src/initctl.c b/src/initctl.c
index fef4500..def621d 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -339,7 +339,7 @@ int main(int argc, char *argv[]) {
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
-        log_info("systemd-initctl running as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-initctl running as pid %lu", (unsigned long) getpid());
 
         if ((n = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
@@ -387,7 +387,7 @@ fail:
 
         server_done(&server);
 
-        log_info("systemd-initctl stopped as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-initctl stopped as pid %lu", (unsigned long) getpid());
 
         dbus_shutdown();
 
diff --git a/src/log.c b/src/log.c
index 4f9f2da..4840185 100644
--- a/src/log.c
+++ b/src/log.c
@@ -265,7 +265,7 @@ static int write_to_syslog(
         if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
                 return -EINVAL;
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) getpid());
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
         char_array_0(header_pid);
 
         zero(iovec);
@@ -301,7 +301,7 @@ static int write_to_kmsg(
         snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_PRI(level));
         char_array_0(header_priority);
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) getpid());
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
         char_array_0(header_pid);
 
         zero(iovec);
diff --git a/src/logger.c b/src/logger.c
index de4dfad..66f6f8c 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -143,7 +143,7 @@ static int stream_log(Stream *s, char *p, usec_t ts) {
                         return -EINVAL;
         }
 
-        snprintf(header_pid, sizeof(header_pid), "[%llu]: ", (unsigned long long) s->pid);
+        snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) s->pid);
         char_array_0(header_pid);
 
         zero(iovec);
@@ -538,7 +538,7 @@ int main(int argc, char *argv[]) {
         log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
         log_parse_environment();
 
-        log_info("systemd-logger running as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-logger running as pid %lu", (unsigned long) getpid());
 
         if ((n = sd_listen_fds(true)) < 0) {
                 log_error("Failed to read listening file descriptors from environment: %s", strerror(-r));
@@ -586,7 +586,7 @@ fail:
 
         server_done(&server);
 
-        log_info("systemd-logger stopped as pid %llu", (unsigned long long) getpid());
+        log_info("systemd-logger stopped as pid %lu", (unsigned long) getpid());
 
         return r;
 }
diff --git a/src/main.c b/src/main.c
index f00d43a..db2a767 100644
--- a/src/main.c
+++ b/src/main.c
@@ -116,7 +116,7 @@ _noreturn_ static void crash(int sig) {
                         else if (!WCOREDUMP(status))
                                 log_error("Caught <%s>, core dump failed.", strsignal(sig));
                         else
-                                log_error("Caught <%s>, dumped core as pid %llu.", strsignal(sig), (unsigned long long) pid);
+                                log_error("Caught <%s>, dumped core as pid %lu.", strsignal(sig), (unsigned long) pid);
                 }
         }
 
@@ -152,7 +152,7 @@ _noreturn_ static void crash(int sig) {
                         _exit(1);
                 }
 
-                log_info("Successfully spawned crash shall as pid %llu.", (unsigned long long) pid);
+                log_info("Successfully spawned crash shall as pid %lu.", (unsigned long) pid);
         }
 
         log_info("Freezing execution.");
diff --git a/src/manager.c b/src/manager.c
index e211eca..da42d7d 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1701,7 +1701,7 @@ static int manager_dispatch_sigchld(Manager *m) {
                         char *name = NULL;
 
                         get_process_name(si.si_pid, &name);
-                        log_debug("Got SIGCHLD for process %llu (%s)", (unsigned long long) si.si_pid, strna(name));
+                        log_debug("Got SIGCHLD for process %lu (%s)", (unsigned long) si.si_pid, strna(name));
                         free(name);
                 }
 
@@ -1727,8 +1727,8 @@ static int manager_dispatch_sigchld(Manager *m) {
                 if (si.si_code != CLD_EXITED && si.si_code != CLD_KILLED && si.si_code != CLD_DUMPED)
                         continue;
 
-                log_debug("Child %llu died (code=%s, status=%i/%s)",
-                          (long long unsigned) si.si_pid,
+                log_debug("Child %lu died (code=%s, status=%i/%s)",
+                          (long unsigned) si.si_pid,
                           sigchld_code_to_string(si.si_code),
                           si.si_status,
                           strna(si.si_code == CLD_EXITED ? exit_status_to_string(si.si_status) : strsignal(si.si_status)));
diff --git a/src/mount.c b/src/mount.c
index 5c16f86..b49c64a 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -505,8 +505,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (m->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) m->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) m->control_pid);
 
         exec_context_dump(&m->exec_context, f, prefix);
 }
diff --git a/src/service.c b/src/service.c
index 4375cb5..9873201 100644
--- a/src/service.c
+++ b/src/service.c
@@ -904,13 +904,13 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) s->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) s->control_pid);
 
         if (s->main_pid > 0)
                 fprintf(f,
-                        "%sMain PID: %llu\n",
-                        prefix, (unsigned long long) s->main_pid);
+                        "%sMain PID: %lu\n",
+                        prefix, (unsigned long) s->main_pid);
 
         if (s->pid_file)
                 fprintf(f,
diff --git a/src/socket.c b/src/socket.c
index fdb6f66..751d8aa 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -313,8 +313,8 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
 
         if (s->control_pid > 0)
                 fprintf(f,
-                        "%sControl PID: %llu\n",
-                        prefix, (unsigned long long) s->control_pid);
+                        "%sControl PID: %lu\n",
+                        prefix, (unsigned long) s->control_pid);
 
         if (s->bind_to_device)
                 fprintf(f,
@@ -447,10 +447,10 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
                         return -errno;
 
                 if (asprintf(&r,
-                             "%u-%llu-%llu",
+                             "%u-%lu-%lu",
                              nr,
-                             (unsigned long long) ucred.pid,
-                             (unsigned long long) ucred.uid) < 0)
+                             (unsigned long) ucred.pid,
+                             (unsigned long) ucred.uid) < 0)
                         return -ENOMEM;
 
                 break;
diff --git a/src/util.c b/src/util.c
index 766aa02..6fa9dec 100644
--- a/src/util.c
+++ b/src/util.c
@@ -446,12 +446,12 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
         int r;
         FILE *f;
         char fn[132], line[256], *p;
-        long long unsigned ppid;
+        long unsigned ppid;
 
         assert(pid >= 0);
         assert(_ppid);
 
-        assert_se(snprintf(fn, sizeof(fn)-1, "/proc/%llu/stat", (unsigned long long) pid) < (int) (sizeof(fn)-1));
+        assert_se(snprintf(fn, sizeof(fn)-1, "/proc/%lu/stat", (unsigned long) pid) < (int) (sizeof(fn)-1));
         fn[sizeof(fn)-1] = 0;
 
         if (!(f = fopen(fn, "r")))
@@ -476,11 +476,11 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 
         if (sscanf(p, " "
                    "%*c "  /* state */
-                   "%llu ", /* ppid */
+                   "%lu ", /* ppid */
                    &ppid) != 1)
                 return -EIO;
 
-        if ((long long unsigned) (pid_t) ppid != ppid)
+        if ((long unsigned) (pid_t) ppid != ppid)
                 return -ERANGE;
 
         *_ppid = (pid_t) ppid;
@@ -552,7 +552,7 @@ int get_process_name(pid_t pid, char **name) {
         assert(pid >= 1);
         assert(name);
 
-        if (asprintf(&p, "/proc/%llu/comm", (unsigned long long) pid) < 0)
+        if (asprintf(&p, "/proc/%lu/comm", (unsigned long) pid) < 0)
                 return -ENOMEM;
 
         r = read_one_line_file(p, name);


More information about the systemd-commits mailing list