Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lib_install): Disable file system translation in checkinstall during dependency installation (fixes #642). #644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions components/core/tools/scripts/lib_install/fmtlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Get number of cpu cores
Expand Down Expand Up @@ -74,11 +74,22 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} make install
install_cmd_args+=(
make install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
21 changes: 16 additions & 5 deletions components/core/tools/scripts/lib_install/libarchive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Get number of cpu cores
Expand Down Expand Up @@ -74,11 +74,22 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} make install
install_cmd_args+=(
make install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
21 changes: 16 additions & 5 deletions components/core/tools/scripts/lib_install/lz4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Get number of cpu cores
Expand Down Expand Up @@ -71,11 +71,22 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} make install
install_cmd_args+=(
make install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
24 changes: 19 additions & 5 deletions components/core/tools/scripts/lib_install/mariadb-connector-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
privileged_command_prefix="sudo"
install_cmd_args+=(${privileged_command_prefix})
Comment on lines +40 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor privilege handling for consistency

The privilege handling needs improvement:

  1. The script still uses privileged_command_prefix variable in multiple places (e.g., lines 78 and 102) after switching to install_cmd_args
  2. There's a potential word splitting vulnerability when adding sudo to the array

Apply these changes:

 install_cmd_args=()
 if [ ${EUID:-$(id -u)} -ne 0 ] ; then
   sudo echo "Script can elevate privileges."
-  privileged_command_prefix="sudo"
-  install_cmd_args+=(${privileged_command_prefix})
+  install_cmd_args+=("sudo")

Then replace remaining ${privileged_command_prefix} usages with "${install_cmd_args[@]}".

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 44-44: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.

(SC2206)

fi

# Get OS version
Expand Down Expand Up @@ -77,11 +78,24 @@ set -e
install_dir=/usr/local
${privileged_command_prefix} mkdir -p ${install_dir}

install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} rsync -a . ${install_dir}/
install_cmd_args+=(
rsync
-a .
"${install_dir}/"
)
"${install_cmd_args[@]}"

# Update ld cache
${privileged_command_prefix} ldconfig ${install_dir}/lib/mariadb
Expand Down
5 changes: 3 additions & 2 deletions components/core/tools/scripts/lib_install/mongocxx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ set -e
if [ $checkinstall_installed -eq 0 ] ; then
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--nodoc
-y
--pakdir "${deb_output_dir}"
)
fi
Expand Down
23 changes: 18 additions & 5 deletions components/core/tools/scripts/lib_install/msgpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Download
Expand All @@ -66,11 +66,24 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} cmake --build . --target install
install_cmd_args+=(
cmake
--build .
--target install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
22 changes: 16 additions & 6 deletions components/core/tools/scripts/lib_install/spdlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Get number of cpu cores
Expand Down Expand Up @@ -81,12 +81,22 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
# NOTE: We use "1:${version}" to override the version installed by Ubuntu 18.04
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '1:${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} make install
install_cmd_args+=(
make install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
21 changes: 16 additions & 5 deletions components/core/tools/scripts/lib_install/zstandard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ if [ $installed -eq 0 ] ; then
fi

echo "Checking for elevated privileges..."
privileged_command_prefix=""
install_cmd_args=()
if [ ${EUID:-$(id -u)} -ne 0 ] ; then
sudo echo "Script can elevate privileges."
privileged_command_prefix="${privileged_command_prefix} sudo"
install_cmd_args+=("sudo")
fi

# Get number of cpu cores
Expand Down Expand Up @@ -74,11 +74,22 @@ checkinstall_installed=$?
set -e

# Install
install_command_prefix="${privileged_command_prefix}"
if [ $checkinstall_installed -eq 0 ] ; then
install_command_prefix="${install_command_prefix} checkinstall --pkgname '${package_name}' --pkgversion '${version}' --provides '${package_name}' --nodoc -y --pakdir \"${deb_output_dir}\""
install_cmd_args+=(
checkinstall
--default
--fstrans=no
--nodoc
--pkgname "${package_name}"
--pkgversion "${version}"
--provides "${package_name}"
--pakdir "${deb_output_dir}"
)
fi
${install_command_prefix} make install
install_cmd_args+=(
make install
)
"${install_cmd_args[@]}"

# Clean up
rm -rf $temp_dir
Loading