use pledge()

This commit is contained in:
sthen 2017-08-14 16:51:41 +00:00
parent 98c8b814ca
commit e901e737b1
2 changed files with 25 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.12 2016/01/17 22:51:33 sthen Exp $
# $OpenBSD: Makefile,v 1.13 2017/08/14 16:51:41 sthen Exp $
COMMENT= realtime bandwidth monitoring of interfaces
DISTNAME= bwm-ng-0.6.1
REVISION= 0
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=bwmng/}
HOMEPAGE= http://www.gropp.org/
@ -12,6 +13,7 @@ MAINTAINER= Stuart Henderson <sthen@openbsd.org>
# GPLv2+
PERMIT_PACKAGE_CDROM= Yes
# uses pledge()
WANTLIB= c curses
CONFIGURE_STYLE= gnu

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-src_bwm-ng_c,v 1.1 2017/08/14 16:51:41 sthen Exp $
unix: performs ioctl on interfaces to check if they're up (press "a" three times)
route: retrieves interface stats via sysctl
Index: src/bwm-ng.c
--- src/bwm-ng.c.orig
+++ src/bwm-ng.c
@@ -211,6 +211,13 @@ int main (int argc, char *argv[]) {
/* end of init curses, now set a sigint handler to deinit the screen on ctrl-break */
signal(SIGINT,sigint);
signal(SIGTERM,sigint);
+ if (out_file_path) {
+ if (pledge("stdio unix cpath wpath route tty", NULL) == -1)
+ deinit(1, "pledge\n");
+ } else {
+ if (pledge("stdio unix route tty", NULL) == -1)
+ deinit(1, "pledge\n");
+ }
#ifdef CSV
/* get stats without verbose if cvs */
if (output_method==CSV_OUT && output_count>-1) {