From 7ad40aa4ca745ca0d25e1a3d545fca9dac7198c5 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sat, 28 Jun 2025 09:16:00 +0200 Subject: [PATCH 01/14] Set errno to ENOENT when files does not exist, not EACCES This is needed for e.g. zsh command-not-found functionality to work. --- .gitignore | 2 ++ Makefile | 10 ++++++++-- src/termux-exec.c | 25 ++++++++++++++++++++----- tests/exec-directory.c | 9 +++++++++ tests/exec-directory.sh | 4 ++++ tests/exec-directory.sh-expected | 1 + tests/execl.c | 22 ++++++++++++++++++++++ tests/execl.sh | 10 ++++++++++ tests/execl.sh-expected | 2 ++ 9 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 tests/exec-directory.c create mode 100755 tests/exec-directory.sh create mode 100644 tests/exec-directory.sh-expected create mode 100644 tests/execl.c create mode 100755 tests/execl.sh create mode 100644 tests/execl.sh-expected diff --git a/.gitignore b/.gitignore index f85e6ed..90ee657 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ *.swp *.deb test-binary +tests/execl +tests/exec-directory tests/fexecve tests/popen tests/system-uname diff --git a/Makefile b/Makefile index 09d147b..75fa500 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC ?= clang TERMUX_BASE_DIR ?= /data/data/com.termux/files -CFLAGS += -Wall -Wextra -Werror -Wshadow -fvisibility=hidden -std=c17 +CFLAGS += -Wall -Wextra -Werror -Wshadow -fvisibility=hidden -std=c23 C_SOURCE := src/termux-exec.c src/exec-variants.c src/termux-readlink.c CLANG_FORMAT := clang-format --sort-includes --style="{ColumnLimit: 120}" $(C_SOURCE) tests/fexecve.c tests/system-uname.c tests/print-argv0.c tests/popen.c CLANG_TIDY ?= clang-tidy @@ -18,6 +18,12 @@ endif libtermux-exec.so: $(C_SOURCE) $(CC) $(CFLAGS) $(LDFLAGS) $(C_SOURCE) -DTERMUX_PREFIX=\"$(TERMUX_PREFIX)\" -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" -shared -fPIC -o libtermux-exec.so +tests/execl: tests/execl.c + $(CC) $(CFLAGS) -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" $< -o $@ + +tests/exec-directory: tests/exec-directory.c + $(CC) $(CFLAGS) -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" $< -o $@ + tests/fexecve: tests/fexecve.c $(CC) $(CFLAGS) -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" $< -o $@ @@ -46,7 +52,7 @@ on-device-tests: make clean ASAN_OPTIONS=symbolize=0,detect_leaks=0 make on-device-tests-internal -on-device-tests-internal: libtermux-exec.so tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 +on-device-tests-internal: libtermux-exec.so tests/execl tests/exec-directory tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 @LD_PRELOAD=${CURDIR}/libtermux-exec.so ./run-tests.sh format: diff --git a/src/termux-exec.c b/src/termux-exec.c index 0407cc8..68fb4d3 100644 --- a/src/termux-exec.c +++ b/src/termux-exec.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -284,9 +285,19 @@ __attribute__((visibility("default"))) int execve(const char *executable_path, c fprintf(stderr, LOG_PREFIX "Rewritten path: '%s'\n", executable_path); } + char normalized_path_buffer[PATH_MAX]; + executable_path = normalize_path(executable_path, normalized_path_buffer); + if (access(executable_path, X_OK) != 0) { - // Error out if the file is not executable: - errno = EACCES; + // Error out if the file is not executable. + struct stat stat_buffer; + if (stat(executable_path, &stat_buffer) == 0) { + // File exists but is executable: + errno = EACCES; + } else { + // File does not exist: + errno = ENOENT; + } return -1; } @@ -315,6 +326,13 @@ __attribute__((visibility("default"))) int execve(const char *executable_path, c // We use one more byte since inspect_file_header() will null terminate the buffer. char header[256]; ssize_t read_bytes = read(fd, header, sizeof(header) - 1); + if (read_bytes < 0) { + if (errno == EISDIR) { + // execve() should error with EACCES if file is directory. + errno = EACCES; + } + return -1; + } close(fd); struct file_header_info info = { @@ -338,9 +356,6 @@ __attribute__((visibility("default"))) int execve(const char *executable_path, c } } - char normalized_path_buffer[PATH_MAX]; - executable_path = normalize_path(executable_path, normalized_path_buffer); - char **new_allocated_envp = NULL; char *termux_self_exe = NULL; diff --git a/tests/exec-directory.c b/tests/exec-directory.c new file mode 100644 index 0000000..e3e469c --- /dev/null +++ b/tests/exec-directory.c @@ -0,0 +1,9 @@ +#include +#include +#include + +int main(int, char **argv) { + execve(".", argv, environ); + printf("errno = %d\n", errno); + return 0; +} diff --git a/tests/exec-directory.sh b/tests/exec-directory.sh new file mode 100755 index 0000000..496d7cb --- /dev/null +++ b/tests/exec-directory.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e -u + +./tests/exec-directory diff --git a/tests/exec-directory.sh-expected b/tests/exec-directory.sh-expected new file mode 100644 index 0000000..0f80479 --- /dev/null +++ b/tests/exec-directory.sh-expected @@ -0,0 +1 @@ +errno = 13 diff --git a/tests/execl.c b/tests/execl.c new file mode 100644 index 0000000..5dfd790 --- /dev/null +++ b/tests/execl.c @@ -0,0 +1,22 @@ +#include +#include +#include + +void exec_debug(char *path) { + int ret = execl(path, "--arg", (char *)NULL); + if (ret != -1) { + fprintf(stderr, "Unexpected return value when execl():ing non-existing file: %d\n", ret); + } else { + printf("errno = %d\n", errno); + } +} + +int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "Unexpected argc=%d\n", argc); + return 1; + } + exec_debug("/this-file-does-not-exist"); + exec_debug(argv[1]); + return 0; +} diff --git a/tests/execl.sh b/tests/execl.sh new file mode 100755 index 0000000..1c07105 --- /dev/null +++ b/tests/execl.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e -u + +# Make TMPFILE an existing but non-executable file: +TMPFILE=$(mktemp) +echo "1" > $TMPFILE + +./tests/execl $TMPFILE + +rm $TMPFILE diff --git a/tests/execl.sh-expected b/tests/execl.sh-expected new file mode 100644 index 0000000..2ff95e4 --- /dev/null +++ b/tests/execl.sh-expected @@ -0,0 +1,2 @@ +errno = 2 +errno = 13 From 0e534c3247b9dde7ed09b174e1ae7e59bd7b895c Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 22:43:27 +0200 Subject: [PATCH 02/14] Update to NDK r28c in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4415ab..00f3e34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - uses: nttld/setup-ndk@v1 id: setup-ndk with: - ndk-version: r26d + ndk-version: r28c link-to-sdk: true - run: brew install clang-format - run: make CC="${ANDROID_NDK_HOME}"/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang From f7443e1a48e9d4dc4a373063235e288326f2be90 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:22:39 +0200 Subject: [PATCH 03/14] Run test on normal Linux --- .github/workflows/ci.yml | 1 + Makefile | 11 ++++++++--- run-tests.sh | 9 +++++++++ tests/exec-directory.c | 2 +- tests/fexecve.c | 1 + tests/not-executable.sh-expected | 2 +- tests/popen.c | 1 + tests/readlink-proc-self-exe.c | 2 ++ 8 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00f3e34..523c05d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - run: make unit-test CC=clang HOST_BUILD=1 + - run: make on-normal-linux-tests actionlint: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 75fa500..c78ae61 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ CC ?= clang TERMUX_BASE_DIR ?= /data/data/com.termux/files -CFLAGS += -Wall -Wextra -Werror -Wshadow -fvisibility=hidden -std=c23 +CFLAGS += -Wall -Wextra -Werror -Wshadow -fvisibility=hidden -std=c23 -D__USE_GNU C_SOURCE := src/termux-exec.c src/exec-variants.c src/termux-readlink.c CLANG_FORMAT := clang-format --sort-includes --style="{ColumnLimit: 120}" $(C_SOURCE) tests/fexecve.c tests/system-uname.c tests/print-argv0.c tests/popen.c CLANG_TIDY ?= clang-tidy +TEST_BINARIES = tests/execl tests/exec-directory tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 ifeq ($(SANITIZE),1) CFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer @@ -37,10 +38,11 @@ tests/readlink-proc-self-exe: tests/readlink-proc-self-exe.c $(CC) $(CFLAGS) -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" $< -o $@ $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0: tests/print-argv0.c + mkdir -p $(TERMUX_BASE_DIR)/usr/bin/ $(CC) $(CFLAGS) $< -o $@ clean: - rm -f libtermux-exec.so tests/*-actual test-binary $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 + rm -f libtermux-exec.so tests/*-actual $(TEST_BINARIES) install: libtermux-exec.so install libtermux-exec.so $(DESTDIR)$(PREFIX)/lib/libtermux-exec.so @@ -52,9 +54,12 @@ on-device-tests: make clean ASAN_OPTIONS=symbolize=0,detect_leaks=0 make on-device-tests-internal -on-device-tests-internal: libtermux-exec.so tests/execl tests/exec-directory tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 +on-device-tests-internal: libtermux-exec.so $(TEST_BINARIES) @LD_PRELOAD=${CURDIR}/libtermux-exec.so ./run-tests.sh +on-normal-linux-tests: $(TEST_BINARIES) + ./run-tests.sh + format: $(CLANG_FORMAT) -i $(C_SOURCE) tests/*.c diff --git a/run-tests.sh b/run-tests.sh index 0c831d7..229743e 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,7 +2,16 @@ set -u +UNAME_OS=$(uname -o) + for f in tests/*.sh; do + if [ "$UNAME_OS" != Android ]; then + if [ "$f" = tests/call-system-bin-sh.sh ] || [ "$f" = tests/print-argv0.sh ]; then + echo "Skipping $f..." + continue + fi + fi + printf "Running $f..." EXPECTED_FILE=$f-expected diff --git a/tests/exec-directory.c b/tests/exec-directory.c index e3e469c..53a1ac3 100644 --- a/tests/exec-directory.c +++ b/tests/exec-directory.c @@ -2,7 +2,7 @@ #include #include -int main(int, char **argv) { +int main(int, char **argv, char** environ) { execve(".", argv, environ); printf("errno = %d\n", errno); return 0; diff --git a/tests/fexecve.c b/tests/fexecve.c index bbc682c..e206591 100644 --- a/tests/fexecve.c +++ b/tests/fexecve.c @@ -1,5 +1,6 @@ #include #include +#define __USE_XOPEN2K8 #include int main() { diff --git a/tests/not-executable.sh-expected b/tests/not-executable.sh-expected index 5e7557b..2309330 100644 --- a/tests/not-executable.sh-expected +++ b/tests/not-executable.sh-expected @@ -1 +1 @@ -./run-tests.sh: line 12: tests/not-executable.sh: Permission denied +./run-tests.sh: line 21: tests/not-executable.sh: Permission denied diff --git a/tests/popen.c b/tests/popen.c index a5cbf20..beb73ad 100644 --- a/tests/popen.c +++ b/tests/popen.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 2 #include int main() { diff --git a/tests/readlink-proc-self-exe.c b/tests/readlink-proc-self-exe.c index f041eb2..0d5e9c0 100644 --- a/tests/readlink-proc-self-exe.c +++ b/tests/readlink-proc-self-exe.c @@ -1,4 +1,6 @@ #define _DEFAULT_SOURCE +#define __USE_XOPEN2K8 +#include #include #include #include From 40f71effadd609f76e61f6c44ae633ec6211302f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:26:50 +0200 Subject: [PATCH 04/14] Fix CI tests --- .github/workflows/ci.yml | 2 +- tests/exec-directory.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 523c05d..3b128a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - run: make unit-test CC=clang HOST_BUILD=1 - - run: make on-normal-linux-tests + - run: make on-normal-linux-tests CC=clang actionlint: runs-on: ubuntu-latest diff --git a/tests/exec-directory.c b/tests/exec-directory.c index 53a1ac3..e7f0d71 100644 --- a/tests/exec-directory.c +++ b/tests/exec-directory.c @@ -2,8 +2,8 @@ #include #include -int main(int, char **argv, char** environ) { - execve(".", argv, environ); +int main(int, char **argv, char** env) { + execve(".", argv, env); printf("errno = %d\n", errno); return 0; } From 6074163f77f61e345b9972dca943d9b4cf40befd Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:28:07 +0200 Subject: [PATCH 05/14] Format --- tests/exec-directory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/exec-directory.c b/tests/exec-directory.c index e7f0d71..b3445e8 100644 --- a/tests/exec-directory.c +++ b/tests/exec-directory.c @@ -2,7 +2,7 @@ #include #include -int main(int, char **argv, char** env) { +int main(int, char **argv, char **env) { execve(".", argv, env); printf("errno = %d\n", errno); return 0; From af73df5141557409bf3ff7ee9d3affd294fbd2f3 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:31:43 +0200 Subject: [PATCH 06/14] Fix CI --- .github/workflows/ci.yml | 2 +- Makefile | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b128a9..d1865f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - run: make unit-test CC=clang HOST_BUILD=1 - - run: make on-normal-linux-tests CC=clang + - run: make on-normal-linux-tests CC=clang HOST_BUILD=1 actionlint: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index c78ae61..82f61f8 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS += -Wall -Wextra -Werror -Wshadow -fvisibility=hidden -std=c23 -D__USE_GN C_SOURCE := src/termux-exec.c src/exec-variants.c src/termux-readlink.c CLANG_FORMAT := clang-format --sort-includes --style="{ColumnLimit: 120}" $(C_SOURCE) tests/fexecve.c tests/system-uname.c tests/print-argv0.c tests/popen.c CLANG_TIDY ?= clang-tidy -TEST_BINARIES = tests/execl tests/exec-directory tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 +TEST_BINARIES = tests/execl tests/exec-directory tests/fexecve tests/popen tests/system-uname tests/readlink-proc-self-exe ifeq ($(SANITIZE),1) CFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer @@ -14,6 +14,8 @@ endif ifeq ($(HOST_BUILD),1) CFLAGS += -Wno-error=tautological-pointer-compare +else + TEST_BINARIES += $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0 endif libtermux-exec.so: $(C_SOURCE) @@ -38,7 +40,6 @@ tests/readlink-proc-self-exe: tests/readlink-proc-self-exe.c $(CC) $(CFLAGS) -DTERMUX_BASE_DIR=\"$(TERMUX_BASE_DIR)\" $< -o $@ $(TERMUX_BASE_DIR)/usr/bin/termux-exec-test-print-argv0: tests/print-argv0.c - mkdir -p $(TERMUX_BASE_DIR)/usr/bin/ $(CC) $(CFLAGS) $< -o $@ clean: From 278aecfd88e300b865a0f513c8fa11ad5f05624e Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:36:27 +0200 Subject: [PATCH 07/14] Fix CI --- .github/workflows/ci.yml | 7 +++++++ run-tests.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1865f5..2d3d6f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,13 @@ jobs: - run: make check CLANG_TIDY="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-tidy --extra-arg=--target=aarch64-linux-android29" env: ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + + host-build-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Homebrew/actions/setup-homebrew@master + - run: brew install clang - run: make unit-test CC=clang HOST_BUILD=1 - run: make on-normal-linux-tests CC=clang HOST_BUILD=1 diff --git a/run-tests.sh b/run-tests.sh index 229743e..7517679 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,4 +1,4 @@ -#!/data/data/com.termux/files/usr/bin/bash +#!/bin/bash set -u From 62f9fe54c68949e140567d3749452699144105a5 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:38:13 +0200 Subject: [PATCH 08/14] Fix CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d3d6f8..9ccaddc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: Homebrew/actions/setup-homebrew@master - - run: brew install clang + - run: brew install clang-format - run: make unit-test CC=clang HOST_BUILD=1 - run: make on-normal-linux-tests CC=clang HOST_BUILD=1 From cefb6d682eaa34b7dca1f240edde5f8359a52ca4 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:39:18 +0200 Subject: [PATCH 09/14] No need for brew and clang-format for host tests --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ccaddc..6885057 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,8 +29,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: Homebrew/actions/setup-homebrew@master - - run: brew install clang-format - run: make unit-test CC=clang HOST_BUILD=1 - run: make on-normal-linux-tests CC=clang HOST_BUILD=1 From 67e085e47a2a84a66fa0ed4a4c66e021d895f24e Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:40:47 +0200 Subject: [PATCH 10/14] Fail with error exit code on error --- run-tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run-tests.sh b/run-tests.sh index 7517679..bb17086 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -3,6 +3,7 @@ set -u UNAME_OS=$(uname -o) +EXIT_CODE=0 for f in tests/*.sh; do if [ "$UNAME_OS" != Android ]; then @@ -24,6 +25,8 @@ for f in tests/*.sh; do printf " OK\n" else printf " FAILED - compare expected $EXPECTED_FILE with ${ACTUAL_FILE}\n" + EXIT_CODE=1 fi done +exit $EXIT_CODE From 13eba750b4c54c7d20fa7b4ccc0b049536d4978a Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:42:56 +0200 Subject: [PATCH 11/14] Show errors --- run-tests.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run-tests.sh b/run-tests.sh index bb17086..3f9b2fd 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -24,7 +24,12 @@ for f in tests/*.sh; do if cmp --silent $ACTUAL_FILE $EXPECTED_FILE; then printf " OK\n" else - printf " FAILED - compare expected $EXPECTED_FILE with ${ACTUAL_FILE}\n" + printf " FAILED - compare expected ${EXPECTED_FILE} with ${ACTUAL_FILE}\n" + echo "### Expected:" + cat "$EXPECTED_FILE" + echo "### Actual:" + cat "$ACTUAL_FILE" + echo "###" EXIT_CODE=1 fi done From 84e7aa57c14d2acacc807a8f4a98a3447b0aaf69 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:45:24 +0200 Subject: [PATCH 12/14] Update --- run-tests.sh | 8 ++++---- tests/not-executable.sh-expected | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 3f9b2fd..9922f92 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -7,10 +7,10 @@ EXIT_CODE=0 for f in tests/*.sh; do if [ "$UNAME_OS" != Android ]; then - if [ "$f" = tests/call-system-bin-sh.sh ] || [ "$f" = tests/print-argv0.sh ]; then - echo "Skipping $f..." - continue - fi + if [ "$f" = tests/call-system-bin-sh.sh ] || [ "$f" = tests/print-argv0.sh ] || [ "$f" = tests/fexecve.sh ] ; then + echo "Skipping $f..." + continue + fi fi printf "Running $f..." diff --git a/tests/not-executable.sh-expected b/tests/not-executable.sh-expected index 2309330..d14d651 100644 --- a/tests/not-executable.sh-expected +++ b/tests/not-executable.sh-expected @@ -1 +1 @@ -./run-tests.sh: line 21: tests/not-executable.sh: Permission denied +./run-tests.sh: line 22: tests/not-executable.sh: Permission denied From 1c11477674ce499fe13e860bbbae91d6f6e7b8a7 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:47:17 +0200 Subject: [PATCH 13/14] Add extra test --- tests/exec-directory.c | 2 ++ tests/exec-directory.sh-expected | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/exec-directory.c b/tests/exec-directory.c index b3445e8..ae40bfd 100644 --- a/tests/exec-directory.c +++ b/tests/exec-directory.c @@ -5,5 +5,7 @@ int main(int, char **argv, char **env) { execve(".", argv, env); printf("errno = %d\n", errno); + execve("/", argv, env); + printf("errno = %d\n", errno); return 0; } diff --git a/tests/exec-directory.sh-expected b/tests/exec-directory.sh-expected index 0f80479..664e139 100644 --- a/tests/exec-directory.sh-expected +++ b/tests/exec-directory.sh-expected @@ -1 +1,2 @@ errno = 13 +errno = 13 From 94bec873cc9d716c40393b1277d6be72acc1dbd9 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 10 Jul 2025 23:48:11 +0200 Subject: [PATCH 14/14] No need to test on merge_request as well --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6885057..673c381 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: - '*' - pull_request: jobs: check: