sfeed_curses: fix: pledge for opening /dev/null for OpenBSD 7.9+ - sfeed - RSS and Atom parser
HTML git clone git://git.codemadness.org/sfeed
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 74f7eb628dc307ad951ed03df44dfeaba10d250a
DIR parent 45fba594ca26328ae1d7ba3b133983755af1d745
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 8 Apr 2026 20:25:00 +0200
sfeed_curses: fix: pledge for opening /dev/null for OpenBSD 7.9+
OpenBSD 7.9+ will be stricter in handling file access outside libc.
/dev/null needs to be opened before the pledge now, because it is opened with
O_RDWR ("wpath"). Before OpenBSD 7.9 pledge "stdio rpath" would allow opening
/dev/null with O_WRONLY.
pledge "stdio" can still write to already opened file descriptors, so the file
descriptor is opened before the pledge now: a common pattern in OpenBSD
programs called pledge hoisting.
sfeed_curses needs no write access to other files during run-time, so a full
"wpath" would be too much (it can still exec programs though).
(Other parts of the program, such as opening /dev/tty should be OK as is.
Unless ncurses does something crazy (no reason to assume it does). But then it
is OK it will abort! :))
References:
https://undeadly.org/cgi?action=article;sid=20260320085305
https://marc.info/?l=openbsd-ports&m=177389567528083&w=2
https://man.openbsd.org/pledge
https://man.openbsd.org/__pledge_open.2
Reported by seninha, thanks!
Diffstat:
M sfeed_curses.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
DIR diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -1944,6 +1944,9 @@ main(int argc, char *argv[])
int button, ch, fd, i, keymask, release, x, y;
off_t pos;
+ if ((devnullfd = open("/dev/null", O_RDWR)) == -1)
+ die("open: /dev/null");
+
#ifdef __OpenBSD__
if (pledge("stdio rpath tty proc exec", NULL) == -1)
die("pledge");
@@ -2012,9 +2015,6 @@ main(int argc, char *argv[])
if (argc <= 1)
feeds[0].fp = NULL;
- if ((devnullfd = open("/dev/null", O_RDWR)) == -1)
- die("open: /dev/null");
-
init();
updatesidebar();
updategeom();