shithub: riscv

Download patch

ref: e684b2a3fbd7d077ba4dabbd7fb4c7d1ff09c30c
parent: bf86c9b4e19cc829db95de26d472f75a594428c0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 19 21:37:38 EDT 2018

authsrv: work arround linux omiting final Z(4) after the AvrPairs

--- a/sys/src/cmd/auth/authsrv.c
+++ b/sys/src/cmd/auth/authsrv.c
@@ -52,6 +52,7 @@
 void	tickauthreply(Ticketreq*, Authkey*);
 void	tickauthreply2(Ticketreq*, Authkey*, uchar *, int, uchar *, int);
 void	safecpy(char*, char*, int);
+void	catch(void*, char*);
 
 void
 main(int argc, char *argv[])
@@ -691,6 +692,7 @@
 	int dupe, lmok, ntok, ntbloblen;
 	uchar phash[SHA1dlen], chash[SHA1dlen], ahash[SHA1dlen];
 	DigestState *s;
+	long timeout;
 	int tries;
 
 	/*
@@ -750,9 +752,14 @@
 		/* Z[4] */
 		if(ntbloblen > sizeof(ntblob)-4)
 			exits(0);
-		if(readn(0, ntblob+ntbloblen, 4) < 0)
-			exits(0);
-		ntbloblen += 4;
+
+		/* LINUX omits the final Z(4), so read with short timeout */
+		notify(catch);
+		timeout = alarm(50);
+		if(readn(0, ntblob+ntbloblen, 4) == 4)
+			ntbloblen += 4;
+		alarm(timeout);
+		notify(nil);
 	}
 
 	safecpy(tr->uid, reply.uid, sizeof(tr->uid));
@@ -1151,3 +1158,10 @@
 	to[len-1] = 0;
 }
 
+void
+catch(void*, char *msg)
+{
+	if(strstr(msg, "alarm") != nil)
+		noted(NCONT);
+	noted(NDFLT);
+}