summaryrefslogtreecommitdiff
path: root/ecp
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2024-05-15 13:21:17 +0200
committerUros Majstorovic <majstor@majstor.org>2024-05-15 13:21:17 +0200
commite870fe53f71c88c636b7c4aadd5655c0fe15bde3 (patch)
tree20122c839332e9030e774d38065e8759b2153d9e /ecp
parent6d50a8bff1938a8d7f398275a886aca37d6f6a7c (diff)
fixed server logging
Diffstat (limited to 'ecp')
-rwxr-xr-xecp/build.sh4
-rw-r--r--ecp/server/acl.c4
-rw-r--r--ecp/server/dir.c4
-rw-r--r--ecp/server/server.c10
-rw-r--r--ecp/server/server.h8
-rw-r--r--ecp/server/sig.c1
-rw-r--r--ecp/server/timer.c2
-rw-r--r--ecp/server/vlink.c3
8 files changed, 21 insertions, 15 deletions
diff --git a/ecp/build.sh b/ecp/build.sh
index a050e85..5cc3a3e 100755
--- a/ecp/build.sh
+++ b/ecp/build.sh
@@ -8,6 +8,10 @@ fi
if [ -z $MAKE ]; then
+ MAKE=`which gmake`
+fi
+
+if [ -z $MAKE ]; then
MAKE=make
fi
diff --git a/ecp/server/acl.c b/ecp/server/acl.c
index 826b292..3341886 100644
--- a/ecp/server/acl.c
+++ b/ecp/server/acl.c
@@ -1,8 +1,8 @@
#include <stdlib.h>
#include <string.h>
-#include <fcntl.h>
+#include <stdio.h>
#include <unistd.h>
-#include <sys/stat.h>
+#include <fcntl.h>
#include <ecp/core.h>
#include <ecp/cr.h>
diff --git a/ecp/server/dir.c b/ecp/server/dir.c
index 91d364f..13bea68 100644
--- a/ecp/server/dir.c
+++ b/ecp/server/dir.c
@@ -1,7 +1,7 @@
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
-#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
#include <ecp/core.h>
#include <ecp/cr.h>
diff --git a/ecp/server/server.c b/ecp/server/server.c
index 59b1c60..1ec55f8 100644
--- a/ecp/server/server.c
+++ b/ecp/server/server.c
@@ -1,12 +1,11 @@
#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <ecp/core.h>
#include <ecp/vconn/vconn.h>
@@ -26,9 +25,9 @@ static SRVConfig srv_config;
static int proc_forked = 0;
static FILE *log_file = NULL;
static const char *log_level_str[] = {
- "DEBUG",
+ "ERROR",
"INFO",
- "ERROR"
+ "DEBUG"
};
SRVConfig *srv_get_config(void) {
@@ -209,6 +208,7 @@ static void daemonize(void) {
if (pid < 0) fail("fork2 failed\n");
if (pid > 0) exit(0);
+ /* redirect stdio to /dev/null */
null_rd = open("/dev/null", O_RDONLY);
if (null_rd == -1) fail("open (r) /dev/null failed\n");
null_wr = open("/dev/null", O_WRONLY);
diff --git a/ecp/server/server.h b/ecp/server/server.h
index 652bd04..47c3a8c 100644
--- a/ecp/server/server.h
+++ b/ecp/server/server.h
@@ -1,11 +1,9 @@
-#include <stdio.h>
-
-#define LOG_DEBUG 0
+#define LOG_ERR 0
#define LOG_INFO 1
-#define LOG_ERR 2
+#define LOG_DEBUG 2
#define LOG_LEVEL LOG_DEBUG
-#define LOG(l, ...) log_printf(l, __VA_ARGS__);
+#define LOG(l, ...) { if (l <= LOG_LEVEL) log_printf(l, __VA_ARGS__); }
typedef struct SRVConfig {
ECPDHKey key_perma;
diff --git a/ecp/server/sig.c b/ecp/server/sig.c
index bf6edbd..6128838 100644
--- a/ecp/server/sig.c
+++ b/ecp/server/sig.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
#include <signal.h>
diff --git a/ecp/server/timer.c b/ecp/server/timer.c
index 7a477ab..efd0847 100644
--- a/ecp/server/timer.c
+++ b/ecp/server/timer.c
@@ -1,5 +1,7 @@
#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
+#include <signal.h>
#include <time.h>
#include <ecp/core.h>
diff --git a/ecp/server/vlink.c b/ecp/server/vlink.c
index 17c84ad..fcb9a5c 100644
--- a/ecp/server/vlink.c
+++ b/ecp/server/vlink.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
#include <ecp/core.h>
#include <ecp/ht.h>