summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2017-04-17 20:22:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2017-04-17 20:22:15 +0000
commit3539f75c29fe2593f27b8208b0e6a208edfa6c52 (patch)
treef7aedca0e4f748e0b8595320fd422e0db4ec79f8
parentfa4391f0ffbb30c89949d72d90c0b156b8911902 (diff)
matthieu@ observes % pax (without any arguments) hits pledge violation,
because it tries MTIOCTOP against stdin, the tty. It is very inconvenient to use isatty to distinguish this difference in userland, so return ENOTTY for tty devices. ok natano
-rw-r--r--sys/kern/kern_pledge.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c
index 406fbfee3fa..b1c5bbcfe13 100644
--- a/sys/kern/kern_pledge.c
+++ b/sys/kern/kern_pledge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_pledge.c,v 1.203 2017/04/13 04:06:46 guenther Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.204 2017/04/17 20:22:14 deraadt Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -1155,9 +1155,12 @@ pledge_ioctl(struct proc *p, long com, struct file *fp)
case MTIOCTOP:
/* for pax(1) and such, checking tapes... */
if (fp->f_type == DTYPE_VNODE &&
- vp->v_type == VCHR &&
- (vp->v_flag & VISTTY) == 0)
- return (0);
+ vp->v_type == VCHR) {
+ if (vp->v_flag & VISTTY)
+ return (ENOTTY);
+ else
+ return (0);
+ }
break;
}
}