aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2019-03-14 17:40:04 +0100
committerJulien Dessaux2019-03-14 17:40:04 +0100
commit3933311d47b236aec9c92b8b64f3a94d6b031a79 (patch)
treecdfa5b07dc80e86f661237b98c587d1752c2bd9f
parentFixed build problem with SESSION_RECORDING flag set to OFF and updated the re... (diff)
downloadbastion-3933311d47b236aec9c92b8b64f3a94d6b031a79.tar.gz
bastion-3933311d47b236aec9c92b8b64f3a94d6b031a79.tar.bz2
bastion-3933311d47b236aec9c92b8b64f3a94d6b031a79.zip
Use proper directories configuration from cmake
-rw-r--r--CMakeLists.txt7
-rw-r--r--README.md6
-rw-r--r--bastion/client.c2
-rw-r--r--bastion/main.c2
-rw-r--r--bastion/recording.c2
-rw-r--r--bastion/recording.h2
-rw-r--r--bastion/session.c2
-rw-r--r--bastion/state.c2
-rw-r--r--common/CMakeLists.txt1
-rw-r--r--common/config.h.in21
-rw-r--r--common/mysql.c2
-rw-r--r--config.h21
12 files changed, 36 insertions, 34 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a61bd0d..c8b30ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required (VERSION 3.0)
-project (bastion LANGUAGES C VERSION 0.1)
+cmake_minimum_required(VERSION 3.0)
+project(bastion LANGUAGES C VERSION 0.1.0)
set(CMAKE_VERBOSE_MAKEFILE FALSE)
set(CMAKE_BUILD_TYPE Release)
@@ -14,6 +14,9 @@ set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -pg -fsanitize=address")
option(LIBSSH_VERBOSE_OUTPUT "whether or not verbose output for libssh mode is activated" OFF)
option(SESSION_RECORDING "whether or not recording feature based on lib termrec is activated" ON)
+configure_file("common/config.h.in" "common/config.h")
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
add_subdirectory(bastion)
add_subdirectory(common)
add_subdirectory(external)
diff --git a/README.md b/README.md
index 6337b47..0447444 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ This project has only one hard dependency :
The following are optional dependencies :
- the libtty from https://github.com/kilobyte/termrec which allows session recording.
-- compression libraries like libbz2, liblzma, libz allows to compress on the fly session records.
+- compression libraries like libbz2, liblzma, libz allow on the fly compression of session records.
- libmysql for now because it hosts the runtime config
## Manual Installation
@@ -45,9 +45,9 @@ You can customise the build with the following cmake flags :
- `CMAKE_INSTALL_PREFIX` : path, defaults to `/usr/local`
- `SESSION_RECORDING` : ON|OFF, defaults to ON
-For exemple this disables session recording for a debug build and install it under /usr :
+For exemple this disables session recording for a debug build and installs the bastion for your current user :
-`cmake .. -DCMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=/usr -DSESSION_RECORDING=OFF`
+`cmake .. -DCMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX=$HOME/.local -DSESSION_RECORDING=OFF`
## Usage
diff --git a/bastion/client.c b/bastion/client.c
index bf20b2c..fc11bb6 100644
--- a/bastion/client.c
+++ b/bastion/client.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../config.h"
+#include "common/config.h"
#include "common/mysql.h"
#include "client.h"
#ifdef SESSION_RECORDING
diff --git a/bastion/main.c b/bastion/main.c
index d2cde12..3ce7d5e 100644
--- a/bastion/main.c
+++ b/bastion/main.c
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <sys/wait.h>
-#include "../config.h"
+#include "common/config.h"
#include "common/mysql.h"
#include "session.h"
diff --git a/bastion/recording.c b/bastion/recording.c
index 7692ff1..8a8c570 100644
--- a/bastion/recording.c
+++ b/bastion/recording.c
@@ -10,7 +10,7 @@
#include <time.h>
#include <ttyrec.h>
-#include "../config.h"
+#include "common/config.h"
#include "recording.h"
#include "state.h"
diff --git a/bastion/recording.h b/bastion/recording.h
index fec76af..5444865 100644
--- a/bastion/recording.h
+++ b/bastion/recording.h
@@ -1,5 +1,3 @@
-#include "../config.h"
-
#ifdef SESSION_RECORDING
#ifndef RECORDING_H_
#define RECORDING_H_
diff --git a/bastion/session.c b/bastion/session.c
index fdca980..5e9f5b8 100644
--- a/bastion/session.c
+++ b/bastion/session.c
@@ -8,7 +8,7 @@
#include <string.h>
#include <sys/wait.h>
-#include "../config.h"
+#include "common/config.h"
#include "common/mysql.h"
#include "proxy.h"
#include "session.h"
diff --git a/bastion/state.c b/bastion/state.c
index dd9cbf3..6784c0a 100644
--- a/bastion/state.c
+++ b/bastion/state.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
-#include "../config.h"
+#include "common/config.h"
#include "state.h"
struct state {
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 8636758..2de8714 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
file(GLOB_RECURSE SOURCES *.c)
ADD_LIBRARY(common STATIC ${SOURCES})
diff --git a/common/config.h.in b/common/config.h.in
new file mode 100644
index 0000000..1263c7c
--- /dev/null
+++ b/common/config.h.in
@@ -0,0 +1,21 @@
+#ifndef COMMON_CONFIG_H_
+#define COMMON_CONFIG_H_
+
+#define LISTEN_PORT 2222
+#define MAX_HOSTNAME_LENGTH 64
+#define MAX_USERNAME_LENGTH 64
+
+#define DSAKEY_PATH "@CMAKE_INSTALL_PREFIX@/etc/ssh_host_dsa_key"
+#define RSAKEY_PATH "@CMAKE_INSTALL_PREFIX@/etc/ssh_host_rsa_key"
+#define ECDSAKEY_PATH "@CMAKE_INSTALL_PREFIX@/etc/ssh_host_ecdsa_key"
+
+#define MYSQL_HOST "localhost"
+#define MYSQL_USER "sshportal"
+#define MYSQL_PASS "graou"
+#define MYSQL_DB "sshportal"
+
+#define LOG_FILENAME_FORMAT "@CMAKE_INSTALL_PREFIX@/var/log/$d/$h/$u/$i.gz" // $d : date in iso format, $h : hostname, $u : username : $i session id
+#define LOG_FILENAME_MAX_LEN 255
+#define LOG_DIRECTORY_MODE S_IRUSR | S_IWUSR | S_IXUSR
+
+#endif
diff --git a/common/mysql.c b/common/mysql.c
index 0931116..83a7930 100644
--- a/common/mysql.c
+++ b/common/mysql.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <string.h>
-#include "../config.h"
+#include "config.h"
#include "mysql.h"
static MYSQL *db;
diff --git a/config.h b/config.h
deleted file mode 100644
index 6f773cb..0000000
--- a/config.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CONFIG_H_
-#define CONFIG_H_
-
-#define LISTEN_PORT 2222
-#define MAX_HOSTNAME_LENGTH 64
-#define MAX_USERNAME_LENGTH 64
-
-#define DSAKEY_PATH "./ssh_host_dsa_key"
-#define RSAKEY_PATH "./ssh_host_rsa_key"
-#define ECDSAKEY_PATH "./ssh_host_ecdsa_key"
-
-#define MYSQL_HOST "localhost"
-#define MYSQL_USER "sshportal"
-#define MYSQL_PASS "graou"
-#define MYSQL_DB "sshportal"
-
-#define LOG_FILENAME_FORMAT "./log/$d/$h/$u/$i.gz" // $d : date in iso format, $h : hostname, $u : username : $i session id
-#define LOG_FILENAME_MAX_LEN 255
-#define LOG_DIRECTORY_MODE S_IRUSR | S_IWUSR | S_IXUSR
-
-#endif