use ndb directly for authdial

This commit is contained in:
rsc 2005-02-11 19:46:29 +00:00
parent 1b3e768e01
commit 15423fd052
2 changed files with 22 additions and 16 deletions

View file

@ -9,23 +9,30 @@ authdial(char *netroot, char *dom)
{
char *p;
int rv;
if(dom != nil){
/* look up an auth server in an authentication domain */
p = csgetvalue(netroot, "authdom", dom, "auth", nil);
Ndb *db;
char *file;
/* if that didn't work, just try the IP domain */
if(p == nil)
p = csgetvalue(netroot, "dom", dom, "auth", nil);
if(p == nil){
werrstr("no auth server found for %s", dom);
if(dom){
file = unsharp("#9/ndb/local");
db = ndbopen(file);
if(db == nil){
fprint(2, "open %s: %r\n", file);
free(file);
return -1;
}
rv = dial(netmkaddr(p, netroot, "ticket"), 0, 0, 0);
free(p);
free(file);
p = ndbgetvalue(db, nil, "authdom", dom, "auth", nil);
if(p == nil)
p = ndbgetvalue(db, nil, "dom", dom, "auth", nil);
if(p == nil)
p = dom;
rv = dial(netmkaddr(p, "tcp", "ticket"), 0, 0, 0);
if(p != dom)
free(p);
return rv;
} else {
/* look for one relative to my machine */
return dial(netmkaddr("$auth", netroot, "ticket"), 0, 0, 0);
}
p = getenv("auth");
if(p == nil)
p = "$auth";
return dial(netmkaddr(p, "tcp", "ticket"), 0, 0, 0);
}

View file

@ -1,11 +1,10 @@
PLAN9=../..
<$PLAN9/src/mkhdr
LIB=libauthsrv.a
OFILES=\
_asgetticket.$O\
_asrdresp.$O\
# authdial.$O\
authdial.$O\
convA2M.$O\
convM2A.$O\
convM2PR.$O\