Skip to content

Commit 2249315

Browse files
committed
Merge remote-tracking branch 'origin/pull/57'
* origin/pull/57: arch-chroot: bind mount over a /etc/resolv.conf symlink
2 parents efad4f1 + 4d3aec6 commit 2249315

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tasks when installing [Arch Linux](https://www.archlinux.org).
66
## Requirements
77

88
* GNU coreutils (>= v8.15)
9-
* util-linux (>= 2.23)
9+
* util-linux (>= 2.39)
1010
* POSIX awk
1111
* bash (>= 4.1)
1212
* asciidoc (for generating man pages)

arch-chroot.in

+6-20
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,20 @@ resolve_link() {
4848
chroot_add_resolv_conf() {
4949
local chrootdir=$1
5050
local src
51-
local dest
51+
local dest="$chrootdir/etc/resolv.conf"
5252

5353
src=$(resolve_link /etc/resolv.conf)
54-
dest=$(resolve_link "$chrootdir/etc/resolv.conf" "$chrootdir")
5554

5655
# If we don't have a source resolv.conf file, there's nothing useful we can do.
5756
[[ -e $src ]] || return 0
5857

59-
if [[ ! -e $dest ]]; then
60-
# There are two reasons the destination might not exist:
61-
#
62-
# 1. There may be no resolv.conf in the chroot. In this case, $dest won't exist,
63-
# and it will be equal to $1/etc/resolv.conf. In this case, we'll just exit.
64-
# The chroot environment must not be concerned with DNS resolution.
65-
#
66-
# 2. $1/etc/resolv.conf is (or resolves to) a broken link. The environment
67-
# clearly intends to handle DNS resolution, but something's wrong. Maybe it
68-
# normally creates the target at boot time. We'll (try to) take care of it by
69-
# creating a dummy file at the target, so that we have something to bind to.
70-
71-
# Case 1.
72-
[[ $dest = $chrootdir/etc/resolv.conf ]] && return 0
73-
74-
# Case 2.
75-
install -Dm644 /dev/null "$dest" || return 1
58+
if [[ ! -e "$dest" && ! -h "$dest" ]]; then
59+
# There may be no resolv.conf in the chroot. In this case, we'll just exit.
60+
# The chroot environment must not be concerned with DNS resolution.
61+
return 0
7662
fi
7763

78-
chroot_add_mount "$src" "$dest" --bind
64+
chroot_add_mount "$src" "$dest" -c --bind
7965
}
8066

8167
arch-chroot() {

0 commit comments

Comments
 (0)