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.
This commit is contained in:
Yu Watanabe
2025-03-11 18:52:28 +09:00
parent a0d8484eeb
commit b8790a875e
+11 -1
View File
@@ -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;