summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-18 18:59:48 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-18 18:59:48 +0200
commitea352b409eec5ea1a430fde176dd5ea57698a6a6 (patch)
tree8d2b839b74df230c7d152bf25d5e12fcfc6f22a2 /src/network/networkd-link.c
parent8aa209ee141b2314e9f1bb502a08c5129bcca3b1 (diff)
networkd: fix how we generate lists in link_save()
https://bugs.freedesktop.org/show_bug.cgi?id=82721
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index a37561a04a..248022133f 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1721,14 +1721,17 @@ int link_save(Link *link) {
admin_state, oper_state);
if (link->network) {
- char **address;
- char **domain;
+ char **address, **domain;
+ bool space;
fputs("DNS=", f);
-
- STRV_FOREACH(address, link->network->dns)
- fprintf(f, "%s%s", *address,
- (address + 1 ? " " : ""));
+ space = false;
+ STRV_FOREACH(address, link->network->dns) {
+ if (space)
+ fputc(' ', f);
+ fputs(*address, f);
+ space = true;
+ }
if (link->network->dhcp_dns &&
link->dhcp_lease) {
@@ -1736,19 +1739,22 @@ int link_save(Link *link) {
r = sd_dhcp_lease_get_dns(link->dhcp_lease, &addresses);
if (r > 0) {
+ if (space)
+ fputc(' ', f);
serialize_in_addrs(f, addresses, r);
- if (link->network->dns)
- fputs(" ", f);
}
}
fputs("\n", f);
fprintf(f, "NTP=");
-
- STRV_FOREACH(address, link->network->ntp)
- fprintf(f, "%s%s", *address,
- (address + 1 ? " " : ""));
+ space = false;
+ STRV_FOREACH(address, link->network->ntp) {
+ if (space)
+ fputc(' ', f);
+ fputs(*address, f);
+ space = true;
+ }
if (link->network->dhcp_ntp &&
link->dhcp_lease) {
@@ -1756,19 +1762,22 @@ int link_save(Link *link) {
r = sd_dhcp_lease_get_ntp(link->dhcp_lease, &addresses);
if (r > 0) {
+ if (space)
+ fputc(' ', f);
serialize_in_addrs(f, addresses, r);
- if (link->network->ntp)
- fputs(" ", f);
}
}
fputs("\n", f);
fprintf(f, "DOMAINS=");
-
- STRV_FOREACH(domain, link->network->domains)
- fprintf(f, "%s%s", *domain,
- (domain + 1 ? " " : ""));
+ space = false;
+ STRV_FOREACH(domain, link->network->domains) {
+ if (space)
+ fputc(' ', f);
+ fputs(*domain, f);
+ space = true;
+ }
if (link->network->dhcp_domains &&
link->dhcp_lease) {
@@ -1776,9 +1785,9 @@ int link_save(Link *link) {
r = sd_dhcp_lease_get_domainname(link->dhcp_lease, &domainname);
if (r >= 0) {
+ if (space)
+ fputc(' ', f);
fputs(domainname, f);
- if (link->network->domains)
- fputs(" ", f);
}
}