From 75d0577dea4f1eefa459a066fa0cca8797e9832f Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Tue, 20 Aug 2019 14:04:00 +0200 Subject: [PATCH] Fix infinite /dev/urandom getting Fixed a bug where the attach scripts would spend an unlimited amount of time getting pseudorandom data while being run from cathook gui --- attach | 6 +++--- attach-gdb | 14 ++++++-------- attach-libnamed.sh | 12 +++++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/attach b/attach index 57b9a37a..32b181b1 100755 --- a/attach +++ b/attach @@ -34,11 +34,11 @@ echo Attaching to "$proc" # pBypass for crash dumps being sent # You may also want to consider using -nobreakpad in your launch options. -sudo rm -rf /tmp/dumps # Remove if it exists -sudo mkdir /tmp/dumps # Make it as root +sudo mkdir -p /tmp/dumps # Make it as root if it doesnt exist +sudo chown root:root /tmp/dumps # Claim it as root sudo chmod 000 /tmp/dumps # No permissions -FILENAME="/tmp/.gl$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)" +FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)" cp "bin/libcathook.so" "$FILENAME" diff --git a/attach-gdb b/attach-gdb index 852203d5..29cf5932 100755 --- a/attach-gdb +++ b/attach-gdb @@ -1,10 +1,8 @@ #!/usr/bin/env bash -if [ $SUDO_USER ]; then - sudo -u $SUDO_USER ./scripts/updater --autoupdater -else - ./scripts/updater -fi +RUNUSER="sudo -u $(logname)" +$RUNUSER bash ./scripts/updater --autoupdater + line=$(pgrep -u $SUDO_USER hl2_linux) arr=($line) inst=$1 @@ -36,11 +34,11 @@ echo Attaching to "$proc" # pBypass for crash dumps being sent # You may also want to consider using -nobreakpad in your launch options. -sudo rm -rf /tmp/dumps # Remove if it exists -sudo mkdir /tmp/dumps # Make it as root +sudo mkdir -p /tmp/dumps # Make it as root if it doesnt exist +sudo chown root:root /tmp/dumps # Claim it as root sudo chmod 000 /tmp/dumps # No permissions -FILENAME="/tmp/.gl$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)" +FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)" cp "bin/libcathook.so" "$FILENAME" diff --git a/attach-libnamed.sh b/attach-libnamed.sh index 46f124c9..53bfb4b8 100755 --- a/attach-libnamed.sh +++ b/attach-libnamed.sh @@ -3,11 +3,9 @@ # Thank you LWSS # https://github.com/LWSS/Fuzion/commit/a53b6c634cde0ed47b08dd587ba40a3806adf3fe -if [ $SUDO_USER ]; then - sudo -u $SUDO_USER ./scripts/updater --autoupdater -else - ./scripts/updater -fi +RUNUSER="sudo -u $(logname)" +$RUNUSER bash ./scripts/updater --autoupdater + line=$(pgrep -u $SUDO_USER hl2_linux) arr=($line) inst=$1 @@ -32,8 +30,8 @@ echo Attaching to "$proc" # pBypass for crash dumps being sent # You may also want to consider using -nobreakpad in your launch options. -sudo rm -rf /tmp/dumps # Remove if it exists -sudo mkdir /tmp/dumps # Make it as root +sudo mkdir -p /tmp/dumps # Make it as root if it doesnt exist +sudo chown root:root /tmp/dumps # Claim it as root sudo chmod 000 /tmp/dumps # No permissions # Get a Random name from the build_names file.