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

1993/0408/port/auth.c (diff list | history)

1993/0407/sys/src/9/port/auth.c:19,241993/0408/sys/src/9/port/auth.c:19,25 (short | long | prev | next)
1993/0330    
struct Session 
{ 
	Lock; 
1993/0408    
	Lock	send; 
1993/0330    
	Crypt	*cache;			/* cache of tickets */ 
	char	cchal[CHALLEN];		/* client challenge */ 
	char	schal[CHALLEN];		/* server challenge */ 
1993/0407/sys/src/9/port/auth.c:25,301993/0408/sys/src/9/port/auth.c:26,32
1993/0330    
	char	authid[NAMELEN];	/* server encryption uid */ 
	char	authdom[DOMLEN];	/* server encryption domain */ 
	ulong	cid;			/* challenge id */ 
1993/0408    
	int	valid; 
1993/0330    
}; 
 
struct 
1993/0407/sys/src/9/port/auth.c:109,1291993/0408/sys/src/9/port/auth.c:111,134
1993/0330    
		nexterror(); 
	} 
1993/0407    
 
	/* 
	 *  if two processes get here at the same 
	 *  time with no session exchanged, we have 
	 *  a race. 
	 */ 
1993/0408    
	/* add a session structure to the channel if it has none */ 
	lock(c); 
1993/0330    
	s = c->session; 
	if(s == 0){ 
1993/0407    
		/* 
		 *  no session exchanged yet 
		 */ 
1993/0330    
		s = malloc(sizeof(Session)); 
		if(s == 0) 
1993/0408    
		if(s == 0){ 
			unlock(c); 
1993/0330    
			error(Enomem); 
		memset(s, 0, sizeof(Session)); 
1993/0408    
		} 
		c->session = s; 
	} 
	unlock(c); 
1993/0407    
 
1993/0408    
	/* back off if someone else is doing an fsession */ 
	while(!canlock(&s->send)) 
		sched(); 
 
	if(s->valid == 0){ 
1993/0407    
		/* 
		 *  Exchange a session message with the server. 
		 *  If an error occurs reading or writing, 
1993/0407/sys/src/9/port/auth.c:144,1501993/0408/sys/src/9/port/auth.c:149,155
1993/0407    
				n = (*devtab[c->type].read)(c, buf, sizeof buf, 0); 
			poperror(); 
			if(convM2S(buf, &f, n) == 0){ 
				free(s); 
1993/0408    
				unlock(s); 
1993/0407    
				error(Emountrpc); 
			} 
			switch(f.type){ 
1993/0407/sys/src/9/port/auth.c:154,1681993/0408/sys/src/9/port/auth.c:159,174
1993/0407    
				memmove(s->authdom, f.authdom, DOMLEN); 
				break; 
			case Rerror: 
				free(s); 
1993/0408    
				unlock(s); 
1993/0407    
				error(f.ename); 
			default: 
				free(s); 
1993/0408    
				unlock(s); 
1993/0407    
				error(Emountrpc); 
			} 
1993/0330    
		} 
		c->session = s; 
1993/0408    
		s->valid = 1; 
1993/0330    
	} 
1993/0408    
	unlock(&s->send); 
1993/0330    
 
	/*  
	 *  If server requires no ticket, or user is "none", or a ticket 
1993/0407/sys/src/9/port/auth.c:169,1861993/0408/sys/src/9/port/auth.c:175,196
1993/0330    
	 *  is already cached, zero the request type 
	 */ 
	tr.type = AuthTreq; 
	if(strcmp(u->p->user, "none") == 0 || c->session->authid[0] == 0) 
1993/0408    
	if(strcmp(u->p->user, "none") == 0 || s->authid[0] == 0) 
1993/0330    
		tr.type = 0; 
	else for(cp = s->cache; cp; cp = cp->next) 
		if(strcmp(cp->t.cuid, u->p->user) == 0){ 
			tr.type = 0; 
			break; 
		} 
1993/0408    
	else{ 
		lock(s); 
		for(cp = s->cache; cp; cp = cp->next) 
			if(strcmp(cp->t.cuid, u->p->user) == 0){ 
				tr.type = 0; 
				break; 
			} 
		unlock(s); 
	} 
1993/0330    
 
	/*  create ticket request */ 
	memmove(tr.chal, c->session->schal, CHALLEN); 
	memmove(tr.authid, c->session->authid, NAMELEN); 
	memmove(tr.authdom, c->session->authdom, DOMLEN); 
1993/0408    
	memmove(tr.chal, s->schal, CHALLEN); 
	memmove(tr.authid, s->authid, NAMELEN); 
	memmove(tr.authdom, s->authdom, DOMLEN); 
1993/0330    
	memmove(tr.uid, u->p->user, NAMELEN); 
	memmove(tr.hostid, eve, NAMELEN); 
	convTR2M(&tr, (char*)arg[1]); 


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