mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
auth/factotum: avoid static buffer from netmkaddr()
factotum calls authdial() in parallel, so use the reentrant version netmkaddrbuf() instead.
This commit is contained in:
parent
e981a26000
commit
a101561223
2 changed files with 10 additions and 4 deletions
|
@ -75,6 +75,7 @@ netndbauthaddr(void)
|
|||
int
|
||||
_authdial(char *authdom)
|
||||
{
|
||||
char addr[256];
|
||||
int i, fd;
|
||||
|
||||
alarm(30*1000);
|
||||
|
@ -97,9 +98,11 @@ _authdial(char *authdom)
|
|||
if(authaddr[0] == nil)
|
||||
netndbauthaddr();
|
||||
for(i = 0; fd < 0 && authaddr[i] != nil; i++){
|
||||
fd = dial(netmkaddr(authaddr[i], "tcp", "567"), 0, 0, 0);
|
||||
fd = dial(netmkaddrbuf(authaddr[i], "tcp", "567", addr, sizeof(addr)),
|
||||
nil, nil, nil);
|
||||
if(fd < 0)
|
||||
fd = dial(netmkaddr(authaddr[i], "il", "566"), 0, 0, 0);
|
||||
fd = dial(netmkaddrbuf(authaddr[i], "il", "566", addr, sizeof(addr)),
|
||||
nil, nil, nil);
|
||||
}
|
||||
}
|
||||
alarm(0);
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
int
|
||||
authdial(char *netroot, char *dom)
|
||||
{
|
||||
char addr[256];
|
||||
Ndbtuple *t, *nt;
|
||||
char *p;
|
||||
int rv;
|
||||
|
||||
if(dom == nil)
|
||||
/* look for one relative to my machine */
|
||||
return dial(netmkaddr("$auth", nil, "ticket"), nil, nil, nil);
|
||||
return dial(netmkaddrbuf("$auth", nil, "ticket", addr, sizeof(addr)),
|
||||
nil, nil, nil);
|
||||
|
||||
/* look up an auth server in an authentication domain */
|
||||
p = csgetvalue(netroot, "authdom", dom, "auth", &t);
|
||||
|
@ -41,7 +43,8 @@ authdial(char *netroot, char *dom)
|
|||
rv = -1;
|
||||
for(nt = t; nt != nil; nt = nt->entry) {
|
||||
if(strcmp(nt->attr, "auth") == 0) {
|
||||
rv = dial(netmkaddr(nt->val, nil, "ticket"), nil, nil, nil);
|
||||
rv = dial(netmkaddrbuf(nt->val, nil, "ticket", addr, sizeof(addr)),
|
||||
nil, nil, nil);
|
||||
if(rv >= 0)
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue