From 7deede64eb7f08522b4b9316c6d6eaab8420af73 Mon Sep 17 00:00:00 2001 From: oddlama Date: Sat, 4 Jan 2020 18:33:41 +0100 Subject: [PATCH] Fixed bug in chroot mount preparation (--rslave not occurring) --- README.md | 2 ++ scripts/functions.sh | 22 +++++++++++++--------- scripts/main.sh | 8 ++++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a33d04e..3420c85 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ What you can get optionally: * LUKS * EFI secure boot * Initramfs (compiled into the kernel for EFIstub) +* Preconfigured sshd +* Ansible (packages, user, ssh) What you will **NOT** get: (i.e. you will have to do it yourself) diff --git a/scripts/functions.sh b/scripts/functions.sh index cfb427c..e22aeb1 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -240,7 +240,7 @@ download_stage3() { || die "Checksum mismatch!" # Create verification file in case the script is restarted - touch_or_die "$CURRENT_STAGE3_VERIFIED" + touch_or_die 0644 "$CURRENT_STAGE3_VERIFIED" fi } @@ -287,16 +287,18 @@ env_update() { || die "Error in env-update" source /etc/profile \ || die "Could not source /etc/profile" + umask 0077 } mkdir_or_die() { - mkdir -p "$1" \ - || die "Could not create directory '$1'" + mkdir -m "$1" -p "$2" \ + || die "Could not create directory '$2'" } touch_or_die() { - touch "$1" \ - || die "Could not touch '$1'" + touch "$2" \ + || die "Could not touch '$2'" + chmod "$1" "$2" } gentoo_chroot() { @@ -321,10 +323,12 @@ gentoo_chroot() { ( mountpoint -q -- "$ROOT_MOUNTPOINT/proc" || mount -t proc /proc "$ROOT_MOUNTPOINT/proc" || exit 1 mountpoint -q -- "$ROOT_MOUNTPOINT/tmp" || mount --rbind /tmp "$ROOT_MOUNTPOINT/tmp" || exit 1 - mountpoint -q -- "$ROOT_MOUNTPOINT/sys" || mount --rbind /sys "$ROOT_MOUNTPOINT/sys" || exit 1 - mountpoint -q -- "$ROOT_MOUNTPOINT/sys" || mount --make-rslave "$ROOT_MOUNTPOINT/sys" || exit 1 - mountpoint -q -- "$ROOT_MOUNTPOINT/dev" || mount --rbind /dev "$ROOT_MOUNTPOINT/dev" || exit 1 - mountpoint -q -- "$ROOT_MOUNTPOINT/dev" || mount --make-rslave "$ROOT_MOUNTPOINT/dev" || exit 1 + mountpoint -q -- "$ROOT_MOUNTPOINT/sys" || { + mount --rbind /sys "$ROOT_MOUNTPOINT/sys" && + mount --make-rslave "$ROOT_MOUNTPOINT/sys"; } || exit 1 + mountpoint -q -- "$ROOT_MOUNTPOINT/dev" || { + mount --rbind /dev "$ROOT_MOUNTPOINT/dev" && + mount --make-rslave "$ROOT_MOUNTPOINT/dev"; } || exit 1 ) || die "Could not mount virtual filesystems" # Execute command diff --git a/scripts/main.sh b/scripts/main.sh index 785422d..77aedd7 100755 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -89,10 +89,10 @@ main_install_gentoo_in_chroot() { env_update # Prepare /etc/portage for autounmask - mkdir_or_die "/etc/portage/package.use" - touch_or_die "/etc/portage/package.use/zz-autounmask" - mkdir_or_die "/etc/portage/package.keywords" - touch_or_die "/etc/portage/package.keywords/zz-autounmask" + mkdir_or_die 0755 "/etc/portage/package.use" + touch_or_die 0644 "/etc/portage/package.use/zz-autounmask" + mkdir_or_die 0755 "/etc/portage/package.keywords" + touch_or_die 0644 "/etc/portage/package.keywords/zz-autounmask" # Install git (for git portage overlays) einfo "Installing git"