Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/secure-network-symlink-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"secure-network": patch
---

Fix intermittent DNS failures on GitHub-hosted runners caused by /etc/resolv.conf being a symlink to a tmpfs file managed by systemd-resolved. chattr +i is a no-op on tmpfs, so systemd-resolved could overwrite the file after setup. The symlink is now removed before writing, creating a real file on /etc (ext4) that chattr can lock.
15 changes: 15 additions & 0 deletions actions/secure-network/secure-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,21 @@ async function main() {
}

console.log("Redirecting DNS to local Unbound resolver...");
// On Ubuntu with systemd-resolved, /etc/resolv.conf is a symlink to
// /run/systemd/resolve/stub-resolv.conf on tmpfs. Writing through the symlink
// lets systemd-resolved silently overwrite our change, and chattr +i is a
// no-op on tmpfs (unsupported filesystem). Remove any existing symlink/file
// first so we create a real file on /etc (ext4), where chattr can lock it.
try {
if (fs.lstatSync("/etc/resolv.conf").isSymbolicLink()) {
fs.unlinkSync("/etc/resolv.conf");
console.log(
" Removed /etc/resolv.conf symlink (was managed by systemd-resolved).",
);
}
} catch (_) {
/* not a symlink or doesn't exist — proceed */
}
Comment on lines +561 to +563
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this catch feels a little over-general -- if we want the "doesn't exist" case, we could fo fs.existsSync(path) && fs.lstatSync(path).isSymbolicLink()

fs.writeFileSync("/etc/resolv.conf", "nameserver 127.0.0.1\n");
// resolv.conf.bak is kept until process exit; the exit handler restores it on error.

Expand Down
Loading