facter 3.12.0.cfacter.20181004 → 3.12.1.cfacter.20181023

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7e3f09b89d6dd6008f50ee2edbb1fcbc68fa06acddbb55b78c13df67cd919f2
4
- data.tar.gz: dcf0f092bbe3ab62b80f1056a9da60f1654e175e40d2da6796844be4fdc2da81
3
+ metadata.gz: a7a8c74c202ab1fa96513997f0f5571779517be1ce2c3aa70ede42bef1adf551
4
+ data.tar.gz: c7a8bd03da7e777d30d91c5d2979072ac4affad9c0e7de5a0235083d47364b85
5
5
  SHA512:
6
- metadata.gz: f568fe0aca25ba832d7b8e6f5eb5d57f536ef3d989b69d7f7462b523c5f6b2b9cd4e51a99d8dd6d8858f5b243deced45e2c6ba6ec774cc157295ab1a2257fe47
7
- data.tar.gz: 41b86b3f3e7088adc07469192ab0973ab44b362e73bc10560500808b971227a047b4c9397f23ad7f89b7d0f53b7680169c2f2e220cacbbf06fc3c9e9620b10b3
6
+ metadata.gz: 8096ed83cbd2460ae62eda375f75aa10339256a4ce12caa21405a88f36d2826431ae9f54cae6fc70e9eb0aac510b31a6eadf2ab74827832842b223a6b64a5b31
7
+ data.tar.gz: d8f2b358f0d7876d96ceffb31e06d0032f97e4c7aebec8040afc626bab43d09faae73885bfc31c13b2c5a7cb275c7e43d8701daa2bfae09b8154661b786f046c
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.2.2)
2
- project(FACTER VERSION 3.12.0)
2
+ project(FACTER VERSION 3.12.1)
3
3
 
4
4
  # Set this early, so it's available. AIX gets weird, man.
5
5
  if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
@@ -523,11 +523,13 @@ module Facter
523
523
  elsif agent['platform'] =~ /2008/
524
524
  os_version = '2008 R2'
525
525
  elsif agent['platform'] =~ /2012/
526
- os_version = '2012 R2'
526
+ os_version = agent['platform'] =~ /R2/ ? '2012 R2' : '2012'
527
527
  elsif agent['platform'] =~ /-10/
528
528
  os_version = '10'
529
529
  elsif agent['platform'] =~ /2016/
530
530
  os_version = '2016'
531
+ elsif agent['platform'] =~ /2019/
532
+ os_version = '2019'
531
533
  else
532
534
  fail_test "Unknown Windows version #{agent['platform']}"
533
535
  end
@@ -15,13 +15,13 @@ test_name "C96148: verify dmi facts" do
15
15
  expected_facts = {
16
16
  'dmi.manufacturer' => /\w+/,
17
17
  'dmi.product.name' => /\w+/,
18
+ 'dmi.product.uuid' => /[-0-9A-Fa-f]+/,
18
19
  }
19
20
  unless agent['platform'] =~ /windows/
20
21
  expected_facts.merge!({'dmi.bios.release_date' => /\d+\/\d+\/\d+/,
21
22
  'dmi.bios.vendor' => /\w+/,
22
23
  'dmi.bios.version' => /\d+/,
23
24
  'dmi.chassis.type' => /\w+/,
24
- 'dmi.product.uuid' => /[-0-9A-Fa-f]+/,
25
25
  })
26
26
  end
27
27
  unless agent['platform'] =~ /windows|cisco|aarch64|el-/
@@ -1,27 +1,21 @@
1
1
  version: 3.1.0.{build}
2
2
  clone_depth: 10
3
3
  environment:
4
- LEATHERMAN_VERSION: 0.99.0
5
- CPPHOCON_VERSION: 0.1.4
4
+ LEATHERMAN_VERSION: 1.4.4
5
+ CPPHOCON_VERSION: 0.1.8
6
6
 
