From 567404d0c43d49cc081734124549c5cdd6e19dc5 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 8 Jul 2024 11:11:13 -0500 Subject: [PATCH 01/13] Adjusted use of pthreads for Android/Termux platform Android/Termux doesn't have pthread_cancel so use pthred_kill instead Ticket: CFE-4401 Changelog: title --- configure.ac | 8 ++++++++ libpromises/evalfunction.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/configure.ac b/configure.ac index 6202c22835..aaee0a1d6c 100644 --- a/configure.ac +++ b/configure.ac @@ -181,6 +181,14 @@ CC="$PTHREAD_CC" CFLAGS="$PTHREAD_CFLAGS $CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" +dnl ###################################################################### +dnl libpromises/evalfunction.c isreadable() uses pthread_cancel so check +dnl if available and reverts to pthread_kill if not. +dnl This check must come after ACX_PTHREAD is called so that CC, CFLAGS, +dnl and LIBS are appropriately set for the local pthreads situation. +dnl ###################################################################### +AC_CHECK_FUNCS([pthread_cancel]) + dnl ###################################################################### dnl Whether to build extensions as builtin extensions or a separate dnl plugin. The default is plugin. diff --git a/libpromises/evalfunction.c b/libpromises/evalfunction.c index b65b514af1..984db5ebdc 100644 --- a/libpromises/evalfunction.c +++ b/libpromises/evalfunction.c @@ -9827,7 +9827,11 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx, "Read operation timed out, exceeded %ld seconds.", path, timeout); +#ifdef HAVE_PTHREAD_CANCEL ret = pthread_cancel(thread_data.thread); +#else + ret = pthread_kill(thread_data.thread, 0); +#endif if (ret != 0) { Log(LOG_LEVEL_ERR, "Failed to cancel thread"); @@ -9857,10 +9861,12 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx, return FnFailure(); } +#ifdef HAVE_PTHREAD_CANCEL if (status == PTHREAD_CANCELED) { Log(LOG_LEVEL_DEBUG, "Thread was canceled"); } +#endif return FnReturnContext(success); } From c0e9b4c29caedb4b043ca604df19cf884361aaf3 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 26 Jul 2024 10:03:59 -0500 Subject: [PATCH 02/13] Take patch in downstream termux-packages project and adjust to use HAVE_PTHREAD_CANCEL instead of __ANDROID__ https://github.com/termux/termux-packages/blob/master/packages/cfengine/pthread_cancel.patch Ticket: CFE-4401 Changelog: none --- libpromises/evalfunction.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libpromises/evalfunction.c b/libpromises/evalfunction.c index 984db5ebdc..7e9fa4c364 100644 --- a/libpromises/evalfunction.c +++ b/libpromises/evalfunction.c @@ -9672,10 +9672,27 @@ struct IsReadableThreadData bool success; }; +#ifndef HAVE_PTHREAD_CANCEL +#define PTHREAD_CANCELED ((void *)-1) +static void ThreadSignalHandler(int signum) +{ + pthread_exit(PTHREAD_CANCELED); +} +#endif + static void *IsReadableThreadRoutine(void *data) { assert(data != NULL); +#ifndef HAVE_PTHREAD_CANCEL + struct sigaction actions; + memset(&actions, 0, sizeof(actions)); + sigemptyset(&actions.sa_mask); + actions.sa_flags = 0; + actions.sa_handler = ThreadSignalHandler; + sigaction(SIGUSR2, &actions, NULL); +#endif + struct IsReadableThreadData *const thread_data = data; // Give main thread time to call pthread_cond_timedwait(3) @@ -9830,7 +9847,7 @@ static FnCallResult FnCallIsReadable(ARG_UNUSED EvalContext *const ctx, #ifdef HAVE_PTHREAD_CANCEL ret = pthread_cancel(thread_data.thread); #else - ret = pthread_kill(thread_data.thread, 0); + ret = pthread_kill(thread_data.thread, SIGUSR2); #endif if (ret != 0) { From 43949b17ef0291e74949cb8af85f45e4292215f3 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 29 Jul 2024 13:04:21 -0500 Subject: [PATCH 03/13] Updated INSTALL information about termux android environment Ticket: none Changelog: none --- INSTALL | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 632a6cb6bf..ec5a8c06e5 100644 --- a/INSTALL +++ b/INSTALL @@ -160,7 +160,8 @@ Note that in order for process promises to work you must install the procps pack * Termux (2020-04-24) pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml -./autogen.sh --without-pam +LDFLAGS='-landroid-glob' ./autogen.sh --without-pam +make && make install * OSX (2021-10-20) From 93a1ffc49b488ccdc31e8466e362cce6ed6bae29 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 29 Jul 2024 13:04:52 -0500 Subject: [PATCH 04/13] macro def'd out dbm_test_api due to use of lrand48_r() and friends on termux android platform, probably find an alternative or disable in Makefile.am instead --- libpromises/dbm_test_api.c | 2 ++ libpromises/dbm_test_api.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libpromises/dbm_test_api.c b/libpromises/dbm_test_api.c index def4d50b92..2d8f3d4007 100644 --- a/libpromises/dbm_test_api.c +++ b/libpromises/dbm_test_api.c @@ -22,6 +22,7 @@ included file COSL.txt. */ +#ifndef __ANDROID__ #include #include /* lrand48_r() */ #include /* usleep(), syscall()/gettid() */ @@ -735,3 +736,4 @@ void RemoveFilament(DBFilament *filament) free(filament); CloseDB(db); } +#endif /* not __ANDROID__ */ diff --git a/libpromises/dbm_test_api.h b/libpromises/dbm_test_api.h index ffda177d75..a6fe0ae63d 100644 --- a/libpromises/dbm_test_api.h +++ b/libpromises/dbm_test_api.h @@ -22,6 +22,7 @@ included file COSL.txt. */ +#ifndef __ANDROID__ #ifndef CFENGINE_DBM_TEST_API_H #define CFENGINE_DBM_TEST_API_H @@ -55,3 +56,4 @@ DBFilament *FillUpDB(dbid db_id, int usage_pct); void RemoveFilament(DBFilament *filament); #endif /* CFENGINE_DBM_TEST_API_H */ +#endif /* not __ANDROID__ */ From cf29e54a7bf87f3cf7c484bb21d000984ca4fb6d Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Mon, 29 Jul 2024 13:05:24 -0500 Subject: [PATCH 05/13] Switch to using MaskTerminationSignalsInThread() and SIGHUP to fix compilation in Termux environment Ticket: CFE-4401 Changelog: title --- libpromises/evalfunction.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpromises/evalfunction.c b/libpromises/evalfunction.c index 7e9fa4c364..d5f24b8d23 100644 --- a/libpromises/evalfunction.c +++ b/libpromises/evalfunction.c @@ -86,6 +86,7 @@ #include #include /* ThreadWait */ #include +#include /* MaskTerminationSignalsInThread */ #include @@ -9685,12 +9686,14 @@ static void *IsReadableThreadRoutine(void *data) assert(data != NULL); #ifndef HAVE_PTHREAD_CANCEL + MaskTerminationSignalsInThread(); struct sigaction actions; memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = ThreadSignalHandler; - sigaction(SIGUSR2, &actions, NULL); + sigaction(SIGHUP, &actions, NULL); + MaskTerminationSignalsInThread(); #endif struct IsReadableThreadData *const thread_data = data; From 76d2c42e13ea45aaac578e11bf46a8eed1e0d24d Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 11 Apr 2025 16:25:47 -0500 Subject: [PATCH 06/13] Fixed check for copy_file_range on Android AC_CHECK_FUNCS apparently doesn't take into account the __ANDROID_API__ level properly and so incorrectly determines that copy_file_range is available for termux at API 24 but copy_file_range is <= 34. Ticket: none Changelog: none --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index aaee0a1d6c..d695a44f95 100644 --- a/configure.ac +++ b/configure.ac @@ -1358,7 +1358,7 @@ AC_CHECK_DECLS([FALLOC_FL_PUNCH_HOLE], [], [], [ ]) AC_CHECK_HEADERS([sys/sendfile.h]) AC_CHECK_FUNCS([sendfile]) -AC_CHECK_FUNCS([copy_file_range]) +AC_CHECK_DECL([copy_file_range]) dnl ####################################################################### From f28e7b29e97d5865b2890fb4e5fc41e696d87fa4 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 10 Oct 2025 11:41:30 -0400 Subject: [PATCH 07/13] Added Termux Linux Environment (Android) for sys.os_name_human We already supported and included the termux class. This change removes noise when running components like cf-agent. Ticket: CFE-4427 Changelog: title --- libenv/sysinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libenv/sysinfo.c b/libenv/sysinfo.c index 16f44c70e2..ddb4266094 100644 --- a/libenv/sysinfo.c +++ b/libenv/sysinfo.c @@ -3809,6 +3809,12 @@ static void SysOSNameHuman(EvalContext *ctx) "Alpine", CF_DATA_TYPE_STRING, "source=agent,derived-from=alpine"); } + else if (EvalContextClassGet(ctx, NULL, "termux") != NULL) + { + EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, lval, + "Termux", CF_DATA_TYPE_STRING, + "source=agent,derived-from=termux"); + } else if (EvalContextClassGet(ctx, NULL, "gentoo") != NULL) { EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS, lval, From 40653af477245bdb5b7e08964882ff782db7dd07 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 10 Oct 2025 14:17:49 -0500 Subject: [PATCH 08/13] Replaced egrep and grep with grep -E and grep -F in testall script Ticket: none Changelog: none --- tests/acceptance/testall | 62 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/acceptance/testall b/tests/acceptance/testall index 0959688b33..1630c5ad76 100755 --- a/tests/acceptance/testall +++ b/tests/acceptance/testall @@ -285,9 +285,9 @@ workdir() { } # Example: fgrepvar 'word' VARNAME -# Silent fgrep for variables: search for "word" in $VARNAME -fgrepvar() { - eval echo \$$2 | fgrep "$1" > /dev/null +# Silent grep -F for variables: search for "word" in $VARNAME +fgrepvar(){ + eval echo \$$2 | grep -F "$1" > /dev/null } # Same but instead of word search for a regex @@ -524,22 +524,22 @@ export CFENGINE_TEST_OVERRIDE_WORKDIR TEMP CFENGINE_TEST_OVERRIDE_EXTENSION_LIBR echo "Return code is $RETVAL." >> "$WORKDIR/$LOG" # Try to collect test metadata if any - if egrep "R: test description: " $OUTFILE > /dev/null + if grep -E "R: test description: " $OUTFILE > /dev/null then - TEST_DESCRIPTION="$(egrep "R: test description" $OUTFILE | sed -e "s,.*test description: \([A-Za-z0-9_]*\),\1,")" + TEST_DESCRIPTION="$(grep -E "R: test description" $OUTFILE | sed -e "s,.*test description: \([A-Za-z0-9_]*\),\1,")" fi - if egrep -e "R: test story_id: " $OUTFILE > /dev/null + if grep -E -e "R: test story_id: " $OUTFILE > /dev/null then - TEST_STORY="$(egrep "R: test story_id" $OUTFILE | sed -e "s,.*test story_id: \([0-9][0-9]*\),\1,")" + TEST_STORY="$(grep -E "R: test story_id" $OUTFILE | sed -e "s,.*test story_id: \([0-9][0-9]*\),\1,")" fi - if egrep -e "R: test covers: " $OUTFILE > /dev/null + if grep -E -e "R: test covers: " $OUTFILE > /dev/null then - TEST_COVERS="$(egrep "R: test covers" $OUTFILE | sed -e "s,.*test covers: \([A-Za-z0-9_]*\),\1,")" + TEST_COVERS="$(grep -E "R: test covers" $OUTFILE | sed -e "s,.*test covers: \([A-Za-z0-9_]*\),\1,")" fi if [ $TEST_TYPE = errorexit ] then - if [ $RETVAL -gt 0 ] && [ $RETVAL -lt 128 ] && egrep "error:|aborted on defined class" $OUTFILE > /dev/null + if [ $RETVAL -gt 0 ] && [ $RETVAL -lt 128 ] && grep -E "error:|aborted on defined class" $OUTFILE > /dev/null then RESULT=Pass RESULT_MSG="${COLOR_SUCCESS}Pass${COLOR_NORMAL}" @@ -557,7 +557,7 @@ export CFENGINE_TEST_OVERRIDE_WORKDIR TEMP CFENGINE_TEST_OVERRIDE_EXTENSION_LIBR then RESULT=FAIL RESULT_MSG="${COLOR_FAILURE}FAIL (NON-ZERO EXIT CODE!)${COLOR_NORMAL}" - elif fgrep 'error: ' "$OUTFILE" > /dev/null + elif grep -F 'error: ' "$OUTFILE" > /dev/null then RESULT=Pass RESULT_MSG="${COLOR_SUCCESS}Pass${COLOR_NORMAL}" @@ -575,21 +575,21 @@ export CFENGINE_TEST_OVERRIDE_WORKDIR TEMP CFENGINE_TEST_OVERRIDE_EXTENSION_LIBR # Some states are output by dcs.sub.cf, therefore check for both TEST # prefix and dcs.sub.cf prefix. ESCAPED_TEST="$(echo "($TEST|dcs.sub.cf)" | sed -e 's/\./\\./g')" - if egrep "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE > /dev/null && ! egrep "R: .*$ESCAPED_TEST Wait/" $OUTFILE > /dev/null + if grep -E "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE > /dev/null && ! grep -E "R: .*$ESCAPED_TEST Wait/" $OUTFILE > /dev/null then # Check for passed outcome, which should not happen. - if egrep "R: .*$ESCAPED_TEST " $OUTFILE | egrep "R: .*$ESCAPED_TEST Pass" > /dev/null + if grep -E "R: .*$ESCAPED_TEST " $OUTFILE | grep -E "R: .*$ESCAPED_TEST Pass" > /dev/null then RESULT=FAIL RESULT_MSG="${COLOR_FAILURE}FAIL (The test Passed, but failure was expected)${COLOR_NORMAL}" - elif egrep "R: .*$ESCAPED_TEST " $OUTFILE | egrep -v "R: .*$ESCAPED_TEST [XS]?FAIL" > /dev/null + elif grep -E "R: .*$ESCAPED_TEST " $OUTFILE | grep -E -v "R: .*$ESCAPED_TEST [XS]?FAIL" > /dev/null then # Other test case outcomes than fail. Should not happen. RESULT=FAIL RESULT_MSG="${COLOR_FAILURE}FAIL (Failure was expected, but the test had an unexpected test outcome, check test output, Pass/FAIL need to match exactly)${COLOR_NORMAL}" else - TICKET="$(egrep "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE | sed -e "s,.*[XS]FAIL/\(.*\),\1,")" - RESULT="$(egrep "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE | sed -e "s,.*\([XS]FAIL\).*,\1,")" + TICKET="$(grep -E "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE | sed -e "s,.*[XS]FAIL/\(.*\),\1,")" + RESULT="$(grep -E "R: .*$ESCAPED_TEST [XS]FAIL" $OUTFILE | sed -e "s,.*\([XS]FAIL\).*,\1,")" if [ "$RESULT" = "XFAIL" ] then RESULT_MSG="${COLOR_WARNING}FAIL (Suppressed, $TICKET)${COLOR_NORMAL}" @@ -600,38 +600,38 @@ export CFENGINE_TEST_OVERRIDE_WORKDIR TEMP CFENGINE_TEST_OVERRIDE_EXTENSION_LIBR elif [ $RETVAL -ne 0 ] then RESULT=FAIL - elif egrep "R: .*$ESCAPED_TEST FAIL/no_ticket_number" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST FAIL/no_ticket_number" $OUTFILE > /dev/null then RESULT=FAIL RESULT_MSG="${COLOR_FAILURE}FAIL (Tried to suppress failure, but no issue number is provided)${COLOR_NORMAL}" - elif egrep "R: .*$ESCAPED_TEST Wait/[0-9]+" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST Wait/[0-9]+" $OUTFILE > /dev/null then if [ -z "$NEXT_TIMEOUT_VAR" ] then RESULT=FAIL RESULT_MSG="${COLOR_FAILURE}FAIL (Test tried to wait but is not in \"timed\" directory)${COLOR_NORMAL}" else - WAIT_TIME=$(egrep "R: .*$ESCAPED_TEST Wait/[0-9]+" $OUTFILE | sed -e 's,.*Wait/\([0-9][0-9]*\).*,\1,') + WAIT_TIME=$(grep -E "R: .*$ESCAPED_TEST Wait/[0-9]+" $OUTFILE | sed -e 's,.*Wait/\([0-9][0-9]*\).*,\1,') eval $NEXT_TIMEOUT_VAR=$(($TEST_END_TIME+$WAIT_TIME)) RESULT=Wait RESULT_MSG="Awaiting ($WAIT_TIME seconds)..." fi - elif egrep "R: .*$ESCAPED_TEST Pass" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST Pass" $OUTFILE > /dev/null then RESULT=Pass RESULT_MSG="${COLOR_SUCCESS}Pass${COLOR_NORMAL}" - elif egrep "R: .*$ESCAPED_TEST Skip/unsupported" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST Skip/unsupported" $OUTFILE > /dev/null then RESULT=Skip RESULT_MSG="${COLOR_WARNING}Skipped (No platform support)${COLOR_NORMAL}" - elif egrep "R: .*$ESCAPED_TEST Skip/needs_work" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST Skip/needs_work" $OUTFILE > /dev/null then RESULT=Skip RESULT_MSG="${COLOR_WARNING}Skipped (Test needs work)${COLOR_NORMAL}" - elif egrep "R: .*$ESCAPED_TEST FLAKEY" $OUTFILE > /dev/null + elif grep -E "R: .*$ESCAPED_TEST FLAKEY" $OUTFILE > /dev/null then RESULT=FLAKEY - TICKET="$(egrep "R: .*$ESCAPED_TEST FLAKEY" $OUTFILE | sed -e "s,.*FLAKEY/\(.*\),\1,")" + TICKET="$(grep -E "R: .*$ESCAPED_TEST FLAKEY" $OUTFILE | sed -e "s,.*FLAKEY/\(.*\),\1,")" RESULT_MSG="${COLOR_WARNING}Flakey fail ($TICKET)${COLOR_NORMAL}" else @@ -1075,7 +1075,7 @@ fi for addtest in $ALL_TESTS do - if echo "$addtest" | fgrep "/timed/" > /dev/null + if echo "$addtest" | grep -F "/timed/" > /dev/null then if [ "$TIMED_TESTS" = 1 ] then @@ -1133,12 +1133,12 @@ print_header() { print_footer() { # Recalculate results since sub invocations may not have been recorded. - PASSED_TESTS=`egrep '^Pass ' $SUMMARY | wc -l | tr -d ' '` - FAILED_TESTS=`egrep '^(FAIL|XFAIL) ' $SUMMARY | wc -l | tr -d ' '` - SUPPRESSED_FAILURES=`egrep '^XFAIL ' $SUMMARY | wc -l | tr -d ' '` - SOFT_FAILURES=`egrep '^SFAIL ' $SUMMARY | wc -l | tr -d ' '` - FLAKEY_FAILURES=`egrep '^FLAKEY ' $SUMMARY | wc -l | tr -d ' '` - SKIPPED_TESTS=`egrep '^Skip ' $SUMMARY | wc -l | tr -d ' '` + PASSED_TESTS=`grep -E '^Pass ' $SUMMARY | wc -l | tr -d ' '` + FAILED_TESTS=`grep -E '^(FAIL|XFAIL) ' $SUMMARY | wc -l | tr -d ' '` + SUPPRESSED_FAILURES=`grep -E '^XFAIL ' $SUMMARY | wc -l | tr -d ' '` + SOFT_FAILURES=`grep -E '^SFAIL ' $SUMMARY | wc -l | tr -d ' '` + FLAKEY_FAILURES=`grep -E '^FLAKEY ' $SUMMARY | wc -l | tr -d ' '` + SKIPPED_TESTS=`grep -E '^Skip ' $SUMMARY | wc -l | tr -d ' '` ( echo echo ====================================================================== From 48b770b857c4c151f371037f320d82cbc2e449de Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 10 Oct 2025 14:26:00 -0500 Subject: [PATCH 09/13] Adjusted termux install instructions to be more accurate Ticket: none Changelog: none --- INSTALL | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index ec5a8c06e5..52b2a8e118 100644 --- a/INSTALL +++ b/INSTALL @@ -157,10 +157,11 @@ sudo apk add alpine-sdk lmdb-dev openssl-dev bison flex-dev acl-dev pcre2-dev au Note that in order for process promises to work you must install the procps package for a "proper" ps command instead of busybox. -* Termux (2020-04-24) +* Termux (2025-10-10) -pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml -LDFLAGS='-landroid-glob' ./autogen.sh --without-pam +pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml binutils librsync +# maybe binutils-is-llvm - Use llvm as binutils instead of binutils to get ld +LDFLAGS='-landroid-glob' ./autogen.sh --without-pam --prefix=$PREFIX --with-workdir=$PREFIX/var/lib/cfengine --without-systemd-service --without-selinux-policy make && make install * OSX (2021-10-20) From e28dd477bf0dfdf7c9d6d34861ae7fa26c3736da Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 13 Feb 2026 17:31:49 -0600 Subject: [PATCH 10/13] Adjusted dbm_test_api.c to build on alpine linux with musl libc The re-entrant versions of srand() and friends aren't technically required and not using them enables compilation on platforms without glibc. Ticket: none Changelog: none --- libpromises/dbm_test_api.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libpromises/dbm_test_api.c b/libpromises/dbm_test_api.c index 2d8f3d4007..0ea5ba94e7 100644 --- a/libpromises/dbm_test_api.c +++ b/libpromises/dbm_test_api.c @@ -24,7 +24,7 @@ #ifndef __ANDROID__ #include -#include /* lrand48_r() */ +#include /* lrand48() */ #include /* usleep(), syscall()/gettid() */ #include /* xstrndup() */ #include @@ -71,23 +71,22 @@ static void DBItemDestroy(DBItem *item) } } -static __thread struct drand48_data rng_data; static void InitializeRNG(long int seed) { - srand48_r(seed, &rng_data); + srand48(seed); } static long GetRandomNumber(long limit) { long rnd_val; - lrand48_r(&rng_data, &rnd_val); /* generates a value in the [0, 2^31) interval */ + rnd_val = lrand48(); const long random_max = ((0x80000000 - 1) / limit) * limit; while (rnd_val > random_max) { /* got a bad value past the greatest multiple of the limit interval, * retry (see "modulo bias" if this is unclear) */ - lrand48_r(&rng_data, &rnd_val); + rnd_val = lrand48(); } return rnd_val % limit; } From 312bf2345e143e2d4981afa13015cb4edca1d476 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 5 May 2026 15:00:17 -0500 Subject: [PATCH 11/13] Adjusted ci/ configure, build and install scripts for termux platform Ticket: none Changelog: none --- ci/build.sh | 5 ++++- ci/configure.sh | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 3bd306e6e8..3e47dfc761 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -5,7 +5,10 @@ set -ex thisdir="$(dirname "$0")" cd "$thisdir"/.. -source /etc/os-release +if [ -f /etc/os-release ]; then + source /etc/os-release +fi + CFLAGS="-Wall" if [ "$ID" != "alpine" ]; then CFLAGS="$CFLAGS -Werror" diff --git a/ci/configure.sh b/ci/configure.sh index dc66f9f7ed..1fb59385e5 100755 --- a/ci/configure.sh +++ b/ci/configure.sh @@ -6,13 +6,22 @@ thisdir="$(dirname "$0")" cd "$thisdir"/.. OPTS="--enable-debug" -source /etc/os-release -if [ "$ID" = "alpine" ]; then - OPTS="" # we don't want --enable-debug so that libpromises/dbm_test_api is not built due to lack of srand48_r() and friends on alpine linux libmusl +if [ -f /etc/os-release ]; then + source /etc/os-release + if [ "$ID" = "alpine" ]; then + OPTS="" # we don't want --enable-debug so that libpromises/dbm_test_api is not built due to lack of srand48_r() and friends on alpine linux libmusl + fi fi if [ -n "$TERMUX_VERSION" ] || [ "$ID" = "alpine" ]; then OPTS="$OPTS --without-pam" fi +if [ -n "$TERMUX_VERSION" ]; then + export LDFLAGS+=" -landroid-glob" + OPTS="$OPTS --prefix=$PREFIX\ + --with-workdir=$PREFIX/var/lib/cfengine \ + --without-selinux-policy \ + --without-systemd-service" +fi ./autogen.sh $OPTS From a7739cf9c1bb7daa32c4d8b1d00f2601d4762e04 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 12 May 2026 13:12:15 -0500 Subject: [PATCH 12/13] Bumped libntech to latest To include MaskTerminationSignalsThread() function now merged there which is required by commits in this pull request. Ticket: CFE-4401 Changelog: none --- libntech | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntech b/libntech index 3e7866b5d3..b0ea745cdd 160000 --- a/libntech +++ b/libntech @@ -1 +1 @@ -Subproject commit 3e7866b5d393b200a814ff5def7550ca18732ec0 +Subproject commit b0ea745cdddb4f8b12cc9709cebbe7a222d1db9e From aee4d94b3fb996af0311d79d1a60dfef408317fb Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Tue, 12 May 2026 13:49:24 -0500 Subject: [PATCH 13/13] Added --config-cache option to ci/configure.sh to enable faster configures Ticket: none Changelog: none --- ci/configure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/configure.sh b/ci/configure.sh index 1fb59385e5..e47d02b6e1 100755 --- a/ci/configure.sh +++ b/ci/configure.sh @@ -4,7 +4,7 @@ set -ex thisdir="$(dirname "$0")" cd "$thisdir"/.. -OPTS="--enable-debug" +OPTS="--config-cache --enable-debug" if [ -f /etc/os-release ]; then source /etc/os-release