Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay/boot-mount-generator: Mount /boot{,efi} read-only,nodev,nosuid #659

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ fi
mk_mount() {
local mount_pt="${1}"; shift
local label="${1}"; shift
local path="/dev/disk/by-label/${label}"
local options="${1}"; shift

local path="/dev/disk/by-label/${label}"
local unit_name=$(systemd-escape -p ${mount_pt} --suffix=mount)

eval $(udevadm info --query property --export "${path}")
Expand All @@ -61,15 +62,20 @@ After=systemd-fsck@${device}.service
[Mount]
What=${path}
Where=${mount_pt}
Options=${options}
EOF

add_wants "${unit_name}"
}


# Don't create mount units for /boot or /boot/efi on live systems.
# Don't create mount units for /boot on live systems.
# ConditionPathExists won't work here because conditions don't affect
# the dependency on the underlying device unit.
if [ ! -f /run/ostree-live ]; then
mk_mount /boot boot
# We mount read-only by default mostly to protect
# against accidental damage. Only a few things
# owned by CoreOS should be touching /boot or the ESP.
# Use nodev,nosuid because some hardening guides want
# that even though it's of minimal value.
mk_mount /boot boot ro,nodev,nosuid
fi
13 changes: 9 additions & 4 deletions tests/kola/misc-ro
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ if ip link | grep -o -e " eth[0-9]:"; then
fi
ok nic naming

if test -w /sysroot; then
fatal "found writable /sysroot"
fi
ok sysroot ro
for part in /sysroot /boot; do
if ! findmnt -n -o options ${part} | grep -q "ro,"; then
fatal "${part} is missing ro option"
fi
if test -w "${part}" || touch "${part}/somefile" 2>/dev/null; then
fatal "${part} is writable"
fi
done
ok read-only partitions

if ! lsattr -d / | grep -qe '--i--'; then
fatal "missing immutable bit on /"
Expand Down