diff --git a/pack/df_linux/distro_fixes.sh b/pack/df_linux/distro_fixes.sh index c7dd0d9..274298d 100755 --- a/pack/df_linux/distro_fixes.sh +++ b/pack/df_linux/distro_fixes.sh @@ -170,6 +170,9 @@ if [ -n "$ZLIB_PATH" ]; then dlog INFO "Attempting to use zlib at $ZLIB_PATH" fi +# Include set_ptracer_any.so in PRELOAD_LIB to remove the necessity to run setcap on the Dwarf Therapist executable +export PRELOAD_LIB="${PRELOAD_LIB:+$PRELOAD_LIB:}./libs/set_ptracer_any.so" + dlog "INFO" "PRELOAD_LIB: $PRELOAD_LIB" dlog "INFO" "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" dlog "INFO" "Done" diff --git a/pack/df_linux/libs/set_ptracer_any.c b/pack/df_linux/libs/set_ptracer_any.c new file mode 100644 index 0000000..99fd7db --- /dev/null +++ b/pack/df_linux/libs/set_ptracer_any.c @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +void set_ptracer_any() __attribute__((constructor)); + +void set_ptracer_any() +{ + if (-1 == prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0)) + perror("prctl"); +} diff --git a/pack/df_linux/libs/set_ptracer_any.so b/pack/df_linux/libs/set_ptracer_any.so new file mode 100755 index 0000000..f507378 Binary files /dev/null and b/pack/df_linux/libs/set_ptracer_any.so differ diff --git a/pack/startlnp b/pack/startlnp index 56b14f2..f2afc1b 100755 --- a/pack/startlnp +++ b/pack/startlnp @@ -26,20 +26,5 @@ if [ ! -d df_linux ]; then echo "working directory: $(pwd)" fi -gcap="$(whereis -b getcap | cut -f2 -d":" | tr -d " ")" -scap="$(whereis -b setcap | cut -f2 -d":" | tr -d " ")" - -if [ -x $gcap ] && [ -x $scap ]; then - #Check whether Dwarf Therapist can read from DF memory: - dt_capabilities=$($gcap LNP/utilities/dwarf_therapist/dwarftherapist |cut -f2 -d"="|tr -d " ") - dt_capabilities=${dt_capabilities:=0} - if [ ${dt_capabilities} != "cap_sys_ptrace+eip" ]; then - msg="Enable Dwarf Therapist to read from Dwarf Fortress memory" - xterm -e "echo $msg;sudo $scap cap_sys_ptrace=eip LNP/utilities/dwarf_therapist/dwarftherapist" - fi -else - warn "Could not find getcap and/or setcap" -fi - #run Lazy Newb Pack ./PyLNP "$@" || warn "Failed to start PyLNP"