diff --git a/src/confparser.c b/src/confparser.c
index 3bcd6f6..f73a5f7 100644
--- a/src/confparser.c
+++ b/src/confparser.c
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with RMPS. If not, see .
*/
-
+#define _GNU_SOURCE
#include
#include
#include
@@ -30,39 +30,11 @@
#include "confparser.h"
#include "enum_functions.h"
-static int test_conf_perms(char *config);
-static int test_conf_syntax(char *config);
+static bool test_conf_perms(char *config);
+static bool test_conf_syntax(char *config);
+static bool test_conf_required(void);
-struct conf_table conf = {
- 0, /* isvalid initial state */
- {
- "", /* db.type */
- "", /* db.hostname */
- "", /* db.port */
- "" /* db.pass */
- },
- {
- "127.0.0.1", /* rmps.agent_ip */
- "7000", /* rmps.agent_port */
- "127.0.0.1", /* rmps.client_ip */
- "7001", /* rmps.client_port */
- "/var/log/rmps/rmpsd.log",
- "/var/log/rmps/rmpsd.err",
- '2', /* rmps.loglevel */
- "/run/rmps/rmpsd.pid",
- "/etc/rmps/agent.crt",
- "/etc/rmps/agent.key",
- "/etc/rmps/ca.crt",
- "", /* rmps.cipherlist */
- 2, /* rmps.agent_poolsize */
- "/etc/rmps/client.crt",
- "/etc/rmps/client.key",
- 2 /* rmps.client_poolsize */
- },
- {
- 0 /* nfs -> TODO */
- }
-};
+struct conf_table conf;
const char *conf_db_pass(void)
{
@@ -142,21 +114,47 @@ static int fopen_and_mkdir(const char *dir)
log(ERROR,
"Permission denied to create dir: %s",
tmp);
- return 1;
+ return false;
}
*p = '/';
}
fp = fopen(dir, "a");
if (!fp) {
log(ERROR, "Permission denied to write into: %s", dir);
- return 1;
+ return false;
}
fclose(fp);
- return 0;
+ return true;
}
*/
-static int test_conf_perms(char *config)
+static void init_conf(void)
+{
+ conf.isvalid = 0; /* initial state */
+ asprintf(&conf.db.type, "mysql");
+ conf.db.hostname[0] = '\0';
+ conf.db.port = NULL;
+ conf.db.pass = NULL;
+ asprintf(&conf.rmps.agent_ip, "any");
+ asprintf(&conf.rmps.agent_port, "7000");
+ asprintf(&conf.rmps.client_ip, "any");
+ asprintf(&conf.rmps.client_port, "7001");
+ asprintf(&conf.rmps.logfile, "/var/log/rmps/rmpsd.log");
+ asprintf(&conf.rmps.errlog, "/var/log/rmps/rmpsd.err");
+ conf.rmps.loglevel = 2; /* WARNING == 2 */
+ asprintf(&conf.rmps.pidfile, "/run/rmps/rmpsd.pid");
+ asprintf(&conf.rmps.agent_tls_crt, "/etc/rmps/certs/server.crt");
+ asprintf(&conf.rmps.agent_tls_key, "/etc/rmps/certs/server.key");
+ asprintf(&conf.rmps.cafile, "/etc/rmps/certs/ca.crt");
+ conf.rmps.cipherlist = NULL;
+ conf.rmps.agent_poolsize = 2;
+ asprintf(&conf.rmps.client_tls_crt, "/etc/rmps/certs/server.crt");
+ asprintf(&conf.rmps.client_tls_key, "/etc/rmps/certs/server.key");
+ conf.rmps.client_poolsize = 2;
+ //conf.nfs = {0}; /* TODO */
+}
+
+static bool test_conf_perms(char *config)
{
struct stat s;
char confresult[128];
@@ -168,26 +166,26 @@ static int test_conf_perms(char *config)
enumtostr(confresult, CONF_MISSING);
log(ERROR, confresult, config);
free(config_copy);
- return 1;
+ return false;
}
} else {
if (!S_ISREG(s.st_mode)) {
enumtostr(confresult, CONF_NOTFILE);
log(ERROR, confresult, config);
free(config_copy);
- return 1;
+ return false;
}
if (!(0400 & s.st_mode)) {
enumtostr(confresult, CONF_PERM);
log(ERROR, confresult, config);
free(config_copy);
- return 1;
+ return false;
}
if (access(config, R_OK) != 0) {
enumtostr(confresult, CONF_NOT_READABLE);
log(ERROR, confresult, config);
free(config_copy);
- return 1;
+ return false;
}
}
@@ -198,257 +196,266 @@ static int test_conf_perms(char *config)
enumtostr(confresult, CONF_DIR_MISSING);
log(ERROR, confresult, config_copy);
free(config_copy);
- return 1;
+ return false;
}
} else {
if (!S_ISDIR(s.st_mode)) {
enumtostr(confresult, CONF_DIR_NOTDIR);
log(ERROR, confresult, config_copy);
free(config_copy);
- return 1;
+ return false;
}
if (!(0400 & s.st_mode) ||
!(0100 & s.st_mode)) {
enumtostr(confresult, CONF_DIR_PERM);
log(ERROR, confresult, config_copy);
free(config_copy);
- return 1;
+ return false;
}
}
free(config_copy);
-
- return 0; /* conf is readable */
+ return true; /* conf is readable */
}
-static int test_conf_syntax(char *config)
+/* Import the config and test the syntax */
+static bool test_conf_syntax(char *config)
{
- int i, j = 0, ok = 1, failed = 0;
- char buf[CFGLINESIZE], *tmp;
+ int i, line_itr = 0;
+ bool failed = false, val_ok = true;
+ char *line = NULL, *val_ptr;
+ size_t len = 0;
FILE *fp = fopen(config, "r");
if (fp == NULL) {
log(ERROR, "Failed to read %s", config);
- return 1;
+ return false;
}
- while (fgets(buf, CFGLINESIZE, fp) != NULL) {
- j++;
+ while (getline(&line, &len, fp) != -1) {
+ line_itr++;
/* kill comments and ignore BLANK lines */
- tmp = strstr(buf, "#");
- if (tmp)
- *tmp = '\0';
- if (buf[strspn(buf, " \t\v\r\n")] == '\0')
+ val_ptr = strstr(line, "#");
+ if (val_ptr)
+ *val_ptr = '\0';
+ if (line[strspn(line, " \t\v\r\n")] == '\0')
continue;
/* If we have "=", it's a possible var */
- tmp = strstr(buf, "=");
- if (tmp)
- *tmp = '\0';
+ val_ptr = strstr(line, "=");
+ if (val_ptr)
+ *val_ptr = '\0';
else {
log(ERROR,
- "Bad entry in %s, line %d: %s", config, j, buf);
- ok = 0;
- failed = 1;
+ "Bad entry in %s, line %d: %s", config, line_itr, line);
+ val_ok = false;
+ failed = true;
continue;
}
/* Check if there actually is a value after '=' */
- i = strlen(tmp + 1);
- if (tmp[i] == '\n')
- tmp[i] = '\0';
- if (tmp[strspn(tmp + 1, " \t\v\r\n") + 1] == '\0') {
+ i = strlen(val_ptr + 1);
+ if (val_ptr[i] == '\n') {
+ val_ptr[i] = '\0';
+ /* move ptr to beginning of the value str */
+ val_ptr = val_ptr + 1;
+ }
+ if (val_ptr[strspn(val_ptr, " \t\v\r\n")] == '\0') {
log(ERROR,
"Specified entry without value, line %d: %s",
- j, buf);
- failed = 1;
+ line_itr, line);
+ failed = true;
continue;
}
/* Here we check every single conf entry manually */
- if (!strcmp(buf, "db.type")) {
- if (!strcmp(tmp + 1, "mysql")) {
- /* || !strcmp(tmp[1], "postgresql") */
- /* || !strcmp(tmp[1], "oracle") */
- strncpy(conf.db.type, tmp + 1,
- sizeof(conf.db.type) - 1);
- if (conf.db.port[0] == '\0')
- strncpy(conf.db.port, "3306",
- sizeof(conf.db.port) - 1);
+ if (!strcmp(line, "db.type")) {
+ if (!strcmp(val_ptr, "mysql")) {
+ /* || !strcmp(val_ptr[1], "postgresql") */
+ /* || !strcmp(val_ptr[1], "oracle") */
+ asprintf(&conf.db.type, "%s", val_ptr);
+ if (!conf.db.port)
+ asprintf(&conf.db.port, "%s", val_ptr);
} else {
- ok = 0;
- log(ERROR, "Invalid db.type: %s", tmp + 1);
- failed = 1;
+ val_ok = false;
+ log(ERROR, "Invalid db.type: %s", "%s", val_ptr);
+ failed = true;
}
- } else if (!strcmp(buf, "db.hostname"))
+ } else if (!strcmp(line, "db.hostname"))
/* Just save it, launch_rmps will check it */
- strncpy(conf.db.hostname, tmp + 1,
- sizeof(conf.db.hostname) - 1);
- else if (!strcmp(buf, "db.port")) {
- i = strlen(tmp + 1);
+ strncpy(conf.db.hostname, val_ptr, HOSTNAMESIZE - 1);
+ else if (!strcmp(line, "db.port")) {
+ i = strlen(val_ptr);
if (i < 6) { /* max 5 digits for network port */
- if ((signed int)strspn(tmp + 1,
- "1234567890") == i) {
- i = atoi(tmp + 1);
+ if ((signed int)strspn(val_ptr, "1234567890") == i) {
+ i = atoi(val_ptr);
if (i > 0 && i < 65536) {
- strncpy(conf.db.port, tmp + 1,
- sizeof(conf.db.port)-1);
+ asprintf(&conf.db.port, "%s", val_ptr);
continue;
}
}
}
- log(ERROR, "Invalid db.port value: %s", tmp + 1);
- ok = 0;
- failed = 1;
- } else if (!strcmp(buf, "db.pass"))
- strncpy(conf.db.pass, tmp + 1,
- sizeof(conf.db.pass) - 1);
- else if (!strcmp(buf, "rmps.agent_ip")) {
+ log(ERROR, "Invalid db.port value: %s", val_ptr);
+ val_ok = false;
+ failed = true;
+ } else if (!strcmp(line, "db.pass"))
+ asprintf(&conf.db.pass, "%s", val_ptr);
+ else if (!strcmp(line, "rmps.agent_ip")) {
/* TODO */
- } else if (!strcmp(buf, "rmps.agent_port")) {
- i = strlen(tmp + 1);
+ } else if (!strcmp(line, "rmps.agent_port")) {
+ i = strlen(val_ptr);
if (i < 6) { /* max 5 digits for network port */
- if ((signed int)strspn(tmp + 1,
+ if ((signed int)strspn(val_ptr,
"1234567890") == i) {
- i = atoi(tmp + 1);
+ i = atoi(val_ptr);
if (i > 0 && i < 65536) {
- strncpy(conf.rmps.agent_port,
- tmp + 1,
- sizeof(conf.rmps.agent_port) - 1);
+ asprintf(&conf.rmps.agent_port, "%s", val_ptr);
continue;
}
}
}
- log(ERROR, "Invalid rmps.agent_port value: %s", tmp + 1);
- ok = 0;
- failed = 1;
- } else if (!strcmp(buf, "rmps.client_ip")) {
+ log(ERROR, "Invalid rmps.agent_port value: %s", val_ptr);
+ val_ok = false;
+ failed = true;
+ } else if (!strcmp(line, "rmps.client_ip")) {
/* TODO */
- } else if (!strcmp(buf, "rmps.client_port")) {
- i = strlen(tmp + 1);
+ } else if (!strcmp(line, "rmps.client_port")) {
+ i = strlen(val_ptr);
if (i < 6) { /* max 5 digits for network port */
- if ((signed int)strspn(tmp + 1,
- "1234567890") == i) {
- i = atoi(tmp + 1);
+ if ((signed int)strspn(val_ptr, "1234567890") == i) {
+ i = atoi(val_ptr);
if (i > 0 && i < 65536) {
- strncpy(conf.rmps.client_port,
- tmp + 1,
- sizeof(conf.rmps.client_port) - 1);
+ asprintf(&conf.rmps.client_port, "%s", val_ptr);
continue;
}
}
}
- log(ERROR, "Invalid rmps.client_port value: %s", tmp + 1);
- ok = 0;
- failed = 1;
- } else if (!strcmp(buf, "rmps.logfile")) {
- strncpy(conf.rmps.logfile, tmp + 1,
- sizeof(conf.rmps.logfile) - 1);
+ log(ERROR, "Invalid rmps.client_port value: %s", val_ptr);
+ val_ok = false;
+ failed = true;
+ } else if (!strcmp(line, "rmps.logfile")) {
+ asprintf(&conf.rmps.logfile, "%s", val_ptr);
/*if (fopen_and_mkdir(conf.rmps.logfile) != 0)
- failed = 1;*/
- } else if (!strcmp(buf, "rmps.errlog")) {
- strncpy(conf.rmps.errlog, tmp + 1,
- sizeof(conf.rmps.errlog) - 1);
+ failed = true;*/
+ } else if (!strcmp(line, "rmps.errlog")) {
+ asprintf(&conf.rmps.errlog, "%s", val_ptr);
/*if (fopen_and_mkdir(conf.rmps.errlog) != 0)
- failed = 1;*/
- } else if (!strcmp(buf, "rmps.pidfile")) {
- strncpy(conf.rmps.pidfile, tmp + 1,
- sizeof(conf.rmps.pidfile) - 1);
+ failed = true;*/
+ } else if (!strcmp(line, "rmps.pidfile")) {
+ asprintf(&conf.rmps.pidfile, "%s", val_ptr);
/*if (fopen_and_mkdir(conf.rmps.pidfile) != 0)
- failed = 1;*/
- } else if (!strcmp(buf, "rmps.loglevel")) {
- if (strlen(tmp + 1) == 1 &&
- (tmp[1] > '0' && tmp[1] < '5'))
- conf.rmps.loglevel = tmp[1] - '0';
+ failed = true;*/
+ } else if (!strcmp(line, "rmps.loglevel")) {
+ if (strlen(val_ptr) == 1 &&
+ (val_ptr[0] > '0' && val_ptr[0] < '5'))
+ conf.rmps.loglevel = val_ptr[0] - '0';
else {
- log(ERROR, "Invalid loglevel: %s", tmp + 1);
- failed = 1;
+ log(ERROR, "Invalid rmps.loglevel: %s", val_ptr);
+ failed = true;
}
- } else if (!strcmp(buf, "rmps.agent_tls_crt")) {
- if (access(tmp + 1, F_OK) == -1) {
- log(ERROR, "%s is missing", tmp + 1);
- failed = 1;
- } else if (access(tmp + 1, R_OK) == -1) {
- log(ERROR, "%s is not readable", tmp + 1);
- failed = 1;
+ } else if (!strcmp(line, "rmps.agent_tls_crt")) {
+ if (access(val_ptr, F_OK) == -1) {
+ log(ERROR, "%s is missing", val_ptr);
+ failed = true;
+ } else if (access(val_ptr, R_OK) == -1) {
+ log(ERROR, "%s is not readable", val_ptr);
+ failed = true;
} else
- strncpy(conf.rmps.agent_tls_crt,
- tmp + 1,
- sizeof(conf.rmps.agent_tls_crt) - 1);
- } else if (!strcmp(buf, "rmps.agent_tls_key")) {
- if (access(tmp + 1, F_OK) == -1) {
- log(ERROR, "%s is missing", tmp + 1);
- failed = 1;
- } else if (access(tmp + 1, R_OK) == -1) {
- log(ERROR, "%s is not readable", tmp + 1);
- failed = 1;
+ asprintf(&conf.rmps.agent_tls_crt, "%s", val_ptr);
+ } else if (!strcmp(line, "rmps.agent_tls_key")) {
+ if (access(val_ptr, F_OK) == -1) {
+ log(ERROR, "%s is missing", val_ptr);
+ failed = true;
+ } else if (access(val_ptr, R_OK) == -1) {
+ log(ERROR, "%s is not readable", val_ptr);
+ failed = true;
} else
- strncpy(conf.rmps.agent_tls_key,
- tmp + 1,
- sizeof(conf.rmps.agent_tls_key) - 1);
- } else if (!strcmp(buf, "rmps.cipherlist")) {
- strncpy(conf.rmps.cipherlist,
- tmp + 1, sizeof(conf.rmps.cipherlist) - 1);
- } else if (!strcmp(buf, "rmps.cafile")) {
- if (access(tmp + 1, F_OK) == -1) {
- log(ERROR, "%s is missing", tmp + 1);
- failed = 1;
- } else if (access(tmp + 1, R_OK) == -1) {
- log(ERROR, "%s is not readable\n", tmp + 1);
- failed = 1;
+ asprintf(&conf.rmps.agent_tls_key, "%s", val_ptr);
+ } else if (!strcmp(line, "rmps.cipherlist")) {
+ asprintf(&conf.rmps.cipherlist, "%s", val_ptr);
+ } else if (!strcmp(line, "rmps.cafile")) {
+ if (access(val_ptr, F_OK) == -1) {
+ log(ERROR, "%s is missing", val_ptr);
+ failed = true;
+ } else if (access(val_ptr, R_OK) == -1) {
+ log(ERROR, "%s is not readable\n", val_ptr);
+ failed = true;
} else
- strncpy(conf.rmps.cafile,
- tmp + 1, sizeof(conf.rmps.cafile) - 1);
- } else if (!strcmp(buf, "rmps.client_tls_crt")) {
- if (access(tmp + 1, F_OK) == -1) {
- log(ERROR, "%s is missing", tmp + 1);
- failed = 1;
- } else if (access(tmp + 1, R_OK) == -1) {
- log(ERROR, "%s is not readable", tmp + 1);
- failed = 1;
+ asprintf(&conf.rmps.cafile, "%s", val_ptr);
+ } else if (!strcmp(line, "rmps.client_tls_crt")) {
+ if (access(val_ptr, F_OK) == -1) {
+ log(ERROR, "%s is missing", val_ptr);
+ failed = true;
+ } else if (access(val_ptr, R_OK) == -1) {
+ log(ERROR, "%s is not readable", val_ptr);
+ failed = true;
} else
- strncpy(conf.rmps.client_tls_crt,
- tmp + 1,
- sizeof(conf.rmps.client_tls_crt) - 1);
- } else if (!strcmp(buf, "rmps.client_tls_key")) {
- if (access(tmp + 1, F_OK) == -1) {
- log(ERROR, "%s is missing", tmp + 1);
- failed = 1;
- } else if (access(tmp + 1, R_OK) == -1) {
- log(ERROR, "%s is not readable", tmp + 1);
- failed = 1;
+ asprintf(&conf.rmps.client_tls_crt, "%s", val_ptr);
+ } else if (!strcmp(line, "rmps.client_tls_key")) {
+ if (access(val_ptr, F_OK) == -1) {
+ log(ERROR, "%s is missing", val_ptr);
+ failed = true;
+ } else if (access(val_ptr, R_OK) == -1) {
+ log(ERROR, "%s is not readable", val_ptr);
+ failed = true;
} else
- strncpy(conf.rmps.client_tls_key,
- tmp + 1,
- sizeof(conf.rmps.client_tls_key) - 1);
+ asprintf(&conf.rmps.client_tls_key, "%s", val_ptr);
} else {
log(ERROR, "Unknown config entry on line %d: %s",
- j, buf);
- failed = 1;
+ line_itr, line);
+ failed = true;
}
- if (!ok) {
+ if (!val_ok) {
log(ERROR,
"Invalid value for \"%s\", line %d: \"%s\"",
- buf, j, tmp + 1);
- ok = !ok;
+ line, line_itr, val_ptr);
+ val_ok = !val_ok;
}
}
fclose(fp);
+ if (errno)
+ log(ERROR, "confparse - getline() - %s", strerror(errno));
+ free(line);
if (failed)
- return 1;
- conf.isvalid = 1;
- return 0;
+ return false;
+ return true;
}
-int confparse(char *config)
+static bool test_conf_required(void)
{
- int result;
+ bool failed = false;
- result = test_conf_perms(config);
- if (result)
- return 1; /* Bad conf perms */
+ if (conf.db.hostname[0] == '\0') {
+ log(ERROR, "cond.db.hostname - not set!");
+ failed = true;
+ }
+ if (!conf.db.type) {
+ log(ERROR, "cond.db.type - not set!");
+ failed = true;
+ }
+ if (!conf.db.pass) {
+ log(ERROR, "cond.db.pass - not set!");
+ failed = true;
+ }
+ if (!conf.db.port) {
+ log(ERROR, "cond.db.port - not set!");
+ failed = true;
+ }
+ if (!conf.rmps.cipherlist) {
+ log(ERROR, "conf.rmps.cipherlist - not set!");
+ failed = true;
+ }
- result = test_conf_syntax(config);
- if (result != 0)
- return 1; /* Bad conf syntax */
- return 0; /* seems legit */
+ if (failed)
+ return false;
+ return true;
+}
+
+bool confparse(char *config)
+{
+ init_conf();
+ if (test_conf_perms(config) &&
+ test_conf_syntax(config) &&
+ test_conf_required())
+ conf.isvalid = true;
+ return conf.isvalid; /* seems legit */
}
diff --git a/src/confparser.h b/src/confparser.h
index a4edd42..4d3f370 100644
--- a/src/confparser.h
+++ b/src/confparser.h
@@ -23,34 +23,34 @@
#define CONFPARSER_H
#include
+#include
#include "log.h"
-#define HOSTNAMESIZE 128
-#define CFGLINESIZE (PATH_MAX + NAME_MAX + 30) /* 30 is pretty random */
+#define HOSTNAMESIZE 256 /* according to RFC 1035 */
struct conf_db {
- char type[15];
+ char *type;
char hostname[HOSTNAMESIZE];
- char port[6];
- char pass[60]; /* random decision */
+ char *port;
+ char *pass; /* random decision */
};
struct conf_rmps {
- char agent_ip[13];
- char agent_port[6];
- char client_ip[13];
- char client_port[6];
- char logfile[PATH_MAX+NAME_MAX];
- char errlog[PATH_MAX+NAME_MAX];
+ char *agent_ip;
+ char *agent_port;
+ char *client_ip;
+ char *client_port;
+ char *logfile;
+ char *errlog;
enum LOG_LEVEL loglevel;
- char pidfile[PATH_MAX+NAME_MAX];
- char agent_tls_crt[PATH_MAX+NAME_MAX];
- char agent_tls_key[PATH_MAX+NAME_MAX];
- char cafile[PATH_MAX+NAME_MAX];
- char cipherlist[1024];
+ char *pidfile;
+ char *agent_tls_crt;
+ char *agent_tls_key;
+ char *cafile;
+ char *cipherlist;
int agent_poolsize;
- char client_tls_crt[PATH_MAX+NAME_MAX];
- char client_tls_key[PATH_MAX+NAME_MAX];
+ char *client_tls_crt;
+ char *client_tls_key;
int client_poolsize;
};
@@ -59,14 +59,14 @@ struct conf_nfs {
};
struct conf_table {
- int isvalid;
+ bool isvalid;
struct conf_db db;
struct conf_rmps rmps;
struct conf_nfs nfs;
};
extern struct conf_table conf;
-extern int confparse(char *config);
+extern bool confparse(char *config);
extern void confexport(void);
extern const char *conf_db_pass(void);
extern const char *conf_db_hostname(void);
diff --git a/src/main.c b/src/main.c
index b2b13b9..67e51cf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
memcpy(config, path, path_size);
}
- if (confparse(config) != 0) {
+ if (!confparse(config)) {
fprintf(stderr, "Failed to parse the conf!\n");
exit(EXIT_FAILURE);
}
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
}
}
if (task == START || task == RESTART)
- rmps_launch(&conf, fork_flag);
+ rmps_launch(fork_flag);
return 0;
}
diff --git a/src/rmps.c b/src/rmps.c
index 007f5ca..7f2fec2 100644
--- a/src/rmps.c
+++ b/src/rmps.c
@@ -331,7 +331,7 @@ int rmps_die(void)
return 0;
}
-void rmps_launch(struct conf_table *conf, int fork_flag)
+void rmps_launch(int fork_flag)
{
pthread_t pool[2];
struct pool_data pool_args[2];
@@ -343,38 +343,38 @@ void rmps_launch(struct conf_table *conf, int fork_flag)
if (fork_flag)
daemonize("/tmp/");
/* Spawn & lock pidfile */
- spawn_pidfile(conf->rmps.pidfile);
+ spawn_pidfile(conf.rmps.pidfile);
/* openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX -nodes
* -nodes is for not protecing with a passphrase
* http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl
*/
- pool_args[0].ctx = init_server_ctx(conf->rmps.cipherlist,
+ pool_args[0].ctx = init_server_ctx(conf.rmps.cipherlist,
SSL_VERIFY_PEER |
SSL_VERIFY_CLIENT_ONCE |
SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
log(VERBOSE, "Loading agent certs and keys.");
- load_certificates(pool_args[0].ctx, conf->rmps.agent_tls_crt,
- conf->rmps.agent_tls_key, conf->rmps.cafile);
+ load_certificates(pool_args[0].ctx, conf.rmps.agent_tls_crt,
+ conf.rmps.agent_tls_key, conf.rmps.cafile);
log(VERBOSE, "Starting agent listener on port: %d",
- atoi(conf->rmps.agent_port));
- pool_args[0].srv = open_listener(atoi(conf->rmps.agent_port));
- pool_args[0].size = conf->rmps.agent_poolsize;
+ atoi(conf.rmps.agent_port));
+ pool_args[0].srv = open_listener(atoi(conf.rmps.agent_port));
+ pool_args[0].size = conf.rmps.agent_poolsize;
log(VERBOSE, "Creating agent thread pool (mutex).");
pthread_create(&pool[0], NULL, agent_pool, &pool_args[0]);
- pool_args[1].ctx = init_server_ctx(conf->rmps.cipherlist,
+ pool_args[1].ctx = init_server_ctx(conf.rmps.cipherlist,
SSL_VERIFY_NONE);
log(VERBOSE, "Loading client certs and keys.");
- load_certificates(pool_args[1].ctx, conf->rmps.client_tls_crt,
- conf->rmps.client_tls_key, conf->rmps.cafile);
+ load_certificates(pool_args[1].ctx, conf.rmps.client_tls_crt,
+ conf.rmps.client_tls_key, conf.rmps.cafile);
log(VERBOSE, "Starting client listener on port: %d",
- atoi(conf->rmps.client_port));
- pool_args[1].srv = open_listener(atoi(conf->rmps.client_port));
- pool_args[1].size = conf->rmps.client_poolsize;
+ atoi(conf.rmps.client_port));
+ pool_args[1].srv = open_listener(atoi(conf.rmps.client_port));
+ pool_args[1].size = conf.rmps.client_poolsize;
log(VERBOSE, "Creating client thread pool (mutex).");
pthread_create(&pool[1], NULL, client_pool, &pool_args[1]);
- if (start_job_queue(conf->rmps.agent_poolsize) == FAIL) {
+ if (start_job_queue(conf.rmps.agent_poolsize) == FAIL) {
log(ERROR,
"On start_job_queue(), RMPS failed to start, shutting down...");
exit(EXIT_FAILURE);
diff --git a/src/rmps.h b/src/rmps.h
index c5f3642..3f3f188 100644
--- a/src/rmps.h
+++ b/src/rmps.h
@@ -31,7 +31,7 @@ struct pool_data {
int size;
};
-extern void rmps_launch(struct conf_table *conf, int fork_flag);
+extern void rmps_launch(int fork_flag);
extern int rmps_die(void);
#endif /* RMPS_H */