tmpfiles: no warning for a d entry on a link to a directory

A d entry for a path that is a link to a directory warned that mode
and owner could not be set:

    d /var/lock 0755

Here /var/lock is a link to /run/lock.  The link is not followed, on
purpose, and the open fails.

That is not an error, leave the directory alone without a warning.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 19:10:03 +01:00
1 parent 7ee991daf2
commit a27c0d40f3
3 files changed
+11 -3

No files matched your search

+3 -1
View File
@@ -1603,7 +1603,9 @@ static void tmpfiles(char *line)
mkparent(path, 0755);
omask = umask(0);
rc = makedir(path, perm.mode ?: 0755);
if (!rc && perm_path(path, &perm, strc, O_RDONLY | O_DIRECTORY))
/* A link to a directory is not followed, and nothing to warn about */
if (!rc && perm_path(path, &perm, strc, O_RDONLY | O_DIRECTORY) &&
!(errno == ENOTDIR && !lstat(path, &ast) && S_ISLNK(ast.st_mode)))
warn("Failed setting mode/owner on %s", path);
umask(omask);
break;