]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: dump priviliges when processing system coredumps
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Feb 2016 22:35:24 +0000 (23:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Feb 2016 15:09:24 +0000 (16:09 +0100)
Let's add an extra-safety net and change UID/GID to the "systemd-coredump" user when processing coredumps from system
user. For coredumps of normal users we keep the current logic of processing the coredumps from the user id the coredump
was created under.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=87354
Makefile.am
README
configure.ac
src/coredump/coredump.c
sysusers.d/systemd.conf.m4

index 87744d784ca4a0e6956bff159fc4b039764ecb5d..125319fe48768026a14564d83687ed6382e0decd 100644 (file)
@@ -4870,7 +4870,6 @@ nodist_systemunit_DATA += \
 GENERAL_ALIASES += \
        $(systemunitdir)/systemd-timesyncd.service $(pkgsysconfdir)/system/sysinit.target.wants/systemd-timesyncd.service
 
-
 nodist_pkgsysconf_DATA += \
        src/timesync/timesyncd.conf
 
diff --git a/README b/README
index c46ac7e5de146c42d87ba58dab75054329a9b445..0a2c0df47d3a0aa75e0e3d7ebc88d15eb8fffdbb 100644 (file)
--- a/README
+++ b/README
@@ -203,6 +203,9 @@ USERS AND GROUPS:
         Similarly, the kdbus dbus1 proxy daemon requires the
         "systemd-bus-proxy" system user and group to exist.
 
+        Similarly, the coredump support requires the
+        "systemd-coredump" system user and group to exist.
+
 NSS:
         systemd ships with three NSS modules:
 
index 0374b3f39b01c75aa9636996a6a9087d04485187..d05d0ba31f09c104921a6ab5e5bb2133aa8899c7 100644 (file)
@@ -1106,6 +1106,7 @@ have_coredump=no
 AC_ARG_ENABLE(coredump, AS_HELP_STRING([--disable-coredump], [disable coredump hook]))
 if test "x$enable_coredump" != "xno"; then
         have_coredump=yes
+        M4_DEFINES="$M4_DEFINES -DENABLE_COREDUMP"
 fi
 AM_CONDITIONAL(ENABLE_COREDUMP, [test "$have_coredump" = "yes"])
 
index 9e056436ea7ff74070c556fb8b8426e03f7fcbe2..085909c20c20f4b8f84daf10633a09cb921668a9 100644 (file)
@@ -569,9 +569,19 @@ static int change_uid_gid(const char *context[]) {
         if (r < 0)
                 return r;
 
-        r = parse_gid(context[CONTEXT_GID], &gid);
-        if (r < 0)
-                return r;
+        if (uid <= SYSTEM_UID_MAX) {
+                const char *user = "systemd-coredump";
+
+                r = get_user_creds(&user, &uid, &gid, NULL, NULL);
+                if (r < 0) {
+                        log_warning_errno(r, "Cannot resolve %s user. Proceeding to dump core as root: %m", user);
+                        uid = gid = 0;
+                }
+        } else {
+                r = parse_gid(context[CONTEXT_GID], &gid);
+                if (r < 0)
+                        return r;
+        }
 
         return drop_privileges(uid, gid, 0);
 }
index 81b1d79c374a01d1238b1945086adff85f430ae4..317240a9fdd76abe2fd66a7b81b7d59f5ee2ba3f 100644 (file)
@@ -16,3 +16,6 @@ u systemd-resolve   - "systemd Resolver"
 m4_ifdef(`ENABLE_TIMESYNCD',
 u systemd-timesync  - "systemd Time Synchronization"
 )m4_dnl
+m4_ifdef(`ENABLE_COREDUMP',
+u systemd-coredump  - "systemd Core Dumper"
+)m4_dnl