Lists of IPs should be comma-separated rather than semicolon or

space-separated.
This commit is contained in:
Nicholas J. Kain 2013-05-10 13:46:58 -04:00
parent 1fc06c6e4f
commit 62d69e1909
2 changed files with 7 additions and 8 deletions

View File

@ -182,7 +182,7 @@ static void write_resolve_conf(struct ifchd_client *cl)
char *p = cl->namesvrs; char *p = cl->namesvrs;
while (p && (*p != '\0')) { while (p && (*p != '\0')) {
char *q = strchr(p, ' '); char *q = strchr(p, ',');
if (!q) if (!q)
q = strchr(p, '\0'); q = strchr(p, '\0');
else else
@ -199,7 +199,7 @@ static void write_resolve_conf(struct ifchd_client *cl)
p = cl->domains; p = cl->domains;
int numdoms = 0; int numdoms = 0;
while (p && (*p != '\0')) { while (p && (*p != '\0')) {
char *q = strchr(p, ' '); char *q = strchr(p, ',');
if (!q) if (!q)
q = strchr(p, '\0'); q = strchr(p, '\0');
else else

View File

@ -97,9 +97,10 @@ static int ifchd_cmd_iplist(char *buf, size_t buflen, char *optname,
{ {
char ipbuf[INET_ADDRSTRLEN]; char ipbuf[INET_ADDRSTRLEN];
char *obuf = buf; char *obuf = buf;
if (!optdata) if (!optdata || optlen < 4)
return -1; return -1;
ssize_t wc = ifchd_cmd_ip(buf, buflen, optname, optdata, optlen); inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf);
ssize_t wc = snprintf(buf, buflen, "%s:%s", optname, ipbuf);
if (wc <= 0) if (wc <= 0)
return wc; return wc;
optlen -= 4; optlen -= 4;
@ -109,13 +110,11 @@ static int ifchd_cmd_iplist(char *buf, size_t buflen, char *optname,
inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf); inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf);
if (buflen < strlen(ipbuf) + (buf - obuf) + 2) if (buflen < strlen(ipbuf) + (buf - obuf) + 2)
break; break;
if (optlen >= 8) buf += snprintf(buf, buflen - (buf - obuf), ",%s", ipbuf);
buf += snprintf(buf, buflen - (buf - obuf), "%s:", ipbuf);
else
buf += snprintf(buf, buflen - (buf - obuf), "%s;", ipbuf);
optlen -= 4; optlen -= 4;
optdata += 4; optdata += 4;
} }
buf += snprintf(buf, buflen - (buf - obuf), ";");
return buf - obuf; return buf - obuf;
} }