diff --git a/arch-nspawn.in b/arch-nspawn.in
index 5c0f46f7b0fe3fef2a288196fd4e78cb5d71bef8..5d5620d9266f0ffb67f9477fcf1eb7e32cd264bd 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -25,8 +25,6 @@ usage() {
 	exit 1
 }
 
-orig_argv=("$@")
-
 while getopts 'hC:M:c:' arg; do
 	case "$arg" in
 		C) pac_conf="$OPTARG" ;;
@@ -39,7 +37,7 @@ done
 shift $(($OPTIND - 1))
 
 (( $# < 1 )) && die 'You must specify a directory.'
-check_root "$0" "${orig_argv[@]}"
+check_root
 
 working_dir=$(readlink -f "$1")
 shift 1
diff --git a/archbuild.in b/archbuild.in
index 9c5d706d84b92d808710913009c23ff6e7d85521..4fb33c3f138222449ad926d6b29e4fef57c8c088 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 m4_include(lib/common.sh)
+m4_include(lib/archroot.sh)
 
 base_packages=(base-devel)
 makechrootpkg_args=(-c -n)
@@ -29,8 +30,6 @@ usage() {
 	exit 1
 }
 
-orig_argv=("$@")
-
 while getopts 'hcr:' arg; do
 	case "${arg}" in
 		c) clean_first=true ;;
@@ -39,7 +38,7 @@ while getopts 'hcr:' arg; do
 	esac
 done
 
-check_root "$0" "${orig_argv[@]}"
+check_root
 
 # Pass all arguments after -- right to makepkg
 makechrootpkg_args+=("${@:$OPTIND}")
diff --git a/lib/archroot.sh b/lib/archroot.sh
index 25e94fbef80f5981cea469a654c487038dcae736..7d7ab671bb6ffa17bda341ff3c2fc628ce2264c5 100644
--- a/lib/archroot.sh
+++ b/lib/archroot.sh
@@ -1 +1,14 @@
 CHROOT_VERSION='v4'
+
+##
+#  usage : check_root
+##
+orig_argv=("$0" "$@")
+check_root() {
+	(( EUID == 0 )) && return
+	if type -P sudo >/dev/null; then
+		exec sudo -- "${orig_argv[@]}"
+	else
+		exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
+	fi
+}
diff --git a/lib/common.sh b/lib/common.sh
index 387fb8c5660e82b4e79951369bb518125d213b46..599be54ac95651c7d9aba22b25213e82512a1b89 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -227,15 +227,3 @@ find_cached_package() {
 			return 1
 	esac
 }
-
-##
-#  usage : check_root ("$0" "$@")
-##
-check_root() {
-	(( EUID == 0 )) && return
-	if type -P sudo >/dev/null; then
-		exec sudo -- "$@"
-	else
-		exec su root -c "$(printf ' %q' "$@")"
-	fi
-}
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 79b387d8611e82544a5219da14026eaa49d065cc..695b89876b3a710df1c20c54fbdb2c227a523382 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -9,6 +9,7 @@
 # GNU General Public License for more details.
 
 m4_include(lib/common.sh)
+m4_include(lib/archroot.sh)
 
 shopt -s nullglob
 
@@ -258,8 +259,6 @@ move_products() {
 }
 # }}}
 
-orig_argv=("$@")
-
 while getopts 'hcur:I:l:nTD:d:U:' arg; do
 	case "$arg" in
 		c) clean_first=true ;;
@@ -279,7 +278,7 @@ done
 [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
 [[ -n $makepkg_user && -z $(id -u "$makepkg_user") ]] && die 'Invalid makepkg user.'
 
-check_root "$0" "${orig_argv[@]}"
+check_root
 
 # Canonicalize chrootdir, getting rid of trailing /
 chrootdir=$(readlink -e "$passeddir")
diff --git a/mkarchroot.in b/mkarchroot.in
index e03b4f9e265ca38292626bd3e544952b42587c6d..010de3c5f79704d966a92f130af17efc33b735eb 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -23,8 +23,6 @@ usage() {
 	exit 1
 }
 
-orig_argv=("$@")
-
 while getopts 'hC:M:c:' arg; do
 	case "$arg" in
 		C) pac_conf="$OPTARG" ;;
@@ -38,7 +36,7 @@ shift $(($OPTIND - 1))
 
 (( $# < 2 )) && die 'You must specify a directory and one or more packages.'
 
-check_root "$0" "${orig_argv[@]}"
+check_root
 
 working_dir="$(readlink -f $1)"
 shift 1