summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/client.c b/client.c
index c951590..35faa4b 100644
--- a/client.c
+++ b/client.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <sysexits.h>
 #include <tls.h>
+#include <unistd.h>
 
 enum Need {
 	NeedNick = 1 << 0,
@@ -96,7 +97,7 @@ static void passRequired(struct Client *client) {
 	client->error = true;
 }
 
-static void sync(struct Client *client) {
+static void maybeSync(struct Client *client) {
 	if (client->need == NeedPass) passRequired(client);
 	if (!client->need) stateSync(client);
 }
@@ -106,7 +107,7 @@ typedef void Handler(struct Client *client, struct Message *msg);
 static void handleNick(struct Client *client, struct Message *msg) {
 	(void)msg;
 	client->need &= ~NeedNick;
-	sync(client);
+	maybeSync(client);
 }
 
 static void handleUser(struct Client *client, struct Message *msg) {
@@ -119,17 +120,21 @@ static void handleUser(struct Client *client, struct Message *msg) {
 	} else {
 		client->need &= ~NeedUser;
 		client->consumer = ringConsumer(msg->params[0]);
-		sync(client);
+		maybeSync(client);
 	}
 }
 
 static void handlePass(struct Client *client, struct Message *msg) {
 	if (!clientPass) return;
-	if (!msg->params[0] || strcmp(msg->params[0], clientPass)) {
+	if (!msg->params[0]) {
 		passRequired(client);
-	} else {
+		return;
+	}
+	if (!strcmp(crypt(msg->params[0], clientPass), clientPass)) {
 		client->need &= ~NeedPass;
-		sync(client);
+		maybeSync(client);
+	} else {
+		passRequired(client);
 	}
 }
 
@@ -139,7 +144,7 @@ static void handleCap(struct Client *client, struct Message *msg) {
 	if (!strcmp(msg->params[0], "END")) {
 		if (!client->need) return;
 		client->need &= ~NeedCapEnd;
-		sync(client);
+		maybeSync(client);
 
 	} else if (!strcmp(msg->params[0], "LS")) {
 		if (client->need) client->need |= NeedCapEnd;
>June McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe 2022-07-03Add The Bone Shard EmperorJune McEnroe 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe