From 0c0f7543541f0f403c26390863b2ba0b66c1230b Mon Sep 17 00:00:00 2001 From: Hello_World Date: Tue, 27 Feb 2024 09:34:04 +0300 Subject: [PATCH 1/2] fix(build): generate tmp dir in current dir --- config_arch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_arch b/config_arch index ab0a7c0..fc06a76 100755 --- a/config_arch +++ b/config_arch @@ -20,7 +20,7 @@ # DEALINGS IN THE SOFTWARE. topdir="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" -dir=$(mktemp -d) +dir=$(mktemp -d -p .) src=$dir/arch.c exe=$dir/arch cat <$src From 0c7caa2be73f08c0310f939cafdff8b6546a2473 Mon Sep 17 00:00:00 2001 From: Hello_World Date: Tue, 27 Feb 2024 10:39:59 +0300 Subject: [PATCH 2/2] fix(build): check /tmp, /dev/shm and current dir --- config_arch | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/config_arch b/config_arch index fc06a76..b171b31 100755 --- a/config_arch +++ b/config_arch @@ -19,8 +19,45 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +# Function to check directory writability and noexec flag +check_dir() { + local dir=$1 + local mount_point + + # Check if directory exists and is writable + if [[ -d "$dir" && -w "$dir" ]]; then + # Find the mount point for the directory + mount_point=$(df --output=target "$dir" | tail -1) + + # Check if the mount point has the noexec flag + if ! mount | grep " on $mount_point type " | grep -q 'noexec'; then + # Return success if the directory is suitable + return 0 + fi + fi + + # Return failure + return 1 +} + +# Initialize working_path as an empty string +working_path="" + +# Check /tmp, /dev/shm, and current directory in order +if check_dir "/tmp"; then + working_path="/tmp" +elif check_dir "/dev/shm"; then + working_path="/dev/shm" +elif check_dir "$(pwd)"; then + working_path="$(pwd)" +fi + +if [ -z "$working_path" ]; then + exit 1 +fi + topdir="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" -dir=$(mktemp -d -p .) +dir=$(mktemp -d -p $working_path) src=$dir/arch.c exe=$dir/arch cat <$src