plan 9 kernel history: overview | file list | diff list

1992/0318/boot/userpasswd.c (diff list | history)

1992/0317/sys/src/9/boot/userpasswd.c:4,391992/0318/sys/src/9/boot/userpasswd.c:4,14 (short | long | prev | next)
1992/0317    
 
char	password[NAMELEN]; 
 
static int 
passtokey(char *key, char *p, int n) 
{ 
	uchar t[10]; 
	int c; 
                 
	memset(t, ' ', sizeof t); 
	if(n < 5) 
		return 0; 
	if(n > 10) 
		n = 10; 
	strncpy((char*)t, p, n); 
	if(n >= 9){ 
		c = p[8] & 0xf; 
		if(n == 10) 
			c += p[9] << 4; 
		for(n = 0; n < 8; n++) 
			if(c & (1 << n)) 
				t[n] -= ' '; 
	} 
	for(n = 0; n < 7; n++) 
		key[n] = (t[n] >> n) + (t[n+1] << (8 - (n+1))); 
	return 1; 
} 
                 
/* 
 *  get/set user name and password.  verify password with auth server. 
 */ 
void 
userpasswd(Method *mp) 
1992/0318    
userpasswd(int islocal, Method *mp) 
1992/0317    
{ 
	char key[7]; 
	char buf[8 + NAMELEN]; 
1992/0317/sys/src/9/boot/userpasswd.c:44,501992/0318/sys/src/9/boot/userpasswd.c:19,25
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
	crfd = fd = -1; 
	while(strcmp(username, "none") != 0 && strcmp(mp->name, "local") != 0){ 
1992/0318    
	while(strcmp(username, "none") != 0 && !islocal){ 
1992/0317    
		getpasswd(password, sizeof password); 
		if(!passtokey(key, password, strlen(password))){ 
			print("bad password; try again\n"); 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)