On Wed, Apr 20, 2016 at 10:59:44PM -0700, steve latif wrote:
> I made an attempt at adding pledge to pstree.
> steve
>
Hi Steve,
Thanks for your contribution !
> $OpenBSD: patch-pstree_c,v 1.5 2015/05/22 13:45:30 schwarze Exp $
> --- pstree.c.orig Wed May 13 05:24:47 2015
> +++ pstree.c Wed Apr 20 22:21:07 2016
> @@ -872,6 +872,11 @@ int main(int argc, char **argv) {
> #ifdef ZOMBIES_HAVE_PID_0
> FixZombies();
> #endif
> +
> + if (pledge("stdio getpw ioctl proc", NULL) == -1){
> + fprintf(stderr, "%s: pledge\n", Progname);
> + exit(1);
> + }
the "ioctl" promise should be replaced by "tty".
I haven't checked if the pledge(2) call could be placed
somewhere else in the code, but the promises looks sane.
below is a full port update.
--
Sebastien Marie
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/pstree/Makefile,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile
--- Makefile 22 May 2015 13:45:30 -0000 1.22
+++ Makefile 21 Apr 2016 06:36:08 -0000
@@ -4,10 +4,12 @@ COMMENT = list processes as a tree
DISTNAME = pstree-2.39
CATEGORIES = sysutils
HOMEPAGE = http://www.thp.uni-duisburg.de/pstree/
+REVISION = 0
# GPL
PERMIT_PACKAGE_CDROM = Yes
+# uses pledge()
WANTLIB = c
MASTER_SITES = ftp://ftp.thp.uni-duisburg.de/pub/source/
Index: patches/patch-pstree_c
===================================================================
RCS file: /cvs/ports/sysutils/pstree/patches/patch-pstree_c,v
retrieving revision 1.5
diff -u -p -r1.5 patch-pstree_c
--- patches/patch-pstree_c 22 May 2015 13:45:30 -0000 1.5
+++ patches/patch-pstree_c 21 Apr 2016 06:36:08 -0000
@@ -1,6 +1,6 @@
$OpenBSD: patch-pstree_c,v 1.5 2015/05/22 13:45:30 schwarze Exp $
---- pstree.c.orig Thu May 21 11:23:56 2015
-+++ pstree.c Thu May 21 11:24:29 2015
+--- pstree.c.orig Wed May 13 14:24:47 2015
++++ pstree.c Thu Apr 21 08:23:00 2016
@@ -77,7 +77,7 @@ extern getargs(struct ProcInfo *, int, char *, int);
* (Net|Open|Free)BSD & Darwin merged by Ralf Meyer <ralf AT
thp.Uni-Duisburg.DE>
*/
@@ -10,3 +10,17 @@ $OpenBSD: patch-pstree_c,v 1.5 2015/05/2
# define PSFORMAT "%s %ld %ld %ld %[^\n]"
# define PSVARS P[i].name, &P[i].pid, &P[i].ppid, &P[i].pgid, P[i].cmd
# define PSVARSN 5
+@@ -872,7 +872,12 @@ int main(int argc, char **argv) {
+ #ifdef ZOMBIES_HAVE_PID_0
+ FixZombies();
+ #endif
+-
++
++ if (pledge("stdio getpw proc tty", NULL) == -1) {
++ fprintf(stderr, "%s: pledge\n", Progname);
++ exit(1);
++ }
++
+ if (NProc == 0) {
+ fprintf(stderr, "%s: No processes read.\n", Progname);
+ exit(1);