From: Albert Brox Date: Wed, 30 Jun 2021 09:54:15 +0000 (-0400) Subject: Improve tmpfiles unsafe transition log message (#20048) X-Git-Tag: v249-rc3~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1bda7ead20c210a28be5decad636e1d95d8c3ec;p=thirdparty%2Fsystemd.git Improve tmpfiles unsafe transition log message (#20048) --- diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 1cfd1700823..8f0834fe46c 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -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) {