From cefebb20aa77ca2157f9d4aacfe77aea238576b4 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Sep 2015 08:23:54 +0500 Subject: [PATCH] Added the disabling PaX's mprotect() during an activation --- bin/n | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/bin/n b/bin/n index d0dbff3..ad024dd 100755 --- a/bin/n +++ b/bin/n @@ -401,6 +401,31 @@ tarball_url() { } +# +# Disable PaX mprotect for +# + +disable_pax_mprotect() { + test -z $1 && abort "binary required" + local binary=$1 + + # try to disable mprotect via XATTR_PAX header + local PAXCTL=$(PATH="/sbin:/usr/sbin:$PATH" which paxctl-ng 2>&1) + local PAXCTL_ERROR=1 + if [ -x "$PAXCTL" ]; then + $PAXCTL -l && $PAXCTL -m "$binary" >/dev/null 2>&1 + PAXCTL_ERROR="$?" + fi + + # try to disable mprotect via PT_PAX header + if [ $PAXCTL_ERROR != 0 ]; then + PAXCTL=$(PATH="/sbin:/usr/sbin:$PATH" which paxctl 2>&1) + if [ -x "$PAXCTL" ]; then + $PAXCTL -Cm "$binary" >/dev/null 2>&1 + fi + fi +} + # # Activate # @@ -417,6 +442,7 @@ activate() { cp -fR "$dir/$subdir" $N_PREFIX fi done + disable_pax_mprotect "$N_PREFIX/bin/node" fi } @@ -490,20 +516,7 @@ install() { [ $QUIET == false ] && erase_line rm -f $dir/n.lock - # try to disable mprotect via XATTR_PAX header - local PAXCTL=$(PATH="/sbin:/usr/sbin:$PATH" which paxctl-ng 2>&1) - local PAXCTL_ERROR=1 - if [ -x "$PAXCTL" ]; then - $PAXCTL -l && $PAXCTL -m bin/node >/dev/null 2>&1 - PAXCTL_ERROR="$?" - fi - # try to disable mprotect via PT_PAX header - if [ $PAXCTL_ERROR != 0 ]; then - PAXCTL=$(PATH="/sbin:/usr/sbin:$PATH" which paxctl 2>&1) - if [ -x "$PAXCTL" ]; then - $PAXCTL -Cm bin/node >/dev/null 2>&1 - fi - fi + disable_pax_mprotect bin/node if $ACTIVATE ; then activate ${BINS[$DEFAULT]}/$version