Files
debianito-post-install/modules/extras/system/software_centers.sh
T
stornic56 9828ea439c Security Patches & Architecture Refactoring
- Extracted hardware detection logic from firmware.sh into new modules/hw_detect.sh. Declares shared arrays (PCI_NET_DEVS, USB_WIFI_DEVS, etc) and _detect_all_network_devices() function. The main script now sources hw_detect.sh immediately after utils.sh. firmware.sh retains only _DETECTED_FW_PKGS and _FW_PLAN_PKG_LINES plus installation logic — the detection loop is fully removed, eliminating the circular dependency with bluetooth.sh.
- Fixed interrupt safety in main script: removed pkill -f "apt.*install" and pkill -f "dpkg.*configure" from _on_interrupt(); updated exit message to "Temp files cleaned." Only the signal handler (trap _on_interrupt INT TERM) remains.
- Added strict URL validation to modules/gaming/heroic.sh and modules/gaming/tools.sh using regex ^https://[A-Za-z0-9./_-]+\.deb$ before passing $deb_url to _run_cmd. Blocks command substitution, non-https URLs, and path traversal attempts that could bypass shell quoting.
- Implemented real Bullseye Archive rewrite in modules/bullseye/legacy.sh: adds idempotency check (grep -q archive.debian.org && return 0), creates timestamped backup of /etc/apt/sources.list with sudo cp, writes exact archive Debian sources via sudo tee heredoc, and runs sudo apt-get update || true on failure.
- Added local scope to modules/bluetooth.sh variable service_enable_only=false before the conditional assignment, preventing state bleed from the previous global-only declaration.
- Applied safe array pattern (while IFS= read -r _pkg; do ...) across 32+ files in modules/extras/* and modules/bullseye/legacy.sh, replacing all vulnerable for pkg in $cleaned / for pkg in $install_list loops. Eliminates word-splitting and command-injection risks.
2026-10-03 00:04:30 -05:00

106 lines
4.9 KiB
Bash

# software_centers.sh — Standalone Software Center + Flatpak installer
_cat_software_centers() {
local headless=false
_is_headless && headless=true
if $headless; then
echo "Software centers require a GUI — skipping."
return
fi
local de_type
de_type=$(_detect_desktop_type)
local -a items=()
local gs_state; gs_state=$(_state "gnome-software")
local pd_state; pd_state=$(_state "plasma-discover")
local sy_state; sy_state=$(_state "synaptic")
local fp_state; fp_state=$(_state "flatpak")
items+=(
"gnome-software" "Software Center for GNOME" "$gs_state"
"plasma-discover" "Software manager for Plasma" "$pd_state"
"synaptic" "Classic APT package manager (GTK)" "$sy_state"
"flatpak" "Flatpak sandbox + Flathub" "$fp_state"
)
local item_count=${#items[@]}
local lista_alto=$((item_count > TUI_ALTO_LISTA ? TUI_ALTO_LISTA : item_count))
local choices
choices=$(_checklist "Software Center & Flatpak" \
"Check [*] the packages you want installed.\n" \
$TUI_ALTO $TUI_ANCHO $lista_alto "${items[@]}")
clear
[ -z "$choices" ] && return
local cleaned; cleaned=$(echo "$choices" | tr -d '"')
# BH-004: Convert to array to avoid word splitting and injection.
local -a _pkgs=()
while IFS= read -r _pkg; do
[ -n "$_pkg" ] && _pkgs+=("$_pkg")
done < <(echo "$cleaned" | tr ' ' '\n')
for pkg in "${_pkgs[@]}"; do
case $pkg in
gnome-software)
if [ "$de_type" = "qt" ]; then
_msg "Warning" "Warning: This store requires extra background libraries \
and may look visually inconsistent with your current desktop environment."
! _confirm "Continue?" "Install anyway?" && continue
fi
_run_cmd "Install" "sudo apt install -y gnome-software" "Installing GNOME Software..."
echo -e "${GREEN}gnome-software installed.${NC}"
;;
plasma-discover)
if [ "$de_type" = "gtk" ]; then
_msg "Warning" "Warning: This store requires extra background libraries \
and may look visually inconsistent with your current desktop environment."
! _confirm "Continue?" "Install anyway?" && continue
fi
_run_cmd "Install" "sudo apt install -y plasma-discover" "Installing Plasma Discover..."
echo -e "${GREEN}plasma-discover installed.${NC}"
;;
synaptic)
_run_cmd "Install" "sudo apt install -y synaptic" "Installing synaptic..."
echo -e "${GREEN}synaptic installed.${NC}"
;;
flatpak)
if ! is_installed "flatpak"; then
_run_cmd "Flatpak" "sudo apt install -y flatpak" "Installing Flatpak..."
else
echo "Flatpak already installed."
fi
flatpak remote-add --if-not-exists flathub \
https://dl.flathub.org/repo/flathub.flatpakrepo
echo "Flathub repository added."
if command -v plasma-discover &>/dev/null; then
if ! is_installed "plasma-discover-backend-flatpak" 2>/dev/null; then
if _confirm "Discover Backend" "Install Flatpak backend for Plasma Discover?"; then
_run_cmd "Backend" "sudo apt install -y plasma-discover-backend-flatpak" "Installing Flatpak backend..."
fi
fi
elif command -v gnome-software &>/dev/null; then
if ! is_installed "gnome-software-plugin-flatpak" 2>/dev/null; then
if _confirm "GNOME Plugin" "Install Flatpak plugin for GNOME Software?"; then
_run_cmd "Plugin" "sudo apt install -y gnome-software-plugin-flatpak" "Installing Flatpak plugin..."
fi
fi
else
if [ "$de_type" = "qt" ]; then
if _confirm "Software Center" "Install Plasma Discover for Flatpak management?"; then
_run_cmd "Discover" "sudo apt install -y plasma-discover plasma-discover-backend-flatpak" "Installing Discover..."
fi
else
if _confirm "Software Center" "Install GNOME Software for Flatpak management?"; then
_run_cmd "GNOME Software" "sudo apt install -y gnome-software gnome-software-plugin-flatpak" "Installing GNOME Software..."
fi
fi
fi
echo -e "${GREEN}A reboot is recommended.${NC}"
;;
esac
done
echo -e "${GREEN}Software center & Flatpak setup complete.${NC}"
}