Coding style is religion

This commit is contained in:
2017-05-17 18:43:29 +03:00
parent 6d0a190c2f
commit b7df1d32fd
7 changed files with 47 additions and 44 deletions

View File

@@ -33,6 +33,7 @@ static void* servlet(void *args) /* Serve the connection -- threadable */
log_ssl(); log_ssl();
} else { } else {
int queue_id = start_msg_queue(); int queue_id = start_msg_queue();
if (queue_id == FAIL) if (queue_id == FAIL)
goto exit; goto exit;
do { do {
@@ -75,6 +76,7 @@ exit:
static void send_reject_msg(SSL *ssl) static void send_reject_msg(SSL *ssl)
{ {
char *reply = "FAILURE - The connection queue is full!\n"; char *reply = "FAILURE - The connection queue is full!\n";
SSL_write(ssl, reply, strlen(reply)); SSL_write(ssl, reply, strlen(reply));
} }
@@ -101,6 +103,7 @@ void* client_pool(void *args)
socklen_t len = sizeof(addr); socklen_t len = sizeof(addr);
SSL *ssl; SSL *ssl;
int agent = accept(pool->srv, (struct sockaddr *)&addr, &len); int agent = accept(pool->srv, (struct sockaddr *)&addr, &len);
log(INFO, log(INFO,
"Connection: %s:%d", "Connection: %s:%d",
inet_ntop(AF_INET, &addr.sin_addr, address, sizeof(address)), inet_ntop(AF_INET, &addr.sin_addr, address, sizeof(address)),

View File

@@ -111,7 +111,7 @@ static int fopen_and_mkdir(const char *dir)
for (p = tmp + 1; *p; p++) for (p = tmp + 1; *p; p++)
if (*p == '/') { if (*p == '/') {
*p = 0; *p = 0;
if (mkdir(tmp, S_IRWXU) == -1 && errno != EEXIST) { if (mkdir(tmp, 0700) == -1 && errno != EEXIST) {
log(ERROR, log(ERROR,
"Permission denied to create directory: %s", "Permission denied to create directory: %s",
tmp); tmp);
@@ -147,8 +147,8 @@ static int test_conf_perms(void)
log(ERROR, confresult); log(ERROR, confresult);
return 1; return 1;
} }
if (!(S_IRUSR & s.st_mode) || if (!(0400 & s.st_mode) ||
!(S_IXUSR & s.st_mode)) { !(0100 & s.st_mode)) {
enumtostr(confresult, CONF_DIR_PERM); enumtostr(confresult, CONF_DIR_PERM);
log(ERROR, confresult); log(ERROR, confresult);
return 1; return 1;
@@ -159,8 +159,8 @@ static int test_conf_perms(void)
} else if (s.st_gid != 0) { } else if (s.st_gid != 0) {
enumtostr(confresult, CONF_DIR_GID_INSECURE); enumtostr(confresult, CONF_DIR_GID_INSECURE);
log(WARNING, confresult); log(WARNING, confresult);
} else if ((S_IROTH & s.st_mode) || } else if ((0004 & s.st_mode) ||
(S_IWOTH & s.st_mode)) { (0002 & s.st_mode)) {
enumtostr(confresult, CONF_DIR_PERM_INSECURE); enumtostr(confresult, CONF_DIR_PERM_INSECURE);
log(WARNING, confresult); log(WARNING, confresult);
} }
@@ -180,7 +180,7 @@ static int test_conf_perms(void)
log(ERROR, confresult); log(ERROR, confresult);
return 1; return 1;
} }
if (!(S_IRUSR & s.st_mode)) { if (!(0400 & s.st_mode)) {
enumtostr(confresult, CONF_PERM); enumtostr(confresult, CONF_PERM);
log(ERROR, confresult); log(ERROR, confresult);
return 1; return 1;
@@ -191,8 +191,8 @@ static int test_conf_perms(void)
} else if (s.st_gid != 0) { } else if (s.st_gid != 0) {
enumtostr(confresult, CONF_FILE_GID_INSECURE); enumtostr(confresult, CONF_FILE_GID_INSECURE);
log(WARNING, confresult); log(WARNING, confresult);
} else if ((S_IROTH & s.st_mode) || } else if ((0004 & s.st_mode) ||
(S_IWOTH & s.st_mode)) { (0002 & s.st_mode)) {
enumtostr(confresult, CONF_FILE_PERM_INSECURE); enumtostr(confresult, CONF_FILE_PERM_INSECURE);
log(WARNING, confresult); log(WARNING, confresult);
} }

View File

@@ -4,7 +4,7 @@
#include "job_queue.h" #include "job_queue.h"
struct msg_t **slot; struct msg_t **slot;
int total_queues = 0; int total_queues;
int start_msg_queue(void) int start_msg_queue(void)
{ {