shithub: riscv

Download patch

ref: e83c9b3e61cf3aff761b9e662bc7495faa18b94c
parent: 8a60d9e2a8dc5b81b44426002b03110ef391f618
author: cinap_lenrek <[email protected]>
date: Wed Dec 16 16:27:44 EST 2015

auth/httpauth: use auth_userpasswd() instead of AuthHttp request to AS

the /sys/lib/httppasswords will be removed soon from authsrv,
so we use auth_userpasswd() to verify a username/password pair
instead.

--- a/sys/src/cmd/auth/httpauth.c
+++ b/sys/src/cmd/auth/httpauth.c
@@ -1,37 +1,7 @@
 #include <u.h>
 #include <libc.h>
-#include <authsrv.h>
+#include <auth.h>
 
-int
-httpauth(char *name, char *password)
-{
-	int afd;
-	Ticketreq tr;
-	Ticket	t;
-	Authkey key;
-
-	afd = authdial(nil, nil);
-	if(afd < 0)
-		return -1;
-
-	passtokey(&key, password);
-
-	/* send ticket request to AS */
-	memset(&tr, 0, sizeof(tr));
-	strcpy(tr.uid, name);
-	tr.type = AuthHttp;
-	if(_asrequest(afd, &tr) < 0){
-		close(afd);
-		return -1;
-	}
-	_asgetresp(afd, &t, nil, &key);
-	close(afd);
-	if(t.num != AuthHr || strcmp(t.cuid, tr.uid) != 0)
-		return -1;
-
-	return 0;
-}
-
 void
 usage(void)
 {
@@ -73,7 +43,7 @@
 	}
 	if(*s == '\0')
 		sysfatal("empty username");
-	if(httpauth(s, a))
+	if(auth_userpasswd(s, a) == nil)
 		sysfatal("bad password");
 	print("%s\n", s);
 	exits(nil);