]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/namespace: rename() might return ENOTEMPTY if target dir exists
authorMike Yuan <me@yhndnzj.com>
Wed, 25 Feb 2026 08:26:44 +0000 (09:26 +0100)
committerMike Yuan <me@yhndnzj.com>
Wed, 25 Feb 2026 11:36:45 +0000 (12:36 +0100)
src/core/namespace.c

index d363ac0973aac1ff9e38a9b8f721919847647746..aa80570885e156b16810acb27f702ab793e491ef 100644 (file)
@@ -3338,6 +3338,8 @@ static int make_tmp_prefix(const char *prefix) {
         _cleanup_close_ int fd = -EBADF;
         int r;
 
+        assert(prefix);
+
         /* Don't do anything unless we know the dir is actually missing */
         r = access(prefix, F_OK);
         if (r >= 0)
@@ -3369,7 +3371,7 @@ static int make_tmp_prefix(const char *prefix) {
         r = RET_NERRNO(rename(t, prefix));
         if (r < 0) {
                 (void) rmdir(t);
-                return r == -EEXIST ? 0 : r; /* it's fine if someone else created the dir by now */
+                return IN_SET(r, -EEXIST, -ENOTEMPTY) ? 0 : r; /* it's fine if someone else created the dir by now */
         }
 
         return 0;