From 99f25469c5ce8070210769f9dfe2a16b7333c14d Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Sat, 15 Oct 2016 18:39:05 +0200 Subject: [PATCH] ctl: take in consideration runtime_dir when creation the ctl socket --- modules/ctl/ctl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/ctl/ctl.c b/modules/ctl/ctl.c index f630f8a67c8..7e2e11fc857 100644 --- a/modules/ctl/ctl.c +++ b/modules/ctl/ctl.c @@ -211,11 +211,12 @@ static int fix_group(modparam_t type, void * val) return -1; } - +#define CTL_SOCKET_PATH_SIZE 128 static int mod_init(void) { struct id_list* l; + char ctl_socket_path[CTL_SOCKET_PATH_SIZE]; binrpc_callbacks_init(); @@ -227,7 +228,21 @@ static int mod_init(void) binrpc_struct_max_body_size *= 1024; if (listen_lst==0) { - add_binrpc_socket(PARAM_STRING, DEFAULT_CTL_SOCKET); + if(strcmp(runtime_dir, RUN_DIR)==0) { + add_binrpc_socket(PARAM_STRING, DEFAULT_CTL_SOCKET); + } else { + if(sizeof(DEFAULT_CTL_SOCKET_PROTO) + + sizeof(DEFAULT_CTL_SOCKET_NAME) + + strlen(runtime_dir) + 4 > CTL_SOCKET_PATH_SIZE) { + LM_ERR("ctl socket path is too big\n"); + return -1; + } + strcpy(ctl_socket_path, DEFAULT_CTL_SOCKET_PROTO); + strcat(ctl_socket_path, runtime_dir); + strcat(ctl_socket_path, "/"); + strcat(ctl_socket_path, DEFAULT_CTL_SOCKET_NAME); + add_binrpc_socket(PARAM_STRING, ctl_socket_path); + } } DBG("listening on:\n"); for (l=listen_lst; l; l=l->next){