#!/bin/sh # Copyright (C) 2022-2024 mustard # # Licensed under the Apache License, Version 2.0 (the "License"); you may not # use this file except in compliance with the License. You may obtain a copy of # the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. set -eu -o pipefail unpriv(){ sudo -u nobody "${@}" } dl() { unpriv curl -s --proxy http://127.0.0.1:8082 "${1}" | sudo tee "${2}" > /dev/null } # Compliance sudo systemctl mask debug-shell.service sudo systemctl mask kdump.service # Setting umask to 077 umask 077 sudo sed -i 's/^UMASK.*/UMASK 077/g' /etc/login.defs sudo sed -i 's/^HOME_MODE/#HOME_MODE/g' /etc/login.defs sudo sed -i 's/umask 022/umask 077/g' /etc/bashrc # Make home directory private sudo chmod 700 /home/* # Harden SSH dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/ssh/ssh_config.d/10-custom.conf /etc/ssh/ssh_config.d/10-custom.conf sudo chmod 644 /etc/ssh/ssh_config.d/10-custom.conf # Security kernel settings dl https://raw.githubusercontent.com/secureblue/secureblue/live/files/system/etc/modprobe.d/blacklist.conf /etc/modprobe.d/workstation-blacklist.conf sudo sed -i 's/^install hfsplus \/bin\/false/# install hfsplus \/bin\/false/' /etc/modprobe.d/workstation-blacklist.conf sudo chmod 644 /etc/modprobe.d/workstation-blacklist.conf dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/sysctl.d/99-workstation.conf /etc/sysctl.d/99-workstation.conf sudo chmod 644 /etc/sysctl.d/99-workstation.conf # Dracut doesn't seem to work - need to investigate # dracut -f sudo sysctl -p # Disable coredump dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/security/limits.d/30-disable-coredump.conf /etc/security/limits.d/30-disable-coredump.conf sudo chmod 644 /etc/security/limits.d/30-disable-coredump.conf sudo mkdir -p /etc/systemd/coredump.conf.d sudo chmod 755 /etc/systemd/coredump.conf.d dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/coredump.conf.d/disable.conf /etc/systemd/coredump.conf.d/disable.conf sudo chmod 644 /etc/systemd/coredump.conf.d/disable.conf # Setup dconf umask 022 mkdir -p /etc/dconf/db/local.d/locks dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/automount-disable /etc/dconf/db/local.d/locks/automount-disable dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/locks/privacy /etc/dconf/db/local.d/locks/privacy dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/adw-gtk3-dark /etc/dconf/db/local.d/adw-gtk3-dark dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/automount-disable /etc/dconf/db/local.d/automount-disable dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/prefer-dark /etc/dconf/db/local.d/prefer-dark dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dconf/db/local.d/privacy /etc/dconf/db/local.d/privacy sudo dconf update umask 077 # Setup ZRAM dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/zram-generator.conf /etc/systemd/zram-generator.conf # Flatpak update service dl https://raw.githubusercontent.com/TommyTran732/QubesOS-Scripts/main/etc/systemd/user/update-user-flatpaks.service /etc/systemd/user/update-user-flatpaks.service dl https://raw.githubusercontent.com/TommyTran732/QubesOS-Scripts/main/etc/systemd/user/update-user-flatpaks.timer /etc/systemd/user/update-user-flatpaks.timer # Setup networking # We don't need the usual mac address randomization and stuff here, because this template is not used for sys-net # This breaks saving network settings with the Fedora 40 template rn, so I am commenting it out. #sudo mkdir -p /etc/systemd/system/NetworkManager.service.d #unpriv curl --proxy http://127.0.0.1:8082 https://gitlab.com/divested/brace/-/raw/master/brace/usr/lib/systemd/system/NetworkManager.service.d/99-brace.conf | sudo tee /etc/systemd/system/NetworkManager.service.d/99-brace.conf # Fix GNOME environment variable echo 'XDG_CURRENT_DESKTOP=GNOME' | sudo tee -a /etc/environment # Moving DNF handling to the bottom as the Qubes template just breaks when repos are changed and needs a reboot to fix # Mark packages as manualy installed to avoid removal sudo dnf mark install flatpak gnome-menus qubes-menus # Remove unwanted groups sudo dnf -y group remove 'Container Management' 'Desktop accessibility' 'Guest Desktop Agents' 'LibreOffice' 'Printing Support' # Remove unnecessary stuff from the Qubes template sudo dnf -y remove gnome-software httpd keepassxc thunderbird # Remove firefox packages sudo dnf -y remove fedora-bookmarks fedora-chromium-config # Remove Network + hardware tools packages sudo dnf -y remove avahi cifs* '*cups' dmidecode dnsmasq geolite2* mtr net-snmp-libs net-tools nfs-utils nmap-ncat nmap-ncat opensc openssh-server rsync rygel sgpio tcpdump teamd traceroute usb_modeswitch # Remove support for some languages and spelling sudo dnf -y remove '*anthy*' '*hangul*' ibus-typing-booster '*m17n*' '*pinyin*' '*speech*' texlive-libs words '*zhuyin*' # Remove codec + image + printers sudo dnf -y remove openh264 ImageMagick* sane* simple-scan # Remove Active Directory + Sysadmin + reporting tools sudo dnf -y remove 'sssd*' realmd cyrus-sasl-gssapi quota* dos2unix kpartx sos samba-client gvfs-smb # Remove NetworkManager sudo dnf -y remove NetworkManager-pptp-gnome NetworkManager-ssh-gnome NetworkManager-openconnect-gnome NetworkManager-openvpn-gnome NetworkManager-vpnc-gnome ppp* ModemManager # Remove Gnome apps sudo dnf remove -y baobab chrome-gnome-shell eog gnome-boxes gnome-calculator gnome-calendar gnome-characters gnome-classic* gnome-clocks gnome-color-manager gnome-connections \ gnome-contacts gnome-disk-utility gnome-font-viewer gnome-logs gnome-maps gnome-photos gnome-remote-desktop gnome-screenshot gnome-shell-extension-apps-menu \ gnome-shell-extension-background-logo gnome-shell-extension-launch-new-instance gnome-shell-extension-places-menu gnome-shell-extension-window-list gnome-text-editor \ gnome-themes-extra gnome-tour gnome-user* gnome-weather loupe snapshot totem # Remove apps sudo dnf remove -y abrt* cheese evince file-roller* libreoffice* mediawriter rhythmbox yelp # Remove other packages # We deviate from the script in TommyTran732/Linux-Setup-Scripts here, as removing yajl will break qubes integration. sudo dnf remove -y lvm2 rng-tools thermald '*perl*' # Install custom packages # gnome-shell is needed for theming to work #This seems to be the problematic line? #sudo dnf -y install qubes-ctap qubes-gpg-split adw-gtk3-theme ncurses gnome-console gnome-shell # Setup hardened_malloc sudo https_proxy=127.0.0.1:8082 dnf copr enable secureblue/hardened_malloc -y sudo dnf install -y hardened_malloc echo 'libhardened_malloc.so' | sudo tee /etc/ld.so.preload sudo chmod 644 /etc/ld.so.preload # Setup DNF dl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/dnf/dnf.conf /etc/dnf/dnf.conf sudo sed -i 's/^metalink=.*/&\&protocol=https/g' /etc/yum.repos.d/* # This errors out for some reason # sudo sed -i 's/&protocol=https//g' /etc/yum.repos.d/divested-release.repo sudo dnf config-manager --enable fedora-cisco-openh264 rpmfusion-free rpmfusion-free-updates rpmfusion-nonfree rpmfusion-nonfree-updates sudo dnf upgrade -y sudo dnf install -y yt-dlp sudo dnf install -y android-tools mediawriter gnome-disk-utility # Install brace firefox (arkenfox) config dl https://raw.githubusercontent.com/divestedcg/Brace/refs/heads/master/brace/usr/lib/firefox/browser/defaults/preferences/userjs-arkenfox.js /usr/lib64/firefox/browser/defaults/preferences/userjs-arkenfox.js dl https://raw.githubusercontent.com/divestedcg/Brace/refs/heads/master/brace/usr/lib/firefox/browser/defaults/preferences/userjs-brace.js /usr/lib64/firefox/browser/defaults/preferences/userjs-brace.js # This causes crashes, comment out #dl https://raw.githubusercontent.com/divestedcg/Brace/refs/heads/master/brace/usr/lib/firefox/browser/defaults/preferences/userjs-brace-perf.js /usr/lib64/firefox/browser/defaults/preferences/userjs-brace-perf.js dl https://raw.githubusercontent.com/divestedcg/Brace/refs/heads/master/brace/usr/lib/firefox/distribution/policies.json /usr/lib64/firefox/distribution/policies.json # sudo prompt in dom0, see https://forum.qubes-os.org/t/replacing-passwordless-root-with-a-dom0-prompt/19074/21 sudo authselect create-profile sudo-dom0-prompt --base-on=sssd --symlink-meta --symlink-pam sudo mv /etc/authselect/custom/sudo-dom0-prompt/system-auth /etc/authselect/custom/sudo-dom0-prompt/system-auth.original_aside sudo cp /etc/authselect/system-auth /etc/authselect/custom/sudo-dom0-prompt sudo sed -i '/^auth/d' /etc/authselect/custom/sudo-dom0-prompt/system-auth sudo sed -i '/^account/ i auth [success=1 default=ignore] pam_exec.so seteuid /usr/lib/qubes/qrexec-client-vm dom0 qubes.VMAuth /bin/grep -q ^1$\nauth requisite pam_deny.so\nauth required pam_permit.so' /etc/authselect/custom/sudo-dom0-prompt/system-auth sudo authselect select custom/sudo-dom0-prompt sudo sed -i '/^%qubes/s/.*/user ALL=(ALL) ALL/' /etc/sudoers.d/qubes sudo rm /etc/polkit-1/rules.d/00-qubes-allow-all.rules