New upstream version 3.11.0
Apollon Oikonomopoulos
6 years ago
0 | 0 | cmake_minimum_required(VERSION 3.2.2) |
1 | project(FACTER VERSION 3.10.0) | |
1 | project(FACTER VERSION 3.11.0) | |
2 | 2 | |
3 | 3 | # Set this early, so it's available. AIX gets weird, man. |
4 | 4 | if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX") |
0 | facter (3.10.0-1puppetlabs1) lucid precise squeeze wheezy trusty; urgency=low | |
0 | facter (3.11.0-1puppetlabs1) lucid precise squeeze wheezy trusty; urgency=low | |
1 | 1 | |
2 | 2 | * Update to version |
3 | 3 | |
4 | -- Puppet Labs Release <info@puppetlabs.com> Mon, 12 Feb 2018 18:16:24 -0800 | |
4 | -- Puppet Labs Release <info@puppetlabs.com> Mon, 19 Mar 2018 15:35:16 -0700 | |
5 | 5 | |
6 | 6 | facter (2.4.2-1puppetlabs1) lucid precise squeeze wheezy trusty; urgency=low |
7 | 7 |
6 | 6 | %global debug_package %{nil} |
7 | 7 | |
8 | 8 | # VERSION is subbed out during rake srpm process |
9 | %global realversion 3.10.0 | |
10 | %global rpmversion 3.10.0 | |
9 | %global realversion 3.11.0 | |
10 | %global rpmversion 3.11.0 | |
11 | 11 | |
12 | 12 | %global build_prefix /opt/pl-build-tools |
13 | 13 | %global _prefix /usr |
105 | 105 | |
106 | 106 | |
107 | 107 | %changelog |
108 | * Mon Feb 12 2018 Puppet Labs Release <info@puppetlabs.com> - 1:3.10.0-1 | |
109 | - Build for 3.10.0 | |
108 | * Mon Mar 19 2018 Puppet Labs Release <info@puppetlabs.com> - 1:3.11.0-1 | |
109 | - Build for 3.11.0 | |
110 | 110 | |
111 | 111 | * Fri Mar 20 2015 Michael Smith <michael.smith@puppetlabs.com> - 2.4.2-1 |
112 | 112 | - Move from Ruby to C++ implementation. |
37 | 37 | # could be handy for archiving the generated documentation or if some version |
38 | 38 | # control system is used. |
39 | 39 | |
40 | PROJECT_NUMBER = 3.10.0 | |
40 | PROJECT_NUMBER = 3.11.0 | |
41 | 41 | |
42 | 42 | # Using the PROJECT_BRIEF tag one can provide an optional one line description |
43 | 43 | # for a project that appears at the top of each page and should give viewer a |
38 | 38 | end |
39 | 39 | require "#{facter_dir}/${LIBFACTER_INSTALL_DESTINATION}/libfacter.so" |
40 | 40 | rescue LoadError |
41 | raise LoadError.new('libfacter was not found. Please make sure it was installed to the expected location.') | |
41 | raise LoadError, "libfacter was not found. Please make sure it was installed to the expected location.\n" + ($!.message || ''), $!.backtrace | |
42 | 42 | end |
43 | 43 | end |
44 | 44 | end |
56 | 56 | * Stores the SSH key's fingerprint. |
57 | 57 | */ |
58 | 58 | fingerprint digest; |
59 | ||
60 | /** | |
61 | * Stores the SSH key type. One of ssh-dss, ssh-rsa, ssh-ed25519, | |
62 | * ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, or ecdsa-sha2-nistp512 | |
63 | */ | |
64 | std::string type; | |
59 | 65 | }; |
60 | 66 | |
61 | 67 | /** |
17 | 17 | { |
18 | 18 | /** |
19 | 19 | * Constructs the uptime_resolver. |
20 | * @param wmi_conn The WMI connection to use when resolving facts. | |
21 | 20 | */ |
22 | uptime_resolver(std::shared_ptr<leatherman::windows::wmi> wmi_conn = std::make_shared<leatherman::windows::wmi>()); | |
21 | uptime_resolver(); | |
23 | 22 | |
24 | 23 | protected: |
25 | 24 | /** |
27 | 26 | * @return Returns the system uptime in seconds. |
28 | 27 | */ |
29 | 28 | virtual int64_t get_uptime() override; |
30 | ||
31 | private: | |
32 | std::shared_ptr<leatherman::windows::wmi> _wmi; | |
33 | 29 | }; |
34 | 30 | |
35 | 31 | }}} // namespace facter::facts::windows |
233 | 233 | caveats: Only present on Solaris. |
234 | 234 | size: |
235 | 235 | type: string |
236 | description: The display size of the disk or block device (e.g. "1 GiB"). | |
236 | description: The display size of the disk or block device, such as "1 GiB". | |
237 | 237 | size_bytes: |
238 | 238 | type: integer |
239 | 239 | description: The size of the disk or block device, in bytes. |
729 | 729 | elements: |
730 | 730 | available: |
731 | 731 | type: string |
732 | description: The display size of the available amount of swap memory (e.g. "1 GiB"). | |
732 | description: The display size of the available amount of swap memory, such as "1 GiB". | |
733 | 733 | available_bytes: |
734 | 734 | type: integer |
735 | 735 | description: The size of the available amount of swap memory, in bytes. |
741 | 741 | description: True if the swap is encrypted or false if not. |
742 | 742 | total: |
743 | 743 | type: string |
744 | description: The display size of the total amount of swap memory (e.g. "1 GiB"). | |
744 | description: The display size of the total amount of swap memory, such as "1 GiB". | |
745 | 745 | total_bytes: |
746 | 746 | type: integer |
747 | 747 | description: The size of the total amount of swap memory, in bytes. |
748 | 748 | used: |
749 | 749 | type: string |
750 | description: The display size of the used amount of swap memory (e.g. "1 GiB"). | |
750 | description: The display size of the used amount of swap memory, such as "1 GiB". | |
751 | 751 | used_bytes: |
752 | 752 | type: integer |
753 | 753 | description: The size of the used amount of swap memory, in bytes. |
757 | 757 | elements: |
758 | 758 | available: |
759 | 759 | type: string |
760 | description: The display size of the available amount of system memory (e.g. "1 GiB"). | |
760 | description: The display size of the available amount of system memory, such as "1 GiB". | |
761 | 761 | available_bytes: |
762 | 762 | type: integer |
763 | 763 | description: The size of the available amount of system memory, in bytes. |
766 | 766 | description: The capacity percentage (0% is empty, 100% is full). |
767 | 767 | total: |
768 | 768 | type: string |
769 | description: The display size of the total amount of system memory (e.g. "1 GiB"). | |
769 | description: The display size of the total amount of system memory, such as "1 GiB". | |
770 | 770 | total_bytes: |
771 | 771 | type: integer |
772 | 772 | description: The size of the total amount of system memory, in bytes. |
773 | 773 | used: |
774 | 774 | type: string |
775 | description: The display size of the used amount of system memory (e.g. "1 GiB"). | |
775 | description: The display size of the used amount of system memory, such as "1 GiB". | |
776 | 776 | used_bytes: |
777 | 777 | type: integer |
778 | 778 | description: The size of the used amount of system memory, in bytes. |
780 | 780 | memoryfree: |
781 | 781 | type: string |
782 | 782 | hidden: true |
783 | description: Return the display size of the free system memory (e.g. "1 GiB"). | |
783 | description: Return the display size of the free system memory, such as "1 GiB". | |
784 | 784 | resolution: | |
785 | 785 | Linux: parse the contents of `/proc/meminfo` to retrieve the free system memory. |
786 | 786 | Mac OSX: use the `sysctl` function to retrieve the free system memory. |
800 | 800 | memorysize: |
801 | 801 | type: string |
802 | 802 | hidden: true |
803 | description: Return the display size of the total system memory (e.g. "1 GiB"). | |
803 | description: Return the display size of the total system memory, such as "1 GiB". | |
804 | 804 | resolution: | |
805 | 805 | Linux: parse the contents of `/proc/meminfo` to retrieve the total system memory. |
806 | 806 | Mac OSX: use the `sysctl` function to retrieve the total system memory. |
834 | 834 | elements: |
835 | 835 | available: |
836 | 836 | type: string |
837 | description: The display size of the available space (e.g. "1 GiB"). | |
837 | description: The display size of the available space, such as "1 GiB". | |
838 | 838 | available_bytes: |
839 | 839 | type: integer |
840 | 840 | description: The size of the available space, in bytes. |
852 | 852 | description: The mount options. |
853 | 853 | size: |
854 | 854 | type: string |
855 | description: The display size of the total space (e.g. "1 GiB"). | |
855 | description: The display size of the total space, such as "1 GiB". | |
856 | 856 | size_bytes: |
857 | 857 | type: integer |
858 | 858 | description: The size of the total space, in bytes. |
859 | 859 | used: |
860 | 860 | type: string |
861 | description: The display size of the used space (e.g. "1 GiB"). | |
861 | description: The display size of the used space, such as "1 GiB". | |
862 | 862 | used_bytes: |
863 | 863 | type: integer |
864 | 864 | description: The size of the used space, in bytes. |
1073 | 1073 | Solaris: parse the contents of `/etc/release` to retrieve the OS major release. |
1074 | 1074 | Windows: use WMI to retrieve the OS major release. |
1075 | 1075 | caveats: | |
1076 | Linux: for Ubuntu, the major release is X.Y (e.g. "10.4"). | |
1076 | Linux: for Ubuntu, the major release is X.Y, such as "10.4". | |
1077 | 1077 | |
1078 | 1078 | operatingsystemrelease: |
1079 | 1079 | type: string |
1211 | 1211 | description: Return the family of the operating system. |
1212 | 1212 | resolution: | |
1213 | 1213 | All platforms: default to the kernel name. |
1214 | Linux: map various Linux distributions to their base distribution (e.g. Ubuntu is a "Debian" distro). | |
1214 | Linux: map various Linux distributions to their base distribution. For example, Ubuntu is a "Debian" distro. | |
1215 | 1215 | Solaris: map various Solaris-based operating systems to the "Solaris" family. |
1216 | 1216 | Windows: use "windows" as the family name. |
1217 | 1217 | |
1247 | 1247 | description: The unique identifier of a GPT partition. |
1248 | 1248 | size: |
1249 | 1249 | type: string |
1250 | description: The display size of the partition (e.g. "1 GiB"). | |
1250 | description: The display size of the partition, such as "1 GiB". | |
1251 | 1251 | size_bytes: |
1252 | 1252 | type: integer |
1253 | 1253 | description: The size of the partition, in bytes. |
1322 | 1322 | description: The count of physical processors. |
1323 | 1323 | speed: |
1324 | 1324 | type: string |
1325 | description: The speed of the processors (e.g. "2.0 GHz"). | |
1325 | description: The speed of the processors, such as "2.0 GHz". | |
1326 | 1326 | |
1327 | 1327 | productname: |
1328 | 1328 | type: string |
1504 | 1504 | key: |
1505 | 1505 | type: string |
1506 | 1506 | description: The DSA public key. |
1507 | type: | |
1508 | type: string | |
1509 | description: The exact type of the key, i.e. "ssh-dss". | |
1507 | 1510 | ecdsa: |
1508 | 1511 | type: map |
1509 | 1512 | description: Represents the public key and fingerprints for the ECDSA algorithm. |
1521 | 1524 | key: |
1522 | 1525 | type: string |
1523 | 1526 | description: The ECDSA public key. |
1527 | type: | |
1528 | type: string | |
1529 | description: The exact type of the key, e.g. "ecdsa-sha2-nistp256". | |
1524 | 1530 | ed25519: |
1525 | 1531 | type: map |
1526 | 1532 | description: Represents the public key and fingerprints for the Ed25519 algorithm. |
1538 | 1544 | key: |
1539 | 1545 | type: string |
1540 | 1546 | description: The Ed25519 public key. |
1547 | type: | |
1548 | type: string | |
1549 | description: The exact type of the key, i.e. "ssh-ed25519". | |
1541 | 1550 | rsa: |
1542 | 1551 | type: map |
1543 | 1552 | description: Represents the public key and fingerprints for the RSA algorithm. |
1555 | 1564 | key: |
1556 | 1565 | type: string |
1557 | 1566 | description: The RSA public key. |
1567 | type: | |
1568 | type: string | |
1569 | description: The exact type of the key, i.e. "ssh-rsa". | |
1558 | 1570 | |
1559 | 1571 | ssh<algorithm>key: |
1560 | 1572 | pattern: ^ssh\w*key$ |
1586 | 1598 | swapfree: |
1587 | 1599 | type: string |
1588 | 1600 | hidden: true |
1589 | description: Return the display size of the free swap memory (e.g. "1 GiB"). | |
1601 | description: Return the display size of the free swap memory, such as "1 GiB". | |
1590 | 1602 | resolution: | |
1591 | 1603 | Linux: parse the contents of `/proc/meminfo` to retrieve the free swap memory. |
1592 | 1604 | Mac OSX: use the `sysctl` function to retrieve the free swap memory. |
1604 | 1616 | swapsize: |
1605 | 1617 | type: string |
1606 | 1618 | hidden: true |
1607 | description: Return the display size of the total swap memory (e.g. "1 GiB"). | |
1619 | description: Return the display size of the total swap memory, such as "1 GiB". | |
1608 | 1620 | resolution: | |
1609 | 1621 | Linux: parse the contents of `/proc/meminfo` to retrieve the total swap memory. |
1610 | 1622 | Mac OSX: use the `sysctl` function to retrieve the total swap memory. |
19 | 19 | string value = get_jail_vm(); |
20 | 20 | |
21 | 21 | if (value.empty()) { |
22 | auto product_name = facts.get<string_value>(fact::product_name); | |
23 | if (product_name) { | |
24 | value = get_product_name_vm(product_name->value()); | |
25 | } | |
22 | value = get_fact_vm(facts); | |
26 | 23 | } |
27 | 24 | |
28 | 25 | return value; |
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | // The SSH file format should be <algo> <key> <hostname> | |
74 | // The SSH public key file format is <algo> <key> <comment> | |
75 | 75 | vector<boost::iterator_range<string::iterator>> parts; |
76 | 76 | boost::split(parts, contents, boost::is_any_of(" "), boost::token_compress_on); |
77 | 77 | if (parts.size() < 2) { |
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | // Assign the key | |
82 | // Assign the key and its type | |
83 | key.type.assign(parts[0].begin(), parts[0].end()); | |
83 | 84 | key.key.assign(parts[1].begin(), parts[1].end()); |
84 | 85 | |
85 | 86 | // Only fingerprint if we are using OpenSSL |
49 | 49 | |
50 | 50 | facts.add(string(key_fact_name), make_value<string_value>(key.key, true)); |
51 | 51 | key_value->add("key", make_value<string_value>(move(key.key))); |
52 | key_value->add("type", make_value<string_value>(move(key.type))); | |
52 | 53 | |
53 | 54 | string fingerprint; |
54 | 55 | if (!key.digest.sha1.empty()) { |
74 | 74 | add(make_shared<windows::memory_resolver>()); |
75 | 75 | add(make_shared<windows::networking_resolver>()); |
76 | 76 | add(make_shared<windows::timezone_resolver>()); |
77 | add(make_shared<windows::uptime_resolver>()); | |
77 | 78 | |
78 | 79 | try { |
79 | 80 | shared_ptr<wmi> shared_wmi = make_shared<wmi>(); |
81 | 82 | add(make_shared<windows::operating_system_resolver>(shared_wmi)); |
82 | 83 | add(make_shared<windows::processor_resolver>(shared_wmi)); |
83 | 84 | add(make_shared<windows::virtualization_resolver>(shared_wmi)); |
84 | add(make_shared<windows::uptime_resolver>(shared_wmi)); | |
85 | 85 | } catch (wmi_exception &e) { |
86 | 86 | LOG_ERROR("failed adding platform facts that require WMI: {1}", e.what()); |
87 | 87 | } |
0 | 0 | #include <internal/facts/windows/uptime_resolver.hpp> |
1 | #include <leatherman/windows/wmi.hpp> | |
1 | #include <leatherman/windows/windows.hpp> | |
2 | 2 | #include <leatherman/util/regex.hpp> |
3 | #include <leatherman/logging/logging.hpp> | |
4 | 3 | #include <leatherman/locale/locale.hpp> |
5 | #include <boost/date_time/posix_time/posix_time.hpp> | |
6 | #include <boost/date_time/gregorian/gregorian_types.hpp> | |
7 | 4 | |
8 | 5 | // Mark string for translation (alias for leatherman::locale::format) |
9 | 6 | using leatherman::locale::_; |
13 | 10 | using namespace std; |
14 | 11 | using namespace leatherman::util; |
15 | 12 | using namespace leatherman::windows; |
16 | using namespace boost::posix_time; | |
17 | using namespace boost::gregorian; | |
18 | 13 | |
19 | uptime_resolver::uptime_resolver(shared_ptr<wmi> wmi_conn) : | |
20 | resolvers::uptime_resolver(), | |
21 | _wmi(move(wmi_conn)) | |
14 | uptime_resolver::uptime_resolver() : | |
15 | resolvers::uptime_resolver() | |
22 | 16 | { |
23 | } | |
24 | ||
25 | static ptime get_ptime(string const& wmitime) | |
26 | { | |
27 | static boost::regex wmi_regex("^(\\d{8,})(\\d{2})(\\d{2})(\\d{2})\\."); | |
28 | string iso_date; | |
29 | int hour, min, sec; | |
30 | if (!re_search(wmitime, wmi_regex, &iso_date, &hour, &min, &sec)) { | |
31 | throw runtime_error(_("failed to parse {1} as a date/time", wmitime)); | |
32 | } | |
33 | ||
34 | return ptime(from_undelimited_string(iso_date), time_duration(hour, min, sec)); | |
35 | 17 | } |
36 | 18 | |
37 | 19 | int64_t uptime_resolver::get_uptime() |
38 | 20 | { |
39 | auto vals = _wmi->query(wmi::operatingsystem, {wmi::lastbootuptime, wmi::localdatetime}); | |
40 | if (vals.empty()) { | |
41 | return -1; | |
42 | } | |
43 | ||
44 | ptime boottime = get_ptime(wmi::get(vals, wmi::lastbootuptime)); | |
45 | ptime now = get_ptime(wmi::get(vals, wmi::localdatetime)); | |
46 | return (now - boottime).total_seconds(); | |
21 | uint64_t tickCount = GetTickCount64(); | |
22 | return (int64_t)(tickCount / 1000); // seconds | |
47 | 23 | } |
48 | 24 | |
49 | 25 | }}} // namespace facter::facts::windows |
26 | 26 | { |
27 | 27 | data result; |
28 | 28 | result.dsa.key = "dsa:key"; |
29 | result.dsa.type = "dsa:type"; | |
29 | 30 | result.dsa.digest.sha1 = "dsa:sha1"; |
30 | 31 | result.dsa.digest.sha256 = "dsa:sha256"; |
31 | 32 | result.ecdsa.key = "ecdsa:key"; |
33 | result.ecdsa.type = "ecdsa:type"; | |
32 | 34 | result.ecdsa.digest.sha1 = "ecdsa:sha1"; |
33 | 35 | result.ecdsa.digest.sha256 = "ecdsa:sha256"; |
34 | 36 | result.ed25519.key = "ed25519:key"; |
37 | result.ed25519.type = "ed25519:type"; | |
35 | 38 | result.ed25519.digest.sha1 = "ed25519:sha1"; |
36 | 39 | result.ed25519.digest.sha256 = "ed25519:sha256"; |
37 | 40 | result.rsa.key = "rsa:key"; |
41 | result.rsa.type = "rsa:type"; | |
38 | 42 | result.rsa.digest.sha1 = "rsa:sha1"; |
39 | 43 | result.rsa.digest.sha256 = "rsa:sha256"; |
40 | 44 | return result; |
65 | 69 | for (auto const& algorithm : algorithms) { |
66 | 70 | auto entry = ssh->get<map_value>(algorithm); |
67 | 71 | REQUIRE(entry); |
68 | REQUIRE(entry->size() == 2u); | |
72 | REQUIRE(entry->size() == 3u); | |
69 | 73 | auto key = entry->get<string_value>("key"); |
70 | 74 | REQUIRE(key); |
71 | 75 | REQUIRE(key->value() == algorithm + ":key"); |
76 | auto type = entry->get<string_value>("type"); | |
77 | REQUIRE(type); | |
78 | REQUIRE(type->value() == algorithm + ":type"); | |
72 | 79 | auto fingerprints = entry->get<map_value>("fingerprints"); |
73 | 80 | REQUIRE(fingerprints); |
74 | 81 | REQUIRE(fingerprints->size() == 2u); |
321 | 321 | { |
322 | 322 | data result; |
323 | 323 | result.dsa.key = "dsa:key"; |
324 | result.dsa.type = "dsa:type"; | |
324 | 325 | result.dsa.digest.sha1 = "dsa:sha1"; |
325 | 326 | result.dsa.digest.sha256 = "dsa:sha256"; |
326 | 327 | result.ecdsa.key = "ecdsa:key"; |
328 | result.ecdsa.type = "ecdsa:type"; | |
327 | 329 | result.ecdsa.digest.sha1 = "ecdsa:sha1"; |
328 | 330 | result.ecdsa.digest.sha256 = "ecdsa:sha256"; |
329 | 331 | result.ed25519.key = "ed25519:key"; |
332 | result.ed25519.type = "ed25519:type"; | |
330 | 333 | result.ed25519.digest.sha1 = "ed25519:sha1"; |
331 | 334 | result.ed25519.digest.sha256 = "ed25519:sha256"; |
332 | 335 | result.rsa.key = "rsa:key"; |
336 | result.rsa.type = "rsa:type"; | |
333 | 337 | result.rsa.digest.sha1 = "rsa:sha1"; |
334 | 338 | result.rsa.digest.sha256 = "rsa:sha256"; |
335 | 339 | return result; |
5 | 5 | #, fuzzy |
6 | 6 | msgid "" |
7 | 7 | msgstr "" |
8 | "Project-Id-Version: FACTER 3.10.0\n" | |
8 | "Project-Id-Version: FACTER 3.11.0\n" | |
9 | 9 | "Report-Msgid-Bugs-To: docs@puppet.com\n" |
10 | 10 | "POT-Creation-Date: \n" |
11 | 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
627 | 627 | msgid "kenv lookup for {1}" |
628 | 628 | msgstr "" |
629 | 629 | |
630 | #. warning | |
630 | #. info | |
631 | 631 | #: lib/src/facts/freebsd/dmi_resolver.cc |
632 | 632 | msgid "kenv lookup for {1} failed: {2} ({3})" |
633 | 633 | msgstr "" |
1228 | 1228 | msgid "wcsftime failed: timezone is unavailable: {1} ({2})" |
1229 | 1229 | msgstr "" |
1230 | 1230 | |
1231 | #: lib/src/facts/windows/uptime_resolver.cc | |
1232 | msgid "failed to parse {1} as a date/time" | |
1233 | msgstr "" | |
1234 | ||
1235 | 1231 | #. log |
1236 | 1232 | #: lib/src/logging/logging.cc |
1237 | 1233 | msgid "locale environment variables were bad; continuing with LANG=C LC_ALL=C" |