summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-08-27 18:23:58 -0400
committerJune McEnroe <june@causal.agency>2020-08-27 18:23:58 -0400
commit76f1d0775b52e7a8a1c322214836cde530117512 (patch)
tree5b0850d4cb7eabaa2c927e02c3bb4055d5237c47
parentRemove rc scripts (diff)
downloadpounce-76f1d0775b52e7a8a1c322214836cde530117512.tar.gz
pounce-76f1d0775b52e7a8a1c322214836cde530117512.zip
Add support for OpenBSD
-rw-r--r--bounce.c10
-rw-r--r--client.c11
-rwxr-xr-xconfigure4
-rw-r--r--local.c2
4 files changed, 24 insertions, 3 deletions
diff --git a/bounce.c b/bounce.c
index 95e3711..924a01b 100644
--- a/bounce.c
+++ b/bounce.c
@@ -64,6 +64,15 @@
 
 bool verbose;
 
+#ifdef __OpenBSD__
+static void hashPass(void) {
+	char hash[_PASSWORD_LEN];
+	char *pass = getpass("Password: ");
+	int error = crypt_newhash(pass, "bcrypt,a", hash, sizeof(hash));
+	if (error) err(EX_OSERR, "crypt_newhash");
+	printf("%s\n", hash);
+}
+#else
 static void hashPass(void) {
 	byte rand[12];
 	int error = getentropy(rand, sizeof(rand));
@@ -75,6 +84,7 @@ static void hashPass(void) {
 	char *pass = getpass("Password: ");
 	printf("%s\n", crypt(pass, salt));
 }
+#endif
 
 static void genReq(const char *path) {
 	const char *name = strrchr(path, '/');
diff --git a/client.c b/client.c
index 06efeb8..dcfc835 100644
--- a/client.c
+++ b/client.c
@@ -166,11 +166,16 @@ static void handlePass(struct Client *client, struct Message *msg) {
 		client->error = true;
 		return;
 	}
-	if (!strcmp(crypt(msg->params[0], clientPass), clientPass)) {
+#ifdef __OpenBSD__
+	int error = crypt_checkpass(msg->params[0], clientPass);
+#else
+	int error = strcmp(crypt(msg->params[0], clientPass), clientPass);
+#endif
+	if (error) {
+		passRequired(client);
+	} else {
 		client->need &= ~NeedPass;
 		maybeSync(client);
-	} else {
-		passRequired(client);
 	}
 	explicit_bzero(msg->params[0], strlen(msg->params[0]));
 }
diff --git a/configure b/configure
index 12f411c..4384104 100755
--- a/configure
+++ b/configure
@@ -37,6 +37,10 @@ case "$(uname)" in
 		defstr OPENSSL_BIN /usr/bin/openssl
 		defstr CERTBOT_PATH /usr/local/etc/letsencrypt
 		;;
+	(OpenBSD)
+		ldlibs -ltls
+		defstr OPENSSL_BIN /usr/bin/openssl
+		;;
 	(Linux)
 		cflags -D_GNU_SOURCE
 		ldlibs -lcrypt
diff --git a/local.c b/local.c
index ad95a00..a697e15 100644
--- a/local.c
+++ b/local.c
@@ -236,9 +236,11 @@ struct tls *localAccept(int *fd, int bind) {
 	int error = setsockopt(*fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
 	if (error) err(EX_OSERR, "setsockopt");
 
+#ifdef TCP_KEEPIDLE
 	int idle = 15 * 60;
 	error = setsockopt(*fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
 	if (error) err(EX_OSERR, "setsockopt");
+#endif
 
 	struct tls *client;
 	error = tls_accept_socket(server, &client, *fd);
Honestly it's kind of weird that IRC clients usually use these for input history. 2019-02-22Remove topic TODOJune McEnroe I played around with it and it doesn't look right unless there is only one channel listed in the status. 2019-02-22Add /znc commandJune McEnroe Only because ZNC tells you to use it and expects it to work. 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe It's actually in a good state now, I think. 2019-02-21Replace "view" with "window"June McEnroe I think originally I didn't want to use the same word as curses WINDOW but it's really much clearer for the user if they're just called windows. UI code probably needs yet another rewrite though. Still feels messy. 2019-02-21Remove ROT13June McEnroe It's just not convenient when it can only do the whole line... 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe Otherwise the "Traveling" message isn't visible while connecting. 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe