AC_SEARCH_LIBS([X509_get_version], [crypto], [],
[AC_MSG_ERROR([unable to find the X509_get_version() function])]
)
-AC_SEARCH_LIBS([backtrace],[execinfo],[],
- [AC_MSG_ERROR([unable to find backtrace() function])]
+
+AC_SEARCH_LIBS([backtrace],[execinfo],
+ [have_backtrace="yes"],
+ [have_backtrace="no"]
)
+AM_CONDITIONAL([BACKTRACE_ENABLED], [test "x$have_backtrace" != "xno"])
# Dependencies managed by pkg-config
# By the way: Apparently PKG_CHECK_MODULES is poor practice now. I can't tell;
{% highlight bash %}
su
-apk add build-base autoconf automake pkgconfig openssl openssl-dev jansson jansson-dev bsd-compat-headers rsync libexecinfo libexecinfo-dev libxml2 libxml2-dev libcurl curl-dev
+apk add build-base autoconf automake pkgconfig openssl-dev jansson-dev curl-dev libxml2-dev bsd-compat-headers rsync
exit
wget https://github.com/NICMx/FORT-validator/releases/download/{{ site.fort-latest-version }}/fort-{{ site.fort-latest-version }}.tar.gz
# Feel free to temporarily remove this one if you're not using gcc 7.3.0.
#fort_CFLAGS += $(GCC_WARNS)
fort_CFLAGS += -std=gnu11 -O2 -g $(FORT_FLAGS) ${XML2_CFLAGS}
+if BACKTRACE_ENABLED
+fort_CFLAGS += -DBACKTRACE_ENABLED
+endif
fort_LDFLAGS = $(LDFLAGS_DEBUG)
fort_LDADD = ${JANSSON_LIBS} ${CURL_LIBS} ${XML2_LIBS}
#include "log.h"
+#ifdef BACKTRACE_ENABLED
#include <execinfo.h>
+#endif
+
#include <openssl/bio.h>
#include <openssl/err.h>
#include <pthread.h>
void
print_stack_trace(char const *title)
{
+#ifdef BACKTRACE_ENABLED
#define STACK_SIZE 64
void *array[STACK_SIZE];
}
free(strings);
+#endif /* BACKTRACE_ENABLED */
}
static void init_config(struct log_config *cfg, bool unit_tests)
cfg->facility = LOG_DAEMON;
}
+#ifdef BACKTRACE_ENABLED
+
static void
sigsegv_handler(int signum)
{
kill(getpid(), signum);
}
+#endif
+
/*
* Register better handlers for some signals.
*
static void
register_signal_handlers(void)
{
+#ifdef BACKTRACE_ENABLED
struct sigaction action;
void* dummy;
pr_op_err("SIGSEGV handler registration failure: %s",
strerror(errno));
}
+#endif
/*
* SIGPIPE can be triggered by any I/O function. libcurl is particularly