Skip to content

Commit 7d3f3d0

Browse files
authored
Mount existing /etc/resolv.conf in UserNSRunner if it has nameserver settings (#117)
1 parent 9ca9771 commit 7d3f3d0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/UserNSRunner.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ function UserNSRunner(workspace_root::String;
6262
push!(workspaces, ccache_dir() => "/root/.ccache")
6363
end
6464

65+
# If we are on a system that uses `/etc/resolv.conf` as a resolver
66+
# configuration file (mainly *BSD and Linux), check if a nameserver is
67+
# specified and if yes, mount the existing `/etc/resolv.conf` to make use
68+
# of system-specific nameserver settings
69+
if (Sys.isbsd() || Sys.islinux()) && isfile("/etc/resolv.conf")
70+
if any(startswith(line, "nameserver") for line in eachline("/etc/resolv.conf"))
71+
# We copy the contents of `/etc/resolv.conf` to a temporary file and mount that one,
72+
# such that `/etc/resolv.conf` is editable inside the container
73+
tmppath, tmpio = mktemp()
74+
write(tmpio, read("/etc/resolv.conf", String))
75+
flush(tmpio) # required as otherwise `tmppath` remains empty
76+
push!(workspaces, tmppath => "/etc/resolv.conf")
77+
end
78+
end
79+
6580
if isnothing(shards)
6681
# Choose the shards we're going to mount
6782
shards = choose_shards(platform; extract_kwargs(kwargs, (:preferred_gcc_version,:preferred_llvm_version,:bootstrap_list,:compilers))...)

0 commit comments

Comments
 (0)