feat core: Run extension-provided scripts under webserver user.

Co-authored-by: itsvic-dev <contact@itsvic.dev>
This commit is contained in:
purple 2024-05-06 16:43:16 +02:00
parent 40a6992ccb
commit 4c75887dcc

View file

@ -11,6 +11,7 @@
# This stores the webserver ownership user which Blueprint uses when applying webserver permissions. # This stores the webserver ownership user which Blueprint uses when applying webserver permissions.
OWNERSHIP="www-data:www-data" #; OWNERSHIP="www-data:www-data" #;
WEBUSER="www-data" #;
# If the version below does not match your downloaded version, please let us know. # If the version below does not match your downloaded version, please let us know.
VERSION="beta-CB38" VERSION="beta-CB38"
@ -1382,14 +1383,15 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) || ( $2 == "-add" ) ]]; then VCMD="
chmod --silent +x ".blueprint/extensions/$identifier/private/install.sh" 2>> $BLUEPRINT__DEBUG chmod --silent +x ".blueprint/extensions/$identifier/private/install.sh" 2>> $BLUEPRINT__DEBUG
# Run script while also parsing some useful variables for the install script to use. # Run script while also parsing some useful variables for the install script to use.
EXTENSION_IDENTIFIER="$identifier" \ su "$WEBUSER" -c "
EXTENSION_TARGET="$target" \ EXTENSION_IDENTIFIER=\"$identifier\" \
EXTENSION_VERSION="$version" \ EXTENSION_TARGET=\"$target\" \
PTERODACTYL_DIRECTORY="$FOLDER" \ EXTENSION_VERSION=\"$version\" \
BLUEPRINT_VERSION="$VERSION" \ PTERODACTYL_DIRECTORY=\"$FOLDER\" \
BLUEPRINT_DEVELOPER="$dev" \ BLUEPRINT_VERSION=\"$VERSION\" \
bash ".blueprint/extensions/$identifier/private/install.sh" BLUEPRINT_DEVELOPER=\"$dev\" \
bash .blueprint/extensions/$identifier/private/install.sh
"
echo -e "\e[0m\x1b[0m\033[0m" echo -e "\e[0m\x1b[0m\033[0m"
fi fi
fi fi
@ -1479,12 +1481,14 @@ if [[ ( $2 == "-r" ) || ( $2 == "-remove" ) ]]; then VCMD="y"
chmod +x ".blueprint/extensions/$identifier/private/remove.sh" chmod +x ".blueprint/extensions/$identifier/private/remove.sh"
# Run script while also parsing some useful variables for the uninstall script to use. # Run script while also parsing some useful variables for the uninstall script to use.
EXTENSION_IDENTIFIER="$identifier" \ su "$WEBUSER" -c "
EXTENSION_TARGET="$target" \ EXTENSION_IDENTIFIER=\"$identifier\" \
EXTENSION_VERSION="$version" \ EXTENSION_TARGET=\"$target\" \
PTERODACTYL_DIRECTORY="$FOLDER" \ EXTENSION_VERSION=\"$version\" \
BLUEPRINT_VERSION="$VERSION" \ PTERODACTYL_DIRECTORY=\"$FOLDER\" \
bash ".blueprint/extensions/$identifier/private/remove.sh" BLUEPRINT_VERSION=\"$VERSION\" \
bash .blueprint/extensions/$identifier/private/remove.sh
"
echo -e "\e[0m\x1b[0m\033[0m" echo -e "\e[0m\x1b[0m\033[0m"
fi fi
@ -1977,14 +1981,15 @@ if [[ ( $2 == "-export" || $2 == "-e" ) ]]; then VCMD="y"
chmod +x "${conf_data_directory}""/export.sh" chmod +x "${conf_data_directory}""/export.sh"
# Run script while also parsing some useful variables for the export script to use. # Run script while also parsing some useful variables for the export script to use.
EXTENSION_IDENTIFIER="$conf_info_identifier" \ su "$WEBUSER" -c "
EXTENSION_TARGET="$conf_info_target" \ EXTENSION_IDENTIFIER=\"$conf_info_identifier\" \
EXTENSION_VERSION="$conf_info_version" \ EXTENSION_TARGET=\"$conf_info_target\" \
PTERODACTYL_DIRECTORY="$FOLDER" \ EXTENSION_VERSION=\"$conf_info_version\" \
BLUEPRINT_EXPORT_DIRECTORY="$FOLDER/.blueprint/tmp" \ PTERODACTYL_DIRECTORY=\"$FOLDER\" \
BLUEPRINT_VERSION="$VERSION" \ BLUEPRINT_EXPORT_DIRECTORY=\"$FOLDER/.blueprint/tmp\" \
bash "${conf_data_directory}""/export.sh" BLUEPRINT_VERSION=\"$VERSION\" \
bash \"${conf_data_directory}\"/private/export.sh
"
echo -e "\e[0m\x1b[0m\033[0m" echo -e "\e[0m\x1b[0m\033[0m"
fi fi
@ -2164,8 +2169,11 @@ if [[ $2 == "-upgrade" ]]; then VCMD="y"
&>> /dev/null # cannot forward to debug dir because it does not exist &>> /dev/null # cannot forward to debug dir because it does not exist
chmod +x blueprint.sh chmod +x blueprint.sh
sed -i -E "s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\"$FOLDER\" #;|g" $FOLDER/blueprint.sh sed -i -E \
sed -i -E "s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\"$OWNERSHIP\" #;|g" $FOLDER/blueprint.sh -e "s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\"$FOLDER\" #;|g" \
-e "s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\"$OWNERSHIP\" #;|g" \
-e "s|WEBUSER=\"www-data\" #;|WEBUSER=\"$WEBUSER\" #;|g" \
$FOLDER/blueprint.sh
mv $FOLDER/blueprint $FOLDER/.blueprint; mv $FOLDER/blueprint $FOLDER/.blueprint;
bash blueprint.sh --post-upgrade bash blueprint.sh --post-upgrade