aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2024-11-07 11:32:31 +0100
committerToni Uhlig <matzeton@googlemail.com>2024-11-07 11:32:42 +0100
commita733d536adeaf6afed3bb96bbc7f822f49802bd3 (patch)
tree70ee425c0fa5deaceafa26232c512e09fba1e3a1
parent9fc35e7a7e29d9a346865651387a02514080c6b4 (diff)
Added env check `NDPID_STARTED_BY_SYSTEMD` to prevent logging to `stderr` in such a case
* removed `nDPId` shutdown on poll/epoll error * fixed `chmod_chown()` rv check Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--nDPId.c5
-rw-r--r--nDPIsrvd.c4
-rw-r--r--packages/systemd/ndpid@.service.in1
-rw-r--r--packages/systemd/ndpisrvd.service.in2
-rw-r--r--utils.c9
5 files changed, 13 insertions, 8 deletions
diff --git a/nDPId.c b/nDPId.c
index 01ef0b9e2..5dcdd613e 100644
--- a/nDPId.c
+++ b/nDPId.c
@@ -3452,8 +3452,8 @@ static uint32_t calculate_ndpi_flow_struct_hash(struct ndpi_flow_struct const *
/* mask for FCF */
#define WIFI_DATA 0x2
#define FCF_TYPE(fc) (((fc) >> 2) & 0x3) /* 0000 0011 = 0x3 */
-#define FCF_TO_DS(fc) ((fc)&0x0100)
-#define FCF_FROM_DS(fc) ((fc)&0x0200)
+#define FCF_TO_DS(fc) ((fc) & 0x0100)
+#define FCF_FROM_DS(fc) ((fc) & 0x0200)
/* mask for Bad FCF presence */
#define BAD_FCS 0x50 /* 0101 0000 */
static int process_datalink_layer(struct nDPId_reader_thread * const reader_thread,
@@ -4881,7 +4881,6 @@ static void run_capture_loop(struct nDPId_reader_thread * const reader_thread)
if (nio_has_error(&io, i) == NIO_SUCCESS)
{
logger(1, "%s", "Event I/O error");
- MT_GET_AND_ADD(reader_thread->workflow->error_or_eof, 1);
}
int fd = nio_get_fd(&io, i);
diff --git a/nDPIsrvd.c b/nDPIsrvd.c
index 9e5614d27..89f697b85 100644
--- a/nDPIsrvd.c
+++ b/nDPIsrvd.c
@@ -1834,7 +1834,7 @@ int main(int argc, char ** argv)
GET_CMDARG_STR(nDPIsrvd_options.user),
strerror(ret));
}
- if (ret != -EPERM)
+ if (ret != EPERM)
{
goto error_unlink_sockets;
}
@@ -1867,7 +1867,7 @@ int main(int argc, char ** argv)
GET_CMDARG_STR(nDPIsrvd_options.user),
strerror(ret));
}
- if (ret != -EPERM)
+ if (ret != EPERM)
{
goto error_unlink_sockets;
}
diff --git a/packages/systemd/ndpid@.service.in b/packages/systemd/ndpid@.service.in
index b59a6612c..5bdd0f1bb 100644
--- a/packages/systemd/ndpid@.service.in
+++ b/packages/systemd/ndpid@.service.in
@@ -8,6 +8,7 @@ Type=simple
ExecStartPre=/bin/sh -c 'test -r "@CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf" || cp -v "@CMAKE_INSTALL_PREFIX@/share/nDPId/ndpid.conf.example" "@CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf"'
ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/nDPId -f @CMAKE_INSTALL_PREFIX@/etc/nDPId/%i.conf -i %i -u ndpid -c /run/nDPIsrvd/collector
Restart=on-failure
+Environment="NDPID_STARTED_BY_SYSTEMD="
[Install]
WantedBy=multi-user.target
diff --git a/packages/systemd/ndpisrvd.service.in b/packages/systemd/ndpisrvd.service.in
index 89f87a682..b74e9af38 100644
--- a/packages/systemd/ndpisrvd.service.in
+++ b/packages/systemd/ndpisrvd.service.in
@@ -6,8 +6,10 @@ After=network.target
Type=simple
ExecStartPre=/bin/sh -c 'test -r "@CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf" || cp -v "@CMAKE_INSTALL_PREFIX@/share/nDPId/ndpisrvd.conf.example" "@CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf"'
ExecStartPre=/bin/sh -c 'mkdir -p /run/nDPIsrvd && chown root:root /run/nDPIsrvd && chmod 0775 /run/nDPIsrvd'
+ExecStopPost=/bin/sh -c 'rm -f /run/nDPIsrvd/collector /run/nDPIsrvd/distributor'
ExecStart=@CMAKE_INSTALL_PREFIX@/bin/nDPIsrvd -f @CMAKE_INSTALL_PREFIX@/etc/nDPId/nDPIsrvd.conf -u ndpisrvd -c /run/nDPIsrvd/collector -s /run/nDPIsrvd/distributor -G ndpid:ndpisrvd-distributor
Restart=on-failure
+Environment="NDPID_STARTED_BY_SYSTEMD="
[Install]
WantedBy=multi-user.target
diff --git a/utils.c b/utils.c
index ecd5dbcc5..25f16f81d 100644
--- a/utils.c
+++ b/utils.c
@@ -586,9 +586,12 @@ __attribute__((format(printf, 2, 3))) void logger_early(int is_error, char const
int old_log_to_console = log_to_console;
va_list ap;
- va_start(ap, format);
- vlogger_to(fileno(stderr), is_error, format, &ap);
- va_end(ap);
+ if (getenv("NDPID_STARTED_BY_SYSTEMD") == NULL)
+ {
+ va_start(ap, format);
+ vlogger_to(fileno(stderr), is_error, format, &ap);
+ va_end(ap);
+ }
log_to_console = 0;