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

1994/0715/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)
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"); 
1992/0318/sys/src/9/boot/userpasswd.c:1,51992/0322/sys/src/9/boot/userpasswd.c:1,6 (short | long)
1992/0317    
#include <u.h> 
#include <libc.h> 
1992/0322    
#include <auth.h> 
1992/0317    
#include <../boot/boot.h> 
 
char	password[NAMELEN]; 
1992/0318/sys/src/9/boot/userpasswd.c:21,301992/0322/sys/src/9/boot/userpasswd.c:22,28
1992/0317    
	crfd = fd = -1; 
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"); 
			continue; 
		} 
1992/0322    
		passtokey(key, password); 
1992/0317    
		fd = open("#c/key", OWRITE); 
		if(fd < 0) 
			fatal("can't open #c/key; please reboot"); 
1992/0322/sys/src/9/boot/userpasswd.c:4,91992/0323/sys/src/9/boot/userpasswd.c:4,10 (short | long)
1992/0317    
#include <../boot/boot.h> 
 
char	password[NAMELEN]; 
1992/0323    
extern	char *sauth; 
1992/0317    
 
/* 
 *  get/set user name and password.  verify password with auth server. 
1992/0322/sys/src/9/boot/userpasswd.c:14,231992/0323/sys/src/9/boot/userpasswd.c:15,31
1992/0317    
	char key[7]; 
	char buf[8 + NAMELEN]; 
	int fd, crfd; 
1992/0323    
	char *p; 
1992/0317    
 
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
		outin("user", username, sizeof(username)); 
1992/0323    
		/* Hack to do authentication testing */ 
		p = utfrrune(username, '!'); 
		if(p && p > username) { 
			*p = '\0'; 
			sauth = "any"; 
		} 
1992/0317    
	} 
	crfd = fd = -1; 
1992/0318    
	while(strcmp(username, "none") != 0 && !islocal){ 
1992/0323/sys/src/9/boot/userpasswd.c:4,101992/0325/sys/src/9/boot/userpasswd.c:4,12 (short | long)
1992/0317    
#include <../boot/boot.h> 
 
char	password[NAMELEN]; 
1992/0325    
#ifdef asdf 
1992/0323    
extern	char *sauth; 
1992/0325    
#endif asdf 
1992/0317    
 
/* 
 *  get/set user name and password.  verify password with auth server. 
1992/0323/sys/src/9/boot/userpasswd.c:20,311992/0325/sys/src/9/boot/userpasswd.c:22,27
1992/0317    
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
		outin("user", username, sizeof(username)); 
1992/0323    
		/* Hack to do authentication testing */ 
		p = utfrrune(username, '!'); 
		if(p && p > username) { 
			*p = '\0'; 
			sauth = "any"; 
		} 
1992/0317    
	} 
	crfd = fd = -1; 
