Commit Graph
2 Commits
Author SHA1 Message Date
Joachim Wiberg 37cbc12946 tmpfiles: add the C+ entry, copy to a directory that is not empty
A C entry leaves a directory alone when there is something in it.  In
tmpfiles.d(5) a C+ entry copies to it anyway: what the directory lacks
is added, and what it has is not overwritten.

    C+ /etc/skel - - - - /usr/share/factory/etc/skel

tmpfiles reads C+ as C.  Let the + through to copy_tree().

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-21 17:14:04 +01:00
Joachim Wiberg 7b3b217e60 tmpfiles: fix C entries, never copy over what exists
A C entry for a directory does the opposite of tmpfiles.d(5):

    C /etc/pam.d - - - -

When /etc/pam.d does not exist the entry fails with "Not a directory",
the files of the source are copied to a file with the name of the
path, one over the other.  When it is an empty directory nothing is
copied.  When it has files in it, they are overwritten with the ones
from /usr/share/factory, at every boot.  For a file, an existing one
is overwritten as well.

is_dir_empty() returns true for a directory that is not empty, and
rsync() from libite copies over what is there and needs a slash at the
end of a destination directory that is missing.

Copy with a tree walk of our own instead.  It copies to a path that
is missing or an empty directory, overwrites nothing, and does not
follow links.  Mode, owner, and modification time are those of the
source.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-21 17:14:04 +01:00