7
7
  init:
8
8
  - |
9
- choco install mingw-w64 -y -Version 4.8.3 -source https://www.myget.org/F/puppetlabs
9
+ choco install -y mingw-w64 -Version 5.2.0 -source https://www.myget.org/F/puppetlabs
10
+ choco install -y cmake -Version 3.2.2 -source https://www.myget.org/F/puppetlabs
10
11
  choco install -y gettext -Version 0.19.6 -source https://www.myget.org/F/puppetlabs
12
+ choco install -y pl-toolchain-x64 -Version 2015.12.01.1 -source https://www.myget.org/F/puppetlabs
13
+ choco install -y pl-boost-x64 -Version 1.58.0.2 -source https://www.myget.org/F/puppetlabs
14
+ choco install -y pl-openssl-x64 -Version 1.0.24.1 -source https://www.myget.org/F/puppetlabs
15
+ choco install -y pl-curl-x64 -Version 7.46.0.1 -source https://www.myget.org/F/puppetlabs
16
+ choco install -y pl-yaml-cpp-x64 -Version 0.5.1.2 -source https://www.myget.org/F/puppetlabs
11
17
  cmake --version
12
18
  - ps: |
13
- $env:PATH = $env:PATH.Replace("Git\bin", "Git\cmd")
14
- $env:PATH = $env:PATH.Replace("Git\usr\bin", "Git\cmd")
15
-
16
- wget 'https://s3.amazonaws.com/kylo-pl-bucket/boost_1_57_0-x86_64_mingw-w64_4.8.3_win32_seh.7z' -OutFile "$env:temp\boost.7z"
17
- 7z.exe x $env:temp\boost.7z -oC:\tools | FIND /V "ing "
18
-
19
- wget 'https://s3.amazonaws.com/kylo-pl-bucket/yaml-cpp-0.5.1-x86_64_mingw-w64_4.8.3_win32_seh.7z' -OutFile "$env:temp\yaml-cpp.7z"
20
- 7z.exe x $env:temp\yaml-cpp.7z -oC:\tools | FIND /V "ing "
21
-
22
- wget 'https://s3.amazonaws.com/kylo-pl-bucket/curl-7.42.1-x86_64_mingw-w64_4.8.3_win32_seh.7z' -OutFile "$env:temp\curl-7.42.1-x86_64_mingw-w64_4.8.3_win32_seh.7z"
23
- 7z.exe x "$env:temp\curl-7.42.1-x86_64_mingw-w64_4.8.3_win32_seh.7z" -oC:\tools | FIND /V "ing "
24
-
25
19
  wget "https://github.com/puppetlabs/leatherman/releases/download/$env:LEATHERMAN_VERSION/leatherman.7z" -OutFile "$env:temp\leatherman.7z"
26
20
  7z.exe x $env:temp\leatherman.7z -oC:\tools | FIND /V "ing "
27
21
 
@@ -29,12 +23,15 @@ init:
29
23
  7z.exe x $env:temp\cpp-hocon.7z -oC:\tools | FIND /V "ing "
30
24
 
31
25
  install:
32
- - SET PATH=C:\Ruby21-x64\bin;C:\tools\mingw64\bin;C:\Program Files\gettext-iconv;%PATH%
26
+ # Minimize environment polution; previously we were linking against the wrong OpenSSL DLLs.
27
+ # Include Ruby and Powershell for unit tests.
28
+ - SET PATH=C:\tools\pl-build-tools\bin;C:\tools\mingw64\bin;C:\ProgramData\chocolatey\bin;C:\Ruby22-x64\bin;C:\Program Files\7-Zip;C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\gettext-iconv
29
+ - ps: rm -r C:\OpenSSL-Win64
33
30
  - bundle install --jobs 4 --retry 2 --gemfile=lib/Gemfile --quiet
34
31
 
35
32
  build_script:
36
33
  - ps: |