1992/0318    
	while(strcmp(username, "none") != 0 && !islocal){ 
1992/0323/sys/src/9/boot/userpasswd.c:41,471992/0325/sys/src/9/boot/userpasswd.c:37,45
1992/0317    
		if(crfd < 0) 
			fatal("can't open crypt file"); 
		write(crfd, "E", 1); 
		fd = (*mp->auth)(); 
1992/0325    
		fd = -1; 
		if(mp->auth) 
			fd = (*mp->auth)(); 
1992/0317    
		if(fd < 0){ 
			warning("password not checked!"); 
			break; 
1992/0325/sys/src/9/boot/userpasswd.c:24,301992/0507/sys/src/9/boot/userpasswd.c:24,30 (short | long)
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
	crfd = fd = -1; 
1992/0318    
	while(strcmp(username, "none") != 0 && !islocal){ 
1992/0507    
	while(strcmp(username, "none") != 0){ 
1992/0317    
		getpasswd(password, sizeof password); 
1992/0322    
		passtokey(key, password); 
1992/0317    
		fd = open("#c/key", OWRITE); 
1992/0325/sys/src/9/boot/userpasswd.c:38,431992/0507/sys/src/9/boot/userpasswd.c:38,45
1992/0317    
			fatal("can't open crypt file"); 
		write(crfd, "E", 1); 
1992/0325    
		fd = -1; 
1992/0507    
		if(islocal) 
			break; 
1992/0325    
		if(mp->auth) 
			fd = (*mp->auth)(); 
1992/0317    
		if(fd < 0){ 
1992/0507/sys/src/9/boot/userpasswd.c:17,231992/0728/sys/src/9/boot/userpasswd.c:17,22 (short | long)
1992/0317    
	char key[7]; 
	char buf[8 + NAMELEN]; 
	int fd, crfd; 
1992/0323    
	char *p; 
1992/0317    
 
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
1992/0728/sys/src/9/boot/userpasswd.c:8,131993/0330/sys/src/9/boot/userpasswd.c:8,15 (short | long)
1992/0323    
extern	char *sauth; 
1992/0325    
#endif asdf 
1992/0317    
 
1993/0330    
char *homsg = "can't set user name or key; please reboot"; 
 
1992/0317    
/* 
 *  get/set user name and password.  verify password with auth server. 
 */ 
1992/0728/sys/src/9/boot/userpasswd.c:14,721993/0330/sys/src/9/boot/userpasswd.c:16,51
1992/0317    
void 
1992/0318    
userpasswd(int islocal, Method *mp) 
1992/0317    
{ 
	char key[7]; 
	char buf[8 + NAMELEN]; 
	int fd, crfd; 
1993/0330    
	int fd; 
	char *msg; 
	char hostkey[DESKEYLEN]; 
1992/0317    
 
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
		outin("user", username, sizeof(username)); 
	} 
	crfd = fd = -1; 
1993/0330    
	fd = -1; 
1992/0507    
	while(strcmp(username, "none") != 0){ 
1992/0317    
		getpasswd(password, sizeof password); 
1992/0322    
		passtokey(key, password); 
1992/0317    
		fd = open("#c/key", OWRITE); 
		if(fd < 0) 
			fatal("can't open #c/key; please reboot"); 
		if(write(fd, key, 7) != 7) 
			fatal("can't write #c/key; please reboot"); 
		close(fd); 
		crfd = open("#c/crypt", ORDWR); 
		if(crfd < 0) 
			fatal("can't open crypt file"); 
		write(crfd, "E", 1); 
1993/0330    
		passtokey(hostkey, password); 
1992/0325    
		fd = -1; 
1992/0507    
		if(islocal) 
			break; 
1992/0325    
		if(mp->auth) 
			fd = (*mp->auth)(); 
1992/0317    
		if(fd < 0){ 
			warning("password not checked!"); 
1993/0330    
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0) 
1992/0317    
			break; 
		} 
		strncpy(buf+8, username, NAMELEN); 
		if(read(fd, buf, 8) != 8 
		|| write(crfd, buf, 8) != 8 
		|| read(crfd, buf, 8) != 8 
		|| write(fd, buf, 8 + NAMELEN) != 8 + NAMELEN){ 
			warning("password not checked!"); 
			break; 
		} 
		if(read(fd, buf, 2) == 2 && buf[0]=='O' && buf[1]=='K') 
			break; 
		close(fd); 
1993/0330    
		fprint(2, "?%s\n", msg); 
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
	close(fd); 
	close(crfd); 
                 
	/* set user now that we're sure */ 
	fd = open("#c/user", OWRITE|OTRUNC); 
	if(fd >= 0){ 
		if(write(fd, username, strlen(username)) < 0) 
			warning("write user name"); 
1993/0330    
	if(fd > 0) 
1992/0317    
		close(fd); 
	}else 
		warning("open #c/user"); 
1993/0330    
 
	/* set host's key */ 
	if(writefile("#c/key", hostkey, DESKEYLEN) < 0) 
		fatal(homsg); 
 
	/* set host's owner (and uid of current process) */ 
	if(writefile("#c/hostowner", username, strlen(username)) < 0) 
		fatal(homsg); 
	close(fd); 
1992/0317    
} 
1993/0330/sys/src/9/boot/userpasswd.c:34,391993/0331/sys/src/9/boot/userpasswd.c:34,47 (short | long)
1993/0330    
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0) 
1992/0317    
			break; 
1993/0331    
		/* try the old key algorithm till everyone has switched */ 
		opasstokey(hostkey, password); 
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0){ 
			print("You have an old style key.  Once you are up, please run 'aux/passwd'\n"); 
			print("and retype your key to convert.\n"); 
			break; 
		} 
1993/0330    
		fprint(2, "?%s\n", msg); 
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
1993/0331/sys/src/9/boot/userpasswd.c:34,471994/0715/sys/src/9/boot/userpasswd.c:34,39 (short | long)
1993/0330    
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0) 
1992/0317    
			break; 
1993/0331    
		/* try the old key algorithm till everyone has switched */ 
		opasstokey(hostkey, password); 
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0){ 
			print("You have an old style key.  Once you are up, please run 'aux/passwd'\n"); 
			print("and retype your key to convert.\n"); 
			break; 
		} 
