From 1ee3d9477ba01dbc3545de8cb321005dd1c7b37f Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Fri, 18 Mar 2022 12:19:02 -0400 Subject: nixos/nixos-enter: fix resolv.conf error handling --- nixos/modules/installer/tools/nixos-enter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules/installer/tools/nixos-enter.sh') diff --git a/nixos/modules/installer/tools/nixos-enter.sh b/nixos/modules/installer/tools/nixos-enter.sh index 115b3d7a7c5..d69b50a8e27 100644 --- a/nixos/modules/installer/tools/nixos-enter.sh +++ b/nixos/modules/installer/tools/nixos-enter.sh @@ -88,7 +88,7 @@ chroot_add_resolv_conf() { mount --bind /etc/resolv.conf "$resolv_conf" } -chroot_add_resolv_conf "$mountPoint" || print "ERROR: failed to set up resolv.conf" +chroot_add_resolv_conf "$mountPoint" || echo "$0: failed to set up resolv.conf" >&2 ( # If silent, write both stdout and stderr of activation script to /dev/null -- cgit 1.4.1 From 69cff425e6654786fdacbdc495a4f560fcdc7c61 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Fri, 18 Mar 2022 12:19:09 -0400 Subject: nixos/nixos-enter: cleanup resolv.conf handling --- nixos/modules/installer/tools/nixos-enter.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'nixos/modules/installer/tools/nixos-enter.sh') diff --git a/nixos/modules/installer/tools/nixos-enter.sh b/nixos/modules/installer/tools/nixos-enter.sh index d69b50a8e27..89beeee7cf9 100644 --- a/nixos/modules/installer/tools/nixos-enter.sh +++ b/nixos/modules/installer/tools/nixos-enter.sh @@ -63,29 +63,29 @@ mount --rbind /sys "$mountPoint/sys" # modified from https://github.com/archlinux/arch-install-scripts/blob/bb04ab435a5a89cd5e5ee821783477bc80db797f/arch-chroot.in#L26-L52 chroot_add_resolv_conf() { - local chrootdir=$1 resolv_conf=$1/etc/resolv.conf + local chrootDir="$1" resolvConf="$1/etc/resolv.conf" [[ -e /etc/resolv.conf ]] || return 0 # Handle resolv.conf as a symlink to somewhere else. - if [[ -L $chrootdir/etc/resolv.conf ]]; then + if [[ -L "$resolvConf" ]]; then # readlink(1) should always give us *something* since we know at this point # it's a symlink. For simplicity, ignore the case of nested symlinks. - # We also ignore the possibility if `../`s escaping the root. - resolv_conf=$(readlink "$chrootdir/etc/resolv.conf") - if [[ $resolv_conf = /* ]]; then - resolv_conf=$chrootdir$resolv_conf + # We also ignore the possibility of `../`s escaping the root. + resolvConf="$(readlink "$resolvConf")" + if [[ "$resolvConf" = /* ]]; then + resolvConf="$chrootDir$resolvConf" else - resolv_conf=$chrootdir/etc/$resolv_conf + resolvConf="$chrootDir/etc/$resolvConf" fi fi # ensure file exists to bind mount over - if [[ ! -f $resolv_conf ]]; then - install -Dm644 /dev/null "$resolv_conf" || return 1 + if [[ ! -f "$resolvConf" ]]; then + install -Dm644 /dev/null "$resolvConf" || return 1 fi - mount --bind /etc/resolv.conf "$resolv_conf" + mount --bind /etc/resolv.conf "$resolvConf" } chroot_add_resolv_conf "$mountPoint" || echo "$0: failed to set up resolv.conf" >&2 -- cgit 1.4.1