summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-04-02 16:33:29 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-04-02 16:33:29 +0000
commit41ae94909625acb9bfbab33ce23bd8a71df68dcf (patch)
tree3f63d060e8c6a880902067138168ea897dd4aef2
parent0b87d85abbce175e36d5967d4f9265f9c1490f69 (diff)
Use open(tty, O_WRONLY) + fdopen() instead of fopen(tty, "w") to
keep stdio from opening with O_CREAT which would require pledge cpath.
-rw-r--r--libexec/comsat/comsat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c
index 0ba89612911..e0b139e7930 100644
--- a/libexec/comsat/comsat.c
+++ b/libexec/comsat/comsat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: comsat.c,v 1.44 2015/10/12 16:54:30 uebayasi Exp $ */
+/* $OpenBSD: comsat.c,v 1.45 2016/04/02 16:33:28 millert Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -234,6 +234,7 @@ static char *cr;
void
notify(struct utmp *utp, off_t offset)
{
+ int fd;
FILE *tp;
struct stat stb;
struct termios ttybuf;
@@ -257,7 +258,8 @@ notify(struct utmp *utp, off_t offset)
return;
(void)signal(SIGALRM, SIG_DFL);
(void)alarm(30);
- if ((tp = fopen(tty, "w")) == NULL) {
+ fd = open(tty, O_WRONLY);
+ if (fd == -1 || (tp = fdopen(fd, "w")) == NULL) {
dsyslog(LOG_ERR, "%s: %s", tty, strerror(errno));
_exit(1);
}