From 16323dcc9df15020e368d4324cf1c1d9dceac805 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 20 Jun 2016 20:57:25 +0200 Subject: build: Change install directories and set correct permissions This sets the correct install directories for all the binaries, library and header files. It also sets the right permissions on the sockets and shared memory so that regular users can also use the ouroboros library. Root privileges are required to run the irmd. Fixes #7 --- CMakeLists.txt | 10 ++++++---- compile_debug.sh | 2 +- compile_release.sh | 4 ++-- include/ouroboros/CMakeLists.txt | 2 +- include/ouroboros/sockets.h | 7 +++++-- install_debug.sh | 2 +- install_release.sh | 4 ++-- ouroboros.pc.in | 4 ++-- src/CMakeLists.txt | 2 +- src/dad/CMakeLists.txt | 24 ------------------------ src/dad/main.c | 10 ---------- src/dad/tests/CMakeLists.txt | 19 ------------------- src/ipcpd/local/CMakeLists.txt | 2 +- src/ipcpd/normal/CMakeLists.txt | 2 +- src/ipcpd/shim-eth-llc/CMakeLists.txt | 2 +- src/ipcpd/shim-udp/CMakeLists.txt | 2 +- src/irmd/CMakeLists.txt | 2 +- src/irmd/main.c | 28 +++++++++++++++++++++++++--- src/lib/CMakeLists.txt | 2 +- src/lib/ipcp.c | 6 ++---- src/lib/shm_ap_rbuff.c | 11 ++++++++++- src/lib/shm_du_map.c | 8 ++++++++ src/lib/sockets.c | 6 +++++- src/nsmd/CMakeLists.txt | 24 ++++++++++++++++++++++++ src/nsmd/main.c | 10 ++++++++++ src/nsmd/tests/CMakeLists.txt | 19 +++++++++++++++++++ src/tools/cbr/CMakeLists.txt | 2 +- src/tools/echo/CMakeLists.txt | 2 +- src/tools/irm/CMakeLists.txt | 2 +- 29 files changed, 133 insertions(+), 87 deletions(-) delete mode 100644 src/dad/CMakeLists.txt delete mode 100644 src/dad/main.c delete mode 100644 src/dad/tests/CMakeLists.txt create mode 100644 src/nsmd/CMakeLists.txt create mode 100644 src/nsmd/main.c create mode 100644 src/nsmd/tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d31262d..9875bd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,10 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${CMAKE_INSTALL_PREFIX}usr/lib" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib") ENDIF("${isSystemDir}" STREQUAL "-1") message(STATUS "Package name is: ${PACKAGE_NAME}") @@ -49,7 +50,7 @@ configure_file( "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc" - DESTINATION "lib/pkgconfig") + DESTINATION "usr/lib/pkgconfig") enable_testing() add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) @@ -71,7 +72,8 @@ set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY + "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") set(CPACK_GENERATOR "TGZ") set(CPACK_SOURCE_GENERATOR "TGZ") diff --git a/compile_debug.sh b/compile_debug.sh index 3ea1e039..9f7da176 100755 --- a/compile_debug.sh +++ b/compile_debug.sh @@ -4,7 +4,7 @@ ME=compile_debug if (($# == 1 )) then - PREFIX=`echo "$1"|sed -e "s,\/$,,"` + PREFIX=$1 else PREFIX="/usr/local/ouroboros" fi diff --git a/compile_release.sh b/compile_release.sh index 0dad6c91..d2400ec2 100755 --- a/compile_release.sh +++ b/compile_release.sh @@ -4,9 +4,9 @@ ME=compile_release if (($# == 1 )) then - PREFIX=`echo "$1"|sed -e "s,\/$,,"` + PREFIX=$1 else - PREFIX="/usr/local/ouroboros" + PREFIX="/" fi BUILDDIR=build diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index 245187e9..8347f928 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -14,4 +14,4 @@ set(HEADER_FILES time_utils.h ) -install(FILES ${HEADER_FILES} DESTINATION include/ouroboros) +install(FILES ${HEADER_FILES} DESTINATION usr/include/ouroboros) diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h index be5ae651..b765b55b 100644 --- a/include/ouroboros/sockets.h +++ b/include/ouroboros/sockets.h @@ -36,10 +36,13 @@ typedef IrmMsg irm_msg_t; #include "ipcpd_messages.pb-c.h" typedef IpcpMsg ipcp_msg_t; -#define IRM_SOCK_PATH "/tmp/irm_sock" +#define SOCK_PATH INSTALL_DIR "var/run/ouroboros/" +#define SOCK_PATH_SUFFIX ".sock" + +#define IRM_SOCK_PATH SOCK_PATH "irm" SOCK_PATH_SUFFIX #define IRM_MSG_BUF_SIZE 256 -#define IPCP_SOCK_PATH_PREFIX "/tmp/ipcp_sock" +#define IPCP_SOCK_PATH_PREFIX SOCK_PATH "ipcp" #define IPCP_MSG_BUF_SIZE IRM_MSG_BUF_SIZE /* Returns the full socket path of an IPCP */ diff --git a/install_debug.sh b/install_debug.sh index ef6b8a30..020677a0 100755 --- a/install_debug.sh +++ b/install_debug.sh @@ -4,7 +4,7 @@ ME=install_debug if (($# == 1 )) then - PREFIX=`echo "$1"|sed -e "s,\/$,,"` + PREFIX=$1 else PREFIX="/usr/local/ouroboros" fi diff --git a/install_release.sh b/install_release.sh index cbba45ff..383c3f9b 100755 --- a/install_release.sh +++ b/install_release.sh @@ -4,9 +4,9 @@ ME=install_release if (($# == 1 )) then - PREFIX=`echo "$1"|sed -e "s,\/$,,"` + PREFIX=$1 else - PREFIX="/usr" + PREFIX="/" fi BUILDDIR=build diff --git a/ouroboros.pc.in b/ouroboros.pc.in index b10ce9a4..44da4b91 100644 --- a/ouroboros.pc.in +++ b/ouroboros.pc.in @@ -1,7 +1,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=${exec_prefix}/usr/lib +includedir=${prefix}/usr/include Name: @PROJECT_NAME@ Description: @PACKAGE_DESCRIPTION@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0732f08..0037d437 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(ipcpd) add_subdirectory(irmd) -add_subdirectory(dad) +add_subdirectory(nsmd) add_subdirectory(lib) add_subdirectory(tools) diff --git a/src/dad/CMakeLists.txt b/src/dad/CMakeLists.txt deleted file mode 100644 index 1f9f4f42..00000000 --- a/src/dad/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -include_directories(${CMAKE_SOURCE_DIR}/include) -include_directories(${CMAKE_BINARY_DIR}/include) - -set(SOURCE_FILES - # Add source files here - main.c -) - -add_executable (dad ${SOURCE_FILES}) - -target_link_libraries (dad LINK_PUBLIC ouroboros) - -include(MacroAddCompileFlags) -if (CMAKE_BUILD_TYPE MATCHES Debug) - MACRO_ADD_COMPILE_FLAGS(dad -DCONFIG_OUROBOROS_DEBUG) -endif (CMAKE_BUILD_TYPE MATCHES Debug) - -install(TARGETS dad RUNTIME DESTINATION bin) - -# Enable once dad has tests -# add_subdirectory(tests) diff --git a/src/dad/main.c b/src/dad/main.c deleted file mode 100644 index e2971dca..00000000 --- a/src/dad/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#define OUROBOROS_PREFIX "da" - -#include - -int main() -{ - LOG_DBG("Test of the DA"); - - return 0; -} diff --git a/src/dad/tests/CMakeLists.txt b/src/dad/tests/CMakeLists.txt deleted file mode 100644 index 68bd762d..00000000 --- a/src/dad/tests/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -get_filename_component(tmp ".." ABSOLUTE) -get_filename_component(src_folder "${tmp}" NAME) - -create_test_sourcelist(${src_folder}_tests test_suite.c - # Add new tests here -) - -add_executable(${src_folder}_test EXCLUDE_FROM_ALL ${${src_folder}_tests}) -target_link_libraries(${src_folder}_test ouroboros) - -add_dependencies(check ${src_folder}_test) - -set(tests_to_run ${${src_folder}_tests}) -remove(tests_to_run test_suite.c) - -foreach(test ${tests_to_run}) - get_filename_component(test_name ${test} NAME_WE) - add_test(${test_name} ${C_TEST_PATH}/${src_folder}_test ${test_name}) -endforeach(test) diff --git a/src/ipcpd/local/CMakeLists.txt b/src/ipcpd/local/CMakeLists.txt index 4d05d474..cc19aad0 100644 --- a/src/ipcpd/local/CMakeLists.txt +++ b/src/ipcpd/local/CMakeLists.txt @@ -26,7 +26,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ipcpd-local -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS ipcpd-local RUNTIME DESTINATION bin) +install(TARGETS ipcpd-local RUNTIME DESTINATION sbin) # Enable once ipcp-local has tests # add_subdirectory(tests) diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index 58584e20..74bd19ec 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -28,7 +28,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ipcpd-normal -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS ipcpd-normal RUNTIME DESTINATION bin) +install(TARGETS ipcpd-normal RUNTIME DESTINATION sbin) # Enable once ipcp-normal has tests # add_subdirectory(tests) diff --git a/src/ipcpd/shim-eth-llc/CMakeLists.txt b/src/ipcpd/shim-eth-llc/CMakeLists.txt index 14441113..a3f96735 100644 --- a/src/ipcpd/shim-eth-llc/CMakeLists.txt +++ b/src/ipcpd/shim-eth-llc/CMakeLists.txt @@ -34,4 +34,4 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ipcpd-shim-eth-llc -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS ipcpd-shim-eth-llc RUNTIME DESTINATION bin) +install(TARGETS ipcpd-shim-eth-llc RUNTIME DESTINATION sbin) diff --git a/src/ipcpd/shim-udp/CMakeLists.txt b/src/ipcpd/shim-udp/CMakeLists.txt index 79d7b72f..6430661c 100644 --- a/src/ipcpd/shim-udp/CMakeLists.txt +++ b/src/ipcpd/shim-udp/CMakeLists.txt @@ -84,7 +84,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ipcpd-shim-udp -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS ipcpd-shim-udp RUNTIME DESTINATION bin) +install(TARGETS ipcpd-shim-udp RUNTIME DESTINATION sbin) # Enable once ipcp-shim-udp has tests # add_subdirectory(tests) diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt index 75d65ba3..a402b242 100644 --- a/src/irmd/CMakeLists.txt +++ b/src/irmd/CMakeLists.txt @@ -19,7 +19,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(irmd -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS irmd RUNTIME DESTINATION bin) +install(TARGETS irmd RUNTIME DESTINATION sbin) # Enable once irmd has tests # add_subdirectory(tests) diff --git a/src/irmd/main.c b/src/irmd/main.c index 7ad7a23a..68789e94 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -49,6 +49,7 @@ #include #include #include +#include #ifndef IRMD_MAX_FLOWS #define IRMD_MAX_FLOWS 4096 @@ -1571,11 +1572,13 @@ void * mainloop() static struct irm * irm_create() { + struct stat st = {0}; + struct irm * i = malloc(sizeof(*i)); if (i == NULL) return NULL; - if (access("/dev/shm/" SHM_DU_MAP_FILENAME, F_OK) != -1) { + if (access(INSTALL_DIR "dev/shm/" SHM_DU_MAP_FILENAME, F_OK) != -1) { struct shm_du_map * dum = shm_du_map_open(); if (dum == NULL) { LOG_ERR("Could not examine existing shm file."); @@ -1592,6 +1595,11 @@ static struct irm * irm_create() } } + if (rw_lock_init(&i->state_lock)) { + irm_destroy(i); + return NULL; + } + i->threadpool = malloc(sizeof(pthread_t) * IRMD_THREADPOOL_SIZE); if (i->threadpool == NULL) { irm_destroy(i); @@ -1613,13 +1621,22 @@ static struct irm * irm_create() return NULL; } + if (stat(SOCK_PATH, &st) == -1) { + if (mkdir(SOCK_PATH, 0777)) { + LOG_ERR("Failed to create sockets directory."); + irm_destroy(i); + return NULL; + } + } + i->sockfd = server_socket_open(IRM_SOCK_PATH); if (i->sockfd < 0) { irm_destroy(i); return NULL; } - if (rw_lock_init(&i->state_lock)) { + if (chmod(IRM_SOCK_PATH, 0666)) { + LOG_ERR("Failed to chmod socket."); irm_destroy(i); return NULL; } @@ -1643,6 +1660,11 @@ int main() int t = 0; + if (geteuid() != 0) { + LOG_ERR("IPC Resource Manager must be run as root."); + exit(EXIT_FAILURE); + } + /* init sig_act */ memset(&sig_act, 0, sizeof sig_act); @@ -1661,7 +1683,7 @@ int main() instance = irm_create(); if (instance == NULL) - return 1; + exit(EXIT_FAILURE); pthread_create(&instance->cleanup_flows, NULL, irm_flow_cleaner, NULL); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 796a0b7c..7db083b6 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -51,7 +51,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) MACRO_ADD_COMPILE_FLAGS(ouroboros -DCONFIG_OUROBOROS_DEBUG) endif (CMAKE_BUILD_TYPE MATCHES Debug) -install(TARGETS ouroboros LIBRARY DESTINATION lib) +install(TARGETS ouroboros LIBRARY DESTINATION usr/lib) target_include_directories(ouroboros PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index 89756235..fcaf9f83 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -105,7 +105,7 @@ pid_t ipcp_create(char * ipcp_name, pid_t pid = 0; char irmd_pid[10]; size_t len = 0; - char * ipcp_dir = "bin"; + char * ipcp_dir = "sbin/"; char * full_name = NULL; char * exec_name = NULL; @@ -135,7 +135,7 @@ pid_t ipcp_create(char * ipcp_name, len += strlen(INSTALL_DIR); len += strlen(ipcp_dir); len += strlen(exec_name); - len += 3; + len += 1; full_name = malloc(len + 1); if (full_name == NULL) { @@ -144,9 +144,7 @@ pid_t ipcp_create(char * ipcp_name, } strcpy(full_name, INSTALL_DIR); - strcat(full_name, "/"); strcat(full_name, ipcp_dir); - strcat(full_name, "/"); strcat(full_name, exec_name); full_name[len] = '\0'; diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c index a855ed8f..6ee2936c 100644 --- a/src/lib/shm_ap_rbuff.c +++ b/src/lib/shm_ap_rbuff.c @@ -20,10 +20,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include + #define OUROBOROS_PREFIX "shm_ap_rbuff" #include +#include #include #include @@ -34,6 +36,7 @@ #include #include #include +#include #define SHM_RBUFF_FILE_SIZE (SHM_RBUFF_SIZE * sizeof(struct rb_entry) \ + 2 * sizeof(size_t) + sizeof(pthread_mutex_t) \ @@ -80,6 +83,12 @@ struct shm_ap_rbuff * shm_ap_rbuff_create() return NULL; } + if (fchmod(shm_fd, 0666)) { + LOG_DBGF("Failed to chmod shared memory."); + free(rb); + return NULL; + } + if (lseek(shm_fd, SHM_RBUFF_FILE_SIZE - 1, SEEK_SET) < 0) { LOG_DBGF("Failed to extend ringbuffer."); free(rb); diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c index 0ce6bdcd..5f935d3f 100644 --- a/src/lib/shm_du_map.c +++ b/src/lib/shm_du_map.c @@ -21,12 +21,14 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include #include #include #include +#include #define OUROBOROS_PREFIX "shm_du_map" @@ -95,6 +97,12 @@ struct shm_du_map * shm_du_map_create() return NULL; } + if (fchmod(shm_fd, 0666)) { + LOG_DBGF("Failed to chmod shared memory map."); + free(dum); + return NULL; + } + if (lseek(shm_fd, SHM_FILE_SIZE - 1, SEEK_SET) < 0) { LOG_DBGF("Failed to extend shared memory map."); free(dum); diff --git a/src/lib/sockets.c b/src/lib/sockets.c index 6c51e916..403d2833 100644 --- a/src/lib/sockets.c +++ b/src/lib/sockets.c @@ -22,6 +22,7 @@ #define OUROBOROS_PREFIX "libouroboros-sockets" +#include #include #include #include @@ -153,7 +154,7 @@ char * ipcp_sock_path(pid_t pid) char * full_name = NULL; char * pid_string = NULL; size_t len = 0; - char * delim = "-"; + char * delim = "_"; len = n_digits(pid); pid_string = malloc(len + 1); @@ -164,6 +165,8 @@ char * ipcp_sock_path(pid_t pid) len += strlen(IPCP_SOCK_PATH_PREFIX); len += strlen(delim); + len += strlen(SOCK_PATH_SUFFIX); + full_name = malloc(len + 1); if (full_name == NULL) { free(pid_string); @@ -173,6 +176,7 @@ char * ipcp_sock_path(pid_t pid) strcpy(full_name, IPCP_SOCK_PATH_PREFIX); strcat(full_name, delim); strcat(full_name, pid_string); + strcat(full_name, SOCK_PATH_SUFFIX); free(pid_string); diff --git a/src/nsmd/CMakeLists.txt b/src/nsmd/CMakeLists.txt new file mode 100644 index 00000000..b916170b --- /dev/null +++ b/src/nsmd/CMakeLists.txt @@ -0,0 +1,24 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_BINARY_DIR}/include) + +set(SOURCE_FILES + # Add source files here + main.c +) + +add_executable (nsmd ${SOURCE_FILES}) + +target_link_libraries (nsmd LINK_PUBLIC ouroboros) + +include(MacroAddCompileFlags) +if (CMAKE_BUILD_TYPE MATCHES Debug) + MACRO_ADD_COMPILE_FLAGS(nsmd -DCONFIG_OUROBOROS_DEBUG) +endif (CMAKE_BUILD_TYPE MATCHES Debug) + +install(TARGETS nsmd RUNTIME DESTINATION sbin) + +# Enable once nsmd has tests +# add_subdirectory(tests) diff --git a/src/nsmd/main.c b/src/nsmd/main.c new file mode 100644 index 00000000..e2971dca --- /dev/null +++ b/src/nsmd/main.c @@ -0,0 +1,10 @@ +#define OUROBOROS_PREFIX "da" + +#include + +int main() +{ + LOG_DBG("Test of the DA"); + + return 0; +} diff --git a/src/nsmd/tests/CMakeLists.txt b/src/nsmd/tests/CMakeLists.txt new file mode 100644 index 00000000..68bd762d --- /dev/null +++ b/src/nsmd/tests/CMakeLists.txt @@ -0,0 +1,19 @@ +get_filename_component(tmp ".." ABSOLUTE) +get_filename_component(src_folder "${tmp}" NAME) + +create_test_sourcelist(${src_folder}_tests test_suite.c + # Add new tests here +) + +add_executable(${src_folder}_test EXCLUDE_FROM_ALL ${${src_folder}_tests}) +target_link_libraries(${src_folder}_test ouroboros) + +add_dependencies(check ${src_folder}_test) + +set(tests_to_run ${${src_folder}_tests}) +remove(tests_to_run test_suite.c) + +foreach(test ${tests_to_run}) + get_filename_component(test_name ${test} NAME_WE) + add_test(${test_name} ${C_TEST_PATH}/${src_folder}_test ${test_name}) +endforeach(test) diff --git a/src/tools/cbr/CMakeLists.txt b/src/tools/cbr/CMakeLists.txt index 7c3f93f8..232bea36 100644 --- a/src/tools/cbr/CMakeLists.txt +++ b/src/tools/cbr/CMakeLists.txt @@ -13,4 +13,4 @@ add_executable(cbr ${SOURCE_FILES}) target_link_libraries(cbr LINK_PUBLIC ouroboros) -install(TARGETS cbr RUNTIME DESTINATION bin) +install(TARGETS cbr RUNTIME DESTINATION usr/bin) diff --git a/src/tools/echo/CMakeLists.txt b/src/tools/echo/CMakeLists.txt index b3d88089..42bcdbfe 100644 --- a/src/tools/echo/CMakeLists.txt +++ b/src/tools/echo/CMakeLists.txt @@ -13,4 +13,4 @@ add_executable(echo-app ${SOURCE_FILES}) target_link_libraries(echo-app LINK_PUBLIC ouroboros) -install(TARGETS echo-app RUNTIME DESTINATION bin) +install(TARGETS echo-app RUNTIME DESTINATION usr/bin) diff --git a/src/tools/irm/CMakeLists.txt b/src/tools/irm/CMakeLists.txt index eb385908..d1f227a8 100644 --- a/src/tools/irm/CMakeLists.txt +++ b/src/tools/irm/CMakeLists.txt @@ -20,4 +20,4 @@ add_executable (irm ${SOURCE_FILES}) target_link_libraries (irm LINK_PUBLIC ouroboros) -install(TARGETS irm RUNTIME DESTINATION bin) +install(TARGETS irm RUNTIME DESTINATION sbin) -- cgit v1.2.3 From 550cfa775b048abe183c4fdcc8ada8476e562185 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 20 Jun 2016 21:53:42 +0200 Subject: lib, irmd: Change sockets and shm path Reverting from previous commit. Even when running Ouroboros sandboxed, the sockets and shared memory should be created in the default system paths. --- include/ouroboros/sockets.h | 2 +- src/irmd/main.c | 4 +++- src/lib/ipcp.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h index b765b55b..0a215a76 100644 --- a/include/ouroboros/sockets.h +++ b/include/ouroboros/sockets.h @@ -36,7 +36,7 @@ typedef IrmMsg irm_msg_t; #include "ipcpd_messages.pb-c.h" typedef IpcpMsg ipcp_msg_t; -#define SOCK_PATH INSTALL_DIR "var/run/ouroboros/" +#define SOCK_PATH "/var/run/ouroboros/" #define SOCK_PATH_SUFFIX ".sock" #define IRM_SOCK_PATH SOCK_PATH "irm" SOCK_PATH_SUFFIX diff --git a/src/irmd/main.c b/src/irmd/main.c index 68789e94..5f7c1ddc 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1578,12 +1578,14 @@ static struct irm * irm_create() if (i == NULL) return NULL; - if (access(INSTALL_DIR "dev/shm/" SHM_DU_MAP_FILENAME, F_OK) != -1) { + if (access("/dev/shm/" SHM_DU_MAP_FILENAME, F_OK) != -1) { struct shm_du_map * dum = shm_du_map_open(); + if (dum == NULL) { LOG_ERR("Could not examine existing shm file."); exit(EXIT_FAILURE); } + if (kill(shm_du_map_owner(dum), 0) < 0) { LOG_INFO("IRMd didn't properly shut down last time."); shm_du_map_destroy(dum); diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index fcaf9f83..a43afd21 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -109,7 +109,7 @@ pid_t ipcp_create(char * ipcp_name, char * full_name = NULL; char * exec_name = NULL; - sprintf (irmd_pid, "%u", getpid()); + sprintf(irmd_pid, "%u", getpid()); pid = fork(); if (pid == -1) { -- cgit v1.2.3