summaryrefslogtreecommitdiff
path: root/sbin/fdisk
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2016-06-25 17:03:23 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2016-06-25 17:03:23 +0000
commitc1f7697058ce73604bb29ebd48553b0462ae0d94 (patch)
tree8b38e057f6879c2ff5a052c153ea8573535286a5 /sbin/fdisk
parentf8d9bd8cebe320e90f4825935bf8c2acf0c45268 (diff)
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.
Diffstat (limited to 'sbin/fdisk')
-rw-r--r--sbin/fdisk/fdisk.c10
1 files 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!");