download_mirror.sh needs sudo to run some commands

If download_mirror.sh is not run by root or under sudo,
and if -n was omitted, then chown and some rm commands
performed internally by download_mirror.sh will need sudo.

The non-root user would need to be permitted to use those
commands in sudoers.

Partial-Bug: 1884944
Change-Id: I93d4569bae23a5601dc2a37f03b1f1dde0fcc6a5
Signed-off-by: Scott Little <scott.little@windriver.com>
(cherry picked from commit 29d71c1559)
Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
This commit is contained in:
Davlet Panech 2020-07-06 23:01:02 +00:00
parent 8214da3727
commit dd9bb4313c
1 changed files with 13 additions and 5 deletions

View File

@ -68,6 +68,8 @@ other_downloads="./other_downloads.lst"
# Overall success
success=1
SUDO=sudo
# Permitted values of dl_source
dl_from_stx_mirror="stx_mirror"
dl_from_upstream="upstream"
@ -109,6 +111,7 @@ while getopts "c:nghsSuU" o; do
n)
# Pass -n ("no-sudo") to rpm downloader
rpm_downloader_extra_args="${rpm_downloader_extra_args} -n"
SUDO=""
;;
c)
# Pass -c ("use alternate yum.conf") to rpm downloader
@ -182,7 +185,7 @@ if [ ${use_system_yum_conf} -ne 0 ]; then
REPO_SOURCE_DIR=/localdisk/yum.repos.d
REPO_DIR=/etc/yum.repos.d
if [ -d $REPO_SOURCE_DIR ] && [ -d $REPO_DIR ]; then
\cp -f $REPO_SOURCE_DIR/*.repo $REPO_DIR/
${SUDO} \cp -f $REPO_SOURCE_DIR/*.repo $REPO_DIR/
fi
fi
@ -272,9 +275,11 @@ fi
if [ ${use_system_yum_conf} -eq 1 ]; then
# deleting the StarlingX_3rd to avoid pull centos packages from the 3rd Repo.
\rm -f $REPO_DIR/StarlingX_3rd*.repo
${SUDO} \rm -f $REPO_DIR/StarlingX_3rd*.repo
${SUDO} \rm -f $REPO_DIR/StarlingX_cengn*.repo
if [ "$TEMP_DIR" != "" ]; then
\rm -f $TEMP_DIR/yum.repos.d/StarlingX_3rd*.repo
${SUDO} \rm -f $TEMP_DIR/yum.repos.d/StarlingX_3rd*.repo
${SUDO} \rm -f $TEMP_DIR/yum.repos.d/StarlingX_cengn*.repo
fi
fi
@ -362,7 +367,9 @@ fi
if [ $change_group_ids -eq 1 ]; then
# change "./output" and sub-folders to 751 (cgcs) group
chown 751:751 -R ./output
NEW_UID=$(id -u)
NEW_GID=751
${SUDO} chown ${NEW_UID}:${NEW_GID} -R ./output
fi
@ -402,7 +409,8 @@ fi
# Clean up the mktemp directory, if required.
#
if [ "$TEMP_DIR" != "" ]; then
\rm -rf "$TEMP_DIR"
echo "${SUDO} rm -rf $TEMP_DIR"
${SUDO} \rm -rf "$TEMP_DIR"
fi
echo "IMPORTANT: The following 3 files are just bootstrap versions. Based"