Skip to content

Commit a50ff29

Browse files
committed
Reset registry storage permissions for mirrored data
1 parent 1b01ba3 commit a50ff29

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/bin/mirror_registry.sh

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,27 @@ QUAY_CONFIG_DIR="${MIRROR_REGISTRY_DIR}/config"
1313
PULL_SECRET=${PULL_SECRET:-${HOME}/.pull-secret.json}
1414
QUAY_PULL_SECRET="${QUAY_CONFIG_DIR}/pull_secret.json"
1515

16+
reset_storage_permissions() {
17+
# Ensure that permissions are open for the current user on the mirror registry
18+
# directories and files
19+
if [ -d "${MIRROR_REGISTRY_DIR}" ] ; then
20+
sudo chgrp -R "$(id -gn)" "${MIRROR_REGISTRY_DIR}"
21+
sudo find "${MIRROR_REGISTRY_DIR}" -type d -exec chmod a+rx '{}' +
22+
sudo find "${MIRROR_REGISTRY_DIR}" -type f -exec chmod a+r '{}' +
23+
fi
24+
}
25+
1626
setup_prereqs() {
1727
# Install packages if not yet available locally
1828
if ! rpm -q podman skopeo jq &>/dev/null ; then
1929
"${SCRIPTDIR}/../../scripts/dnf_retry.sh" "install" "podman skopeo jq"
2030
fi
2131

22-
# Create registry repository base directory structure
32+
# Create registry repository base directory structure and reset permissions
33+
# if downloaded from cache
2334
mkdir -p "${MIRROR_REGISTRY_DIR}"
2435
mkdir -p "${QUAY_CONFIG_DIR}"
36+
reset_storage_permissions
2537

2638
# Create a new pull secret file containing authentication information for both
2739
# remote (from PULL_SECRET environment) and local registries
@@ -268,11 +280,7 @@ EOF
268280
}
269281

270282
finalize_registry() {
271-
# Ensure that permissions are open for the current user on the mirror registry
272-
# directories and files. This is necessary to avoid 'find' command errors.
273-
sudo chgrp -R "$(id -gn)" "${MIRROR_REGISTRY_DIR}"
274-
sudo find "${MIRROR_REGISTRY_DIR}" -type d -exec chmod a+rx '{}' +
275-
sudo find "${MIRROR_REGISTRY_DIR}" -type f -exec chmod a+r '{}' +
283+
reset_storage_permissions
276284
# Delete the combined pull secret file
277285
rm -f "${QUAY_PULL_SECRET}"
278286
}

0 commit comments

Comments
 (0)