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

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

2001/0807/sys/src/9/port/auth.c:11,412001/0808/sys/src/9/port/auth.c:11,16 (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/0807/sys/src/9/port/auth.c:136,1512001/0808/sys/src/9/port/auth.c:111,146
2001/0527    
	return m; 
1993/0330    
} 
 
2001/0807    
void 
sendsession(Chan *c) 
2001/0808    
long 
sysfsession(ulong *arg) 
1993/0330    
{ 
2001/0527    
	Fcall f; 
	uchar *msg; 
2001/0807    
	uint n, m; 
2001/0808    
	uint authlen, n, m; 
	Chan *c; 
2001/0527    
	uvlong oo; 
1993/0330    
 
2001/0808    
//BUG print("warning: stub fsession being used\n"); 
	authlen = arg[2]; 
	validaddr(arg[1], authlen, 1); 
	c = fdtochan(arg[0], ORDWR, 0, 1); 
	if(waserror()){ 
		cclose(c); 
		nexterror(); 
	} 
 
	if(c->flag & CMSG){ 
//BUG what to do? 
		((uchar*)arg[1])[0] = 0; 
		poperror(); 
		cclose(c); 
		return 0; 
	} 
 
2001/0527    
	f.type = Tsession; 
	f.tag = NOTAG; 
2001/0808    
	f.nchal = 0; 
	f.chal = (uchar*)""; 
2001/0529    
	msg = smalloc(8192+IOHDRSZ); 
2001/0527    
	if(waserror()){ 
		free(msg); 
2001/0807/sys/src/9/port/auth.c:161,1672001/0808/sys/src/9/port/auth.c:156,161
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/0807/sys/src/9/port/auth.c:174,1802001/0808/sys/src/9/port/auth.c:168,173
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/0807/sys/src/9/port/auth.c:181,2512001/0808/sys/src/9/port/auth.c:174,201
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"); 
2001/0807    
	c->session = allocsession(f.authlist); 
2001/0808    
	m = f.nchal; 
	if(m > authlen) 
		error(Eshort); 
//BUG print("auth stuff ignored; noauth by default\n"); 
	((uchar*)arg[1])[0] = 0; 
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); 
2001/0807    
	return n; 
                 
2001/0808    
	return m; 
1993/0330    
} 
 
long 
2001/0807    
sysfauth(ulong *arg) 
2001/0808    
sysfauth(ulong *) 
1993/0330    
{ 
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; 
                 
2001/0808    
	error("sysfauth unimplemented"); 
	return -1; 
1993/0731    
} 
 
/* 


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