mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 15:39:42 +00:00
🐛 Prevent deletion of system critical paths
This commit is contained in:
27
install.sh
27
install.sh
@@ -398,8 +398,34 @@ uninstall_mole() {
|
|||||||
log_success "Removed mo alias from $INSTALL_DIR"
|
log_success "Removed mo alias from $INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# SAFETY CHECK: Verify config directory is safe to remove
|
||||||
|
# Only allow removal of mole-specific directories
|
||||||
|
local is_safe=0
|
||||||
|
|
||||||
|
# Safe patterns: must end with 'mole' or be in user's home .config
|
||||||
|
if [[ "$CONFIG_DIR" == "$HOME/.config/mole" ]] ||
|
||||||
|
[[ "$CONFIG_DIR" == "$HOME"/.*/mole ]] ||
|
||||||
|
[[ "$CONFIG_DIR" == */mole ]]; then
|
||||||
|
is_safe=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Additional safety: never delete system critical paths
|
||||||
|
case "$CONFIG_DIR" in
|
||||||
|
/|/usr|/usr/local|/usr/local/bin|/usr/local/lib|/usr/local/share|\
|
||||||
|
/Library|/System|/bin|/sbin|/etc|/var|/opt|"$HOME"|"$HOME/Library")
|
||||||
|
is_safe=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Ask before removing config directory
|
# Ask before removing config directory
|
||||||
if [[ -d "$CONFIG_DIR" ]]; then
|
if [[ -d "$CONFIG_DIR" ]]; then
|
||||||
|
if [[ $is_safe -eq 0 ]]; then
|
||||||
|
log_warning "Config directory $CONFIG_DIR is not safe to auto-remove"
|
||||||
|
log_warning "Skipping automatic removal for safety"
|
||||||
|
echo ""
|
||||||
|
echo "Please manually review and remove mole-specific files from:"
|
||||||
|
echo " $CONFIG_DIR"
|
||||||
|
else
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Remove configuration directory $CONFIG_DIR? (y/N): " -n 1 -r
|
read -p "Remove configuration directory $CONFIG_DIR? (y/N): " -n 1 -r
|
||||||
echo
|
echo
|
||||||
@@ -410,6 +436,7 @@ uninstall_mole() {
|
|||||||
log_info "Configuration directory preserved"
|
log_info "Configuration directory preserved"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log_success "Mole uninstalled successfully"
|
log_success "Mole uninstalled successfully"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user