Skip to content

Commit 4076842

Browse files
committed
Fixes for multiple users being specified and turning off setfacl for fuse.osx
1 parent ed5ad46 commit 4076842

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

ubuntu/16.04/usr/local/share/bootstrap/common_functions.sh

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,30 @@ is_hem_project() {
136136
return "$?"
137137
}
138138

139+
get_filesystem_for_work_directory() (
140+
set +e
141+
grep "$WORK_DIRECTORY" /proc/mounts | awk '{ print $3 }'
142+
)
143+
139144
is_app_mountpoint() {
140-
grep -q -E "/app (nfs|vboxsf|fuse\\.osxfs)" /proc/mounts
145+
local FILESYSTEM=''
146+
FILESYSTEM="$(get_filesystem_for_work_directory)"
147+
echo "$FILESYSTEM" | grep -q -E "(nfs|vboxsf|fuse\\.osxfs)"
141148
return "$?"
142149
}
143150

144151
is_chown_forbidden() {
145152
# Determine if the app directory is an NFS mountpoint, which doesn't allow chowning.
146-
grep -q -E "/app (nfs|vboxsf)" /proc/mounts
153+
local FILESYSTEM=''
154+
FILESYSTEM="$(get_filesystem_for_work_directory)"
155+
echo "$FILESYSTEM" | grep -q -E "(nfs|vboxsf)"
147156
return "$?"
148157
}
149158

150159
is_vboxsf_mountpoint() {
151-
grep -q "/app vboxsf" /proc/mounts
160+
local FILESYSTEM=''
161+
FILESYSTEM="$(get_filesystem_for_work_directory)"
162+
echo "$FILESYSTEM" | grep -q "vboxsf"
152163
return "$?"
153164
}
154165

@@ -255,18 +266,44 @@ function canonical_port() {
255266
echo "$PORT"
256267
}
257268

269+
function has_acl() {
270+
local FILESYSTEM=''
271+
FILESYSTEM="$(get_filesystem_for_work_directory)"
272+
case "$FILESYSTEM" in
273+
fuse.osx)
274+
return 1
275+
;;
276+
*)
277+
return 0
278+
;;
279+
esac
280+
}
281+
282+
function permission_mode() {
283+
if [ "$IS_CHOWN_FORBIDDEN" == "true" ]; then
284+
echo "chmod"
285+
elif has_acl; then
286+
echo "facl"
287+
else
288+
echo "stickybit"
289+
fi
290+
}
291+
258292
function set_path_permissions() {
259293
local -r READABLE_USERS=($1)
260294
local -r WRITEABLE_USERS=($2)
261295
local -r PATHS=("${@:3}")
262296

263297
case "$PERMISSION_MODE" in
264298
facl)
265-
setfacl -R $(printf -- '-m user:%s:rwX ' "${WRITEABLE_USERS[@]}") \
266-
$(printf -- '-m default:user:%s:rwX ' "${WRITEABLE_USERS[@]}") \
267-
$(printf -- '-m user:%s:rX ' "${READABLE_USERS[@]}") \
268-
$(printf -- '-m default:user:%s:rX ' "${READABLE_USERS[@]}") \
269-
"${PATHS[@]}"
299+
PERMISSIONS=()
300+
for user in "${WRITEABLE_USERS[@]}"; do
301+
PERMISSIONS+=(-m "$(printf -- 'user:%s:rwX' "$user")" -m "$(printf -- 'default:user:%s:rwX' "$user")")
302+
done
303+
for user in "${READABLE_USERS[@]}"; do
304+
PERMISSIONS+=(-m "$(printf -- 'user:%s:rX' "$user")" -m "$(printf -- 'default:user:%s:rX' "$user")")
305+
done
306+
setfacl -R ${PERMISSIONS[@]} "${PATHS[@]}"
270307
chmod -R ug+rw,o-rwx "${PATHS[@]}"
271308
;;
272309
stickybit)
@@ -346,17 +383,3 @@ function do_list_functions() {
346383
function do_shell() {
347384
bash "$@"
348385
}
349-
350-
function has_acl() {
351-
return 0
352-
}
353-
354-
function permission_mode() {
355-
if [ "$IS_CHOWN_FORBIDDEN" == "true" ]; then
356-
echo "chmod"
357-
elif has_acl; then
358-
echo "facl"
359-
else
360-
echo "stickybit"
361-
fi
362-
}

0 commit comments

Comments
 (0)