sandbox() does not finalize unveil(2) by calling unveil(NULL, NULL),
i.e. further calls would be allowed during runtime.
Simply logic, be more idiomatic and finalize by pledging after all
unveiling is done by omitting the "unveil" promise and thereby not
allowing further calls to it.
---
chat.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/chat.c b/chat.c
index ebffe46..78b6ab7 100644
--- a/chat.c
+++ b/chat.c
@@ -142,11 +142,7 @@ static void unveilData(const char *name) {
}
}
-static void sandbox(const char *trust, const char *cert, const char *priv) {
- int error = pledge(
- "stdio rpath wpath cpath inet dns tty proc exec unveil", NULL
- );
- if (error) err(EX_OSERR, "pledge");
+static void unveilAll(const char *trust, const char *cert, const char *priv) {
if (!self.restricted) return;
dataMkdir("");
@@ -284,7 +280,9 @@ int main(int argc, char *argv[]) {
commandCompleteAdd();
#ifdef __OpenBSD__
- sandbox(trust, cert, priv);
+ unveilAll(trust, cert, priv);
+ if (pledge("stdio rpath wpath cpath inet dns tty proc exec", NULL) == -1)
+ err(EX_OSERR, "pledge");
#endif
ircConfig(insecure, trust, cert, priv);
--
2.30.0