Fit in 80 symbols per line
This commit is contained in:
@@ -113,11 +113,13 @@ static int fopen_and_mkdir(const char *dir)
|
||||
struct stat st = {0};
|
||||
*p = 0;
|
||||
if (stat(tmp, &st) == -1)
|
||||
log(VERBOSE, "Directory \"%s\" doesn't exist. Creating...", tmp);
|
||||
log(VERBOSE,
|
||||
"Path \"%s\" doesn't exist. Creating...",
|
||||
tmp);
|
||||
if (mkdir(tmp, 0700) == -1 && errno != EEXIST) {
|
||||
log(ERROR,
|
||||
"Permission denied to create directory: %s",
|
||||
tmp);
|
||||
"Permission denied to create dir: %s",
|
||||
tmp);
|
||||
return 1;
|
||||
}
|
||||
*p = '/';
|
||||
@@ -252,16 +254,19 @@ static int test_conf_syntax(void)
|
||||
if (!strcmp(tmp + 1, "mysql")) {
|
||||
/* || !strcmp(tmp[1], "postgresql") */
|
||||
/* || !strcmp(tmp[1], "oracle") */
|
||||
strncpy(conf.db.type, tmp + 1, sizeof(conf.db.type) - 1);
|
||||
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);
|
||||
strncpy(conf.db.port, "3306",
|
||||
sizeof(conf.db.port) - 1);
|
||||
} else {
|
||||
ok = 0;
|
||||
failed = 1;
|
||||
}
|
||||
} else if (!strcmp(buf, "db.hostname"))
|
||||
/* Just save it, launch_rmps will check it */
|
||||
strncpy(conf.db.hostname, tmp + 1, sizeof(conf.db.hostname) - 1);
|
||||
strncpy(conf.db.hostname, tmp + 1,
|
||||
sizeof(conf.db.hostname) - 1);
|
||||
else if (!strcmp(buf, "db.port")) {
|
||||
i = strlen(tmp + 1);
|
||||
if (i < 6) { /* max 5 digits for network port */
|
||||
@@ -269,7 +274,8 @@ static int test_conf_syntax(void)
|
||||
"1234567890") == i) {
|
||||
i = atoi(tmp + 1);
|
||||
if (i > 0 && i < 65536) {
|
||||
strncpy(conf.db.port, tmp + 1, sizeof(conf.db.port) - 1);
|
||||
strncpy(conf.db.port, tmp + 1,
|
||||
sizeof(conf.db.port)-1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -277,7 +283,8 @@ static int test_conf_syntax(void)
|
||||
ok = 0;
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "db.pass"))
|
||||
strncpy(conf.db.pass, tmp + 1, sizeof(conf.db.pass) - 1);
|
||||
strncpy(conf.db.pass, tmp + 1,
|
||||
sizeof(conf.db.pass) - 1);
|
||||
else if (!strcmp(buf, "rmps.agent_ip")) {
|
||||
/* TODO */
|
||||
} else if (!strcmp(buf, "rmps.agent_port")) {
|
||||
@@ -288,7 +295,8 @@ static int test_conf_syntax(void)
|
||||
i = atoi(tmp + 1);
|
||||
if (i > 0 && i < 65536) {
|
||||
strncpy(conf.rmps.agent_port,
|
||||
tmp + 1, sizeof(conf.rmps.agent_port) - 1);
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.agent_port) - 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +313,8 @@ static int test_conf_syntax(void)
|
||||
i = atoi(tmp + 1);
|
||||
if (i > 0 && i < 65536) {
|
||||
strncpy(conf.rmps.client_port,
|
||||
tmp + 1, sizeof(conf.rmps.client_port) - 1);
|
||||
tmp + 1,
|
||||
sizeof(conf.rmps.client_port) - 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -313,15 +322,18 @@ static int test_conf_syntax(void)
|
||||
ok = 0;
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "rmps.logfile")) {
|
||||
strncpy(conf.rmps.logfile, tmp + 1, sizeof(conf.rmps.logfile) - 1);
|
||||
strncpy(conf.rmps.logfile, tmp + 1,
|
||||
sizeof(conf.rmps.logfile) - 1);
|
||||
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);
|
||||
strncpy(conf.rmps.errlog, tmp + 1,
|
||||
sizeof(conf.rmps.errlog) - 1);
|
||||
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);
|
||||
strncpy(conf.rmps.pidfile, tmp + 1,
|
||||
sizeof(conf.rmps.pidfile) - 1);
|
||||
if (fopen_and_mkdir(conf.rmps.pidfile) != 0)
|
||||
failed = 1;
|
||||
} else if (!strcmp(buf, "rmps.loglevel")) {
|
||||
|
||||
Reference in New Issue
Block a user