From 1dbdb6ae7a5317b0d6fa82896edc177421cc3464 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 25 Jun 2016 17:03:22 +0000 Subject: [PATCH] Move pledge after opendev and DIOCGPDINFO. Fixes e.g. fdisk /dev/tty. This diff by deraadt was overlooked far too many times, mostly by me. It's the original fix of the pledge disklabel breakage found by espie. diff by deraadt; ok semarie, tb. --- sbin/fdisk/fdisk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index b2f6989a10e..eb0fbc89f17 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.100 2016/03/28 16:55:09 mestre Exp $ */ +/* $OpenBSD: fdisk.c,v 1.101 2016/06/25 17:03:22 tb Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -85,10 +85,6 @@ main(int argc, char *argv[]) struct dos_mbr dos_mbr; struct mbr mbr; - /* "proc exec" for man page display */ - if (pledge("stdio rpath wpath disklabel proc exec", NULL) == -1) - err(1, "pledge"); - while ((ch = getopt(argc, argv, "iegpuvf:c:h:s:l:b:y")) != -1) { const char *errstr; @@ -169,6 +165,10 @@ main(int argc, char *argv[]) disk.name = argv[0]; DISK_open(i_flag || u_flag || e_flag); + /* "proc exec" for man page display */ + if (pledge("stdio rpath wpath disklabel proc exec", NULL) == -1) + err(1, "pledge"); + error = MBR_read(0, &dos_mbr); if (error) errx(1, "Can't read sector 0!"); -- 2.20.1