diff --git a/Makefile b/Makefile index d2928a5..29d67bc 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ -VER=26 +VER=29 -PREFIX = /usr/local +PREFIX = /usr BINPROGS = \ - arch-chroot \ + flarebird-chroot \ genfstab \ pacstrap MANS = \ - doc/arch-chroot.8 \ + doc/flarebird-chroot.8 \ doc/genfstab.8 \ doc/pacstrap.8 @@ -25,7 +25,7 @@ _v_GEN_0 = @echo " GEN " $@; edit = $(V_GEN) m4 -P $@.in >$@ && chmod go-w,+x $@ -arch-chroot: arch-chroot.in common +flarebird-chroot: flarebird-chroot.in common $(edit) genfstab: genfstab.in fstab-helpers @@ -49,8 +49,8 @@ shellcheck: $(BINPROGS) shellcheck -W 99 --color -x test/test_* install: all - install -d $(DESTDIR)$(PREFIX)/bin - install -m 0755 $(BINPROGS) $(DESTDIR)$(PREFIX)/bin + install -d $(DESTDIR)$(PREFIX)/sbin + install -m 0755 $(BINPROGS) $(DESTDIR)$(PREFIX)/sbin install -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions install -m 0644 $(ZSHCOMP) $(DESTDIR)$(PREFIX)/share/zsh/site-functions install -d $(DESTDIR)$(PREFIX)/share/bash-completion/completions diff --git a/common b/common index ced125b..b6397ed 100644 --- a/common +++ b/common @@ -29,15 +29,14 @@ chroot_setup() { [[ $(trap -p EXIT) ]] && die '(BUG): attempting to overwrite existing EXIT trap' trap 'chroot_teardown' EXIT - chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev && - chroot_add_mount sys "$1/sys" -t sysfs -o nosuid,noexec,nodev,ro && + chroot_add_mount proc "$1/proc" -t proc && + chroot_add_mount sysfs "$1/sys" -t sysfs && ignore_error chroot_maybe_add_mount "[[ -d '$1/sys/firmware/efi/efivars' ]]" \ - efivarfs "$1/sys/firmware/efi/efivars" -t efivarfs -o nosuid,noexec,nodev && - chroot_add_mount udev "$1/dev" -t devtmpfs -o mode=0755,nosuid && - chroot_add_mount devpts "$1/dev/pts" -t devpts -o mode=0620,gid=5,nosuid,noexec && - chroot_add_mount shm "$1/dev/shm" -t tmpfs -o mode=1777,nosuid,nodev && - chroot_add_mount /run "$1/run" --bind --make-private && - chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid + efivarfs "$1/sys/firmware/efi/efivars" -t efivarfs && + chroot_add_mount /dev "$1/dev" --bind && + chroot_add_mount devpts "$1/dev/pts" -t devpts -o mode=0620,gid=5 && + chroot_add_mount tmpfs "$1/dev/shm" -t tmpfs -o nosuid,nodev && + chroot_add_mount tmpfs "$1/run" -t tmpfs -o mode=1777 } chroot_teardown() { @@ -68,8 +67,8 @@ unshare_setup() { trap 'unshare_teardown' EXIT chroot_add_mount_lazy "$1" "$1" --bind && - chroot_add_mount proc "$1/proc" -t proc -o nosuid,noexec,nodev && - chroot_add_mount_lazy /sys "$1/sys" --rbind && + chroot_add_mount proc "$1/proc" -t proc && + chroot_add_mount_lazy sysfs "$1/sys" -t sysfs && chroot_add_link /proc/self/fd "$1/dev/fd" && chroot_add_link /proc/self/fd/0 "$1/dev/stdin" && chroot_add_link /proc/self/fd/1 "$1/dev/stdout" && @@ -80,8 +79,7 @@ unshare_setup() { chroot_bind_device /dev/tty "$1/dev/tty" && chroot_bind_device /dev/urandom "$1/dev/urandom" && chroot_bind_device /dev/zero "$1/dev/zero" && - chroot_add_mount run "$1/run" -t tmpfs -o nosuid,nodev,mode=0755 && - chroot_add_mount tmp "$1/tmp" -t tmpfs -o mode=1777,strictatime,nodev,nosuid + chroot_add_mount tmpfs "$1/run" -t tmpfs -o mode=1777 } unshare_teardown() { diff --git a/completion/bash/arch-chroot b/completion/bash/flarebird-chroot similarity index 86% rename from completion/bash/arch-chroot rename to completion/bash/flarebird-chroot index de53d92..77d2382 100644 --- a/completion/bash/arch-chroot +++ b/completion/bash/flarebird-chroot @@ -1,4 +1,4 @@ -_arch_chroot() { +_flarebird_chroot() { compopt +o dirnames local cur prev opts i _init_completion -n : || return @@ -22,4 +22,4 @@ _arch_chroot() { compopt -o dirnames } -complete -F _arch_chroot arch-chroot +complete -F _flarebird_chroot flarebird-chroot diff --git a/completion/zsh/_arch-chroot b/completion/zsh/_flarebird-chroot similarity index 96% rename from completion/zsh/_arch-chroot rename to completion/zsh/_flarebird-chroot index 6229af8..a1879e9 100644 --- a/completion/zsh/_arch-chroot +++ b/completion/zsh/_flarebird-chroot @@ -1,4 +1,4 @@ -#compdef arch-chroot +#compdef flarebird-chroot # NOTE: nearly everything here is borrowed from the chroot completion local -a args=( diff --git a/doc/arch-chroot.8.asciidoc b/doc/flarebird-chroot.8.asciidoc similarity index 77% rename from doc/arch-chroot.8.asciidoc rename to doc/flarebird-chroot.8.asciidoc index 5f3f27c..a83344a 100644 --- a/doc/arch-chroot.8.asciidoc +++ b/doc/flarebird-chroot.8.asciidoc @@ -1,21 +1,21 @@ -arch-chroot(8) -============== +flarebird-chroot(8) +=================== Name ---- -arch-chroot - enhanced chroot command +flarebird-chroot - enhanced chroot command Synopsis -------- -arch-chroot [options] chroot-dir [command] [arguments...] +flarebird-chroot [options] chroot-dir [command] [arguments...] Description ----------- -arch-chroot wraps the linkman:chroot[1] command while ensuring that important +flarebird-chroot wraps the linkman:chroot[1] command while ensuring that important functionality is available, e.g. mounting '/dev/', '/proc' and other API filesystems, or exposing linkman:resolv.conf[5] to the chroot. -If 'command' is unspecified, arch-chroot will launch */bin/bash*. +If 'command' is unspecified, flarebird-chroot will launch */bin/bash*. [NOTE] ====== diff --git a/arch-chroot.in b/flarebird-chroot.in similarity index 94% rename from arch-chroot.in rename to flarebird-chroot.in index 0868a2a..f884cfb 100644 --- a/arch-chroot.in +++ b/flarebird-chroot.in @@ -19,7 +19,7 @@ usage: ${0##*/} chroot-dir [command] [arguments...] If 'command' is unspecified, ${0##*/} will launch /bin/bash. -Note that when using arch-chroot, the target chroot directory *should* be a +Note that when using flarebird-chroot, the target chroot directory *should* be a mountpoint. This ensures that tools such as pacman(8) or findmnt(8) have an accurate hierarchy of the mounted filesystems within the chroot. @@ -65,7 +65,7 @@ chroot_add_resolv_conf() { chroot_add_mount "$src" "$dest" -c --bind } -arch-chroot() { +flarebird-chroot() { (( EUID == 0 )) || die 'This script must be run with root privileges' [[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir" @@ -117,8 +117,8 @@ shift args=("$@") if (( unshare )); then setup=unshare_setup - $mount_unshare bash -c "$(declare_all); arch-chroot" + $mount_unshare bash -c "$(declare_all); flarebird-chroot" else setup=chroot_setup - arch-chroot + flarebird-chroot fi