Adjust: Lock the deb file before the install begin to secure

This commit is contained in:
shenmo 2024-07-16 14:32:46 +08:00
parent 249b0c7a02
commit 38d592d7e3

View File

@ -83,7 +83,13 @@ function hash_check() {
IS_SHA512SUM_CHECKED=$(cat "$PACKAGES_DATA_PATH" | grep "$DEB_SHA512SUM")
}
function lock_file(){
chattr +i "$1"
}
function unlock_file(){
chattr -i "$1"
}
####################################
@ -121,6 +127,7 @@ if [ ! -f "$1" ]; then
DEBPATH=$(realpath "$1")
fi
lock_file "$DEBPATH"
hash_check "$DEBPATH"
@ -158,6 +165,8 @@ if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then
dpkg -i "$DEBPATH" || aptss install -yf
unlock_file "$DEBPATH"
if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then
if dpkg -s "$package_name" >/dev/null 2>&1; then
echo "软件包已安装:$package_name"