Start working on client listener
This commit is contained in:
108
confparser.c
108
confparser.c
@@ -19,17 +19,22 @@ struct conf_table conf = {
|
||||
"" /* db.port */
|
||||
},
|
||||
{
|
||||
"127.0.0.1", /* rmps.bind_on_ip */
|
||||
"7000", /* rmps.bind_on_port */
|
||||
"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/cert.pem",
|
||||
"/etc/rmps/key.pem",
|
||||
"/etc/rmps/agent.crt",
|
||||
"/etc/rmps/agent.key",
|
||||
"/etc/rmps/ca.crt",
|
||||
"", /* rmps.cipherlist */
|
||||
2 /* rmps.threadpoolsize */
|
||||
2, /* rmps.agent_poolsize */
|
||||
"/etc/rmps/client.crt",
|
||||
"/etc/rmps/client.key",
|
||||
2 /* rmps.client_poolsize */
|
||||
},
|
||||
{
|
||||
0 /* nfs -> TODO */
|
||||
@@ -41,31 +46,41 @@ void confexport(void)
|
||||
printf( "db.type=%s\n"
|
||||
"db.hostname=%s\n"
|
||||
"db.port=%s\n"
|
||||
"rmps.bind_on_ip=%s\n"
|
||||
"rmps.bind_on_port=%s\n"
|
||||
"rmps.agent_ip=%s\n"
|
||||
"rmps.agent_port=%s\n"
|
||||
"rmps.client_ip=%s\n"
|
||||
"rmps.client_port=%s\n"
|
||||
"rmps.logfile=%s\n"
|
||||
"rmps.errlog=%s\n"
|
||||
"rmps.loglevel=%c\n"
|
||||
"rmps.loglevel=%d\n"
|
||||
"rmps.pidfile=%s\n"
|
||||
"rmps.certfile=%s\n"
|
||||
"rmps.keyfile=%s\n"
|
||||
"rmps.agent_tls_crt=%s\n"
|
||||
"rmps.agent_tls_key=%s\n"
|
||||
"rmps.cafile=%s\n"
|
||||
"rmps.cipherlist=%s\n"
|
||||
"rmps.threadpoolsize=%d\n",
|
||||
"rmps.agent_poolsize=%d\n"
|
||||
"rmps.client_tls_crt=%s\n"
|
||||
"rmps.client_tls_key=%s\n"
|
||||
"rmps.client_poolsize=%d\n",
|
||||
conf.db.type,
|
||||
conf.db.hostname,
|
||||
conf.db.port,
|
||||
conf.rmps.bind_on_ip,
|
||||
conf.rmps.bind_on_port,
|
||||
conf.rmps.agent_ip,
|
||||
conf.rmps.agent_port,
|
||||
conf.rmps.client_ip,
|
||||
conf.rmps.client_port,
|
||||
conf.rmps.logfile,
|
||||
conf.rmps.errlog,
|
||||
conf.rmps.loglevel,
|
||||
conf.rmps.pidfile,
|
||||
conf.rmps.certfile,
|
||||
conf.rmps.keyfile,
|
||||
conf.rmps.agent_tls_crt,
|
||||
conf.rmps.agent_tls_key,
|
||||
conf.rmps.cafile,
|
||||
conf.rmps.cipherlist,
|
||||
conf.rmps.threadpoolsize
|
||||
conf.rmps.agent_poolsize,
|
||||
conf.rmps.client_tls_crt,
|
||||
conf.rmps.client_tls_key,
|
||||
conf.rmps.client_poolsize
|
||||
);
|
||||
}
|
||||
|
||||
@@ -217,7 +232,7 @@ static int test_conf_syntax(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Here we check every single entry manually */
|
||||
/* Here we check every single conf entry manually */
|
||||
if (!strcmp(buf, "db.type")) {
|
||||
if (!strcmp(tmp + 1, "mysql")) {
|
||||
/* || !strcmp(tmp[1], "postgresql") */
|
||||
@@ -244,15 +259,28 @@ static int test_conf_syntax(void)
|
||||
}
|
||||
ok = 0;
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "rmps.bind_on_ip")) {
|
||||
} else if (!strcmp(buf, "rmps.agent_ip")) {
|
||||
/* TODO */
|
||||
|
||||
} else if (!strcmp(buf, "rmps.bind_on_port")) {
|
||||
} else if (!strcmp(buf, "rmps.agent_port")) {
|
||||
if ((i = strlen(tmp + 1)) < 6) {
|
||||
if ((signed int)strspn(tmp + 1, "1234567890") == i) {
|
||||
i = atoi(tmp + 1);
|
||||
if (i > 0 && i < 65536) {
|
||||
strcpy(conf.rmps.bind_on_port, tmp + 1);
|
||||
strcpy(conf.rmps.agent_port, tmp + 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = 0;
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "rmps.client_ip")) {
|
||||
/* TODO */
|
||||
} else if (!strcmp(buf, "rmps.client_port")) {
|
||||
if ((i = strlen(tmp + 1)) < 6) {
|
||||
if ((signed int)strspn(tmp + 1, "1234567890") == i) {
|
||||
i = atoi(tmp + 1);
|
||||
if (i > 0 && i < 65536) {
|
||||
strcpy(conf.rmps.client_port, tmp + 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -276,7 +304,7 @@ static int test_conf_syntax(void)
|
||||
conf.rmps.loglevel = tmp[1] - '0';
|
||||
else
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "rmps.certfile")) {
|
||||
} else if (!strcmp(buf, "rmps.agent_tls_crt")) {
|
||||
if (access(tmp + 1, F_OK) == -1) {
|
||||
log(ERROR, "%s is missing", tmp + 1);
|
||||
failed = 1;
|
||||
@@ -285,18 +313,22 @@ static int test_conf_syntax(void)
|
||||
log(ERROR, "%s is not readable", tmp + 1);
|
||||
failed = 1;
|
||||
} else
|
||||
strncpy(conf.rmps.certfile, tmp + 1, sizeof(conf.rmps.certfile));
|
||||
strncpy(conf.rmps.agent_tls_crt,
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.agent_tls_crt));
|
||||
}
|
||||
else if (!strcmp(buf, "rmps.keyfile")) {
|
||||
else if (!strcmp(buf, "rmps.agent_tls_key")) {
|
||||
if (access(tmp + 1, F_OK) == -1) {
|
||||
log(ERROR, "%s is missing", conf.rmps.keyfile);
|
||||
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
|
||||
strncpy(conf.rmps.keyfile, tmp + 1, sizeof(conf.rmps.keyfile));
|
||||
strncpy(conf.rmps.agent_tls_key,
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.agent_tls_key));
|
||||
} else if (!strcmp(buf, "rmps.cipherlist")) {
|
||||
strncpy(conf.rmps.cipherlist, tmp + 1, sizeof(conf.rmps.cipherlist));
|
||||
} else if (!strcmp(buf, "rmps.cafile")) {
|
||||
@@ -309,6 +341,30 @@ static int test_conf_syntax(void)
|
||||
failed = 1;
|
||||
} else
|
||||
strncpy(conf.rmps.cafile, tmp + 1, sizeof(conf.rmps.cafile));
|
||||
} 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;
|
||||
} else
|
||||
strncpy(conf.rmps.client_tls_crt,
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.client_tls_crt));
|
||||
} 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;
|
||||
} else
|
||||
strncpy(conf.rmps.client_tls_key,
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.client_tls_key));
|
||||
} else
|
||||
log(ERROR, "Unknown config entry on line %d: %s", j, buf);
|
||||
if (!ok) {
|
||||
|
||||
Reference in New Issue
Block a user