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
|
int
|
||||||
_authdial(char *authdom)
|
_authdial(char *authdom)
|
||||||
{
|
{
|
||||||
|
char addr[256];
|
||||||
int i, fd;
|
int i, fd;
|
||||||
|
|
||||||
alarm(30*1000);
|
alarm(30*1000);
|
||||||
|
@ -97,9 +98,11 @@ _authdial(char *authdom)
|
||||||
if(authaddr[0] == nil)
|
if(authaddr[0] == nil)
|
||||||
netndbauthaddr();
|
netndbauthaddr();
|
||||||
for(i = 0; fd < 0 && authaddr[i] != nil; i++){
|
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)
|
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);
|
alarm(0);
|
||||||
|
|
|
@ -7,13 +7,15 @@
|
||||||
int
|
int
|
||||||
authdial(char *netroot, char *dom)
|
authdial(char *netroot, char *dom)
|
||||||
{
|
{
|
||||||
|
char addr[256];
|
||||||
Ndbtuple *t, *nt;
|
Ndbtuple *t, *nt;
|
||||||
char *p;
|
char *p;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if(dom == nil)
|
if(dom == nil)
|
||||||
/* look for one relative to my machine */
|
/* 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 */
|
/* look up an auth server in an authentication domain */
|
||||||
p = csgetvalue(netroot, "authdom", dom, "auth", &t);
|
p = csgetvalue(netroot, "authdom", dom, "auth", &t);
|
||||||
|
@ -41,7 +43,8 @@ authdial(char *netroot, char *dom)
|
||||||
rv = -1;
|
rv = -1;
|
||||||
for(nt = t; nt != nil; nt = nt->entry) {
|
for(nt = t; nt != nil; nt = nt->entry) {
|
||||||
if(strcmp(nt->attr, "auth") == 0) {
|
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)
|
if(rv >= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue