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

2001/0807/port/auth.c (diff list | history)

2001/0529/sys/src/9/port/auth.c:11,162001/0807/sys/src/9/port/auth.c:11,41 (short | long | prev | next)
1993/0330    
char	evekey[DESKEYLEN]; 
char	hostdomain[DOMLEN]; 
 
2001/0807    
struct Session 
{ 
	char *authlist; 
}; 
 
Session* 
allocsession(char *authlist) 
{ 
	Session *s; 
 
	s = smalloc(sizeof(*s)); 
	s->authlist = nil; 
	kstrdup(&s->authlist, authlist); 
	return s; 
} 
 
void 
freesession(Session *s) 
{ 
	if(s == nil) 
		return; 
	free(s->authlist); 
	free(s); 
} 
 
1993/0330    
/* 
 *  return true if current user is eve 
 */ 
2001/0529/sys/src/9/port/auth.c:111,1462001/0807/sys/src/9/port/auth.c:136,151
2001/0527    
	return m; 
1993/0330    
} 
 
long 
2001/0527    
sysfsession(ulong *arg) 
2001/0807    
void 
sendsession(Chan *c) 
1993/0330    
{ 
2001/0527    
	Fcall f; 
	uchar *msg; 
	uint authlen, n, m; 
1993/0330    
	Chan *c; 
2001/0807    
	uint n, m; 
2001/0527    
	uvlong oo; 
1993/0330    
 
2001/0527    
//BUG print("warning: stub fsession being used\n"); 
	authlen = arg[2]; 
	validaddr(arg[1], authlen, 1); 
	c = fdtochan(arg[0], ORDWR, 0, 1); 
1993/0330    
	if(waserror()){ 
1999/0331    
		cclose(c); 
1993/0330    
		nexterror(); 
	} 
                 
2001/0527    
	if(c->flag & CMSG){ 
//BUG what to do? 
		((uchar*)arg[1])[0] = 0; 
		poperror(); 
		cclose(c); 
1993/0330    
		return 0; 
	} 
                 
2001/0527    
	f.type = Tsession; 
	f.tag = NOTAG; 
	f.nchal = 0; 
	f.chal = (uchar*)""; 
2001/0529    
	msg = smalloc(8192+IOHDRSZ); 
2001/0527    
	if(waserror()){ 
		free(msg); 
2001/0529/sys/src/9/port/auth.c:156,1612001/0807/sys/src/9/port/auth.c:161,167
2001/0527    
	unlock(c); 
1993/0330    
 
2001/0527    
	m = devtab[c->type]->write(c, msg, n, oo); 
2001/0807    
print("session sent\n"); 
1993/0731    
 
2001/0527    
	if(m < n){ 
		lock(c); 
2001/0529/sys/src/9/port/auth.c:168,1732001/0807/sys/src/9/port/auth.c:174,180
2001/0529    
	m = devtab[c->type]->read(c, msg, 8192+IOHDRSZ, c->offset); 
2001/0527    
	if(m <= 0) 
		error("EOF receiving fsession reply"); 
2001/0807    
print("rsession rcvd\n"); 
1993/0330    
 
2001/0527    
	lock(c); 
	c->offset += m; 
2001/0529/sys/src/9/port/auth.c:174,2012001/0807/sys/src/9/port/auth.c:181,251
2001/0527    
	unlock(c); 
1993/0731    
 
2001/0527    
	n = convM2S(msg, m, &f); 
2001/0807    
print("rsession conv returns %d\n", n); 
2001/0527    
	if(n != m) 
		error("bad fsession conversion on reply"); 
	if(f.type != Rsession) 
		error("unexpected reply type in fsession"); 
	m = f.nchal; 
	if(m > authlen) 
		error(Eshort); 
//BUG print("auth stuff ignored; noauth by default\n"); 
	((uchar*)arg[1])[0] = 0; 
2001/0807    
	c->session = allocsession(f.authlist); 
1993/0731    
 
2001/0527    
	free(msg); 
	poperror(); 
2001/0807    
} 
 
long 
sysfsession(ulong *arg) 
{ 
	Chan *c; 
	uint authlen, n; 
 
	authlen = arg[2]; 
	validaddr(arg[1], authlen, 1); 
	c = fdtochan(arg[0], ORDWR, 0, 1); 
	if(waserror()){ 
		cclose(c); 
		nexterror(); 
	} 
 
	if(c->session == nil){ 
		if(c->flag&CMSG) 
			error("session on mounted channel"); 
		sendsession(c); 
	} 
 
	n = strlen(c->session->authlist)+1; 
	if(n > authlen) 
		error(Eshort); 
	memmove((uchar*)arg[1], c->session->authlist, n); 
 
2001/0527    
	poperror(); 
	cclose(c); 
	return m; 
2001/0807    
	return n; 
 
1993/0330    
} 
 
long 
2001/0527    
sysfauth(ulong *) 
2001/0807    
sysfauth(ulong *arg) 
1993/0330    
{ 
2001/0527    
	error("sysfauth unimplemented"); 
	return -1; 
2001/0807    
	Chan *c; 
	uint authlen, rauthlen; 
	int n; 
 
	authlen = arg[2]; 
	validaddr(arg[1], authlen, 1); 
	rauthlen = arg[4]; 
	validaddr(arg[3], rauthlen, 1); 
	c = fdtochan(arg[0], ORDWR, 0, 1); 
	if(waserror()){ 
		cclose(c); 
		nexterror(); 
	} 
 
	n = mntauth(c, (uchar*)arg[1], authlen, (uchar*)arg[3], rauthlen); 
 
	poperror(); 
	cclose(c); 
	return n; 
 
1993/0731    
} 
 
/* 


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