shithub: riscv

Download patch

ref: 0f59758d126d800fdf57fd913947f4d4ca9cc253
parent: b4d2e39d8cfad9fe9585dd6b2382d1261122f22f
author: cinap_lenrek <[email protected]>
date: Sat Jul 28 22:53:59 EDT 2012

factotum: authdial timeout

--- a/sys/src/cmd/auth/factotum/fs.c
+++ b/sys/src/cmd/auth/factotum/fs.c
@@ -220,7 +220,7 @@
 static void
 notifyf(void*, char *s)
 {
-	if(strncmp(s, "interrupt", 9) == 0)
+	if(strncmp(s, "interrupt", 9) == 0 || strncmp(s, "alarm", 5) == 0)
 		noted(NCONT);
 	noted(NDFLT);
 }
--- a/sys/src/cmd/auth/factotum/util.c
+++ b/sys/src/cmd/auth/factotum/util.c
@@ -27,30 +27,33 @@
 {
 	int fd, vanilla;
 
+	alarm(30*1000);
 	vanilla = net==nil || strcmp(net, "/net")==0;
-
 	if(!vanilla || bindnetcs()>=0)
-		return authdial(net, authdom);
+		fd = authdial(net, authdom);
+	else {
+		/*
+		 * If we failed to mount /srv/cs, assume that
+		 * we're still bootstrapping the system and dial
+		 * the one auth server passed to us on the command line.
+		 * In normal operation, it is important *not* to do this,
+		 * because the bootstrap auth server is only good for
+		 * a single auth domain.
+		 *
+		 * The ticket request code should really check the
+		 * remote authentication domain too.
+		 */
 
-	/*
-	 * If we failed to mount /srv/cs, assume that
-	 * we're still bootstrapping the system and dial
-	 * the one auth server passed to us on the command line.
-	 * In normal operation, it is important *not* to do this,
-	 * because the bootstrap auth server is only good for
-	 * a single auth domain.
-	 *
-	 * The ticket request code should really check the
-	 * remote authentication domain too.
-	 */
-
-	/* use the auth server passed to us as an arg */
-	if(authaddr == nil)
-		return -1;
-	fd = dial(netmkaddr(authaddr, "tcp", "567"), 0, 0, 0);
-	if(fd >= 0)
-		return fd;
-	return dial(netmkaddr(authaddr, "il", "566"), 0, 0, 0);
+		/* use the auth server passed to us as an arg */
+		fd = -1;
+		if(authaddr != nil){
+			fd = dial(netmkaddr(authaddr, "tcp", "567"), 0, 0, 0);
+			if(fd < 0)
+				fd = dial(netmkaddr(authaddr, "il", "566"), 0, 0, 0);
+		}
+	}
+	alarm(0);
+	return fd;
 }
 
 int