Skip to content

Commit

Permalink
Make preload.sh POSIX-compliant
Browse files Browse the repository at this point in the history
I've made `preload.sh` fully POSIX-compliant, meaning it can now run on any POSIX-compatible shell, not just `bash`.
  • Loading branch information
AlbydST authored Nov 15, 2024
1 parent a7302ad commit f4fdc99
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions preload.sh
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit f4fdc99

Please sign in to comment.