radius: a server may be a name, and the port is taken as written (#1027)

The port was promised by the man page but never parsed: a server
address with a port was refused, and only the default 1812 could be
used. The address is parsed with parsehost() now, as nserver and
authnserver are, so a name is resolved when the configuration is read,
an IPv6 address may be written in brackets, and the port is the one
authentication is asked on, the accounting of the same server going to
the port after it. The man page says which name servers resolve the
name.
This commit is contained in:
Vladimir Dubrovin committed 2026-11-21 14:43:03 +03:00
1 parent ab78b0bf69
commit 44b9e344e1
3 files changed
+48 -3

No files matched your search

+2 -2
View File
@@ -1821,8 +1821,8 @@ static int h_radius(int argc, unsigned char **argv){
*s = 0;
s++;
}
if( !getip46(46, argv[conf->nradservers + 2], (struct sockaddr *)&conf->radiuslist[conf->nradservers].authaddr)) return 1;
if( s && !getip46(46, (unsigned char *)s, (struct sockaddr *)&conf->radiuslist[conf->nradservers].localaddr)) return 2;
if(parsehost(46, argv[conf->nradservers + 2], (struct sockaddr *)&conf->radiuslist[conf->nradservers].authaddr)) return 1;
if(s && parsehost(46, (unsigned char *)s, (struct sockaddr *)&conf->radiuslist[conf->nradservers].localaddr)) return 2;
if(!*SAPORT(&conf->radiuslist[conf->nradservers].authaddr))*SAPORT(&conf->radiuslist[conf->nradservers].authaddr) = htons(1812);
port = ntohs(*SAPORT(&conf->radiuslist[conf->nradservers].authaddr));
conf->radiuslist[conf->nradservers].logaddr = conf->radiuslist[conf->nradservers].authaddr;