37
- cmake -G "MinGW Makefiles" -DBOOST_ROOT="C:\tools\boost_1_57_0-x86_64_mingw-w64_4.8.3_win32_seh" -DYAMLCPP_ROOT="C:\tools\yaml-cpp-0.5.1-x86_64_mingw-w64_4.8.3_win32_seh" -DBOOST_STATIC=ON -DCURL_STATIC=ON -DCMAKE_INSTALL_PREFIX="C:\Program Files\FACTER" -DCMAKE_PREFIX_PATH="C:\tools\leatherman;C:\tools\curl-7.42.1-x86_64_mingw-w64_4.8.3_win32_seh;C:\tools\cpp-hocon" .
34
+ cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="C:\tools\pl-build-tools\pl-build-toolchain.cmake" -DCMAKE_PREFIX_PATH="C:\tools\leatherman;C:\tools\cpp-hocon" -DCMAKE_INSTALL_PREFIX="C:\Program Files\FACTER" -DBOOST_STATIC=ON .
38
35
  mingw32-make -j2
39
36
 
40
37
  test_script:
@@ -332,7 +332,8 @@ int main(int argc, char **argv)
332
332
  if (vm.count("custom-dir")) {
333
333
  custom_directories = vm["custom-dir"].as<vector<string>>();
334
334
  }
335
- facter::ruby::load_custom_facts(facts, vm.count("puppet"), custom_directories);
335
+ bool redirect_ruby_stdout = vm.count("json") || vm.count("yaml");
336
+ facter::ruby::load_custom_facts(facts, vm.count("puppet"), redirect_ruby_stdout, custom_directories);
336
337
  }
337
338
 
338
339
  if (!vm["no-external-facts"].as<bool>()) {
@@ -38,7 +38,7 @@ PROJECT_NAME = facter
38
38
  # could be handy for archiving the generated documentation or if some version
39
39
  # control system is used.
40
40
 
41
- PROJECT_NUMBER = 3.12.0
41
+ PROJECT_NUMBER = 3.12.1
42
42
 
43
43
  # Using the PROJECT_BRIEF tag one can provide an optional one line description
44
44
  # for a project that appears at the top of each page and should give viewer a
@@ -21,6 +21,17 @@ namespace facter { namespace ruby {
21
21
  */
22
22
  LIBFACTER_EXPORT bool initialize(bool include_stack_trace = false);
23
23
 
24
+ /**
25
+ * Loads custom facts into the given collection.
26
+ * Important: this function should be called from main().
27
+ * Calling this function from an arbitrary stack depth may result in segfaults during Ruby GC.
28
+ * @param facts The collection to populate with custom facts.
29
+ * @param initialize_puppet Whether puppet should be loaded to find additional facts.
30
+ * @param redirect_stdout Whether Ruby's stdout should be redirected to stderr
31
+ * @param paths The paths to search for custom facts.
32
+ */
33
+ LIBFACTER_EXPORT void load_custom_facts(facter::facts::collection& facts, bool initialize_puppet, bool redirect_stdout, std::vector<std::string> const& paths = {});
34
+
24
35
  /**
25
36
  * Loads custom facts into the given collection.
26
37
  * Important: this function should be called from main().
@@ -309,6 +309,8 @@ namespace facter { namespace facts {
309
309
  {
310
310
  resolve_facts();
311
311
 
312
+ // We intentionally are using find_if with no return value as a "map until" construct.
313
+ // cppcheck-suppress ignoredReturnValue
312
314
  find_if(begin(_facts), end(_facts), [&func](map<string, unique_ptr<value>>::value_type const& it) {
313
315
  return !func(it.first, it.second.get());
314
316
  });
@@ -17,11 +17,12 @@ namespace facter { namespace facts { namespace windows {
17
17
  {
18
18
  data result;
19
19
 
20
- auto vals = _wmi->query(wmi::computersystemproduct, {wmi::name});
20
+ auto vals = _wmi->query(wmi::computersystemproduct, {wmi::name, wmi::uuid});
21
21
  if (vals.empty()) {
22
- LOG_DEBUG("WMI query returned no results for {1} with value {2}.", wmi::computersystemproduct, wmi::name);
22
+ LOG_DEBUG("WMI query returned no results for {1} with values {2} and {3}.", wmi::computersystemproduct, wmi::name, wmi::uuid);
23
23
  } else {
24
24
  result.product_name = wmi::get(vals, wmi::name);
25
+ result.uuid = wmi::get(vals, wmi::uuid);
25
26
  }
26
27
 
27
28
  vals = _wmi->query(wmi::bios, {wmi::manufacturer, wmi::serialnumber});
@@ -2,7 +2,9 @@
2
2
  #include <leatherman/windows/system_error.hpp>
3
3
  #include <leatherman/windows/wmi.hpp>
4
4
  #include <leatherman/windows/windows.hpp>
5
+ #include <facter/facts/fact.hpp>
5
6
  #include <facter/facts/collection.hpp>
7
+ #include <facter/facts/scalar_value.hpp>
6
8
  #include <facter/facts/os_family.hpp>
7
9
  #include <leatherman/logging/logging.hpp>
8
10
  #include <leatherman/util/regex.hpp>
@@ -10,6 +12,7 @@
10
12
  #include <winnt.h>
11
13
  #include <Shlobj.h>
12
14
  #include <map>
15
+ #include <string>
13
16
  #include <boost/filesystem.hpp>
14
17
 
15
18
  using namespace std;
@@ -101,7 +104,26 @@ namespace facter { namespace facts { namespace windows {
101
104
  auto version = result.release.substr(0, lastDot);
102
105
  bool consumerrel = (wmi::get(vals, wmi::producttype) == "1");
103
106
  if (version == "10.0") {
104
- result.release = consumerrel ? "10" : "2016";
107
+ // Calculate the build number to distinguish between
108
+ // Windows Server 2016 and 2019. Note that the kernel
109
+ // version is written as <major>.<minor>.<build_number>
110
+ auto kernel_version_fact = facts.get<string_value>(fact::kernel_version);
111
+ if (! kernel_version_fact) {
112
+ LOG_DEBUG("Could not resolve the OS release and OS major version facts from the kernel version fact");
113
+ return result;
114
+ }
115
+ auto kernel_version = kernel_version_fact->value();
116
+ auto build_number_as_str = kernel_version.substr(
117
+ kernel_version.find_last_of('.') + 1);
118
+ auto build_number = stol(build_number_as_str);
119
+
120
+ if (consumerrel) {
121
+ result.release = "10";
122
+ } else if (build_number >= 17623L) {
123
+ result.release = "2019";
124
+ } else {
125
+ result.release = "2016";
126
+ }
105
127
  } else if (version == "6.3") {
106
128
  result.release = consumerrel ? "8.1" : "2012 R2";
107
129
  } else if (version == "6.2") {
@@ -30,6 +30,27 @@ static const char load_puppet[] =
30
30
  " end\n"
31
31
  "end\n";
32
32
 
33
+ // This struct redirects stdout to stderr in the ruby runtime for the
34
+ // duration of its lifetime. We use this to ensure that any custom
35
+ // facts writing to stdout during their initialization or execution
36
+ // won't corrupt json/yaml output from the facter executable.
37
+ struct RbStdoutGuard {
38
+ VALUE old_stdout;
39
+ api& ruby;
40
+
41
+ RbStdoutGuard(api& ruby) :ruby(ruby) {
42
+ LOG_DEBUG("Redirecting ruby's stdout to stderr");
43
+ auto rb_stderr = ruby.rb_gv_get("$stderr");
44
+ old_stdout = ruby.rb_gv_get("$stdout");
45
+ ruby.rb_gv_set("$stdout", rb_stderr);
46
+ }
47
+
48
+ ~RbStdoutGuard() {
49
+ LOG_DEBUG("Restoring Ruby's stdout");
50
+ ruby.rb_gv_set("$stdout", old_stdout);
51
+ }
52
+ };
53
+
33
54
  namespace facter { namespace ruby {
34
55
 
35
56
  bool initialize(bool include_stack_trace)
@@ -48,7 +69,7 @@ namespace facter { namespace ruby {
48
69
  return true;
49
70
  }
50
71
 
51
- void load_custom_facts(collection& facts, bool initialize_puppet, vector<string> const& paths)
72
+ void load_custom_facts(collection& facts, bool initialize_puppet, bool redirect_stdout, vector<string> const& paths)
52
73
  {
53
74
  #ifdef _WIN32
54
75
  // Initialize WSA before resolving custom facts. The Ruby runtime does this only when running
@@ -67,12 +88,23 @@ namespace facter { namespace ruby {
67
88
  }
68
89
  }
69
90
  mod.search(paths);
70
- mod.resolve_facts();
91
+ if (redirect_stdout) {
92
+ // Redirect stdout->stderr for custom facts.
93
+ RbStdoutGuard stdout_guard{ruby};
94
+ mod.resolve_facts();
95
+ } else {
96
+ mod.resolve_facts();
97
+ }
71
98
  }
72
99
 
73
100
  void load_custom_facts(collection& facts, vector<string> const& paths)
74
101
  {
75
- load_custom_facts(facts, false, paths);
102
+ load_custom_facts(facts, false, false, paths);
103
+ }
104
+
105
+ void load_custom_facts(collection& facts, bool initialize_puppet, vector<string> const& paths)
106
+ {
107
+ load_custom_facts(facts, initialize_puppet, false, paths);
76
108
  }
77
109
 
78
110
  value const* lookup(value const* value, vector<string>::iterator segment, vector<string>::iterator end) {
@@ -40,6 +40,7 @@ set(LIBFACTER_TESTS_COMMON_SOURCES
40
40
  "logging/logging.cc"
41
41
  "log_capture.cc"
42
42
  "main.cc"
43
+ "mock_server.cc"
43
44
  "util/string.cc"
44
45
  "fixtures.cc"
45
46
  "collection_fixture.cc"
@@ -127,37 +128,20 @@ include_directories(
127
128
  ${CPPHOCON_INCLUDE_DIRS}
128
129
  )
129
130
 
130
- # On EL 4, we run into a linking error when trying to create libraries or
131
- # executables that link in a static library with code using threads. As I
132
- # described in https://gcc.gnu.org/ml/gcc-help/2015-08/msg00035.html, we get
133
- # the error undefined reference to symbol '__tls_get_addr@@GLIBC_2.3'.
134
- # Build mock_server as a separate shared library to avoid this error.
135
131
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
136
- add_library(mock-server SHARED mock_server.cc)
137
- target_link_libraries(mock-server PRIVATE
138
- ${Boost_THREAD_LIBRARY}
139
- ${Boost_SYSTEM_LIBRARY}
140
- ${LIBFACTER_TESTS_PLATFORM_LIBRARIES})
132
+ if (WIN32)
133
+ # On Windows with GCC 5.2, Boost.System emits warnings that aren't correctly
134
+ # suppressed by pragmas. Explicitly skip them.
135
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
136
+ endif()
141
137
 
142
138
  add_executable(libfacter_test $<TARGET_OBJECTS:libfactersrc>
143
139
  ${LIBFACTER_TESTS_COMMON_SOURCES}
144
140
  ${LIBFACTER_TESTS_PLATFORM_SOURCES}
145
141
  ${LIBFACTER_TESTS_CATEGORY_SOURCES})
146
- # On Windows, mock-server comes after Boost libraries to avoid double
147
- # definition of boost::system::system_category() on Windows. On Linux, it
148
- # comes before to avoid picking up incomplete Boost.Asio symbols included
149
- # by Boost.Log in Leatherman logging.
150
- if (WIN32)
151
- target_link_libraries(libfacter_test
152
- ${LIBS}
153
- ${LIBFACTER_TESTS_PLATFORM_LIBRARIES}
154
- mock-server)
155
- else()
156
- target_link_libraries(libfacter_test
157
- mock-server
158
- ${LIBS}
159
- ${LIBFACTER_TESTS_PLATFORM_LIBRARIES})
160
- endif()
142
+ target_link_libraries(libfacter_test
143
+ ${LIBS}
144
+ ${LIBFACTER_TESTS_PLATFORM_LIBRARIES})
161
145
 
162
146
  if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND BOOST_STATIC AND LEATHERMAN_USE_LOCALES)
163
147
  target_link_libraries(libfacter_test iconv)
@@ -67,7 +67,7 @@ struct multi_resolver : facter::facts::resolver
67
67
 
68
68
  struct temp_variable
69
69
  {
70
- temp_variable(string name, string const& value) :
70
+ temp_variable(string&& name, string const& value) :
71
71
  _name(move(name))
72
72
  {
73
73
  environment::set(_name, value);
@@ -6,7 +6,7 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: FACTER 3.12.0\n"
9
+ "Project-Id-Version: FACTER 3.12.1\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"
@@ -1225,11 +1225,6 @@ msgstr ""
1225
1225
  msgid "failed adding platform facts that require WMI: {1}"
1226
1226
  msgstr ""
1227
1227
 
1228
- #. debug
1229
- #: lib/src/facts/windows/dmi_resolver.cc
1230
- msgid "WMI query returned no results for {1} with value {2}."
1231
- msgstr ""
1232
-
1233
1228
  #. debug
1234
1229
  #: lib/src/facts/windows/dmi_resolver.cc
1235
1230
  msgid "WMI query returned no results for {1} with values {2} and {3}."
@@ -1294,6 +1289,13 @@ msgstr ""
1294
1289
  msgid "error finding SYSTEMROOT: {1}"
1295
1290
  msgstr ""
1296
1291
 
1292
+ #. debug
1293
+ #: lib/src/facts/windows/operating_system_resolver.cc
1294
+ msgid ""
1295
+ "Could not resolve the OS release and OS major version facts from the kernel "
1296
+ "version fact"
1297
+ msgstr ""
1298
+
1297
1299
  #. debug
1298
1300
  #: lib/src/facts/windows/processor_resolver.cc
1299
1301
  msgid "WMI processor Name, Architecture query returned no results."
@@ -1529,6 +1531,16 @@ msgstr ""
1529
1531
  msgid "timeout= is not supported for custom facts and will be ignored."
1530
1532
  msgstr ""
1531
1533
 
1534
+ #. debug
1535
+ #: lib/src/ruby/ruby.cc
1536
+ msgid "Redirecting ruby's stdout to stderr"
1537
+ msgstr ""
1538
+
1539
+ #. debug
1540
+ #: lib/src/ruby/ruby.cc
1541
+ msgid "Restoring Ruby's stdout"
1542
+ msgstr ""
1543
+
1532
1544
  #. warning
1533
1545
  #: lib/src/ruby/ruby.cc
1534
1546
  msgid "Could not load puppet; some facts may be unavailable: {1}"
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.2.2)
2
- project(leatherman VERSION 1.5.1)
2
+ project(leatherman VERSION 1.5.2)
3
3
 
4
4
  if (WIN32)
5
5
  link_libraries("-Wl,--nxcompat -Wl,--dynamicbase")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.0.cfacter.20181004
4
+ version: 3.12.1.cfacter.20181023
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-04 00:00:00.000000000 Z
12
+ date: 2018-10-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: info@puppet.com