aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-init-shared19
1 files changed, 16 insertions, 3 deletions
diff --git a/git-init-shared b/git-init-shared
index ea18234..c06f418 100755
--- a/git-init-shared
+++ b/git-init-shared
@@ -7,16 +7,29 @@ usage() {
exit 1
}
+acl_mask() {
+ # Set the ACL mask for the directory. The default mask will be inherited by
+ # new directories and files (where it will correctly be set to rw-)
+ setfacl -m "d:m:rwx" "$1"
+ setfacl -m "m:rwx" "$1"
+}
+
add_to_acl() {
- setfacl -m "d:u:$2:rwx" "$1"
- setfacl -m "u:$2:rwx" "$1"
+ # Recursively apply all necessary ACL settings as we may be reinitializing
+ # the git repository with additional authorised users.
+ # Take care *not* to recalculate the ACL mask (-n), since rwX translates to
+ # a mask of rwx even on non-directory files.
+ setfacl -Rnm "d:u:$2:rwX" "$1"
+ setfacl -Rnm "u:$2:rwX" "$1"
}
test $# -ge 1 || usage
dir=$1
shift
-mkdir "$dir"
+mkdir -p "$dir"
+
+acl_mask "$dir"
for user in "$(id -un)" "$@"; do
add_to_acl "$dir" "$user"