Improve conf and conf testing
This commit is contained in:
@@ -166,30 +166,35 @@ static int test_conf_perms(char *config)
|
||||
if (err == -1) {
|
||||
if (errno == ENOENT) {
|
||||
enumtostr(confresult, CONF_MISSING);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (!S_ISREG(s.st_mode)) {
|
||||
enumtostr(confresult, CONF_NOTFILE);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config);
|
||||
return 1;
|
||||
}
|
||||
if (!(0400 & s.st_mode)) {
|
||||
enumtostr(confresult, CONF_PERM);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config);
|
||||
return 1;
|
||||
}
|
||||
if (access(config, R_OK) != 0) {
|
||||
enumtostr(confresult, CONF_NOT_READABLE);
|
||||
log(ERROR, confresult, config);
|
||||
return 1;
|
||||
}
|
||||
if (s.st_uid != 0) {
|
||||
enumtostr(confresult, CONF_FILE_UID_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config);
|
||||
} else if (s.st_gid != 0) {
|
||||
enumtostr(confresult, CONF_FILE_GID_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config);
|
||||
} else if ((0004 & s.st_mode) ||
|
||||
(0002 & s.st_mode)) {
|
||||
enumtostr(confresult, CONF_FILE_PERM_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,31 +203,31 @@ static int test_conf_perms(char *config)
|
||||
if (err == -1) {
|
||||
if (errno == ENOENT) {
|
||||
enumtostr(confresult, CONF_DIR_MISSING);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config_copy);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (!S_ISDIR(s.st_mode)) {
|
||||
enumtostr(confresult, CONF_DIR_NOTDIR);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config_copy);
|
||||
return 1;
|
||||
}
|
||||
if (!(0400 & s.st_mode) ||
|
||||
!(0100 & s.st_mode)) {
|
||||
enumtostr(confresult, CONF_DIR_PERM);
|
||||
log(ERROR, confresult);
|
||||
log(ERROR, confresult, config_copy);
|
||||
return 1;
|
||||
}
|
||||
if (s.st_uid != 0) {
|
||||
enumtostr(confresult, CONF_DIR_UID_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config_copy);
|
||||
} else if (s.st_gid != 0) {
|
||||
enumtostr(confresult, CONF_DIR_GID_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config_copy);
|
||||
} else if ((0004 & s.st_mode) ||
|
||||
(0002 & s.st_mode)) {
|
||||
enumtostr(confresult, CONF_DIR_PERM_INSECURE);
|
||||
log(WARNING, confresult);
|
||||
log(WARNING, confresult, config_copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,18 +352,18 @@ static int test_conf_syntax(char *config)
|
||||
} else if (!strcmp(buf, "rmps.logfile")) {
|
||||
strncpy(conf.rmps.logfile, tmp + 1,
|
||||
sizeof(conf.rmps.logfile) - 1);
|
||||
if (fopen_and_mkdir(conf.rmps.logfile) != 0)
|
||||
failed = 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);
|
||||
if (fopen_and_mkdir(conf.rmps.errlog) != 0)
|
||||
failed = 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);
|
||||
if (fopen_and_mkdir(conf.rmps.pidfile) != 0)
|
||||
failed = 1;
|
||||
/*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'))
|
||||
|
||||
Reference in New Issue
Block a user