Use proper directories configuration from cmake
This commit is contained in:
parent
efb8b7c3ae
commit
3933311d47
12 changed files with 36 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required (VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project (bastion LANGUAGES C VERSION 0.1)
|
project(bastion LANGUAGES C VERSION 0.1.0)
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE FALSE)
|
set(CMAKE_VERBOSE_MAKEFILE FALSE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
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(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)
|
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(bastion)
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
add_subdirectory(external)
|
add_subdirectory(external)
|
||||||
|
|
|
@ -25,7 +25,7 @@ This project has only one hard dependency :
|
||||||
|
|
||||||
The following are optional dependencies :
|
The following are optional dependencies :
|
||||||
- the libtty from https://github.com/kilobyte/termrec which allows session recording.
|
- 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
|
- libmysql for now because it hosts the runtime config
|
||||||
|
|
||||||
## Manual Installation
|
## Manual Installation
|
||||||
|
@ -45,9 +45,9 @@ You can customise the build with the following cmake flags :
|
||||||
- `CMAKE_INSTALL_PREFIX` : path, defaults to `/usr/local`
|
- `CMAKE_INSTALL_PREFIX` : path, defaults to `/usr/local`
|
||||||
- `SESSION_RECORDING` : ON|OFF, defaults to ON
|
- `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
|
## Usage
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "common/config.h"
|
||||||
#include "common/mysql.h"
|
#include "common/mysql.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#ifdef SESSION_RECORDING
|
#ifdef SESSION_RECORDING
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "common/config.h"
|
||||||
#include "common/mysql.h"
|
#include "common/mysql.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ttyrec.h>
|
#include <ttyrec.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "common/config.h"
|
||||||
#include "recording.h"
|
#include "recording.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#include "../config.h"
|
|
||||||
|
|
||||||
#ifdef SESSION_RECORDING
|
#ifdef SESSION_RECORDING
|
||||||
#ifndef RECORDING_H_
|
#ifndef RECORDING_H_
|
||||||
#define RECORDING_H_
|
#define RECORDING_H_
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "common/config.h"
|
||||||
#include "common/mysql.h"
|
#include "common/mysql.h"
|
||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "common/config.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
|
||||||
struct state {
|
struct state {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
file(GLOB_RECURSE SOURCES *.c)
|
file(GLOB_RECURSE SOURCES *.c)
|
||||||
|
|
||||||
ADD_LIBRARY(common STATIC ${SOURCES})
|
ADD_LIBRARY(common STATIC ${SOURCES})
|
||||||
|
|
21
common/config.h.in
Normal file
21
common/config.h.in
Normal file
|
@ -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
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "config.h"
|
||||||
#include "mysql.h"
|
#include "mysql.h"
|
||||||
|
|
||||||
static MYSQL *db;
|
static MYSQL *db;
|
||||||
|
|
21
config.h
21
config.h
|
@ -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
|
|
Reference in a new issue