aboutsummaryrefslogtreecommitdiff
path: root/src/libauthsrv
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 19:46:29 +0000
committerrsc <devnull@localhost>2005-02-11 19:46:29 +0000
commit15423fd0524fae25926d807eddfe1336b2ec3be3 (patch)
tree1de3f4819a20b6d690818c55aff22acc2008aa59 /src/libauthsrv
parent1b3e768e01ef80ecdb758617e88ada3fb5a8226c (diff)
downloadplan9port-15423fd0524fae25926d807eddfe1336b2ec3be3.tar.gz
plan9port-15423fd0524fae25926d807eddfe1336b2ec3be3.tar.bz2
plan9port-15423fd0524fae25926d807eddfe1336b2ec3be3.zip
use ndb directly for authdial
Diffstat (limited to 'src/libauthsrv')
-rw-r--r--src/libauthsrv/authdial.c35
-rw-r--r--src/libauthsrv/mkfile3
2 files changed, 22 insertions, 16 deletions
diff --git a/src/libauthsrv/authdial.c b/src/libauthsrv/authdial.c
index 5e608058..5e305a54 100644
--- a/src/libauthsrv/authdial.c
+++ b/src/libauthsrv/authdial.c
@@ -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);
}
diff --git a/src/libauthsrv/mkfile b/src/libauthsrv/mkfile
index a69cc942..ddbefa56 100644
--- a/src/libauthsrv/mkfile
+++ b/src/libauthsrv/mkfile
@@ -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\