-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: changing owner while creating container for download support
Signed-off-by: Viet Nguyen Duc <[email protected]>
- Loading branch information
Showing
7 changed files
with
152 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
_log () { | ||
if [[ "$*" == "ERROR:"* ]] || [[ "$*" == "WARNING:"* ]] || [[ "${CONTAINER_LOGS_QUIET}" == "" ]]; then | ||
echo "$@" | ||
fi | ||
} | ||
|
||
if [ "${SE_DOWNLOAD_DIR}" != "${HOME}/Downloads" ]; then | ||
MKDIR_EXTRA=${SE_DOWNLOAD_DIR}","${MKDIR_EXTRA} | ||
fi | ||
|
||
CHOWN_EXTRA=${MKDIR_EXTRA}","${CHOWN_EXTRA} | ||
|
||
if [ -n "${MKDIR_EXTRA}" ]; then | ||
for extra_dir in $(echo "${MKDIR_EXTRA}" | tr ',' ' '); do | ||
_log "Creating directory ${extra_dir} ${MKDIR_EXTRA_OPTS:+(mkdir options: ${MKDIR_EXTRA_OPTS})}" | ||
# shellcheck disable=SC2086 | ||
mkdir ${MKDIR_EXTRA_OPTS:-"-p"} "${extra_dir}" | ||
done | ||
fi | ||
|
||
if [ -n "${CHOWN_EXTRA}" ]; then | ||
for extra_dir in $(echo "${CHOWN_EXTRA}" | tr ',' ' '); do | ||
_log "Changing ${extra_dir} ownership. Ensure ${extra_dir} is owned by ${SEL_USER} ${CHOWN_EXTRA_OPTS:+(chown options: ${CHOWN_EXTRA_OPTS})}" | ||
fix-permissions "${extra_dir}" | ||
done | ||
fi | ||
|
||
# Raise warning if the user isn't able to write files to extra dirs | ||
if [ -n "${CHOWN_EXTRA}" ]; then | ||
for extra_dir in $(echo "${CHOWN_EXTRA}" | tr ',' ' '); do | ||
if [[ ! -w ${extra_dir} ]]; then | ||
_log "WARNING: no write access to dir ${extra_dir}. Please correct the permissions manually (or run with --user root) once then start again with non-root user." | ||
else | ||
_log "Verified dir ${extra_dir} has write access." | ||
fi | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
#!/bin/bash | ||
set -e | ||
# Run this with USER root only | ||
for d in "$@"; do | ||
find "${d}" \ | ||
! \( \ | ||
-group "${SEL_GID}" \ | ||
-a -perm -g+rwX \ | ||
\) \ | ||
-exec chgrp -R "${SEL_GID}" -- {} \+ \ | ||
-exec chmod -R g+rwX -- {} \+ | ||
# setuid, setgid *on directories only* | ||
find "${d}" \ | ||
\( \ | ||
-type d \ | ||
-a ! -perm -6000 \ | ||
\) \ | ||
-exec chmod -R +6000 -- {} \+ | ||
# Relaxing permissions for OpenShift and other non-sudo environments | ||
chmod -R u+x "${d}" | ||
chgrp -R 0 "${d}" | ||
chmod -R g=u "${d}" | ||
done | ||
|
||
if [ "$(id -u)" == 0 ]; then | ||
# For root user to change ownership | ||
for d in "$@"; do | ||
# Relaxing permissions for OpenShift and other non-sudo environments | ||
chmod -R u+x "${d}" | ||
chgrp -R ${CHGRP_EXTRA:-0} "${d}" | ||
chmod -R g=u "${d}" | ||
find "${d}" \ | ||
! \( \ | ||
-group "${SEL_GID}" \ | ||
-a -perm -g+rwX \ | ||
\) \ | ||
-exec chown -R "${SEL_USER}:${SEL_GID}" -- {} \+ \ | ||
-exec chgrp -R "${SEL_GID}" -- {} \+ \ | ||
-exec chmod -R g+rwX -- {} \+ | ||
# setuid, setgid *on directories only* | ||
find "${d}" \ | ||
\( \ | ||
-type d \ | ||
-a ! -perm -6000 \ | ||
\) \ | ||
-exec chmod -R +6000 -- {} \+ | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters