From f4fdc99f232eb5ed5700a1539c9532e541cfb709 Mon Sep 17 00:00:00 2001 From: AlbydS <119180144+AlbydST@users.noreply.github.com> Date: Fri, 15 Nov 2024 18:14:59 +0000 Subject: [PATCH] Make preload.sh POSIX-compliant I've made `preload.sh` fully POSIX-compliant, meaning it can now run on any POSIX-compatible shell, not just `bash`. --- preload.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/preload.sh b/preload.sh index ee6abb6..6fcd7b1 100755 --- a/preload.sh +++ b/preload.sh @@ -1,6 +1,8 @@ -#!/bin/bash +#!/bin/sh -dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -[[ $LD_PRELOAD ]] && LD_PRELOAD+=" " -export LD_PRELOAD+="$dir/libhardened_malloc.so" -exec "$@" +# preload.sh - Test dynamically linked executables + +[ ! -f "out/libhardened_malloc.so" ] && make -j"$(nproc)" # If the library isn't found, build it. +[ -n "${LD_PRELOAD}" ] && LD_PRELOAD="${LD_PRELOAD} " # If LD_PRELOAD is already set, add a space. +export LD_PRELOAD="${LD_PRELOAD}${PWD}/out/libhardened_malloc.so" # Add the library to LD_PRELOAD. +exec "$@" # Run the command.