summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--memo-supervisor.txt4
-rw-r--r--src/afb-supervision.c8
-rw-r--r--src/afs-config.c20
-rw-r--r--src/afs-supervision.h10
-rw-r--r--src/afs-supervisor.c8
6 files changed, 35 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f60cacee..75faf41e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,7 @@ INCLUDE(CTest)
set(AGL_DEVEL OFF CACHE BOOL "Activates developping features")
set(INCLUDE_MONITORING OFF CACHE BOOL "Activates installation of monitoring")
set(INCLUDE_SUPERVISOR OFF CACHE BOOL "Activates installation of supervisor")
-set(AFS_SURPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
+set(AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" CACHE STRING "Internal socket for supervision")
set(AFS_SUPERVISOR_PORT 1619 CACHE STRING "Port of service for the supervisor")
set(AFS_SUPERVISOR_TOKEN HELLO CACHE STRING "Secret token for the supervisor")
set(UNITDIR_SYSTEM ${CMAKE_INSTALL_LIBDIR}/systemd/system CACHE STRING "Path to systemd system unit files")
@@ -86,7 +86,9 @@ PKG_CHECK_MODULES(openssl openssl)
PKG_CHECK_MODULES(uuid uuid)
PKG_CHECK_MODULES(cynara cynara-client)
-ADD_DEFINITIONS("-DAFS_SURPERVISION_SOCKET=\"${AFS_SURPERVISION_SOCKET}\"")
+ADD_DEFINITIONS("-DAFS_SUPERVISION_SOCKET=\"${AFS_SUPERVISION_SOCKET}\"")
+ADD_DEFINITIONS("-DAFS_SUPERVISOR_TOKEN=\"${AFS_SUPERVISOR_TOKEN}\"")
+ADD_DEFINITIONS("-DAFS_SUPERVISOR_PORT=${AFS_SUPERVISOR_PORT}")
IF(AGL_DEVEL)
ADD_DEFINITIONS(-DAGL_DEVEL)
diff --git a/memo-supervisor.txt b/memo-supervisor.txt
index 9f996b78..13e9d1d2 100644
--- a/memo-supervisor.txt
+++ b/memo-supervisor.txt
@@ -2,12 +2,12 @@
Run the supervisor on the target for the public IP:
---------------------------------------------------
- # afs-supervisor --port 1712 --token HELLO
+ # afs-supervisor --port 1619 --token HELLO
Run the client
--------------
- # afb-client-demo -H host:1712/api?token=HELLO
+ # afb-client-demo -H host:1619/api?token=HELLO
verbs that can be run, all are of the API 'supervisor':
diff --git a/src/afb-supervision.c b/src/afb-supervision.c
index 4d471e86..fa678ee9 100644
--- a/src/afb-supervision.c
+++ b/src/afb-supervision.c
@@ -51,11 +51,11 @@
extern struct afb_config *main_config;
/* api and apiset name */
-static const char supervision_apiname[] = AFS_SURPERVISION_APINAME;
-static const char supervisor_apiname[] = AFS_SURPERVISOR_APINAME;
+static const char supervision_apiname[] = AFS_SUPERVISION_APINAME;
+static const char supervisor_apiname[] = AFS_SUPERVISOR_APINAME;
/* path of the supervision socket */
-static const char supervisor_socket_path[] = AFS_SURPERVISION_SOCKET;
+static const char supervisor_socket_path[] = AFS_SUPERVISION_SOCKET;
/* mutual exclusion */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -176,7 +176,7 @@ static void try_connect_supervisor()
ERROR("Bad interface of supervisor %s", supervisor_socket_path);
goto end2;
}
- if (strcmp(initiator.interface, AFS_SURPERVISION_INTERFACE_1)) {
+ if (strcmp(initiator.interface, AFS_SUPERVISION_INTERFACE_1)) {
ERROR("Unknown interface %s for supervisor %s", initiator.interface, supervisor_socket_path);
goto end2;
}
diff --git a/src/afs-config.c b/src/afs-config.c
index 3cb851be..eee4ccc0 100644
--- a/src/afs-config.c
+++ b/src/afs-config.c
@@ -28,9 +28,18 @@
#include "afs-config.h"
#if !defined(AFB_VERSION)
-#error "you should define AFB_VERSION"
+# error "you should define AFB_VERSION"
#endif
+#if !defined(AFS_SUPERVISOR_TOKEN)
+# define AFS_SUPERVISOR_TOKEN ""
+#endif
+#if !defined(AFS_SUPERVISOR_PORT)
+# define AFS_SUPERVISOR_PORT 1619
+#endif
+#define _STRINGIFY_(x) #x
+#define STRINGIFY(x) _STRINGIFY_(x)
+
// default
#define DEFLT_CNTX_TIMEOUT 32000000 // default Client Connection
// Timeout: few more than one year
@@ -88,7 +97,7 @@ static AFB_options cliOptions[] = {
{SET_NAME, 1, "name", "Set the visible name"},
- {SET_TCP_PORT, 1, "port", "HTTP listening TCP port [default 1234]"},
+ {SET_TCP_PORT, 1, "port", "HTTP listening TCP port [default " STRINGIFY(AFS_SUPERVISOR_PORT) "]"},
{SET_ROOT_HTTP, 1, "roothttp", "HTTP Root Directory [default no root http (files not served but apis still available)]"},
{SET_ROOT_BASE, 1, "rootbase", "Angular Base Root URL [default /opa]"},
{SET_ROOT_API, 1, "rootapi", "HTML Root API URL [default /api]"},
@@ -102,7 +111,7 @@ static AFB_options cliOptions[] = {
{SET_ROOT_DIR, 1, "rootdir", "Root Directory of the application [default: workdir]"},
{SET_SESSION_DIR, 1, "sessiondir", "OBSOLETE (was: Sessions file path)"},
- {SET_AUTH_TOKEN, 1, "token", "Initial Secret [default=random, use --token="" to allow any token]"},
+ {SET_AUTH_TOKEN, 1, "token", "Initial Secret [default=" AFS_SUPERVISOR_TOKEN ", use --token="" to allow any token]"},
{DISPLAY_VERSION, 0, "version", "Display version and copyright"},
{DISPLAY_HELP, 0, "help", "Display this help"},
@@ -335,7 +344,7 @@ static void fulfill_config(struct afs_config *config)
{
// default HTTP port
if (config->httpdPort == 0)
- config->httpdPort = 1234;
+ config->httpdPort = AFS_SUPERVISOR_PORT;
// default binding API timeout
if (config->apiTimeout == 0)
@@ -369,6 +378,9 @@ static void fulfill_config(struct afs_config *config)
if (config->rootapi == NULL)
config->rootapi = "/api";
+
+ if (config->token == NULL)
+ config->token = AFS_SUPERVISOR_TOKEN;
}
void afs_config_dump(struct afs_config *config)
diff --git a/src/afs-supervision.h b/src/afs-supervision.h
index fe3d2718..bee40a1a 100644
--- a/src/afs-supervision.h
+++ b/src/afs-supervision.h
@@ -25,15 +25,15 @@
* anyone to create a such socket and usurpate the
* supervisor.
*/
-#if !defined(AFS_SURPERVISION_SOCKET)
-# define AFS_SURPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" /* abstract */
+#if !defined(AFS_SUPERVISION_SOCKET)
+# define AFS_SUPERVISION_SOCKET "@urn:AGL:afs:supervision:socket" /* abstract */
#endif
/*
* generated using
* uuid -v 5 ns:URL urn:AGL:afs:supervision:interface:1
*/
-#define AFS_SURPERVISION_INTERFACE_1 "86040e8d-eee5-5900-a129-3edb8da3ed46"
+#define AFS_SUPERVISION_INTERFACE_1 "86040e8d-eee5-5900-a129-3edb8da3ed46"
/**
@@ -45,5 +45,5 @@ struct afs_supervision_initiator
char extra[27]; /**< zero terminated extra computed here to be 64-37 */
};
-#define AFS_SURPERVISION_APINAME "$"
-#define AFS_SURPERVISOR_APINAME "supervisor"
+#define AFS_SUPERVISION_APINAME "$"
+#define AFS_SUPERVISOR_APINAME "supervisor"
diff --git a/src/afs-supervisor.c b/src/afs-supervisor.c
index acad7920..62adf9b6 100644
--- a/src/afs-supervisor.c
+++ b/src/afs-supervisor.c
@@ -60,14 +60,14 @@ struct supervised
};
/* api and apiset name */
-static const char supervision_apiname[] = AFS_SURPERVISION_APINAME;
-static const char supervisor_apiname[] = AFS_SURPERVISOR_APINAME;
+static const char supervision_apiname[] = AFS_SUPERVISION_APINAME;
+static const char supervisor_apiname[] = AFS_SUPERVISOR_APINAME;
/* the empty apiset */
static struct afb_apiset *empty_apiset;
/* supervision socket path */
-static const char supervision_socket_path[] = AFS_SURPERVISION_SOCKET;
+static const char supervision_socket_path[] = AFS_SUPERVISION_SOCKET;
static struct fdev *supervision_fdev;
/* global mutex */
@@ -137,7 +137,7 @@ static int send_initiator(int fd, const char *command)
/* set */
memset(&asi, 0, sizeof asi);
- strcpy(asi.interface, AFS_SURPERVISION_INTERFACE_1);
+ strcpy(asi.interface, AFS_SUPERVISION_INTERFACE_1);
if (command)
strncpy(asi.extra, command, sizeof asi.extra - 1);