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
commit03781457a91edcb9364e720d89e71a4e6afb0597 (patch)
tree3fd40851e759f8f302c3ed350eb43e5304bd390a
parentOpenBSD: pledge(2) server (diff)
downloadtorus-03781457a91edcb9364e720d89e71a4e6afb0597.tar.gz
torus-03781457a91edcb9364e720d89e71a4e6afb0597.zip
OpenBSD: pledge(2) client
Diffstat (limited to '')
-rw-r--r--client.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/client.c b/client.c
index a16c682..8e5d2f2 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");