Bug 82721 - systemd-networkd nonsense
Summary: systemd-networkd nonsense
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Zbigniew Jedrzejewski-Szmek
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-17 07:38 UTC by Hristo Venev
Modified: 2014-08-18 17:00 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Hristo Venev 2014-08-17 07:38:34 UTC
In src/network/networkd-link.c link_save():

--
  1365	                        fprintf(f, "%s%s", *address,
  1366	                                (address + 1 ? " " : ""));
--
  1380	                        fprintf(f, "%s%s", *address,
  1381	                                (address + 1 ? " " : ""));
--
  1395	                        fprintf(f, "%s%s", *domain,
  1396	                                (domain + 1 ? " " : ""));

THIS DOES NOT MAKE SENSE!

address and domain will almost never equal ((char*)NULL)-1 because they are pointers to allocated storage and (usually) the higher half of the address space is reserved for the kernel.

You probably meant *(address+1) and *(domain+1). That would make sense however it would break DHCP (you append an address/domain and then append " "). Therefore the behavior should be preserved and spaces should always be appended.

I know your love for patches submitted through bugzilla. I will never send the following patch to the mailing list:

--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1727,8 +1727,7 @@
                 fputs("DNS=", f);
 
                 STRV_FOREACH(address, link->network->dns)
-                        fprintf(f, "%s%s", *address,
-                                (address + 1 ? " " : ""));
+                        fprintf(f, "%s ", *address);
 
                 if (link->network->dhcp_dns &&
                     link->dhcp_lease) {
@@ -1747,8 +1746,7 @@
                 fprintf(f, "NTP=");
 
                 STRV_FOREACH(address, link->network->ntp)
-                        fprintf(f, "%s%s", *address,
-                                (address + 1 ? " " : ""));
+                        fprintf(f, "%s ", *address);
 
                 if (link->network->dhcp_ntp &&
                     link->dhcp_lease) {
@@ -1767,8 +1765,7 @@
                 fprintf(f, "DOMAINS=");
 
                 STRV_FOREACH(domain, link->network->domains)
-                        fprintf(f, "%s%s", *domain,
-                                (domain + 1 ? " " : ""));
+                        fprintf(f, "%s ", *domain);
 
                 if (link->network->dhcp_domains &&
                     link->dhcp_lease) {


P.S.: Thanks for implementing domains.
Comment 1 Lennart Poettering 2014-08-18 17:00:58 UTC
Thanks for the note!

Fixed in git!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.