mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
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>
This commit is contained in:
4 files changed
+13
-3
No files matched your search
@@ -43,6 +43,8 @@ All relevant changes are documented in this file.
|
||||
- tmpfiles: an `x` or `X` entry with an age now has what it keeps cleaned
|
||||
by that age, as in `x /tmp/build 30d` below a `/tmp` cleaned after ten
|
||||
days. Before the age was not read
|
||||
- tmpfiles: add the `C+` entry, which also copies to a directory that has
|
||||
something in it. What is missing is added, nothing is overwritten
|
||||
- tmpfiles: add `--prefix=PATH`, to only run the entries for paths below
|
||||
it. `--prefix` and `--exclude-prefix` match whole path components,
|
||||
`--exclude-prefix=/dev` no longer skips `/devices`
|
||||
|
||||
@@ -11,7 +11,6 @@ files or common packages already rely on, last what few will miss.
|
||||
1. Remaining types and modifiers
|
||||
--------------------------------
|
||||
|
||||
* `C+`, which is read as `C`
|
||||
* `z` and `Z` only set the SELinux label when `restorecon` is installed
|
||||
* Modifier `=` (remove what is of another type). `-` (do not fail) has
|
||||
nothing to do, tmpfiles never exits with an error for an entry, and
|
||||
|
||||
+1
-1
@@ -1917,7 +1917,7 @@ static void tmpfiles(char *line)
|
||||
if (lstat(arg, &ast))
|
||||
break;
|
||||
|
||||
rc = copy_tree(arg, &ast, path, 0);
|
||||
rc = copy_tree(arg, &ast, path, plus);
|
||||
if (!rc && !lstat(path, &st) && !S_ISLNK(st.st_mode) && !((st.st_mode ^ ast.st_mode) & S_IFMT) &&
|
||||
perm_path(path, &perm, strc, O_PATH))
|
||||
warn("Failed setting mode/owner on %s", path);
|
||||
|
||||
+10
-1
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Verify the C entry of tmpfiles, copy a file or a tree
|
||||
# Verify the C and C+ entries of tmpfiles, copy a file or a tree
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
@@ -25,11 +25,13 @@ test_teardown()
|
||||
run "mkdir -p $SRC/sub $DIR/empty $DIR/full/sub $DIR/merge/sub"
|
||||
run "echo new > $SRC/file; echo new > $SRC/sub/file; echo new > $SRC/sub/other; ln -s file $SRC/link; chmod 640 $SRC/file"
|
||||
run "echo old > $DIR/full/file; echo old > $DIR/merge/sub/file; echo old > $DIR/one-old"
|
||||
run "mkdir $SRC/away $DIR/out; echo new > $SRC/away/file; ln -s ../out $DIR/merge/away"
|
||||
|
||||
run "cat > $CONF" <<CONF
|
||||
C $DIR/tree - - - - $SRC
|
||||
C $DIR/empty - - - - $SRC
|
||||
C $DIR/full - - - - $SRC
|
||||
C+ $DIR/merge - - - - $SRC
|
||||
C $DIR/one 0600 - - - $SRC/file
|
||||
C $DIR/one-old - - - - $SRC/file
|
||||
C $DIR/missing - - - - /no/such/path
|
||||
@@ -48,6 +50,13 @@ assert "Empty directory" "$(content $DIR/empty/sub/file)" = "new"
|
||||
assert "Existing file" "$(content $DIR/full/file)" = "old"
|
||||
assert "Nothing added" "$(content $DIR/full/sub/file)" = "none"
|
||||
|
||||
sep
|
||||
say 'C+ adds what is missing and overwrites nothing'
|
||||
assert "Existing file" "$(content $DIR/merge/sub/file)" = "old"
|
||||
assert "Missing file" "$(content $DIR/merge/sub/other)" = "new"
|
||||
assert "Missing at top" "$(content $DIR/merge/file)" = "new"
|
||||
assert "Not through a link" "$(content $DIR/out/file)" = "none"
|
||||
|
||||
sep
|
||||
say 'C copies a file, unless it is there'
|
||||
assert "New file" "$(content $DIR/one)" = "new"
|
||||
|
||||
Reference in new issue
Block a user