From: Yu Watanabe Date: Mon, 10 Mar 2025 22:01:16 +0000 (+0900) Subject: tmpfiles: ignore ENOENT when file is removed during setting parmission and friends X-Git-Tag: v258-rc1~1120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8790a875e19b6fe7db0fa7899655a6f053aa718;p=thirdparty%2Fsystemd.git tmpfiles: ignore ENOENT when file is removed during setting parmission and friends After a file matches with a glob pattern, the file may be removed or renamed before opening it. Let's ignore the error in such case. Fixes #30938. --- diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 5cb73b63602..24bffab034d 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1117,7 +1117,9 @@ static int path_open_safe(const char *path) { if (r == -ENOLINK) return r; /* Unsafe symlink: already covered by CHASE_WARN */ if (r < 0) - return log_error_errno(r, "Failed to open path %s: %m", path); + return log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_ERR, r, + "Failed to open path %s%s: %m", path, + r == -ENOENT ? ", ignoring" : ""); return fd; } @@ -1135,6 +1137,8 @@ static int path_set_perms( assert(path); fd = path_open_safe(path); + if (fd == -ENOENT) + return 0; if (fd < 0) return fd; @@ -1219,6 +1223,8 @@ static int path_set_xattrs( assert(path); fd = path_open_safe(path); + if (fd == -ENOENT) + return 0; if (fd < 0) return fd; @@ -1502,6 +1508,8 @@ static int path_set_acls( assert(path); fd = path_open_safe(path); + if (fd == -ENOENT) + return 0; if (fd < 0) return fd; @@ -1673,6 +1681,8 @@ static int path_set_attribute( return 0; fd = path_open_safe(path); + if (fd == -ENOENT) + return 0; if (fd < 0) return fd;