Skip to content

Commit bb2ded4

Browse files
committed
Fixes for multiple users being specified and turning off setfacl for fuse.osx
1 parent 453d0d3 commit bb2ded4

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

@@ -237,18 +248,44 @@ function canonical_port() {
237248
echo "$PORT"
238249
}
239250

251+
function has_acl() {
252+
local FILESYSTEM=''
253+
FILESYSTEM="$(get_filesystem_for_work_directory)"
254+
case "$FILESYSTEM" in
255+
fuse.osx)
256+
return 1
257+
;;
258+
*)
259+
return 0
260+
;;
261+
esac
262+
}
263+
264+
function permission_mode() {
265+
if [ "$IS_CHOWN_FORBIDDEN" == "true" ]; then
266+
echo "chmod"
267+
elif has_acl; then
268+
echo "facl"
269+
else
270+
echo "stickybit"
271+
fi
272+
}
273+
240274
function set_path_permissions() {
241275
local -r READABLE_USERS=($1)
242276
local -r WRITEABLE_USERS=($2)
243277
local -r PATHS=("${@:3}")
244278

245279
case "$PERMISSION_MODE" in
246280
facl)
247-
setfacl -R $(printf -- '-m user:%s:rwX ' "${WRITEABLE_USERS[@]}") \
248-
$(printf -- '-m default:user:%s:rwX ' "${WRITEABLE_USERS[@]}") \
249-
$(printf -- '-m user:%s:rX ' "${READABLE_USERS[@]}") \
250-
$(printf -- '-m default:user:%s:rX ' "${READABLE_USERS[@]}") \
251-
"${PATHS[@]}"
281+
PERMISSIONS=()
282+
for user in "${WRITEABLE_USERS[@]}"; do
283+
PERMISSIONS+=(-m "$(printf -- 'user:%s:rwX' "$user")" -m "$(printf -- 'default:user:%s:rwX' "$user")")
284+
done
285+
for user in "${READABLE_USERS[@]}"; do
286+
PERMISSIONS+=(-m "$(printf -- 'user:%s:rX' "$user")" -m "$(printf -- 'default:user:%s:rX' "$user")")
287+
done
288+
setfacl -R ${PERMISSIONS[@]} "${PATHS[@]}"
252289
chmod -R ug+rw,o-rwx "${PATHS[@]}"
253290
;;
254291
stickybit)
@@ -328,17 +365,3 @@ function do_list_functions() {
328365
function do_shell() {
329366
bash "$@"
330367
}
331-
332-
function has_acl() {
333-
return 0
334-
}
335-
336-
function permission_mode() {
337-
if [ "$IS_CHOWN_FORBIDDEN" == "true" ]; then
338-
echo "chmod"
339-
elif has_acl; then
340-
echo "facl"
341-
else
342-
echo "stickybit"
343-
fi
344-
}

0 commit comments

Comments
 (0)