diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b38d7e862f..951b07c16f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -60,7 +60,6 @@ jobs: --disable-smtp --disable-java --disable-java-modules - --disable-mqtt --disable-pacct " CMAKE_CONFIGURE_FLAGS=" @@ -74,7 +73,6 @@ jobs: -DENABLE_GRPC=OFF -DENABLE_JAVA=OFF -DENABLE_JAVA_MODULES=OFF - -DENABLE_MQTT=OFF -DENABLE_PACCT=OFF " PATH="${HOMEBREW_PREFIX}/opt/bison/bin:${HOMEBREW_PREFIX}/opt/libnet/bin:${HOMEBREW_PREFIX}/opt/net-snmp/bin:${HOMEBREW_PREFIX}/bin:${HOMEBREW_PREFIX}/sbin:${PYTHONUSERBASE}/bin:${PATH}" diff --git a/CMakeLists.txt b/CMakeLists.txt index ec485f87af..683a8d1ac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,19 @@ project(axosyslog C) option(ENABLE_CPP "Enable C++" ON) +if (ENABLE_CPP) + enable_language(CXX) + set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard") + set(CMAKE_CXX_STANDARD_REQUIRED OFF CACHE BOOL "C++ standard is a requirement") + set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "C++ compiler specific extensions") + set(SYSLOG_NG_ENABLE_CPP ${ENABLE_CPP}) +endif() + if(APPLE) + option(ENABLE_OBJC "Enable OSLog" ENABLE_DARWIN_OSL) +endif() + +if(ENABLE_OBJC) # Turned out that even the latest gcc has no proper support of the required ObjC version # Once gcc was able to compile our ObjC modules properly this requirement could be removed again set(CMAKE_OBJC_COMPILER clang) @@ -27,14 +39,6 @@ if(APPLE) set_property(GLOBAL PROPERTY OBJC_STANDARD_REQUIRED ON) endif() -if (ENABLE_CPP) - enable_language(CXX) - set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard") - set(CMAKE_CXX_STANDARD_REQUIRED OFF CACHE BOOL "C++ standard is a requirement") - set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "C++ compiler specific extensions") - set(SYSLOG_NG_ENABLE_CPP ${ENABLE_CPP}) -endif() - set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${PROJECT_SOURCE_DIR}/cmake/) set(CMAKE_POSITION_INDEPENDENT_CODE 1) set(BISON_FLAGS "-Wno-other -Werror=conflicts-sr -Werror=conflicts-rr -Wcounterexamples") @@ -142,10 +146,6 @@ if (HAVE_TCP_KEEPIDLE AND HAVE_TCP_KEEPINTVL AND HAVE_TCP_KEEPCNT) set(SYSLOG_NG_HAVE_TCP_KEEPALIVE_TIMERS 1) endif() -if (NOT APPLE) - set(SYSLOG_NG_HAVE_ENVIRON 1) -endif() - option(ENV_LD_LIBRARY_PATH "Set LD_LIBRARY_PATH during runtime to the value given" "") if (ENV_LD_LIBRARY_PATH) set(SYSLOG_NG_ENABLE_ENV_WRAPPER 1) diff --git a/configure.ac b/configure.ac index 77c362ec27..b245efe83d 100644 --- a/configure.ac +++ b/configure.ac @@ -860,10 +860,6 @@ if test "x$blb_cv_keepcaps" = "xyes"; then AC_DEFINE(HAVE_PR_SET_KEEPCAPS, 1, [have PR_SET_KEEPCAPS]) fi -if test "$ostype" != "Darwin" ; then - AC_DEFINE(HAVE_ENVIRON, [1], [Specifies whether the environ global variable exists]) -fi - AC_CACHE_CHECK(for modern utmp, blb_cv_c_modern_utmp, [AC_TRY_COMPILE([ diff --git a/contrib/Brewfile b/contrib/Brewfile index a9797418d2..9c328124ef 100644 --- a/contrib/Brewfile +++ b/contrib/Brewfile @@ -10,7 +10,7 @@ brew "ivykis" brew "json-c" brew "libtool" brew "openssl@3" -brew "pcre" +brew "pcre2" brew "pkg-config" brew "curl" @@ -25,6 +25,7 @@ brew "net-snmp" brew "python@3", link: true, force: true brew "rabbitmq-c" brew "riemann-client" +brew "libpaho-mqtt" brew "grpc" diff --git a/lib/compat/CMakeLists.txt b/lib/compat/CMakeLists.txt index f8071833e9..8beee2b923 100644 --- a/lib/compat/CMakeLists.txt +++ b/lib/compat/CMakeLists.txt @@ -18,6 +18,7 @@ set(COMPAT_HEADERS compat/cpp-end.h compat/curl.h compat/json.h + compat/inttypes.h PARENT_SCOPE) set(COMPAT_SOURCES diff --git a/lib/compat/Makefile.am b/lib/compat/Makefile.am index 879436a247..8582efd811 100644 --- a/lib/compat/Makefile.am +++ b/lib/compat/Makefile.am @@ -22,7 +22,8 @@ compatinclude_HEADERS = \ lib/compat/un.h \ lib/compat/cpp-start.h \ lib/compat/cpp-end.h \ - lib/compat/curl.h + lib/compat/curl.h \ + lib/compat/inttypes.h compat_sources = \ lib/compat/getutent.c \ diff --git a/lib/compat/inttypes.h b/lib/compat/inttypes.h new file mode 100644 index 0000000000..3fe37c864d --- /dev/null +++ b/lib/compat/inttypes.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002-2014 Balabit + * Copyright (c) 2024 Sergey Fedorov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef COMPAT_INTTYPES_H_INCLUDED +#define COMPAT_INTTYPES_H_INCLUDED + +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif + +#include + +#endif diff --git a/lib/gprocess.c b/lib/gprocess.c index a07b371482..4ed3edec62 100644 --- a/lib/gprocess.c +++ b/lib/gprocess.c @@ -104,7 +104,10 @@ static gboolean stderr_present = TRUE; static int have_capsyslog = FALSE; static cap_value_t cap_syslog; #endif -#ifdef SYSLOG_NG_HAVE_ENVIRON +#ifdef __APPLE__ +#include +#define environ (*_NSGetEnviron()) +#else extern char **environ; #endif @@ -553,7 +556,6 @@ g_process_set_caps(const gchar *caps) void g_process_set_argv_space(gint argc, gchar **argv) { -#ifdef SYSLOG_NG_HAVE_ENVIRON gchar *lastargv = NULL; gchar **envp = environ; gint i; @@ -595,7 +597,6 @@ g_process_set_argv_space(gint argc, gchar **argv) for (i = 0; envp[i] != NULL; i++) environ[i] = g_strdup(envp[i]); environ[i] = NULL; -#endif } /** @@ -1132,7 +1133,6 @@ g_process_perform_startup(void) static void g_process_setproctitle(const gchar *proc_title) { -#ifdef SYSLOG_NG_HAVE_ENVIRON size_t len; g_assert(process_opts.argv_start != NULL); @@ -1140,7 +1140,6 @@ g_process_setproctitle(const gchar *proc_title) len = g_strlcpy(process_opts.argv_start, proc_title, process_opts.argv_env_len); for (; len < process_opts.argv_env_len; ++len) process_opts.argv_start[len] = SPT_PADCHAR; -#endif } @@ -1526,7 +1525,6 @@ g_process_startup_ok(void) void g_process_finish(void) { -#ifdef SYSLOG_NG_HAVE_ENVIRON /** * There is a memory leak for **environ and elements that should be * freed here theoretically. @@ -1548,7 +1546,6 @@ g_process_finish(void) * As this leak does not cause any real problem like accumulating over * time, it is safe to leave it as it is. */ -#endif g_process_remove_pidfile(); } diff --git a/modules/darwinosl/CMakeLists.txt b/modules/darwinosl/CMakeLists.txt index 93403a9f00..b62e85c290 100644 --- a/modules/darwinosl/CMakeLists.txt +++ b/modules/darwinosl/CMakeLists.txt @@ -1,4 +1,4 @@ -if(APPLE) +if(ENABLE_OBJC AND ENABLE_DARWIN_OSL) set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -fobjc-arc") # Take care, this must follow any compiler setting overrides! (e.g. set(CMAKE_OBJC_COMPILER clang) etc.) @@ -19,35 +19,37 @@ if(APPLE) ${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.h ) - include(CheckOBJCSourceCompiles) - - # TODO: Once gcc was able to compile our ObjC code correctly we should add here a more sopgisticated check - check_objc_source_compiles(" - #include - int main(int, char**) - { return 0; } - " HAVE_OSLLOG) - - module_switch(ENABLE_DARWIN_OSL "Enable Darwin OSLog source" HAVE_OSLLOG) - if(ENABLE_DARWIN_OSL) - generate_y_from_ym(modules/darwinosl/darwinosl-grammar) - - bison_target(DarwinOSLGrammar - ${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.y - ${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.c - COMPILE_FLAGS ${BISON_FLAGS}) - - add_module( - TARGET darwinosl - GRAMMAR darwinosl-grammar - SOURCES ${DARWINOSL_SOURCES} - ) - - target_link_libraries(darwinosl PRIVATE - "-framework Foundation" - "-framework OSLog" - ) - target_link_options(darwinosl PRIVATE -ObjC) + include(CheckOBJCSourceCompiles) + + # TODO: Once gcc was able to compile our ObjC code correctly we should add here a more sopgisticated check + check_objc_source_compiles(" + #include + int main(int, char**) + { return 0; } + " HAVE_OSLOG) + + if(HAVE_OSLOG) + generate_y_from_ym(modules/darwinosl/darwinosl-grammar) + + bison_target(DarwinOSLGrammar + ${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.y + ${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.c + COMPILE_FLAGS ${BISON_FLAGS}) + + add_module( + TARGET darwinosl + GRAMMAR darwinosl-grammar + SOURCES ${DARWINOSL_SOURCES} + ) + + target_link_libraries(darwinosl PRIVATE + "-framework Foundation" + "-framework OSLog" + ) + target_link_options(darwinosl PRIVATE -ObjC) + else() + message(STATUS "OSLog is not supported on this system") + endif() endif() endif() diff --git a/modules/geoip2/maxminddb-helper.c b/modules/geoip2/maxminddb-helper.c index 8c7b36ec9f..2c1c5bc58e 100644 --- a/modules/geoip2/maxminddb-helper.c +++ b/modules/geoip2/maxminddb-helper.c @@ -22,6 +22,7 @@ #include "maxminddb-helper.h" #include "scratch-buffers.h" +#include "compat/inttypes.h" #include #include diff --git a/modules/grpc/otel/otel-protobuf-formatter.cpp b/modules/grpc/otel/otel-protobuf-formatter.cpp index 3630c1873c..cd32626811 100644 --- a/modules/grpc/otel/otel-protobuf-formatter.cpp +++ b/modules/grpc/otel/otel-protobuf-formatter.cpp @@ -28,6 +28,7 @@ #include "value-pairs/value-pairs.h" #include "scanner/list-scanner/list-scanner.h" #include "compat/cpp-end.h" +#include "compat/inttypes.h" #include diff --git a/modules/grpc/otel/otel-protobuf-parser.cpp b/modules/grpc/otel/otel-protobuf-parser.cpp index 16776b4c4c..3b8928dd79 100644 --- a/modules/grpc/otel/otel-protobuf-parser.cpp +++ b/modules/grpc/otel/otel-protobuf-parser.cpp @@ -31,8 +31,7 @@ #include "str-repr/encode.h" #include "scratch-buffers.h" #include "compat/cpp-end.h" - -#include +#include "compat/inttypes.h" using namespace syslogng::grpc::otel; using namespace google::protobuf; diff --git a/packaging/debian/copyright b/packaging/debian/copyright index cce0398464..7a5ce73df2 100644 --- a/packaging/debian/copyright +++ b/packaging/debian/copyright @@ -84,6 +84,7 @@ Files: lib/cache.* lib/compat/socket.h lib/compat/string.h lib/compat/strtok_r.c + lib/compat/inttypes.h lib/control/control-server.* lib/control/control-server-unix.c lib/hostname.h