authdial.c 687 B

12345678910111213141516171819202122232425262728293031
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <authsrv.h>
  4. #include <bio.h>
  5. #include <ndb.h>
  6. int
  7. authdial(char *netroot, char *dom)
  8. {
  9. char *p;
  10. int rv;
  11. if(dom != nil){
  12. /* look up an auth server in an authentication domain */
  13. p = csgetvalue(netroot, "authdom", dom, "auth", nil);
  14. /* if that didn't work, just try the IP domain */
  15. if(p == nil)
  16. p = csgetvalue(netroot, "dom", dom, "auth", nil);
  17. if(p == nil){
  18. werrstr("no auth server found for %s", dom);
  19. return -1;
  20. }
  21. rv = dial(netmkaddr(p, netroot, "ticket"), 0, 0, 0);
  22. free(p);
  23. return rv;
  24. } else {
  25. /* look for one relative to my machine */
  26. return dial(netmkaddr("$auth", netroot, "ticket"), 0, 0, 0);
  27. }
  28. }