facter 3.11.0.cfacter.20180319 → 3.11.2.cfacter.20180606

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/ext/facter/facter/CMakeLists.txt +1 -1
  3. data/ext/facter/facter/acceptance/Gemfile +4 -3
  4. data/ext/facter/facter/acceptance/Rakefile +2 -342
  5. data/ext/facter/facter/acceptance/config/aio/options.rb +0 -6
  6. data/ext/facter/facter/acceptance/config/git/options.rb +1 -5
  7. data/ext/facter/facter/lib/Doxyfile +1 -1
  8. data/ext/facter/facter/lib/inc/internal/facts/aix/networking_resolver.hpp +7 -0
  9. data/ext/facter/facter/lib/inc/internal/facts/bsd/networking_resolver.hpp +2 -0
  10. data/ext/facter/facter/lib/inc/internal/facts/freebsd/networking_resolver.hpp +7 -0
  11. data/ext/facter/facter/lib/inc/internal/facts/linux/networking_resolver.hpp +7 -0
  12. data/ext/facter/facter/lib/inc/internal/facts/openbsd/networking_resolver.hpp +7 -0
  13. data/ext/facter/facter/lib/inc/internal/facts/osx/networking_resolver.hpp +7 -0
  14. data/ext/facter/facter/lib/inc/internal/facts/posix/networking_resolver.hpp +7 -0
  15. data/ext/facter/facter/lib/inc/internal/facts/resolvers/networking_resolver.hpp +3 -2
  16. data/ext/facter/facter/lib/inc/internal/facts/solaris/networking_resolver.hpp +7 -0
  17. data/ext/facter/facter/lib/src/facts/aix/disk_resolver.cc +11 -2
  18. data/ext/facter/facter/lib/src/facts/aix/networking_resolver.cc +5 -0
  19. data/ext/facter/facter/lib/src/facts/bsd/networking_resolver.cc +60 -4
  20. data/ext/facter/facter/lib/src/facts/freebsd/networking_resolver.cc +10 -1
  21. data/ext/facter/facter/lib/src/facts/linux/networking_resolver.cc +10 -1
  22. data/ext/facter/facter/lib/src/facts/openbsd/networking_resolver.cc +10 -1
  23. data/ext/facter/facter/lib/src/facts/osx/networking_resolver.cc +10 -1
  24. data/ext/facter/facter/lib/src/facts/posix/networking_resolver.cc +2 -1
  25. data/ext/facter/facter/lib/src/facts/resolvers/networking_resolver.cc +23 -7
  26. data/ext/facter/facter/lib/src/facts/solaris/networking_resolver.cc +5 -0
  27. data/ext/facter/facter/locales/FACTER.pot +32 -1
  28. data/ext/facter/leatherman/CHANGELOG.md +9 -0
  29. data/ext/facter/leatherman/CMakeLists.txt +2 -1
  30. data/ext/facter/leatherman/cmake/FindICU.cmake +690 -0
  31. data/ext/facter/leatherman/locale/CMakeLists.txt +7 -0
  32. metadata +4 -9
  33. data/ext/facter/facter/acceptance/setup/aio/pre-suite/010_Install.rb +0 -22
  34. data/ext/facter/facter/acceptance/setup/aio/pre-suite/021_InstallAristaModule.rb +0 -12
  35. data/ext/facter/facter/acceptance/setup/aio/pre-suite/022_Remove_LD_PRELOAD.rb +0 -11
  36. data/ext/facter/facter/acceptance/setup/common/00_EnvSetup.rb +0 -64
  37. data/ext/facter/facter/acceptance/setup/common/pre-suite/000-delete-puppet-when-none.rb +0 -11
  38. data/ext/facter/facter/acceptance/setup/git/pre-suite/01_TestSetup.rb +0 -31
