summaryrefslogtreecommitdiff
path: root/pre-commit.d/30store-metadata
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-11-25 12:07:37 -0400
committerJoey Hess <joey@kitenet.net>2011-11-25 12:07:37 -0400
commit618123e77322ea002cde9b80cce269b1960b574d (patch)
tree4b4d892bca00ff208854540ad436cfff53da97d4 /pre-commit.d/30store-metadata
parent4112f3f7426cf4a647d7fb034b70f7e912235e20 (diff)
store all permissions of files and directories, even those with standard permissions of 644 and 755
This is unfortunately necessary in order to support etckeeper init on a checkout that was made with a nonstandard umask, in which case the files that were expected to be 644 and 755, won't be. Closes: #649701 Thanks to Дмитрий Матросов for reporting the bug and developing a fixup script (attached to the bug) which could be used if you've already encountered this problem.
Diffstat (limited to 'pre-commit.d/30store-metadata')
-rwxr-xr-xpre-commit.d/30store-metadata21
1 files changed, 6 insertions, 15 deletions
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 2e35e6c..871d5c8 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -37,14 +37,16 @@ statf() {
}
generate_metadata() {
- # This function generates the script commands to fix any files
- # that aren't owner=root, group=root, or mode=0644 or 0755.
+ # This function generates the script commands to fix any file
+ # ownerships that aren't owner=root, group=root, as well as to
+ # store the permissions of all files (all are needed because the
+ # user may have an unusual umask).
# 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
+ # We want files in the directory containing VCS data
# but we want find to ignore the VCS files themselves.
#
# (Note that when using this, the find expression must end with
@@ -77,18 +79,7 @@ generate_metadata() {
# Find all files and directories that don't have root as the group
find $NOVCS \! -group $(id -g) -print | statf "maybe chgrp %G" | sort | filter_unknown 'maybe chgrp' group
- # Find all directories that aren't 0755
- find $NOVCS -type d \! -perm 0755 -print | statf "maybe chmod %a" | sort
-
- if [ "$VCS" = darcs ]; then
- # Find all files that aren't 0644 (darcs doesn't maintain
- # the executable bit).
- find $NOVCS -type f \! -perm 0644 -print | statf "maybe chmod %a" | sort
- else
- # 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 -print | statf "maybe chmod %a" | sort
- fi
+ find $NOVCS -print | statf "maybe chmod %a" | sort
# We don't handle xattrs.
# Maybe check for getfattr/setfattr and use them if they're available?