1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-12 09:17:44 +03:00

Improve tmpfiles unsafe transition log message (#20048)

This commit is contained in:
Albert Brox 2021-06-30 05:54:15 -04:00 committed by GitHub
parent 9fcfc0470d
commit f1bda7ead2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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) {