@@ -48,34 +48,20 @@ resolve_link() {
48
48
chroot_add_resolv_conf () {
49
49
local chrootdir=$1
50
50
local src
51
- local dest
51
+ local dest= " $chrootdir /etc/resolv.conf "
52
52
53
53
src=$( resolve_link /etc/resolv.conf)
54
- dest=$( resolve_link " $chrootdir /etc/resolv.conf" " $chrootdir " )
55
54
56
55
# If we don't have a source resolv.conf file, there's nothing useful we can do.
57
56
[[ -e $src ]] || return 0
58
57
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
76
62
fi
77
63
78
- chroot_add_mount " $src " " $dest " --bind
64
+ chroot_add_mount " $src " " $dest " -c - -bind
79
65
}
80
66
81
67
arch-chroot () {
0 commit comments