about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-24 19:42:10 -0400
committerJune McEnroe <june@causal.agency>2021-09-26 12:16:57 -0400
commitb230d1909a493b92da855274e976b9f5b11baf97 (patch)
tree85c96d2b26c799949e158e416e97745293a7270d
parentOpenBSD: pledge(2) server (diff)
downloadtorus-b230d1909a493b92da855274e976b9f5b11baf97.tar.gz
torus-b230d1909a493b92da855274e976b9f5b11baf97.zip
OpenBSD: pledge(2) client
-rw-r--r--client.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/client.c b/client.c
index bb2ee1b..4736261 100644
--- a/client.c
+++ b/client.c
@@ -681,6 +681,7 @@ static void readInput(void) {
 }
 
 int main(int argc, char *argv[]) {
+	int error;
 	const char *sockPath = DefaultSockPath;
 	int opt;
 	while (0 < (opt = getopt(argc, argv, "hs:"))) {
@@ -695,6 +696,12 @@ int main(int argc, char *argv[]) {
 	}
 
 	curse();
+
+#ifdef __OpenBSD__
+	error = pledge("stdio tty unix", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
+
 	modeHelp();
 	readInput();
 
@@ -703,9 +710,14 @@ int main(int argc, char *argv[]) {
 
 	struct sockaddr_un addr = { .sun_family = AF_LOCAL };
 	snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", sockPath);
-	int error = connect(client, (struct sockaddr *)&addr, SUN_LEN(&addr));
+	error = connect(client, (struct sockaddr *)&addr, SUN_LEN(&addr));
 	if (error) err(EX_NOINPUT, "%s", sockPath);
 
+#ifdef __OpenBSD__
+	error = pledge("stdio tty", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
+
 #ifdef __FreeBSD__
 	error = cap_enter();
 	if (error) err(EX_OSERR, "cap_enter");