Codebase list facter / af6b1d8
New upstream version 3.11.0 Apollon Oikonomopoulos 6 years ago
16 changed file(s) with 71 addition(s) and 75 deletion(s). Raw diff Collapse all Expand all
00 cmake_minimum_required(VERSION 3.2.2)
1 project(FACTER VERSION 3.10.0)
1 project(FACTER VERSION 3.11.0)
22
33 # Set this early, so it's available. AIX gets weird, man.
44 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
11
22 * Update to version
33
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
55
66 facter (2.4.2-1puppetlabs1) lucid precise squeeze wheezy trusty; urgency=low
77
66 %global debug_package %{nil}
77
88 # 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
1111
1212 %global build_prefix /opt/pl-build-tools
1313 %global _prefix /usr
105105
106106
107107 %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
110110
111111 * Fri Mar 20 2015 Michael Smith <michael.smith@puppetlabs.com> - 2.4.2-1
112112 - Move from Ruby to C++ implementation.
3737 # could be handy for archiving the generated documentation or if some version
3838 # control system is used.
3939
40 PROJECT_NUMBER = 3.10.0
40 PROJECT_NUMBER = 3.11.0
4141
4242 # Using the PROJECT_BRIEF tag one can provide an optional one line description
4343 # for a project that appears at the top of each page and should give viewer a
3838 end
3939 require "#{facter_dir}/${LIBFACTER_INSTALL_DESTINATION}/libfacter.so"
4040 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
4242 end
4343 end
4444 end
5656 * Stores the SSH key's fingerprint.
5757 */
5858 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;
5965 };
6066
6167 /**
1717 {
1818 /**
1919 * Constructs the uptime_resolver.
20 * @param wmi_conn The WMI connection to use when resolving facts.
2120 */
22 uptime_resolver(std::shared_ptr<leatherman::windows::wmi> wmi_conn = std::make_shared<leatherman::windows::wmi>());
21 uptime_resolver();
2322
2423 protected:
2524 /**
2726 * @return Returns the system uptime in seconds.
2827 */
2928 virtual int64_t get_uptime() override;
30
31 private:
32 std::shared_ptr<leatherman::windows::wmi> _wmi;
3329 };
3430
3531 }}} // namespace facter::facts::windows
233233 caveats: Only present on Solaris.
234234 size:
235235 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".
237237 size_bytes:
238238 type: integer
239239 description: The size of the disk or block device, in bytes.
729729 elements:
730730 available:
731731 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".
733733 available_bytes:
734734 type: integer
735735 description: The size of the available amount of swap memory, in bytes.
741741 description: True if the swap is encrypted or false if not.
742742 total:
743743 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".
745745 total_bytes:
746746 type: integer
747747 description: The size of the total amount of swap memory, in bytes.
748748 used:
749749 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".
751751 used_bytes:
752752 type: integer
753753 description: The size of the used amount of swap memory, in bytes.
757757 elements:
758758 available:
759759 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".
761761 available_bytes:
762762 type: integer
763763 description: The size of the available amount of system memory, in bytes.
766766 description: The capacity percentage (0% is empty, 100% is full).
767767 total:
768768 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".
770770 total_bytes:
771771 type: integer
772772 description: The size of the total amount of system memory, in bytes.
773773 used:
774774 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".
776776 used_bytes:
777777 type: integer
778778 description: The size of the used amount of system memory, in bytes.
780780 memoryfree:
781781 type: string
782782 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".
784784 resolution: |
785785 Linux: parse the contents of `/proc/meminfo` to retrieve the free system memory.
786786 Mac OSX: use the `sysctl` function to retrieve the free system memory.
800800 memorysize:
801801 type: string
802802 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".
804804 resolution: |
805805 Linux: parse the contents of `/proc/meminfo` to retrieve the total system memory.
806806 Mac OSX: use the `sysctl` function to retrieve the total system memory.
834834 elements:
835835 available:
836836 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".
838838 available_bytes:
839839 type: integer
840840 description: The size of the available space, in bytes.
852852 description: The mount options.
853853 size:
854854 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".
856856 size_bytes:
857857 type: integer
858858 description: The size of the total space, in bytes.
859859 used:
860860 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".
862862 used_bytes:
863863 type: integer
864864 description: The size of the used space, in bytes.
10731073 Solaris: parse the contents of `/etc/release` to retrieve the OS major release.
10741074 Windows: use WMI to retrieve the OS major release.
10751075 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".
10771077
10781078 operatingsystemrelease:
10791079 type: string
12111211 description: Return the family of the operating system.
12121212 resolution: |
12131213 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.
12151215 Solaris: map various Solaris-based operating systems to the "Solaris" family.
12161216 Windows: use "windows" as the family name.
12171217
12471247 description: The unique identifier of a GPT partition.
12481248 size:
12491249 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".
12511251 size_bytes:
12521252 type: integer
12531253 description: The size of the partition, in bytes.
13221322 description: The count of physical processors.
13231323 speed:
13241324 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".
13261326
13271327 productname:
13281328 type: string
15041504 key:
15051505 type: string
15061506 description: The DSA public key.
1507 type:
1508 type: string
1509 description: The exact type of the key, i.e. "ssh-dss".
15071510 ecdsa:
15081511 type: map
15091512 description: Represents the public key and fingerprints for the ECDSA algorithm.
15211524 key:
15221525 type: string
15231526 description: The ECDSA public key.
1527 type:
1528 type: string
1529 description: The exact type of the key, e.g. "ecdsa-sha2-nistp256".
15241530 ed25519:
15251531 type: map
15261532 description: Represents the public key and fingerprints for the Ed25519 algorithm.
15381544 key:
15391545 type: string
15401546 description: The Ed25519 public key.
1547 type:
1548 type: string
1549 description: The exact type of the key, i.e. "ssh-ed25519".
15411550 rsa:
15421551 type: map
15431552 description: Represents the public key and fingerprints for the RSA algorithm.
15551564 key:
15561565 type: string
15571566 description: The RSA public key.
1567 type:
1568 type: string
1569 description: The exact type of the key, i.e. "ssh-rsa".
15581570
15591571 ssh<algorithm>key:
15601572 pattern: ^ssh\w*key$
15861598 swapfree:
15871599 type: string
15881600 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".
15901602 resolution: |
15911603 Linux: parse the contents of `/proc/meminfo` to retrieve the free swap memory.
15921604 Mac OSX: use the `sysctl` function to retrieve the free swap memory.
16041616 swapsize:
16051617 type: string
16061618 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".
16081620 resolution: |
16091621 Linux: parse the contents of `/proc/meminfo` to retrieve the total swap memory.
16101622 Mac OSX: use the `sysctl` function to retrieve the total swap memory.
1919 string value = get_jail_vm();
2020
2121 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);
2623 }
2724
2825 return value;
7171 return;
7272 }
7373
74 // The SSH file format should be <algo> <key> <hostname>
74 // The SSH public key file format is <algo> <key> <comment>
7575 vector<boost::iterator_range<string::iterator>> parts;
7676 boost::split(parts, contents, boost::is_any_of(" "), boost::token_compress_on);
7777 if (parts.size() < 2) {
7979 return;
8080 }
8181
82 // Assign the key
82 // Assign the key and its type
83 key.type.assign(parts[0].begin(), parts[0].end());
8384 key.key.assign(parts[1].begin(), parts[1].end());
8485
8586 // Only fingerprint if we are using OpenSSL
4949
5050 facts.add(string(key_fact_name), make_value<string_value>(key.key, true));
5151 key_value->add("key", make_value<string_value>(move(key.key)));
52 key_value->add("type", make_value<string_value>(move(key.type)));
5253
5354 string fingerprint;
5455 if (!key.digest.sha1.empty()) {
7474 add(make_shared<windows::memory_resolver>());
7575 add(make_shared<windows::networking_resolver>());
7676 add(make_shared<windows::timezone_resolver>());
77 add(make_shared<windows::uptime_resolver>());
7778
7879 try {
7980 shared_ptr<wmi> shared_wmi = make_shared<wmi>();
8182 add(make_shared<windows::operating_system_resolver>(shared_wmi));
8283 add(make_shared<windows::processor_resolver>(shared_wmi));
8384 add(make_shared<windows::virtualization_resolver>(shared_wmi));
84 add(make_shared<windows::uptime_resolver>(shared_wmi));
8585 } catch (wmi_exception &e) {
8686 LOG_ERROR("failed adding platform facts that require WMI: {1}", e.what());
8787 }
00 #include <internal/facts/windows/uptime_resolver.hpp>
1 #include <leatherman/windows/wmi.hpp>
1 #include <leatherman/windows/windows.hpp>
22 #include <leatherman/util/regex.hpp>
3 #include <leatherman/logging/logging.hpp>
43 #include <leatherman/locale/locale.hpp>
5 #include <boost/date_time/posix_time/posix_time.hpp>
6 #include <boost/date_time/gregorian/gregorian_types.hpp>
74
85 // Mark string for translation (alias for leatherman::locale::format)
96 using leatherman::locale::_;
1310 using namespace std;
1411 using namespace leatherman::util;
1512 using namespace leatherman::windows;
16 using namespace boost::posix_time;
17 using namespace boost::gregorian;
1813
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()
2216 {
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));
3517 }
3618
3719 int64_t uptime_resolver::get_uptime()
3820 {
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
4723 }
4824
4925 }}} // namespace facter::facts::windows
2626 {
2727 data result;
2828 result.dsa.key = "dsa:key";
29 result.dsa.type = "dsa:type";
2930 result.dsa.digest.sha1 = "dsa:sha1";
3031 result.dsa.digest.sha256 = "dsa:sha256";
3132 result.ecdsa.key = "ecdsa:key";
33 result.ecdsa.type = "ecdsa:type";
3234 result.ecdsa.digest.sha1 = "ecdsa:sha1";
3335 result.ecdsa.digest.sha256 = "ecdsa:sha256";
3436 result.ed25519.key = "ed25519:key";
37 result.ed25519.type = "ed25519:type";
3538 result.ed25519.digest.sha1 = "ed25519:sha1";
3639 result.ed25519.digest.sha256 = "ed25519:sha256";
3740 result.rsa.key = "rsa:key";
41 result.rsa.type = "rsa:type";
3842 result.rsa.digest.sha1 = "rsa:sha1";
3943 result.rsa.digest.sha256 = "rsa:sha256";
4044 return result;
6569 for (auto const& algorithm : algorithms) {
6670 auto entry = ssh->get<map_value>(algorithm);
6771 REQUIRE(entry);
68 REQUIRE(entry->size() == 2u);
72 REQUIRE(entry->size() == 3u);
6973 auto key = entry->get<string_value>("key");
7074 REQUIRE(key);
7175 REQUIRE(key->value() == algorithm + ":key");
76 auto type = entry->get<string_value>("type");
77 REQUIRE(type);
78 REQUIRE(type->value() == algorithm + ":type");
7279 auto fingerprints = entry->get<map_value>("fingerprints");
7380 REQUIRE(fingerprints);
7481 REQUIRE(fingerprints->size() == 2u);
321321 {
322322 data result;
323323 result.dsa.key = "dsa:key";
324 result.dsa.type = "dsa:type";
324325 result.dsa.digest.sha1 = "dsa:sha1";
325326 result.dsa.digest.sha256 = "dsa:sha256";
326327 result.ecdsa.key = "ecdsa:key";
328 result.ecdsa.type = "ecdsa:type";
327329 result.ecdsa.digest.sha1 = "ecdsa:sha1";
328330 result.ecdsa.digest.sha256 = "ecdsa:sha256";
329331 result.ed25519.key = "ed25519:key";
332 result.ed25519.type = "ed25519:type";
330333 result.ed25519.digest.sha1 = "ed25519:sha1";
331334 result.ed25519.digest.sha256 = "ed25519:sha256";
332335 result.rsa.key = "rsa:key";
336 result.rsa.type = "rsa:type";
333337 result.rsa.digest.sha1 = "rsa:sha1";
334338 result.rsa.digest.sha256 = "rsa:sha256";
335339 return result;
55 #, fuzzy
66 msgid ""
77 msgstr ""
8 "Project-Id-Version: FACTER 3.10.0\n"
8 "Project-Id-Version: FACTER 3.11.0\n"
99 "Report-Msgid-Bugs-To: docs@puppet.com\n"
1010 "POT-Creation-Date: \n"
1111 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
627627 msgid "kenv lookup for {1}"
628628 msgstr ""
629629
630 #. warning
630 #. info
631631 #: lib/src/facts/freebsd/dmi_resolver.cc
632632 msgid "kenv lookup for {1} failed: {2} ({3})"
633633 msgstr ""
12281228 msgid "wcsftime failed: timezone is unavailable: {1} ({2})"
12291229 msgstr ""
12301230
1231 #: lib/src/facts/windows/uptime_resolver.cc
1232 msgid "failed to parse {1} as a date/time"
1233 msgstr ""
1234
12351231 #. log
12361232 #: lib/src/logging/logging.cc
12371233 msgid "locale environment variables were bad; continuing with LANG=C LC_ALL=C"