mirror of
https://github.com/optim-enterprises-bv/nDPId.git
synced 2025-11-01 18:57:48 +00:00
nDPId-test: added JSON distribution + JSON parsing (Multithreaded design re-using most of nDPId/nDPIsrvd core)
* improved Makefile.old install targets * splitted nDPIsrvd_parse into nDPIsrvd_parse_line and nDPIsrvd_parse_all for the sake of readability * minor Python script improvments (check for nDPIsrvd.py on multiple locations, may be superseeded by setuptools in the future) * some paths needs to be absolute (chdir() during daemonize) and therefor additional checks introduced * test run script checks and fails if certain files are are missing (PCAP file <=> result output file) * removed not very useful "internal format error" JSON serialization if a BUG for same exists * fixed invalid l4 type statistics counters for nDPIsrvd-collectd Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
19
utils.c
19
utils.c
@@ -55,6 +55,11 @@ static int create_pidfile(char const * const pidfile)
|
||||
{
|
||||
int pfd;
|
||||
|
||||
if (is_path_absolute("Pidfile", pidfile) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
pfd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
if (pfd < 0)
|
||||
@@ -74,6 +79,20 @@ static int create_pidfile(char const * const pidfile)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_path_absolute(char const * const prefix,
|
||||
char const * const path)
|
||||
{
|
||||
if (path[0] != '/')
|
||||
{
|
||||
syslog(LOG_DAEMON | LOG_ERR,
|
||||
"%s path must be absolut i.e. starting with a `/', path given: `%s'",
|
||||
prefix, path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int daemonize_with_pidfile(char const * const pidfile)
|
||||
{
|
||||
pid_str ps = {};
|
||||
|
||||
Reference in New Issue
Block a user