Skip to content

Instantly share code, notes, and snippets.

@Kokan
Created February 18, 2020 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kokan/a4ac2103d156d44a3ea7e866b08a4474 to your computer and use it in GitHub Desktop.
Save Kokan/a4ac2103d156d44a3ea7e866b08a4474 to your computer and use it in GitHub Desktop.
diff --git a/modules/secure-logging/CMakeLists.txt b/modules/secure-logging/CMakeLists.txt
index 3a9d8abcd..7c0fbe3b7 100644
--- a/modules/secure-logging/CMakeLists.txt
+++ b/modules/secure-logging/CMakeLists.txt
@@ -12,5 +12,9 @@ if (OPENSSL_FOUND)
install(TARGETS secure-logging LIBRARY DESTINATION lib/syslog-ng/ COMPONENT secure-logging)
+ add_subdirectory(slogimport)
+ add_subdirectory(slogkey)
+ add_subdirectory(slogverify)
+
add_test_subdirectory(tests)
endif()
diff --git a/modules/secure-logging/slogimport/CMakeLists.txt b/modules/secure-logging/slogimport/CMakeLists.txt
index ea855c2df..e9d74a269 100644
--- a/modules/secure-logging/slogimport/CMakeLists.txt
+++ b/modules/secure-logging/slogimport/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogimport slogimport.c)
-target_link_libraries(slogimport eventlog)
+target_link_libraries(slogimport eventlog syslog-ng)
set_target_properties(slogimport PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogimport RUNTIME DESTINATION bin)
diff --git a/modules/secure-logging/slogkey/CMakeLists.txt b/modules/secure-logging/slogkey/CMakeLists.txt
index 287bd54b3..1920e57d7 100644
--- a/modules/secure-logging/slogkey/CMakeLists.txt
+++ b/modules/secure-logging/slogkey/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogkey slogkey.c)
-target_link_libraries(slogkey eventlog)
+target_link_libraries(slogkey eventlog syslog-ng)
set_target_properties(slogkey PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogkey RUNTIME DESTINATION bin)
diff --git a/modules/secure-logging/slogverify/CMakeLists.txt b/modules/secure-logging/slogverify/CMakeLists.txt
index acd176ac7..91c031a3f 100644
--- a/modules/secure-logging/slogverify/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogverify slogverify.c)
-target_link_libraries(slogverify eventlog)
+target_link_libraries(slogverify eventlog syslog-ng)
set_target_properties(slogverify PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogverify RUNTIME DESTINATION bin)
diff --git a/modules/secure-logging/tests/CMakeLists.txt b/modules/secure-logging/tests/CMakeLists.txt
index 314483864..1533b2422 100644
--- a/modules/secure-logging/tests/CMakeLists.txt
+++ b/modules/secure-logging/tests/CMakeLists.txt
@@ -1 +1 @@
-add_unit_test(LIBTEST CRITERION TARGET test_secure_logging DEPENDS secure_logging)
+add_unit_test(LIBTEST CRITERION TARGET test_secure_logging DEPENDS secure-logging)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index e712766eb..cf49911df 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -195,7 +195,6 @@ set(LIB_SOURCES
logwriter.c
mainloop.c
signal-handler.c
- slog.c
mainloop-call.c
mainloop-worker.c
mainloop-io-worker.c
diff --git a/modules/secure-logging/CMakeLists.txt b/modules/secure-logging/CMakeLists.txt
index 7c0fbe3b7..577391d83 100644
--- a/modules/secure-logging/CMakeLists.txt
+++ b/modules/secure-logging/CMakeLists.txt
@@ -1,12 +1,14 @@
set (SECURE_LOGGING_SOURCES
secure-logging.c
+ slog.c
+ slog.h
)
find_package(OpenSSL)
if (OPENSSL_FOUND)
add_library(secure-logging SHARED ${SECURE_LOGGING_SOURCES})
- target_include_directories (secure-logging PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+ target_include_directories (secure-logging PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (secure-logging PRIVATE SYSTEM ${OPENSSL_INCLUDE_DIR})
target_link_libraries(secure-logging PRIVATE syslog-ng ${OPENSSL_LIBRARIES})
diff --git a/lib/slog.c b/modules/secure-logging/slog.c
similarity index 100%
rename from lib/slog.c
rename to modules/secure-logging/slog.c
diff --git a/lib/slog.h b/modules/secure-logging/slog.h
similarity index 96%
rename from lib/slog.h
rename to modules/secure-logging/slog.h
index e7682f4d0..ecbcc0b12 100644
--- a/lib/slog.h
+++ b/modules/secure-logging/slog.h
@@ -48,9 +48,9 @@
#define CUTSTRING "###CUT###"
// This initialization only works with GCC.
-unsigned char KEYPATTERN[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = IPAD };
-unsigned char MACPATTERN[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = OPAD };
-unsigned char GAMMA[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = EPAD};
+static unsigned char KEYPATTERN[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = IPAD };
+static unsigned char MACPATTERN[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = OPAD };
+static unsigned char GAMMA[AES_BLOCKSIZE] = { [0 ... (AES_BLOCKSIZE-1) ] = EPAD};
// Dump contents of an array on STDOUT, byte by byte, converting to hex.
diff --git a/modules/secure-logging/slogimport/CMakeLists.txt b/modules/secure-logging/slogimport/CMakeLists.txt
index e9d74a269..cdd8775b9 100644
--- a/modules/secure-logging/slogimport/CMakeLists.txt
+++ b/modules/secure-logging/slogimport/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogimport slogimport.c)
-target_link_libraries(slogimport eventlog syslog-ng)
+target_link_libraries(slogimport eventlog syslog-ng secure-logging)
set_target_properties(slogimport PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogimport RUNTIME DESTINATION bin)
diff --git a/modules/secure-logging/slogkey/CMakeLists.txt b/modules/secure-logging/slogkey/CMakeLists.txt
index 1920e57d7..1a0a99672 100644
--- a/modules/secure-logging/slogkey/CMakeLists.txt
+++ b/modules/secure-logging/slogkey/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogkey slogkey.c)
-target_link_libraries(slogkey eventlog syslog-ng)
+target_link_libraries(slogkey eventlog syslog-ng secure-logging)
set_target_properties(slogkey PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogkey RUNTIME DESTINATION bin)
diff --git a/modules/secure-logging/slogverify/CMakeLists.txt b/modules/secure-logging/slogverify/CMakeLists.txt
index 91c031a3f..71a9e7fe6 100644
--- a/modules/secure-logging/slogverify/CMakeLists.txt
+++ b/modules/secure-logging/slogverify/CMakeLists.txt
@@ -1,5 +1,5 @@
add_executable(slogverify slogverify.c)
-target_link_libraries(slogverify eventlog syslog-ng)
+target_link_libraries(slogverify eventlog syslog-ng secure-logging)
set_target_properties(slogverify PROPERTIES COMPILE_FLAGS "-Wno-pointer-sign")
install(TARGETS slogverify RUNTIME DESTINATION bin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment