diff --git a/doc/tmpfiles-todo.md b/doc/tmpfiles-todo.md index 93ba5a83..8d8fab3a 100644 --- a/doc/tmpfiles-todo.md +++ b/doc/tmpfiles-todo.md @@ -33,8 +33,6 @@ Missing options: `--root`, `--replace`, `--dry-run`, `--purge`, in `/etc` should run before `50-y.conf` in `/usr/lib` * `a` and `A` handle an ACL of at most 32 entries, a path with more is left as it is, with a warning -* A `d` or `e` entry for a path that is a link to a directory warns - that mode and owner could not be set * An `x` or `X` entry with an age should have what it names cleaned by that age, the age is not read * The `%T` and `%V` specifiers are always `/tmp` and `/var/tmp`, they diff --git a/src/tmpfiles.c b/src/tmpfiles.c index edb92aef..9b098153 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -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; diff --git a/test/tmpfiles-perm.sh b/test/tmpfiles-perm.sh index a93f5378..2cd37100 100755 --- a/test/tmpfiles-perm.sh +++ b/test/tmpfiles-perm.sh @@ -120,3 +120,11 @@ sep say 'A new file without a mode is 0644, whatever the umask' run "echo 'f $DIR/default' > $CONF; umask 077; /libexec/finit/tmpfiles --create $CONF" assert "Default mode" "$(texec stat -c '%a' $DIR/default)" = "644" + +sep +say 'A link to a directory is left alone, without complaints' +run "mkdir $DIR/real; chmod 700 $DIR/real; ln -s real $DIR/link" +run "printf 'd $DIR/link 0755\ne $DIR/link 0755\n' > $CONF" +msg=$(texec sh -c "/libexec/finit/tmpfiles --create $CONF 2>&1") +assert "No warning" "$msg" = "" +assert "Directory as it was" "$(texec stat -c '%a' $DIR/real)" = "700"