summaryrefslogtreecommitdiff
path: root/pre-commit.d
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-27 14:31:47 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-27 14:31:47 -0500
commit82b8b65128ee45da3cc284623fa6e250509e8adc (patch)
tree50d3a354752613210e1ec71215e652e0d1c03130 /pre-commit.d
parent6325e8bad3997a5860911b8ccb6b57065c0b5ed3 (diff)
Make .etckeeper test that files actually exist before acting on them. Closes: #509888
Diffstat (limited to 'pre-commit.d')
-rwxr-xr-xpre-commit.d/30store-metadata15
1 files changed, 9 insertions, 6 deletions
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 243e019..5d3496c 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -18,6 +18,9 @@ generate_metadata() {
# This function generates the script commands to fix any files
# that aren't owner=root, group=root, or mode=0644 or 0755.
# The script is produced on stdout. Errors go to stderr.
+ #
+ # The script can use a 'maybe' function, which only runs a command
+ # if the file in its last argument exists.
# We maintain the permissions on the directory containing VCS data
# but we want find to ignore the VCS files themselves.
@@ -35,20 +38,20 @@ generate_metadata() {
fi
# Find all files and directories that don't have root as the owner
- find $NOVCS \! -user root -exec stat --format="chown %U '{}'" {} \; \
- | sort | filter_unknown chown owner
+ find $NOVCS \! -user root -exec stat --format="maybe chown %U '{}'" {} \; \
+ | sort | filter_unknown maybe chown owner
# Find all files and directories that don't have root as the group
- find $NOVCS \! -group root -exec stat --format="chgrp %G '{}'" {} \; \
- | sort | filter_unknown chgrp group
+ find $NOVCS \! -group root -exec stat --format="maybe chgrp %G '{}'" {} \; \
+ | sort | filter_unknown maybe chgrp group
# Find all directories that aren't 0755
find $NOVCS -type d \! -perm 0755 \
- -exec stat --format="chmod %a '{}'" {} \; | sort
+ -exec stat --format="maybe chmod %a '{}'" {} \; | sort
# Find all files that aren't 0644 or 0755 (we can assume the VCS will
# maintain the executable bit).
find $NOVCS -type f \! -perm 0644 \! -perm 0755 \
- -exec stat --format="chmod %a '{}'" {} \; | sort
+ -exec stat --format="maybe chmod %a '{}'" {} \; | sort
# We don't handle xattrs.
# Maybe check for getfattr/setfattr and use them if they're available?