git: 9front

Download patch

ref: f7b715c137ed1e388236bee247a285620aeeb4eb
parent: c696151b3bd9b21dfb1053077b3157a170d4c66d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Aug 21 16:36:19 EDT 2015

auth/changeuser: set the aes key in plan9 database, but not in securenet db

--- a/sys/src/cmd/auth/changeuser.c
+++ b/sys/src/cmd/auth/changeuser.c
@@ -82,9 +82,11 @@
 			if(answer[0] != 'y' && answer[0] != 'Y')
 				newkey = 0;
 		}
-		if(newkey)
+		if(newkey){
+			memset(&key, 0, sizeof(key));
 			for(i=0; i<DESKEYLEN; i++)
 				key.des[i] = nrand(256);
+		}
 		if(a.user == 0){
 			t = getexpiration(f->keys, u);
 			newbio = querybio(f->who, u, &a);
@@ -117,11 +119,8 @@
 	}
 
 	if(newkey){
-		sprint(buf, "%s/%s/key", db, u);
-		fd = open(buf, OWRITE);
-		if(fd < 0 || write(fd, key->des, DESKEYLEN) != DESKEYLEN)
+		if(!setkey(db, u, key))
 			error("can't set key: %r");
-		close(fd);
 	}
 
 	if(t == -1)
--