commit:     e980183fcb2c242de5ae68f4f333f052011d5eae
Author:     Jeroen Roovers <jer <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  3 09:11:57 2020 +0000
Commit:     Jeroen Roovers <jer <AT> gentoo <DOT> org>
CommitDate: Fri Jul  3 09:55:02 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e980183f

net-analyzer/darkstat: Really disable debug

- Passing --disable-debug to configure has the effect of enabling it.
  Rather than fixing the autoconf logic, simply remove the CFLAGS
  additions instead.
- Add a simple patch that ensures strncpy copies enough bytes

Package-Manager: Portage-2.3.103, Repoman-2.3.23
Signed-off-by: Jeroen Roovers <jer <AT> gentoo.org>

 net-analyzer/darkstat/darkstat-3.0.719-r1.ebuild   | 73 ++++++++++++++++++++++
 .../darkstat-3.0.719-strncpy-off-by-one.patch      | 11 ++++
 2 files changed, 84 insertions(+)

diff --git a/net-analyzer/darkstat/darkstat-3.0.719-r1.ebuild 
b/net-analyzer/darkstat/darkstat-3.0.719-r1.ebuild
new file mode 100644
index 00000000000..8075830d412
--- /dev/null
+++ b/net-analyzer/darkstat/darkstat-3.0.719-r1.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit autotools user
+
+DESCRIPTION="Network traffic analyzer with cute web interface"
+HOMEPAGE="https://unix4lyfe.org/darkstat/";
+SRC_URI="https://unix4lyfe.org/${PN}/${P}.tar.bz2";
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~x86"
+
+DEPEND="
+       dev-libs/libbsd
+       net-libs/libpcap
+       sys-libs/zlib
+"
+RDEPEND="
+       ${DEPEND}
+"
+DARKSTAT_CHROOT_DIR=${DARKSTAT_CHROOT_DIR:-/var/lib/darkstat}
+DOCS=( AUTHORS ChangeLog README NEWS )
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.0.719-strncpy-off-by-one.patch
+)
+
+src_prepare() {
+       default
+
+       sed -i \
+               -e '/-DNDEBUG/d' \
+               -e 's|-flto||g' \
+               configure.ac || die
+
+       eautoreconf
+}
+
+src_configure() {
+       econf --with-privdrop-user=darkstat
+}
+
+src_install() {
+       default
+
+       newinitd "${FILESDIR}"/darkstat-initd darkstat
+       newconfd "${FILESDIR}"/darkstat-confd darkstat
+
+       sed -i -e "s:__CHROOT__:${DARKSTAT_CHROOT_DIR}:g" 
"${D}"/etc/conf.d/darkstat || die
+       sed -i -e "s:__CHROOT__:${DARKSTAT_CHROOT_DIR}:g" 
"${D}"/etc/init.d/darkstat || die
+
+       keepdir "${DARKSTAT_CHROOT_DIR}"
+       chown darkstat:0 "${D}${DARKSTAT_CHROOT_DIR}"
+}
+
+pkg_preinst() {
+       enewuser darkstat
+}
+
+pkg_postinst() {
+       # Workaround bug #141619
+       DARKSTAT_CHROOT_DIR=`sed -n 's/^#CHROOT=\(.*\)/\1/p' 
"${ROOT}"etc/conf.d/darkstat`
+       chown darkstat:0 "${ROOT}${DARKSTAT_CHROOT_DIR}"
+
+       elog "To start different darkstat instances which will listen on a 
different"
+       elog "interfaces create in /etc/init.d directory the 'darkstat.if' 
symlink to"
+       elog "darkstat script where 'if' is the name of the interface."
+       elog "Also in /etc/conf.d directory copy darkstat to darkstat.if"
+       elog "and edit it to change default values."
+       elog
+       elog "darkstat's default chroot directory is: 
\"${ROOT}${DARKSTAT_CHROOT_DIR}\""
+}

diff --git 
a/net-analyzer/darkstat/files/darkstat-3.0.719-strncpy-off-by-one.patch 
b/net-analyzer/darkstat/files/darkstat-3.0.719-strncpy-off-by-one.patch
new file mode 100644
index 00000000000..cab429c0ece
--- /dev/null
+++ b/net-analyzer/darkstat/files/darkstat-3.0.719-strncpy-off-by-one.patch
@@ -0,0 +1,11 @@
+--- a/localip.c
++++ b/localip.c
+@@ -58,7 +58,7 @@
+    } else {
+       /* Warn about changed address. */
+       if (!addr_equal(ips->addrs + *idx, a)) {
+-         static char before[INET6_ADDRSTRLEN];
++         static char before[INET6_ADDRSTRLEN + 1];
+          strncpy(before, addr_to_str(ips->addrs + *idx), INET6_ADDRSTRLEN);
+          verbosef("interface '%s' address %d/%d changed from %s to %s",
+             iface, *idx+1, ips->num_addrs, before, addr_to_str(a));

Reply via email to