Merge branch 'main' of github.com:utoni/nDPId

This commit is contained in:
Toni Uhlig
2022-10-20 16:13:27 +02:00
3 changed files with 50 additions and 7 deletions

View File

@@ -0,0 +1,27 @@
# Maintainer: Toni Uhlig <toni@impl.cc>
pkgname=nDPId-testing
pkgver=1.0
pkgrel=1
pkgdesc="Tiny nDPI based deep packet inspection daemons / toolkit."
arch=('i686' 'x86_64')
url="https://github.com/utoni/nDPId"
license=('GPL3')
options=()
build() {
cd "${srcdir}/../../.."
mkdir -p build-archlinux && cd build-archlinux
cmake .. \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="/usr/local" \
-DBUILD_EXAMPLES=ON \
-DBUILD_NDPI=ON \
-DENABLE_SANITIZER=ON
make VERBOSE=1
}
package() {
cd "${srcdir}/../../../build-archlinux"
make DESTDIR="${pkgdir}/" install
}

View File

@@ -0,0 +1,4 @@
HowTo use this
==============
Change to this directory and simply run `makepkg`, that's it.

26
utils.c
View File

@@ -161,7 +161,7 @@ int change_user_group(char const * const user,
pwd = getpwnam(user);
if (pwd == NULL)
{
return 1;
return -errno;
}
if (group != NULL)
@@ -170,7 +170,7 @@ int change_user_group(char const * const user,
grp = getgrnam(group);
if (grp == NULL)
{
return 1;
return -errno;
}
gid = grp->gr_gid;
}
@@ -181,17 +181,29 @@ int change_user_group(char const * const user,
if (uds_collector_path != NULL)
{
chmod(uds_collector_path, S_IRUSR | S_IWUSR);
chown(uds_collector_path, pwd->pw_uid, gid);
errno = 0;
if (chmod(uds_collector_path, S_IRUSR | S_IWUSR) != 0 ||
chown(uds_collector_path, pwd->pw_uid, gid) != 0)
{
return -errno;
}
}
if (uds_distributor_path != NULL)
{
chmod(uds_distributor_path, S_IRUSR | S_IWUSR | S_IRGRP);
chown(uds_distributor_path, pwd->pw_uid, gid);
errno = 0;
if (chmod(uds_distributor_path, S_IRUSR | S_IWUSR | S_IRGRP) != 0 ||
chown(uds_distributor_path, pwd->pw_uid, gid) != 0)
{
return -errno;
}
}
if (pidfile != NULL)
{
chown(pidfile, pwd->pw_uid, gid);
errno = 0;
if (chown(pidfile, pwd->pw_uid, gid) != 0)
{
return -errno;
}
}
return setregid(gid, gid) != 0 || setreuid(pwd->pw_uid, pwd->pw_uid);
}