@@ -37,6 +37,13 @@ namespace facter { namespace facts { namespace openbsd {
37
37
  * @return Returns a pointer to the address bytes or nullptr if not a link address.
38
38
  */
39
39
  virtual uint8_t const* get_link_address_bytes(sockaddr const* addr) const override;
40
+
41
+ /**
42
+ * Gets the length of the link address.
43
+ * @param addr The socket address representing the link address.
44
+ * @return Returns the length of the address or 0 if not a link address.
45
+ */
46
+ virtual uint8_t get_link_address_length(sockaddr const* addr) const override;
40
47
  };
41
48
 
42
49
  }}} // namespace facter::facts::openbsd
@@ -28,6 +28,13 @@ namespace facter { namespace facts { namespace osx {
28
28
  */
29
29
  virtual uint8_t const* get_link_address_bytes(sockaddr const* addr) const override;
30
30
 
31
+ /**
32
+ * Gets the length of the link address.
33
+ * @param addr The socket address representing the link address.
34
+ * @return Returns the length of the address or 0 if not a link address.
35
+ */
36
+ virtual uint8_t get_link_address_length(sockaddr const* addr) const override;
37
+
31
38
  /**
32
39
  * Gets the MTU of the link layer data.
33
40
  * @param interface The name of the link layer interface.
@@ -37,6 +37,13 @@ namespace facter { namespace facts { namespace posix {
37
37
  */
38
38
  virtual uint8_t const* get_link_address_bytes(sockaddr const* addr) const = 0;
39
39
 
40
+ /**
41
+ * Gets the length of the link address.
42
+ * @param addr The socket address representing the link address.
43
+ * @return Returns the length of the address or 0 if not a link address.
44
+ */
45
+ virtual uint8_t get_link_address_length(sockaddr const* addr) const = 0;
46
+
40
47
  /**
41
48
  * Collects the resolver data.
42
49
  * @param facts The fact collection that is resolving facts.
@@ -24,10 +24,11 @@ namespace facter { namespace facts { namespace resolvers {
24
24
 
25
25
  /**
26
26
  * Utility function to convert the bytes of a MAC address to a string.
27
- * @param bytes The bytes of the MAC address; expected to be 6 bytes long.
27
+ * @param bytes The bytes of the MAC address; accepts 6-byte and 20-byte addresses.
28
+ * @param byte_count The number of bytes in the MAC address; defaults to be 6 bytes long.
28
29
  * @returns Returns the MAC address as a string or an empty string if the address is the "NULL" MAC address.
29
30
  */
30
- static std::string macaddress_to_string(uint8_t const* bytes);
31
+ static std::string macaddress_to_string(uint8_t const* bytes, uint8_t byte_count = 6);
31
32
 
32
33
  /**
33
34
  * Returns whether the address is an ignored IPv4 address.
@@ -37,6 +37,13 @@ namespace facter { namespace facts { namespace solaris {
37
37
  */
38
38
  virtual uint8_t const* get_link_address_bytes(sockaddr const* addr) const override;
39
39
 
40
+ /**
41
+ * Gets the length of the link address.
42
+ * @param addr The socket address representing the link address.
43
+ * @return Returns the length of the address or 0 if not a link address.
44
+ */
45
+ virtual uint8_t get_link_address_length(sockaddr const* addr) const override;
46
+
40
47
  private:
41
48
  void populate_binding(interface& iface, lifreq const* addr) const;
42
49
  void populate_macaddress(interface& iface, lifreq const* addr) const;
@@ -36,9 +36,18 @@ namespace facter { namespace facts { namespace aix {
36
36
 
37
37
  {
38
38
  string device = (boost::format("/dev/%1%") % d.name).str();
39
- scoped_descriptor fd(open(device.c_str(), O_RDONLY));
39
+ auto descriptor = open(device.c_str(), O_RDONLY);
40
+ if (descriptor < 0) {
41
+ LOG_DEBUG("Could not open device %1% for reading: %2% (%3%). Disk facts will not be populated for this device", d.name, strerror(errno), errno);
42
+ continue;
43
+ }
44
+ scoped_descriptor fd(descriptor);
40
45
  devinfo info;
41
- ioctl(fd, IOCINFO, &info);
46
+ auto result = ioctl(fd, IOCINFO, &info);
47
+ if (result < 0) {
48
+ LOG_DEBUG("Ioctl IOCINFO failed for device %1%: %2% (%3%). Disk facts will not be populated for this device", d.name, strerror(errno), errno);
49
+ continue;
50
+ }
42
51
  switch (info.devtype) {
43
52
  case DD_DISK:
44
53
  case DD_SCDISK:
@@ -241,5 +241,10 @@ namespace facter { namespace facts { namespace aix {
241
241
  return nullptr;
242
242
  }
243
243
 
244
+ uint8_t networking_resolver::get_link_address_length(const sockaddr * addr) const
245
+ {
246
+ return 0;
247
+ }
248
+
244
249
 
245
250
  }}} // namespace facter::facts::aix
@@ -1,15 +1,21 @@
1
+ #include <facter/util/string.hpp>
1
2
  #include <internal/facts/bsd/networking_resolver.hpp>
2
3
  #include <internal/util/bsd/scoped_ifaddrs.hpp>
3
4
  #include <leatherman/execution/execution.hpp>
4
5
  #include <leatherman/file_util/file.hpp>
5
6
  #include <leatherman/file_util/directory.hpp>
6
7
  #include <leatherman/logging/logging.hpp>
8
+ #include <leatherman/util/regex.hpp>
7
9
  #include <boost/algorithm/string.hpp>
10
+ #include <boost/filesystem.hpp>
8
11
  #include <netinet/in.h>
12
+ #include <unordered_map>
9
13
 
10
14
  using namespace std;
11
15
  using namespace facter::util::bsd;
12
16
  using namespace leatherman::execution;
17
+ using namespace leatherman::util;
18
+ using facter::util::maybe_stoi;
13
19
 
14
20
  namespace lth_file = leatherman::file_util;
15
21
 
@@ -117,11 +123,8 @@ namespace facter { namespace facts { namespace bsd {
117
123
  // that has a non-loopback address
118
124
  return {};
119
125
  }
120
-
121
- map<string, string> networking_resolver::find_dhcp_servers() const
126
+ void networking_resolver::find_dhclient_dhcp_servers(std::map<std::string, std::string>& servers) const
122
127
  {
123
- map<string, string> servers;
124
-
125
128
  static vector<string> const dhclient_search_directories = {
126
129
  "/var/lib/dhclient",
127
130
  "/var/lib/dhcp",
@@ -153,6 +156,59 @@ namespace facter { namespace facts { namespace bsd {
153
156
  return true;
154
157
  }, "^dhclient.*lease.*$");
155
158
  }
159
+ }
160
+
161
+ void networking_resolver::find_networkd_dhcp_servers(std::map<std::string, std::string>& servers) const
162
+ {
163
+ // Files in this lease directory are not part of systemd's public API,
164
+ // and they include warnings against parsing them, but they seem to be
165
+ // the only way to get this information for now.
166
+ // Each file is named after the interface's index number.
167
+ static const string networkd_lease_directory = "/run/systemd/netif/leases/";
168
+
169
+ if (!boost::filesystem::is_directory(networkd_lease_directory)) return;
170
+
171
+ static boost::regex ip_link_re("^(\\d+):\\s+([^:]+)");
172
+ unordered_map<int, string> iface_index_names;
173
+ string key, value;
174
+
175
+ // Gather a map of interface indices and their interface names from `ip link show` --
176
+ // Only the index is known in the lease files.
177
+ each_line("ip", {"link", "show"}, [&](string line) {
178
+ if (re_search(line, ip_link_re, &key, &value)) {
179
+ iface_index_names.insert(make_pair(stoi(key), value));
180
+ }
181
+ return true;
182
+ });
183
+
184
+ LOG_DEBUG("searching \"{1}\" for systemd-networkd DHCP lease files", networkd_lease_directory);
185
+
186
+ lth_file::each_file(networkd_lease_directory, [&](string const& path) {
187
+ LOG_DEBUG("searching \"{1}\" for systemd-networkd DHCP lease information", path);
188
+ string server_address;
189
+
190
+ static boost::regex server_address_re("^SERVER_ADDRESS=(.*)$");
191
+ lth_file::each_line(path, [&](string& line) {
192
+ boost::trim(line);
193
+ if (re_search(line, server_address_re, &server_address)) {
194
+ boost::filesystem::path p {path};
195
+ auto iface_index = maybe_stoi(p.filename().string());
196
+ if (!iface_index) return true;
197
+ servers.emplace(make_pair(iface_index_names[iface_index.get()], server_address));
198
+ }
199
+ return true;
200
+ });
201
+ return true;
202
+ });
203
+ }
204
+
205
+ map<string, string> networking_resolver::find_dhcp_servers() const
206
+ {
207
+ map<string, string> servers;
208
+
209
+ find_networkd_dhcp_servers(servers);
210
+ if (servers.empty()) find_dhclient_dhcp_servers(servers);
211
+
156
212
  return servers;
157
213
  }
158
214
 
@@ -27,12 +27,21 @@ namespace facter { namespace facts { namespace freebsd {
27
27
  return nullptr;
28
28
  }
29
29
  sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
30
- if (link_addr->sdl_alen != 6) {
30
+ if (link_addr->sdl_alen != 6 && link_addr->sdl_alen != 20) {
31
31
  return nullptr;
32
32
  }
33
33
  return reinterpret_cast<uint8_t const*>(LLADDR(link_addr));
34
34
  }
35
35
 
36
+ uint8_t networking_resolver::get_link_address_length(sockaddr const* addr) const
37
+ {
38
+ if (!is_link_address(addr)) {
39
+ return 0;
40
+ }
41
+ sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
42
+ return link_addr->sdl_alen;
43
+ }
44
+
36
45
  boost::optional<uint64_t> networking_resolver::get_link_mtu(string const& interface, void* data) const
37
46
  {
38
47
  ifreq ifr;
@@ -67,12 +67,21 @@ namespace facter { namespace facts { namespace linux {
67
67
  return nullptr;
68
68
  }
69
69
  sockaddr_ll const* link_addr = reinterpret_cast<sockaddr_ll const*>(addr);
70
- if (link_addr->sll_halen != 6) {
70
+ if (link_addr->sll_halen != 6 && link_addr->sll_halen != 20) {
71
71
  return nullptr;
72
72
  }
73
73
  return reinterpret_cast<uint8_t const*>(link_addr->sll_addr);
74
74
  }
75
75
 
76
+ uint8_t networking_resolver::get_link_address_length(sockaddr const* addr) const
77
+ {
78
+ if (!is_link_address(addr)) {
79
+ return 0;
80
+ }
81
+ sockaddr_ll const* link_addr = reinterpret_cast<sockaddr_ll const*>(addr);
82
+ return link_addr->sll_halen;
83
+ }
84
+
76
85
  boost::optional<uint64_t> networking_resolver::get_link_mtu(string const& interface, void* data) const
77
86
  {
78
87
  // Unfortunately in Linux, the data points at interface statistics
@@ -27,12 +27,21 @@ namespace facter { namespace facts { namespace openbsd {
27
27
  return nullptr;
28
28
  }
29
29
  sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
30
- if (link_addr->sdl_alen != 6) {
30
+ if (link_addr->sdl_alen != 6 && link_addr->sdl_alen != 20) {
31
31
  return nullptr;
32
32
  }
33
33
  return reinterpret_cast<uint8_t const*>(LLADDR(link_addr));
34
34
  }
35
35
 
36
+ uint8_t networking_resolver::get_link_address_length(sockaddr const* addr) const
37
+ {
38
+ if (!is_link_address(addr)) {
39
+ return 0;
40
+ }
41
+ sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
42
+ return link_addr->sdl_alen;
43
+ }
44
+
36
45
  boost::optional<uint64_t> networking_resolver::get_link_mtu(string const& interface, void* data) const
37
46
  {
38
47
  ifreq ifr;
@@ -23,12 +23,21 @@ namespace facter { namespace facts { namespace osx {
23
23
  return nullptr;
24
24
  }
25
25
  sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
26
- if (link_addr->sdl_alen != 6) {
26
+ if (link_addr->sdl_alen != 6 && link_addr->sdl_alen != 20) {
27
27
  return nullptr;
28
28
  }
29
29
  return reinterpret_cast<uint8_t const*>(LLADDR(link_addr));
30
30
  }
31
31
 
32
+ uint8_t networking_resolver::get_link_address_length(sockaddr const* addr) const
33
+ {
34
+ if (!is_link_address(addr)) {
35
+ return 0;
36
+ }
37
+ sockaddr_dl const* link_addr = reinterpret_cast<sockaddr_dl const*>(addr);
38
+ return link_addr->sdl_alen;
39
+ }
40
+
32
41
  boost::optional<uint64_t> networking_resolver::get_link_mtu(string const& interface, void* data) const
33
42
  {
34
43
  if (!data) {
@@ -49,8 +49,9 @@ namespace facter { namespace facts { namespace posix {
49
49
  return buffer;
50
50
  } else if (is_link_address(addr)) {
51
51
  auto link_addr = get_link_address_bytes(addr);
52
+ uint8_t link_addr_len = get_link_address_length(addr);
52
53
  if (link_addr) {
53
- return macaddress_to_string(reinterpret_cast<uint8_t const*>(link_addr));
54
+ return macaddress_to_string(reinterpret_cast<uint8_t const*>(link_addr), link_addr_len);
54
55
  }
55
56
  }
56
57
 
@@ -151,15 +151,15 @@ namespace facter { namespace facts { namespace resolvers {
151
151
  }
152
152
  }
153
153
 
154
- string networking_resolver::macaddress_to_string(uint8_t const* bytes)
154
+ string networking_resolver::macaddress_to_string(uint8_t const* bytes, uint8_t byte_count)
155
155
  {
156
- if (!bytes) {
156
+ if (!bytes || (byte_count != 6 && byte_count != 20)) {
157
157
  return {};
158
158
  }
159
159
 
160
160
  // Ignore MAC address "0"
161
161
  bool nonzero = false;
162
- for (size_t i = 0; i < 6; ++i) {
162
+ for (size_t i = 0; i < byte_count; ++i) {
163
163
  if (bytes[i] != 0) {
164
164
  nonzero = true;
165
165
  break;
@@ -169,10 +169,26 @@ namespace facter { namespace facts { namespace resolvers {
169
169
  return {};
170
170
  }
171
171
 
172
- return (boost::format("%02x:%02x:%02x:%02x:%02x:%02x") %
173
- static_cast<int>(bytes[0]) % static_cast<int>(bytes[1]) %
174
- static_cast<int>(bytes[2]) % static_cast<int>(bytes[3]) %
175
- static_cast<int>(bytes[4]) % static_cast<int>(bytes[5])).str();
172
+ if (byte_count == 6) {
173
+ return (boost::format("%02x:%02x:%02x:%02x:%02x:%02x") %
174
+ static_cast<int>(bytes[0]) % static_cast<int>(bytes[1]) %
175
+ static_cast<int>(bytes[2]) % static_cast<int>(bytes[3]) %
176
+ static_cast<int>(bytes[4]) % static_cast<int>(bytes[5])).str();
177
+ } else if (byte_count == 20) {
178
+ return (boost::format("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x") %
179
+ static_cast<int>(bytes[0]) % static_cast<int>(bytes[1]) %
180
+ static_cast<int>(bytes[2]) % static_cast<int>(bytes[3]) %
181
+ static_cast<int>(bytes[4]) % static_cast<int>(bytes[5]) %
182
+ static_cast<int>(bytes[6]) % static_cast<int>(bytes[7]) %
183
+ static_cast<int>(bytes[8]) % static_cast<int>(bytes[9]) %
184
+ static_cast<int>(bytes[10]) % static_cast<int>(bytes[11]) %
185
+ static_cast<int>(bytes[12]) % static_cast<int>(bytes[13]) %
186
+ static_cast<int>(bytes[14]) % static_cast<int>(bytes[15]) %
187
+ static_cast<int>(bytes[16]) % static_cast<int>(bytes[17]) %
188
+ static_cast<int>(bytes[18]) % static_cast<int>(bytes[19])).str();
189
+ } else {
190
+ return {};
191
+ }
176
192
  }
177
193
 
178
194
  bool networking_resolver::ignored_ipv4_address(string const& addr)
@@ -171,6 +171,11 @@ namespace facter { namespace facts { namespace solaris {
171
171
  return nullptr;
172
172
  }
173
173
 
174
+ uint8_t networking_resolver::get_link_address_length(const sockaddr * addr) const
175
+ {
176
+ return 0;
177
+ }
178
+
174
179
  string networking_resolver::find_dhcp_server(string const& interface) const
175
180
  {
176
181
  auto exec = execute("dhcpinfo", { "-i", interface, "ServerID" });
@@ -6,7 +6,7 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: FACTER 3.11.0\n"
9
+ "Project-Id-Version: FACTER 3.11.2\n"
10
10
  "Report-Msgid-Bugs-To: docs@puppet.com\n"
11
11
  "POT-Creation-Date: \n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -275,6 +275,20 @@ msgstr ""
275
275
  msgid "/dev/%1%"
276
276
  msgstr ""
277
277
 
278
+ #. debug
279
+ #: lib/src/facts/aix/disk_resolver.cc
280
+ msgid ""
281
+ "Could not open device %1% for reading: %2% (%3%). Disk facts will not be "
282
+ "populated for this device"
283
+ msgstr ""
284
+
285
+ #. debug
286
+ #: lib/src/facts/aix/disk_resolver.cc
287
+ msgid ""
288
+ "Ioctl IOCINFO failed for device %1%: %2% (%3%). Disk facts will not be "
289
+ "populated for this device"
290
+ msgstr ""
291
+
278
292
  #. warning
279
293
  #: lib/src/facts/aix/disk_resolver.cc
280
294
  msgid ""
@@ -401,6 +415,16 @@ msgstr ""
401
415
  msgid "reading \"{1}\" for dhclient lease information."
402
416
  msgstr ""
403
417
 
418
+ #. debug
419
+ #: lib/src/facts/bsd/networking_resolver.cc
420
+ msgid "searching \"{1}\" for systemd-networkd DHCP lease files"
421
+ msgstr ""
422
+
423
+ #. debug
424
+ #: lib/src/facts/bsd/networking_resolver.cc
425
+ msgid "searching \"{1}\" for systemd-networkd DHCP lease information"
426
+ msgstr ""
427
+
404
428
  #. debug
405
429
  #: lib/src/facts/cache.cc
406
430
  msgid "Deleting unused cache file {1}"
@@ -1020,6 +1044,13 @@ msgstr ""
1020
1044
  msgid "%02x:%02x:%02x:%02x:%02x:%02x"
1021
1045
  msgstr ""
1022
1046
 
1047
+ #: lib/src/facts/resolvers/networking_resolver.cc
1048
+ #, c-format
1049
+ msgid ""
1050
+ "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
1051
+ "%02x:%02x:%02x:%02x:%02x"
1052
+ msgstr ""
1053
+
1023
1054
  #. error
1024
1055
  #: lib/src/facts/resolvers/ruby_resolver.cc
1025
1056
  msgid "error while resolving ruby {1} fact: {2}"
@@ -69,6 +69,15 @@ This is a pre-release version for Leatherman 1.0.0, containing backwards-incompa
69
69
  ### Changed
70
70
  - Remove Ruby bindings for Fixnum and Bignum, replace with Integer for Ruby 2.4 support (LTH-124)
71
71
 
72
+ ## [0.12.3]
73
+
74
+ This is a maintenance release to re-sync the code version with the tag, in order to make our internal automation happy
75
+
76
+ ## [0.12.2]
77
+
78
+ ### Added
79
+ - Leatherman can now be built with DEP on Windows
80
+
72
81
  ## [0.12.1]
73
82
 
74
83
  ### Fixed