commit 092c4a08d5736df64b5a4e8b89e9fb3a2d7265c0
parent be905ef9eeb17304b0701fbb1d7943bc02580c22
Author: torter <koubbamohamedrayan@gmail.com>
Date: Thu, 26 Nov 2026 18:46:29 +0000
secure defaults: a default-deny firewall (nftables, like pf's block in) and umask 077, on both editions; the installer turns the firewall on at boot
Diffstat:
5 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/files/etc/nftables.nft b/files/etc/nftables.nft
@@ -0,0 +1,22 @@
+#!/usr/sbin/nft -f
+# the firewall. nothing comes in that you did not ask for; everything goes out. drop it to open a box up,
+# or add your own "tcp dport 22 accept" lines to the input chain to let something in.
+flush ruleset
+
+table inet filter {
+ chain input {
+ type filter hook input priority 0; policy drop;
+ ct state established,related accept
+ ct state invalid drop
+ iif lo accept
+ ip protocol icmp accept
+ ip6 nexthdr icmpv6 accept
+ udp sport 67 udp dport 68 accept # a dhcp client's answers
+ }
+ chain forward {
+ type filter hook forward priority 0; policy drop;
+ }
+ chain output {
+ type filter hook output priority 0; policy accept;
+ }
+}
diff --git a/files/etc/profile.d/00-umask.sh b/files/etc/profile.d/00-umask.sh
@@ -0,0 +1,2 @@
+# new files are yours alone until you open them up
+umask 077
diff --git a/pkg/chamesle-base-glibc32/files/etc/init.d/nftables b/pkg/chamesle-base-glibc32/files/etc/init.d/nftables
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+# arch32's nftables ships only a systemd unit; this loads /etc/nftables.nft at boot
+description="the firewall"
+depend() {
+ before net
+ after sysctl
+}
+start() {
+ ebegin "Loading the firewall"
+ nft -f /etc/nftables.nft
+ eend $?
+}
+stop() {
+ ebegin "Flushing the firewall"
+ nft flush ruleset
+ eend $?
+}
diff --git a/tools/chamesle-install b/tools/chamesle-install
@@ -156,6 +156,7 @@ step() { echo "==> $1" >> $log; d --infobox "$1" 3 60; }
for g in wheel video input audio netdev; do arch-chroot /mnt addgroup "$user" $g >> $log 2>&1; done
fi
step "Turning on the services"
+ arch-chroot /mnt rc-update add nftables boot >> $log 2>&1 # the firewall, before the network comes up
case $wifi in
iwd) arch-chroot /mnt rc-update add iwd default >> $log 2>&1;;
networkmanager)
diff --git a/tools/mkpkgs b/tools/mkpkgs
@@ -64,7 +64,7 @@ if [ "$LIBC" = glibc ]; then
gconf=chamesle-base-glibc32
# no pacman: it hard-pulls systemd on arch32, and mag is the package manager and runs the alpm hooks itself.
# the keyring packages pull pacman too, so the base bakes the arch32 and arch keyrings in (below) instead.
- gdeps="filesystem glibc bash coreutils util-linux shadow procps-ng iproute2 iputils findutils grep sed gawk tar gzip xz bzip2 file pciutils psmisc licenses dracut kmod opendoas dhcpcd e2fsprogs dosfstools curl mag rifle openrc"
+ gdeps="filesystem glibc bash coreutils util-linux shadow procps-ng iproute2 iputils findutils grep sed gawk tar gzip xz bzip2 file pciutils psmisc licenses dracut kmod opendoas dhcpcd nftables e2fsprogs dosfstools curl mag rifle openrc"
else
gconf=chamesle-base-glibc
gdeps="base openrc elogind-openrc mkinitcpio dhcpcd dhcpcd-openrc opendoas arch-install-scripts artix-keyring archlinux-keyring e2fsprogs dosfstools curl mag rifle"
@@ -72,6 +72,10 @@ if [ "$LIBC" = glibc ]; then
b=$tmp/base
common "$b"
[ -d "$here/pkg/$gconf/files" ] && cp -R "$here/pkg/$gconf/files/." "$b/"
+ # the secure defaults the musl base gets from its files overlay: the firewall and the umask (sysctl is below)
+ mkdir -p "$b/etc/profile.d"
+ cp "$here/files/etc/nftables.nft" "$b/etc/"
+ cp "$here/files/etc/profile.d/00-umask.sh" "$b/etc/profile.d/"
if [ "$arch" = x86 ]; then
# the running system verifies arch32 packages with these, baked in since the keyring packages pull pacman
mkdir -p "$b/usr/share/pacman/keyrings"
@@ -96,7 +100,7 @@ fi
mkdir -p "$tmp/init"
mkapk -n chamesle-init -v 1 -d "moves a base from before r20 over to OpenRC" -s "$here/pkg/chamesle-init" "$tmp/init"
-deps="alpine-baselayout busybox busybox-binsh busybox-suid doas mksh agetty bash mount umount findmnt util-linux-misc chamesle-init openrc busybox-openrc eudev eudev-openrc udev-init-scripts udev-init-scripts-openrc dhcpcd-openrc kmod dhcpcd e2fsprogs dosfstools curl mag"
+deps="alpine-baselayout busybox busybox-binsh busybox-suid doas mksh agetty bash mount umount findmnt util-linux-misc chamesle-init openrc busybox-openrc eudev eudev-openrc udev-init-scripts udev-init-scripts-openrc dhcpcd-openrc kmod dhcpcd nftables nftables-openrc e2fsprogs dosfstools curl mag"
if [ -n "$RIFLE" ]; then
mkdir -p "$tmp/rifle/usr/bin"
install -m755 "$RIFLE" "$tmp/rifle/usr/bin/rifle"