1993/0330    
		fprint(2, "?%s\n", msg); 
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
1994/0715/sys/src/9/boot/userpasswd.c:47,512000/0328/sys/src/9/boot/userpasswd.c:47,50 (short | long)
1993/0330    
	/* set host's owner (and uid of current process) */ 
	if(writefile("#c/hostowner", username, strlen(username)) < 0) 
		fatal(homsg); 
	close(fd); 
1992/0317    
} 
2000/0328/sys/src/9/boot/userpasswd.c:3,92001/0527/sys/src/9/boot/userpasswd.c:3,10 (short | long)
1992/0322    
#include <auth.h> 
1992/0317    
#include <../boot/boot.h> 
 
char	password[NAMELEN]; 
2001/0527    
char	username[64]; 
char	password[64]; 
1992/0325    
#ifdef asdf 
1992/0323    
extern	char *sauth; 
1992/0325    
#endif asdf 
2000/0328/sys/src/9/boot/userpasswd.c:11,482001/0527/sys/src/9/boot/userpasswd.c:12,26
1993/0330    
char *homsg = "can't set user name or key; please reboot"; 
 
1992/0317    
/* 
 *  get/set user name and password.  verify password with auth server. 
2001/0527    
 *  get/set user name. 
1992/0317    
 */ 
void 
1992/0318    
userpasswd(int islocal, Method *mp) 
2001/0527    
setusername(int, Method*) 
1992/0317    
{ 
1993/0330    
	int fd; 
	char *msg; 
	char hostkey[DESKEYLEN]; 
1992/0317    
                 
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
		outin("user", username, sizeof(username)); 
	} 
1993/0330    
	fd = -1; 
1992/0507    
	while(strcmp(username, "none") != 0){ 
1992/0317    
		getpasswd(password, sizeof password); 
1993/0330    
		passtokey(hostkey, password); 
1992/0325    
		fd = -1; 
1992/0507    
		if(islocal) 
			break; 
1993/0330    
		msg = checkkey(mp, username, hostkey); 
		if(msg == 0) 
1992/0317    
			break; 
1993/0330    
		fprint(2, "?%s\n", msg); 
1992/0317    
		outin("user", username, sizeof(username)); 
	} 
1993/0330    
	if(fd > 0) 
1992/0317    
		close(fd); 
1993/0330    
                 
	/* set host's key */ 
	if(writefile("#c/key", hostkey, DESKEYLEN) < 0) 
		fatal(homsg); 
 
	/* set host's owner (and uid of current process) */ 
	if(writefile("#c/hostowner", username, strlen(username)) < 0) 
2001/0527/sys/src/9/boot/userpasswd.c:1,282001/1107/sys/src/9/boot/userpasswd.c:0 (short | long)
Deleted.
rsc Mon Mar 7 10:21:03 2005
1992/0317    
#include <u.h> 
#include <libc.h> 
1992/0322    
#include <auth.h> 
1992/0317    
#include <../boot/boot.h> 
                 
2001/0527    
char	username[64]; 
char	password[64]; 
1992/0325    
#ifdef asdf 
1992/0323    
extern	char *sauth; 
1992/0325    
#endif asdf 
1992/0317    
                 
1993/0330    
char *homsg = "can't set user name or key; please reboot"; 
                 
1992/0317    
/* 
2001/0527    
 *  get/set user name. 
1992/0317    
 */ 
void 
2001/0527    
setusername(int, Method*) 
1992/0317    
{ 
	if(*username == 0 || strcmp(username, "none") == 0){ 
		strcpy(username, "none"); 
		outin("user", username, sizeof(username)); 
	} 
1993/0330    
                 
	/* set host's owner (and uid of current process) */ 
	if(writefile("#c/hostowner", username, strlen(username)) < 0) 
		fatal(homsg); 
1992/0317    
} 


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