diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/afb-api-so-v1.c | 2 | ||||
-rw-r--r-- | src/afb-api-so-v1.h | 2 | ||||
-rw-r--r-- | src/afb-api-so-v2.c | 2 | ||||
-rw-r--r-- | src/afb-api-so-v2.h | 2 | ||||
-rw-r--r-- | src/afb-api-so-v3.c | 3 | ||||
-rw-r--r-- | src/afb-api-so-v3.h | 4 | ||||
-rw-r--r-- | src/afb-api-so-vdyn.c | 2 | ||||
-rw-r--r-- | src/afb-api-so-vdyn.h | 2 | ||||
-rw-r--r-- | src/afb-api-so.c | 3 | ||||
-rw-r--r-- | src/afb-api-so.h | 4 | ||||
-rw-r--r-- | src/afb-args.c | 42 | ||||
-rw-r--r-- | src/afb-autoset.c | 4 | ||||
-rw-r--r-- | src/afb-autoset.h | 2 | ||||
-rw-r--r-- | src/afb-debug.h | 2 | ||||
-rw-r--r-- | src/main-afb-daemon.c | 2 |
17 files changed, 63 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a8bfaaa..f841b5de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,10 +97,6 @@ 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) -ENDIF() - IF(cynara_FOUND) ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA) ENDIF(cynara_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1475e31..71cd1ff2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,7 @@ ADD_DEFINITIONS(-DBINDING_INSTALL_DIR="${binding_install_dir}") ADD_DEFINITIONS(-DINFER_EXTENSION) ############################################################################ -# TODO: improve below setting +# TODO: improve below setting by using config file option(WITH_SIG_MONITOR_DUMPSTACK "activate dump stack on error" ON) option(WITH_SIG_MONITOR_SIGNALS "activate handling of signals" ON) option(WITH_SIG_MONITOR_FOR_CALL "activate monitoring of calls" ON) @@ -37,6 +37,7 @@ option(WITH_DBUS_TRANSPARENCY "Allows API transparency over DBUS" OFF) option(WITH_LEGACY_BINDING_V1 "Includes the legacy Binding API version 1" OFF) option(WITH_LEGACY_BINDING_V2 "Includes the legacy Binding API version 2" ON) option(WITH_LEGACY_BINDING_VDYN "Includes the legacy Binding API version dynamic" OFF) +option(WITH_DYNAMIC_BINDING "Allow to load dynamic bindings (shared libraries)" ON) if(INCLUDE_SUPERVISOR) set(WITH_SUPERVISOR ON) @@ -52,6 +53,7 @@ if(INCLUDE_LEGACY_BINDING_VDYN) endif() add_definitions( + -DAGL_DEVEL=$<BOOL:${AGL_DEVEL}> -DWITH_SIG_MONITOR_DUMPSTACK=$<BOOL:${WITH_SIG_MONITOR_DUMPSTACK}> -DWITH_SIG_MONITOR_SIGNALS=$<BOOL:${WITH_SIG_MONITOR_SIGNALS}> -DWITH_SIG_MONITOR_FOR_CALL=$<BOOL:${WITH_SIG_MONITOR_FOR_CALL}> @@ -63,6 +65,7 @@ add_definitions( -DWITH_LEGACY_BINDING_VDYN=$<BOOL:${INCLUDE_LEGACY_BINDING_VDYN}> -DWITH_DBUS_TRANSPARENCY=$<BOOL:${INCLUDE_DBUS_TRANSPARENCY}> -DWITH_SUPERVISION=$<BOOL:${INCLUDE_SUPERVISOR}> + -DWITH_DYNAMIC_BINDING=$<BOOL:${WITH_DYNAMIC_BINDING}> ) ############################################################################ diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c index 5ab2c4c4..c6317ba7 100644 --- a/src/afb-api-so-v1.c +++ b/src/afb-api-so-v1.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#if WITH_LEGACY_BINDING_V1 +#if WITH_LEGACY_BINDING_V1 && WITH_DYNAMIC_BINDING #define _GNU_SOURCE diff --git a/src/afb-api-so-v1.h b/src/afb-api-so-v1.h index 4e167512..06426e28 100644 --- a/src/afb-api-so-v1.h +++ b/src/afb-api-so-v1.h @@ -18,7 +18,7 @@ #pragma once -#if WITH_LEGACY_BINDING_V1 +#if WITH_LEGACY_BINDING_V1 && WITH_DYNAMIC_BINDING struct afb_apiset; struct afb_binding_v1; diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c index a0399da1..f10e18d3 100644 --- a/src/afb-api-so-v2.c +++ b/src/afb-api-so-v2.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#if WITH_LEGACY_BINDING_V2 +#if WITH_LEGACY_BINDING_V2 && WITH_DYNAMIC_BINDING #define _GNU_SOURCE diff --git a/src/afb-api-so-v2.h b/src/afb-api-so-v2.h index 9b4cb091..278bdc39 100644 --- a/src/afb-api-so-v2.h +++ b/src/afb-api-so-v2.h @@ -18,7 +18,7 @@ #pragma once -#if WITH_LEGACY_BINDING_V2 +#if WITH_LEGACY_BINDING_V2 && WITH_DYNAMIC_BINDING struct afb_apiset; struct afb_binding_v2; diff --git a/src/afb-api-so-v3.c b/src/afb-api-so-v3.c index c48ab74d..230a93fc 100644 --- a/src/afb-api-so-v3.c +++ b/src/afb-api-so-v3.c @@ -15,6 +15,8 @@ * limitations under the License. */ +#if WITH_DYNAMIC_BINDING + #define _GNU_SOURCE #include <stdlib.h> @@ -135,3 +137,4 @@ error: return -1; } +#endif diff --git a/src/afb-api-so-v3.h b/src/afb-api-so-v3.h index 801b6ada..a3288510 100644 --- a/src/afb-api-so-v3.h +++ b/src/afb-api-so-v3.h @@ -18,6 +18,10 @@ #pragma once +#if WITH_DYNAMIC_BINDING + struct afb_apiset; extern int afb_api_so_v3_add(const char *path, void *handle, struct afb_apiset *declare_set, struct afb_apiset * call_set); + +#endif diff --git a/src/afb-api-so-vdyn.c b/src/afb-api-so-vdyn.c index 6be16b95..1b78edab 100644 --- a/src/afb-api-so-vdyn.c +++ b/src/afb-api-so-vdyn.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#if WITH_LEGACY_BINDING_VDYN +#if WITH_LEGACY_BINDING_VDYN && WITH_DYNAMIC_BINDING #define _GNU_SOURCE diff --git a/src/afb-api-so-vdyn.h b/src/afb-api-so-vdyn.h index 1188ad8f..f51ff513 100644 --- a/src/afb-api-so-vdyn.h +++ b/src/afb-api-so-vdyn.h @@ -18,7 +18,7 @@ #pragma once -#if WITH_LEGACY_BINDING_VDYN +#if WITH_LEGACY_BINDING_VDYN && WITH_DYNAMIC_BINDING struct afb_apiset; diff --git a/src/afb-api-so.c b/src/afb-api-so.c index 3838380e..74305c69 100644 --- a/src/afb-api-so.c +++ b/src/afb-api-so.c @@ -15,6 +15,8 @@ * limitations under the License. */ +#if WITH_DYNAMIC_BINDING + #define _GNU_SOURCE #include <stdio.h> @@ -322,3 +324,4 @@ int afb_api_so_add_pathset_nofails(const char *pathset, struct afb_apiset *decla return afb_api_so_add_pathset(pathset, declare_set, call_set, 0); } +#endif diff --git a/src/afb-api-so.h b/src/afb-api-so.h index 76294efe..df264673 100644 --- a/src/afb-api-so.h +++ b/src/afb-api-so.h @@ -18,6 +18,8 @@ #pragma once +#if WITH_DYNAMIC_BINDING + struct afb_apiset; extern int afb_api_so_add_binding(const char *path, struct afb_apiset *declare_set, struct afb_apiset * call_set); @@ -31,4 +33,4 @@ extern int afb_api_so_add_pathset(const char *pathset, struct afb_apiset *declar extern int afb_api_so_add_pathset_fails(const char *pathset, struct afb_apiset *declare_set, struct afb_apiset * call_set); extern int afb_api_so_add_pathset_nofails(const char *pathset, struct afb_apiset *declare_set, struct afb_apiset * call_set); - +#endif diff --git a/src/afb-args.c b/src/afb-args.c index 1dc2e6ca..af3cfcab 100644 --- a/src/afb-args.c +++ b/src/afb-args.c @@ -80,14 +80,13 @@ #define SET_CACHE_TIMEOUT 7 -#define AUTO_WS 8 -#define AUTO_LINK 9 - +#if WITH_DYNAMIC_BINDING #define ADD_LDPATH 10 -#define SET_API_TIMEOUT 11 -#define SET_SESSION_TIMEOUT 12 -#define ADD_WEAK_LDPATH 13 -#define SET_NO_LDPATH 14 +#define ADD_WEAK_LDPATH 11 +#define SET_NO_LDPATH 12 +#endif +#define SET_API_TIMEOUT 13 +#define SET_SESSION_TIMEOUT 14 #define SET_SESSIONMAX 15 @@ -115,7 +114,9 @@ #endif #define ADD_AUTO_API 'A' +#if WITH_DYNAMIC_BINDING #define ADD_BINDING 'b' +#endif #define SET_CONFIG 'C' #define SET_COLOR 'c' #define SET_DAEMON 'D' @@ -174,11 +175,12 @@ static struct option_desc optdefs[] = { {SET_UPLOAD_DIR, 1, "uploaddir", "Directory for uploading files [default: workdir] relative to workdir"}, {SET_ROOT_DIR, 1, "rootdir", "Root Directory of the application [default: workdir] relative to workdir"}, +#if WITH_DYNAMIC_BINDING {ADD_LDPATH, 1, "ldpaths", "Load bindings from dir1:dir2:... [default = " BINDING_INSTALL_DIR "]"}, {ADD_BINDING, 1, "binding", "Load the binding of path"}, {ADD_WEAK_LDPATH, 1, "weak-ldpaths","Same as --ldpaths but ignore errors"}, {SET_NO_LDPATH, 0, "no-ldpaths", "Discard default ldpaths loading"}, - +#endif {SET_TOKEN, 1, "token", "Initial Secret [default=random, use --token="" to allow any token]"}, {SET_RANDOM_TOKEN, 0, "random-token","Enforce a random token"}, @@ -369,7 +371,13 @@ static void printVersion(FILE * file) #endif "TRACE " - "[BINDINGS " + "[" +#if WITH_DYNAMIC_BINDING + "BINDINGS " + "+" +#else + "-" +#endif #if WITH_LEGACY_BINDING_V1 "+" #else @@ -426,7 +434,11 @@ static void printHelp(FILE * file, const char *name) fprintf(file, "Example:\n %s --verbose --port=" d2s(DEFAULT_HTTP_PORT) - " --token='azerty' --ldpaths=build/bindings:/usr/lib64/agl/bindings\n", + " --token='azerty'" +#if WITH_DYNAMIC_BINDING + " --ldpaths=build/bindings:/usr/lib64/agl/bindings" +#endif + "\n", name); } @@ -826,12 +838,14 @@ static void parse_arguments_inner(int argc, char **argv, struct json_object *con case ADD_DBUS_SERVICE: #endif case ADD_ALIAS: +#if WITH_DYNAMIC_BINDING case ADD_LDPATH: case ADD_WEAK_LDPATH: + case ADD_BINDING: +#endif case ADD_CALL: case ADD_WS_CLIENT: case ADD_WS_SERVICE: - case ADD_BINDING: case ADD_AUTO_API: config_add_optstr(config, optid); break; @@ -845,7 +859,9 @@ static void parse_arguments_inner(int argc, char **argv, struct json_object *con #endif case SET_RANDOM_TOKEN: case SET_NO_HTTPD: +#if WITH_DYNAMIC_BINDING case SET_NO_LDPATH: +#endif noarg(optid); config_set_bool(config, optid, 1); break; @@ -979,8 +995,10 @@ static void fulfill_config(struct json_object *config) if (config_has_bool(config, SET_RANDOM_TOKEN)) config_del(config, SET_TOKEN); +#if WITH_DYNAMIC_BINDING if (!config_has(config, ADD_LDPATH) && !config_has(config, ADD_WEAK_LDPATH) && !config_has_bool(config, SET_NO_LDPATH)) config_add_str(config, ADD_LDPATH, BINDING_INSTALL_DIR); +#endif #if defined(WITH_MONITORING_OPTION) if (config_has_bool(config, SET_MONITORING) && !config_has_str(config, ADD_ALIAS, MONITORING_ALIAS)) @@ -1040,7 +1058,9 @@ static void parse_environment(struct json_object *config) on_environment_enum(config, SET_TRACESVC, "AFB_TRACESVC", afb_hook_flags_legacy_svc_from_text); #endif #endif +#if WITH_DYNAMIC_BINDING on_environment(config, ADD_LDPATH, "AFB_LDPATHS", config_add_str); +#endif on_environment(config, ADD_SET, "AFB_SET", config_mix2_str); on_environment_bool(config, SET_TRAP_FAULTS, "AFB_TRAP_FAULTS"); } diff --git a/src/afb-autoset.c b/src/afb-autoset.c index cdfd2806..fcb353af 100644 --- a/src/afb-autoset.c +++ b/src/afb-autoset.c @@ -94,6 +94,7 @@ int afb_autoset_add_ws(const char *path, struct afb_apiset *declare_set, struct /*******************************************************************/ +#if WITH_DYNAMIC_BINDING static int create_so(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set) { return afb_api_so_add_binding(path, declare_set, call_set) >= 0; @@ -108,6 +109,7 @@ int afb_autoset_add_so(const char *path, struct afb_apiset *declare_set, struct { return add(path, declare_set, call_set, onlack_so); } +#endif /*******************************************************************/ @@ -120,9 +122,11 @@ static int create_any(const char *path, struct afb_apiset *declare_set, struct a rc = stat(path, &st); if (!rc) { switch(st.st_mode & S_IFMT) { +#if WITH_DYNAMIC_BINDING case S_IFREG: rc = afb_api_so_add_binding(path, declare_set, call_set); break; +#endif case S_IFSOCK: snprintf(sockname, sizeof sockname, "unix:%s", path); rc = afb_api_ws_add_client(sockname, declare_set, call_set, 0); diff --git a/src/afb-autoset.h b/src/afb-autoset.h index c9aacff7..4ced3136 100644 --- a/src/afb-autoset.h +++ b/src/afb-autoset.h @@ -20,5 +20,7 @@ struct afb_apiset; extern int afb_autoset_add_ws(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set); +#if WITH_DYNAMIC_BINDING extern int afb_autoset_add_so(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set); +#endif extern int afb_autoset_add_any(const char *path, struct afb_apiset *declare_set, struct afb_apiset *call_set); diff --git a/src/afb-debug.h b/src/afb-debug.h index 5dc63dcc..a535b02b 100644 --- a/src/afb-debug.h +++ b/src/afb-debug.h @@ -18,7 +18,7 @@ #pragma once -#if defined(AGL_DEVEL) && !defined(AFB_INSERT_DEBUG_FEATURES) +#if AGL_DEVEL && !defined(AFB_INSERT_DEBUG_FEATURES) # define AFB_INSERT_DEBUG_FEATURES #endif diff --git a/src/main-afb-daemon.c b/src/main-afb-daemon.c index a85ffc0a..d825d803 100644 --- a/src/main-afb-daemon.c +++ b/src/main-afb-daemon.c @@ -835,9 +835,11 @@ static void start(int signum, void *arg) /* load bindings and apis */ afb_debug("start-load"); +#if WITH_DYNAMIC_BINDING apiset_start_list("binding", afb_api_so_add_binding, "the binding"); apiset_start_list("ldpaths", afb_api_so_add_pathset_fails, "the binding path set"); apiset_start_list("weak-ldpaths", afb_api_so_add_pathset_nofails, "the weak binding path set"); +#endif apiset_start_list("auto-api", afb_autoset_add_any, "the automatic api path set"); #if WITH_DBUS_TRANSPARENCY apiset_start_list("dbus-client", afb_api_dbus_add_client, "the afb-dbus client"); |