]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Improve tmpfiles unsafe transition log message (#20048)
authorAlbert Brox <albert@exypno.tech>
Wed, 30 Jun 2021 09:54:15 +0000 (05:54 -0400)
committerGitHub <noreply@github.com>
Wed, 30 Jun 2021 09:54:15 +0000 (11:54 +0200)
src/basic/fs-util.c

index 1cfd17008230cd675bde57f0ede3a789e5cb9fe9..8f0834fe46c2cad2f2001042425d542fe548a1f5 100644 (file)
@@ -742,7 +742,8 @@ bool unsafe_transition(const struct stat *a, const struct stat *b) {
 }
 
 static int log_unsafe_transition(int a, int b, const char *path, unsigned flags) {
-        _cleanup_free_ char *n1 = NULL, *n2 = NULL;
+        _cleanup_free_ char *n1 = NULL, *n2 = NULL, *user_a = NULL, *user_b = NULL;
+        struct stat st;
 
         if (!FLAGS_SET(flags, CHASE_WARN))
                 return -ENOLINK;
@@ -750,9 +751,14 @@ static int log_unsafe_transition(int a, int b, const char *path, unsigned flags)
         (void) fd_get_path(a, &n1);
         (void) fd_get_path(b, &n2);
 
+        if (fstat(a, &st) == 0)
+                user_a = uid_to_name(st.st_uid);
+        if (fstat(b, &st) == 0)
+                user_b = uid_to_name(st.st_uid);
+
         return log_warning_errno(SYNTHETIC_ERRNO(ENOLINK),
-                                 "Detected unsafe path transition %s %s %s during canonicalization of %s.",
-                                 strna(n1), special_glyph(SPECIAL_GLYPH_ARROW), strna(n2), path);
+                                 "Detected unsafe path transition %s (owned by %s) %s %s (owned by %s) during canonicalization of %s.",
+                                 strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW), strna(n2), strna(user_b), path);
 }
 
 static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {