shithub: drawterm

Download patch

ref: 64b62a3fd4e0b99754a67fbd25b8d583bfd5a24b
parent: ad9a404582539cc0d069e71ba2269e35775f0800
author: Russ Cox <[email protected]>
date: Mon Nov 7 12:43:17 EST 2005

fiddle

--- a/cpu.c
+++ b/cpu.c
@@ -99,7 +99,7 @@
 void
 cpumain(int argc, char **argv)
 {
-	char dat[MaxStr], buf[MaxStr], cmd[MaxStr], *p, *err, *secstoreserver, *s;
+	char dat[MaxStr], buf[MaxStr], cmd[MaxStr], *err, *secstoreserver, *s;
 	int fd, ms, data;
 
 	/* see if we should use a larger message size */
@@ -115,6 +115,12 @@
         if(user == nil)
         	user = readcons("user", nil, 0);
 	secstoreserver = nil;
+	authserver = getenv("auth");
+	if(authserver == nil)
+		authserver = "auth";
+	system = getenv("cpu");
+	if(system == nil)
+		system = "cpu";
 	ARGBEGIN{
 	case 'a':
 		authserver = EARGF(usage());
@@ -154,6 +160,9 @@
 		usage();
 	}ARGEND;
 
+	if(argc != 0)
+		usage();
+
 	if(mountfactotum() < 0){
 		if(secstoreserver == nil)
 			secstoreserver = authserver;
@@ -165,23 +174,6 @@
 	                        strcpy(secstorebuf, s);
 	                }
 	        }
-	}
-
-	if(argc != 0)
-		usage();
-
-	if(system == nil) {
-		p = getenv("cpu");
-		if(p == 0)
-			fatal(0, "set $cpu");
-		system = p;
-	}
-	
-	if(authserver == nil) {
-		p = getenv("auth");
-		if(p == 0)
-			fatal(0, "set $auth");
-		authserver = p;
 	}
 
 	if((err = rexcall(&data, system, srvname)))
--- a/drawterm.h
+++ b/drawterm.h
@@ -2,7 +2,7 @@
 extern char *secstore;
 extern char secstorebuf[65536];
 extern char *secstorefetch(char *addr, char *owner, char *passwd);
-extern char *authaddr;
+extern char *authserver;
 extern char *readcons(char *prompt, char *def, int secret);
 extern int exportfs(int, int);
 extern char *user;
--- a/main.c
+++ b/main.c
@@ -6,8 +6,6 @@
 
 #include "drawterm.h"
 
-char *authaddr = "auth";
-char *cpuaddr = "cpu";
 char *argv0;
 char *user;
 
--- a/secstore.c
+++ b/secstore.c
@@ -41,9 +41,9 @@
 	 * like il!host or tcp!host or host.
 	 */
 	if(strcmp(p, "$auth")==0){
-		if(authaddr == nil)
+		if(authserver == nil)
 			return -1;
-		strecpy(buf, buf+sizeof buf, authaddr);
+		strecpy(buf, buf+sizeof buf, authserver);
 		nf = getfields(buf, f, nelem(f), 0, "!");
 		switch(nf){
 		default: