commit:     75bf552a579f71ee671e10fab2c322d8084fab16
Author:     Peter Levine <plevine457 <AT> gmail <DOT> com>
AuthorDate: Wed Oct 23 19:13:46 2019 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar 15 23:32:10 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75bf552a

net-analyzer/netselect: Add filecaps support

Closes: https://bugs.gentoo.org/564902
Closes: https://github.com/gentoo/gentoo/pull/13388
Package-Manager: Portage-2.3.78, Repoman-2.3.17
Signed-off-by: Peter Levine <plevine457 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net-analyzer/netselect/netselect-0.4-r2.ebuild | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/net-analyzer/netselect/netselect-0.4-r2.ebuild 
b/net-analyzer/netselect/netselect-0.4-r2.ebuild
index 8ac47519b25..e887b8335a1 100644
--- a/net-analyzer/netselect/netselect-0.4-r2.ebuild
+++ b/net-analyzer/netselect/netselect-0.4-r2.ebuild
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
-inherit toolchain-funcs
+inherit fcaps toolchain-funcs
 
 DESCRIPTION="Ultrafast implementation of ping"
 HOMEPAGE="http://apenwarr.ca/netselect/";
@@ -23,12 +23,20 @@ PATCHES=(
 
 DOCS=( HISTORY README )
 
+FILECAPS=( -g wheel cap_net_raw /usr/bin/netselect )
+
 S=${WORKDIR}/${PN}-${P}
 
 src_prepare() {
        use ipv6 && eapply "${WORKDIR}"/${PN}-0.4-ipv6.patch
 
        default
+
+       # Don't warn about "root privileges required" when running as
+       # an unprivileged user with filecaps
+       if ! use prefix && use filecaps; then
+               sed -i -e '/if (geteuid () != 0)/,+2d' "${S}"/netselect.c || die
+       fi
 }
 
 src_compile() {
@@ -38,12 +46,11 @@ src_compile() {
 src_install() {
        dobin netselect
 
-       if ! use prefix ; then
-               fowners root:wheel /usr/bin/netselect
-               fperms 4711 /usr/bin/netselect
-       fi
-
        einstalldocs
 
        doman netselect.1
 }
+
+pkg_postinst() {
+       ! use prefix && fcaps_pkg_postinst
+}

Reply via email to