Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <authsrv.h>
4
#include <bio.h>
5
#include <ndb.h>
6
 
7
int
8
authdial(char *netroot, char *dom)
9
{
10
	char *p;
11
	int rv;
12
 
13
	if(dom == nil)
14
		/* look for one relative to my machine */
15
		return dial(netmkaddr("$auth", netroot, "ticket"), 0, 0, 0);
16
 
17
	/* look up an auth server in an authentication domain */
18
	p = csgetvalue(netroot, "authdom", dom, "auth", nil);
19
 
20
	/* if that didn't work, just try the IP domain */
21
	if(p == nil)
22
		p = csgetvalue(netroot, "dom", dom, "auth", nil);
23
	/*
24
	 * if that didn't work, try p9auth.$dom.  this is very helpful if
25
	 * you can't edit /lib/ndb.
26
	 */
27
	if(p == nil)
28
		p = smprint("p9auth.%s", dom);
29
	if(p == nil){			/* should no longer ever happen */
30
		werrstr("no auth server found for %s", dom);
31
		return -1;
32
	}
33
	rv = dial(netmkaddr(p, netroot, "ticket"), 0, 0, 0);
34
	free(p);
35
	return rv;
36
}