Renamed log_trace() to log()

This commit is contained in:
2016-08-10 20:21:54 +03:00
parent 65b923cba8
commit dcd7a46d0a
10 changed files with 100 additions and 97 deletions

View File

@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log_trace.h"
#include "log.h"
#include "confparser.h"
#include "enum_functions.h"
@@ -36,7 +36,7 @@ struct conf_table conf = {
}
};
void confexport()
void confexport(void)
{
printf( "db.type=%s\n"
"db.hostname=%s\n"
@@ -83,7 +83,7 @@ static int fopen_and_mkdir(const char *dir) {
if(*p == '/') {
*p = 0;
if (mkdir(tmp, S_IRWXU) == -1 && errno != EEXIST) {
log_trace( ERROR,
log( ERROR,
"Permission denied to create directory: %s",
tmp );
return 1;
@@ -92,7 +92,7 @@ static int fopen_and_mkdir(const char *dir) {
}
fp = fopen(dir, "a");
if (!fp) {
log_trace(ERROR, "Permission denied to write into: %s", dir);
log(ERROR, "Permission denied to write into: %s", dir);
return 1;
}
fclose(fp);
@@ -100,7 +100,7 @@ static int fopen_and_mkdir(const char *dir) {
}
static int test_conf_perms()
static int test_conf_perms(void)
{
struct stat s;
char confresult[128];
@@ -109,33 +109,33 @@ static int test_conf_perms()
if (err == -1) {
if (errno == ENOENT) {
enumtostr(confresult, CONF_DIR_MISSING);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
} else {
if (!S_ISDIR(s.st_mode)) {
enumtostr(confresult, CONF_DIR_NOTDIR);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
if ( !(S_IRUSR & s.st_mode) ||
!(S_IXUSR & s.st_mode) ) {
enumtostr(confresult, CONF_DIR_PERM);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
if (s.st_uid != 0) {
enumtostr(confresult, CONF_DIR_UID_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
else if (s.st_gid != 0) {
enumtostr(confresult, CONF_DIR_GID_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
else if ( (S_IROTH & s.st_mode) ||
(S_IWOTH & s.st_mode) ) {
enumtostr(confresult, CONF_DIR_PERM_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
}
@@ -144,45 +144,45 @@ static int test_conf_perms()
if (err == -1) {
if (errno == ENOENT) {
enumtostr(confresult, CONF_MISSING);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
} else {
if (!S_ISREG(s.st_mode)) {
enumtostr(confresult, CONF_NOTFILE);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
if (!(S_IRUSR & s.st_mode)) {
enumtostr(confresult, CONF_PERM);
log_trace(ERROR, confresult);
log(ERROR, confresult);
return 1;
}
if (s.st_uid != 0) {
enumtostr(confresult, CONF_FILE_UID_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
else if (s.st_gid != 0) {
enumtostr(confresult, CONF_FILE_GID_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
else if ( (S_IROTH & s.st_mode) ||
(S_IWOTH & s.st_mode) ) {
enumtostr(confresult, CONF_FILE_PERM_INSECURE);
log_trace(WARNING, confresult);
log(WARNING, confresult);
}
}
return 0; /* conf is readable */
}
static int test_conf_syntax()
static int test_conf_syntax(void)
{
int i, j = 0, ok = 1, failed = 0;
char buf[CFGLINESIZE], *tmp;
FILE *fp = fopen("/etc/rmps/rmps.conf", "r");
if (fp == NULL) {
log_trace(ERROR, "Failed to read /etc/rmps/rmps.conf");
log(ERROR, "Failed to read /etc/rmps/rmps.conf");
return 1;
}
@@ -198,7 +198,7 @@ static int test_conf_syntax()
if ((tmp = strstr(buf, "=")))
*tmp = '\0';
else {
log_trace( ERROR,
log( ERROR,
"Bad entry in /etc/rmps/rmps.conf, line %d: %s",
j, buf );
ok = 0;
@@ -210,7 +210,7 @@ static int test_conf_syntax()
if (tmp[i] == '\n')
tmp[i] = '\0';
if (tmp[strspn(tmp + 1, " \t\v\r\n") + 1] == '\0') {
log_trace( ERROR,
log( ERROR,
"Specified entry without value, line %d: %s",
j, buf );
failed = 1;
@@ -278,22 +278,22 @@ static int test_conf_syntax()
failed = 1;
} else if (!strcmp(buf, "rmps.certfile")) {
if (access(tmp + 1, F_OK) == -1) {
log_trace(ERROR, "%s is missing", tmp + 1);
log(ERROR, "%s is missing", tmp + 1);
failed = 1;
}
else if (access(tmp + 1, R_OK) == -1) {
log_trace(ERROR, "%s is not readable", tmp + 1);
log(ERROR, "%s is not readable", tmp + 1);
failed = 1;
} else
strncpy(conf.rmps.certfile, tmp + 1, sizeof(conf.rmps.certfile));
}
else if (!strcmp(buf, "rmps.keyfile")) {
if (access(tmp + 1, F_OK) == -1) {
log_trace(ERROR, "%s is missing", conf.rmps.keyfile);
log(ERROR, "%s is missing", conf.rmps.keyfile);
failed = 1;
}
else if (access(tmp + 1, R_OK) == -1) {
log_trace(ERROR, "%s is not readable", tmp + 1);
log(ERROR, "%s is not readable", tmp + 1);
failed = 1;
} else
strncpy(conf.rmps.keyfile, tmp + 1, sizeof(conf.rmps.keyfile));
@@ -301,18 +301,18 @@ static int test_conf_syntax()
strncpy(conf.rmps.cipherlist, tmp + 1, sizeof(conf.rmps.cipherlist));
} else if (!strcmp(buf, "rmps.cafile")) {
if (access(tmp + 1, F_OK) == -1) {
log_trace(ERROR, "%s is missing", tmp + 1);
log(ERROR, "%s is missing", tmp + 1);
failed = 1;
}
else if (access(tmp + 1, R_OK) == -1) {
log_trace(ERROR, "%s is not readable\n", tmp + 1);
log(ERROR, "%s is not readable\n", tmp + 1);
failed = 1;
} else
strncpy(conf.rmps.cafile, tmp + 1, sizeof(conf.rmps.cafile));
} else
log_trace(ERROR, "Unknown config entry on line %d: %s", j, buf);
log(ERROR, "Unknown config entry on line %d: %s", j, buf);
if (!ok) {
log_trace( ERROR,
log( ERROR,
"Invalid value for \"%s\", line %d: \"%s\"",
buf, j, tmp + 1 );
ok = !ok;
@@ -326,7 +326,7 @@ static int test_conf_syntax()
return 0;
}
int confparse()
int confparse(void)
{
int result;