From 80c873c8a4835ae8d02db938729fb63508ee0994 Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Sun, 30 Jun 2024 19:25:52 -0300 Subject: [PATCH] improve: `TMP_PATH` related code This commit improves the code that decides which path will be for "TMP_PATH" variable. --- loader/src/ptracer/main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/loader/src/ptracer/main.cpp b/loader/src/ptracer/main.cpp index 973e4f5..aba0fe3 100644 --- a/loader/src/ptracer/main.cpp +++ b/loader/src/ptracer/main.cpp @@ -14,18 +14,15 @@ int main(int argc, char **argv) { if (getenv("TMP_PATH") == NULL) { tmp_path_type = SBIN_AS_TMP_PATH; - FILE *fp = fopen("/sbin", "r"); - if (fp == NULL) { + if (access("/sbin", F_OK) == -1) { tmp_path_type = DEBUG_RAMDISK_AS_TMP_PATH; - fp = fopen("/debug_ramdisk", "r"); - - if (fp == NULL) { + if (access("/debug_ramdisk", F_OK) == -1) { printf("Cannot find TMP_PATH. You should make an issue about that.\n"); return 1; - } else fclose(fp); - } else fclose(fp); + } + } } else { tmp_path_type = CUSTOM_TMP_PATH; }