]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: ignore ENOENT when file is removed during setting parmission and friends
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 10 Mar 2025 22:01:16 +0000 (07:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Mar 2025 09:52:28 +0000 (18:52 +0900)
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.

src/tmpfiles/tmpfiles.c

index 5cb73b63602719c20b74f6676b0c1b86c441e76d..24bffab034d35c2b764a1584411382545d89b3c2 100644 (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;