puppet 2.7.3 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +166 -0
- data/install.rb +27 -7
- data/lib/puppet/application/agent.rb +29 -29
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/inspect.rb +9 -1
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/application/queue.rb +1 -1
- data/lib/puppet/application/resource.rb +3 -0
- data/lib/puppet/application.rb +4 -5
- data/lib/puppet/configurer.rb +1 -4
- data/lib/puppet/defaults.rb +45 -15
- data/lib/puppet/feature/base.rb +28 -17
- data/lib/puppet/feature/rails.rb +0 -3
- data/lib/puppet/feature/rubygems.rb +0 -3
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_bucket/file.rb +3 -3
- data/lib/puppet/file_serving/base.rb +4 -5
- data/lib/puppet/file_serving/configuration.rb +7 -13
- data/lib/puppet/file_serving/content.rb +0 -4
- data/lib/puppet/file_serving/fileset.rb +7 -6
- data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
- data/lib/puppet/file_serving/metadata.rb +0 -4
- data/lib/puppet/file_serving/mount/file.rb +9 -12
- data/lib/puppet/file_serving/mount.rb +0 -5
- data/lib/puppet/file_serving/terminus_helper.rb +0 -4
- data/lib/puppet/file_serving.rb +0 -4
- data/lib/puppet/indirector/catalog/compiler.rb +0 -18
- data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
- data/lib/puppet/indirector/direct_file_server.rb +0 -4
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/store_configs.rb +5 -0
- data/lib/puppet/indirector/file_content/file.rb +0 -4
- data/lib/puppet/indirector/file_content/file_server.rb +0 -4
- data/lib/puppet/indirector/file_content/rest.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
- data/lib/puppet/indirector/file_server.rb +1 -5
- data/lib/puppet/indirector/indirection.rb +3 -5
- data/lib/puppet/indirector/node/store_configs.rb +5 -0
- data/lib/puppet/indirector/request.rb +3 -1
- data/lib/puppet/indirector/resource/active_record.rb +97 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +5 -1
- data/lib/puppet/indirector/store_configs.rb +30 -0
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/indirector.rb +7 -0
- data/lib/puppet/network/client.rb +0 -5
- data/lib/puppet/network/http_pool.rb +0 -56
- data/lib/puppet/node/environment.rb +9 -11
- data/lib/puppet/parameter/path.rb +1 -5
- data/lib/puppet/parameter.rb +1 -7
- data/lib/puppet/parser/ast/collection.rb +2 -2
- data/lib/puppet/parser/ast/collexpr.rb +10 -39
- data/lib/puppet/parser/collector.rb +41 -90
- data/lib/puppet/parser/compiler.rb +0 -3
- data/lib/puppet/parser/functions/create_resources.rb +22 -10
- data/lib/puppet/parser/functions/versioncmp.rb +9 -6
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +2 -1
- data/lib/puppet/provider/augeas/augeas.rb +5 -3
- data/lib/puppet/provider/cron/crontab.rb +2 -2
- data/lib/puppet/provider/exec/posix.rb +23 -96
- data/lib/puppet/provider/exec/shell.rb +11 -2
- data/lib/puppet/provider/exec/windows.rb +35 -0
- data/lib/puppet/provider/exec.rb +79 -0
- data/lib/puppet/provider/group/windows_adsi.rb +48 -0
- data/lib/puppet/provider/host/parsed.rb +3 -0
- data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
- data/lib/puppet/provider/mount.rb +0 -3
- data/lib/puppet/provider/naginator.rb +0 -3
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +3 -7
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/aptrpm.rb +0 -1
- data/lib/puppet/provider/package/blastwave.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +5 -6
- data/lib/puppet/provider/package/fink.rb +3 -4
- data/lib/puppet/provider/package/freebsd.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +0 -1
- data/lib/puppet/provider/package/hpux.rb +3 -3
- data/lib/puppet/provider/package/macports.rb +0 -1
- data/lib/puppet/provider/package/msi.rb +82 -0
- data/lib/puppet/provider/package/openbsd.rb +18 -19
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +0 -1
- data/lib/puppet/provider/package/pkgdmg.rb +9 -7
- data/lib/puppet/provider/package/pkgutil.rb +0 -1
- data/lib/puppet/provider/package/ports.rb +0 -1
- data/lib/puppet/provider/package/portupgrade.rb +183 -193
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +0 -1
- data/lib/puppet/provider/package/sunfreeware.rb +0 -2
- data/lib/puppet/provider/package/up2date.rb +0 -1
- data/lib/puppet/provider/package/urpmi.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package.rb +4 -3
- data/lib/puppet/provider/service/systemd.rb +64 -0
- data/lib/puppet/provider/service/windows.rb +110 -0
- data/lib/puppet/provider/user/windows_adsi.rb +71 -0
- data/lib/puppet/rails/resource.rb +1 -1
- data/lib/puppet/relationship.rb +0 -3
- data/lib/puppet/reports/tagmail.rb +15 -11
- data/lib/puppet/resource/catalog.rb +17 -24
- data/lib/puppet/ssl/certificate_authority.rb +7 -5
- data/lib/puppet/ssl/host.rb +6 -10
- data/lib/puppet/type/augeas.rb +19 -13
- data/lib/puppet/type/cron.rb +13 -12
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file/content.rb +7 -3
- data/lib/puppet/type/file/source.rb +14 -9
- data/lib/puppet/type/file.rb +44 -23
- data/lib/puppet/type/filebucket.rb +13 -5
- data/lib/puppet/type/package.rb +14 -1
- data/lib/puppet/type/service.rb +11 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type.rb +8 -17
- data/lib/puppet/util/adsi.rb +278 -0
- data/lib/puppet/util/autoload.rb +0 -2
- data/lib/puppet/util/cacher.rb +15 -67
- data/lib/puppet/util/feature.rb +0 -3
- data/lib/puppet/util/graph.rb +0 -3
- data/lib/puppet/util/ldap/connection.rb +0 -3
- data/lib/puppet/util/ldap/generator.rb +0 -3
- data/lib/puppet/util/ldap.rb +0 -3
- data/lib/puppet/util/log_paths.rb +0 -3
- data/lib/puppet/util/network_device/cisco/device.rb +2 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/pidlock.rb +5 -1
- data/lib/puppet/util/rdoc/parser.rb +3 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/settings/file_setting.rb +3 -2
- data/lib/puppet/util/settings.rb +4 -6
- data/lib/puppet/util/suidmanager.rb +62 -15
- data/lib/puppet/util.rb +113 -131
- data/lib/puppet.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +22 -17
- data/spec/integration/file_serving/content_spec.rb +0 -6
- data/spec/integration/file_serving/metadata_spec.rb +0 -6
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
- data/spec/integration/network/server/webrick_spec.rb +6 -9
- data/spec/integration/node/facts_spec.rb +0 -6
- data/spec/integration/node_spec.rb +3 -4
- data/spec/integration/parser/compiler_spec.rb +2 -1
- data/spec/integration/parser/parser_spec.rb +2 -4
- data/spec/integration/provider/mount_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +13 -3
- data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
- data/spec/integration/reports_spec.rb +0 -4
- data/spec/integration/resource/catalog_spec.rb +0 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
- data/spec/integration/ssl/certificate_request_spec.rb +10 -17
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
- data/spec/integration/ssl/host_spec.rb +8 -14
- data/spec/integration/transaction/report_spec.rb +0 -5
- data/spec/integration/transaction_spec.rb +11 -13
- data/spec/integration/type/file_spec.rb +16 -16
- data/spec/integration/type/tidy_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +2 -2
- data/spec/integration/util_spec.rb +13 -0
- data/spec/lib/puppet_spec/files.rb +18 -10
- data/spec/shared_behaviours/file_server_terminus.rb +1 -5
- data/spec/shared_behaviours/file_serving.rb +0 -4
- data/spec/shared_behaviours/memory_terminus.rb +0 -4
- data/spec/shared_behaviours/path_parameters.rb +20 -18
- data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/unit/agent_spec.rb +0 -4
- data/spec/unit/application/apply_spec.rb +8 -2
- data/spec/unit/application/certificate_spec.rb +2 -0
- data/spec/unit/application/device_spec.rb +8 -6
- data/spec/unit/application/inspect_spec.rb +2 -1
- data/spec/unit/application/master_spec.rb +7 -2
- data/spec/unit/application/queue_spec.rb +3 -4
- data/spec/unit/application/resource_spec.rb +26 -0
- data/spec/unit/application/secret_agent_spec.rb +3 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/configurer/downloader_spec.rb +4 -3
- data/spec/unit/configurer_spec.rb +11 -4
- data/spec/unit/daemon_spec.rb +3 -1
- data/spec/unit/face/ca_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +5 -1
- data/spec/unit/face/secret_agent_spec.rb +3 -1
- data/spec/unit/file_bucket/dipper_spec.rb +4 -4
- data/spec/unit/file_bucket/file_spec.rb +9 -3
- data/spec/unit/file_serving/configuration_spec.rb +26 -37
- data/spec/unit/file_serving/fileset_spec.rb +71 -55
- data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
- data/spec/unit/file_serving/mount/file_spec.rb +163 -169
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
- data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
- data/spec/unit/indirector/facts/facter_spec.rb +0 -4
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_content/file_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
- data/spec/unit/indirector/file_server_spec.rb +1 -5
- data/spec/unit/indirector/indirection_spec.rb +0 -4
- data/spec/unit/indirector/key/ca_spec.rb +0 -4
- data/spec/unit/indirector/key/file_spec.rb +0 -4
- data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -4
- data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
- data/spec/unit/indirector/ssl_file_spec.rb +25 -6
- data/spec/unit/indirector/store_configs_spec.rb +8 -0
- data/spec/unit/indirector/yaml_spec.rb +14 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +5 -5
- data/spec/unit/network/http/mongrel_spec.rb +0 -4
- data/spec/unit/network/http/webrick_spec.rb +5 -9
- data/spec/unit/network/http_pool_spec.rb +4 -75
- data/spec/unit/network/http_spec.rb +0 -4
- data/spec/unit/network/server_spec.rb +0 -4
- data/spec/unit/node/environment_spec.rb +18 -31
- data/spec/unit/node/facts_spec.rb +0 -4
- data/spec/unit/node_spec.rb +1 -8
- data/spec/unit/other/selinux_spec.rb +3 -1
- data/spec/unit/parameter_spec.rb +0 -10
- data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
- data/spec/unit/parser/collector_spec.rb +147 -263
- data/spec/unit/parser/compiler_spec.rb +3 -1
- data/spec/unit/parser/files_spec.rb +7 -4
- data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
- data/spec/unit/parser/type_loader_spec.rb +7 -7
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
- data/spec/unit/provider/exec/posix_spec.rb +102 -106
- data/spec/unit/provider/exec/shell_spec.rb +1 -1
- data/spec/unit/provider/exec/windows_spec.rb +119 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
- data/spec/unit/provider/ldap_spec.rb +0 -4
- data/spec/unit/provider/macauthorization_spec.rb +5 -0
- data/spec/unit/provider/mount/parsed_spec.rb +1 -5
- data/spec/unit/provider/package/msi_spec.rb +170 -0
- data/spec/unit/provider/service/redhat_spec.rb +2 -0
- data/spec/unit/provider/service/smf_spec.rb +3 -0
- data/spec/unit/provider/service/systemd_spec.rb +25 -0
- data/spec/unit/provider/service/windows_spec.rb +166 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/ldap_spec.rb +0 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
- data/spec/unit/relationship_spec.rb +0 -4
- data/spec/unit/resource/catalog_spec.rb +37 -25
- data/spec/unit/resource/status_spec.rb +4 -2
- data/spec/unit/resource_spec.rb +5 -5
- data/spec/unit/simple_graph_spec.rb +0 -4
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
- data/spec/unit/ssl/host_spec.rb +12 -13
- data/spec/unit/ssl/inventory_spec.rb +2 -2
- data/spec/unit/sslcertificates/ca_spec.rb +6 -10
- data/spec/unit/transaction/event_manager_spec.rb +4 -2
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/report_spec.rb +2 -6
- data/spec/unit/transaction/resource_harness_spec.rb +9 -5
- data/spec/unit/transaction_spec.rb +3 -1
- data/spec/unit/type/cron_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +80 -47
- data/spec/unit/type/file/checksum_spec.rb +9 -8
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/file/selinux_spec.rb +10 -8
- data/spec/unit/type/file/source_spec.rb +18 -36
- data/spec/unit/type/file_spec.rb +170 -217
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/noop_metaparam_spec.rb +3 -1
- data/spec/unit/type/package_spec.rb +15 -3
- data/spec/unit/type/resources_spec.rb +2 -2
- data/spec/unit/type/service_spec.rb +19 -4
- data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
- data/spec/unit/type/tidy_spec.rb +3 -1
- data/spec/unit/type/user_spec.rb +1 -1
- data/spec/unit/type_spec.rb +29 -34
- data/spec/unit/util/adsi_spec.rb +202 -0
- data/spec/unit/util/autoload_spec.rb +23 -19
- data/spec/unit/util/backups_spec.rb +16 -13
- data/spec/unit/util/cacher_spec.rb +64 -141
- data/spec/unit/util/checksums_spec.rb +0 -4
- data/spec/unit/util/constant_inflector_spec.rb +0 -4
- data/spec/unit/util/execution_stub_spec.rb +1 -1
- data/spec/unit/util/ldap/connection_spec.rb +0 -4
- data/spec/unit/util/ldap/generator_spec.rb +0 -4
- data/spec/unit/util/ldap/manager_spec.rb +0 -4
- data/spec/unit/util/log_spec.rb +4 -2
- data/spec/unit/util/logging_spec.rb +2 -2
- data/spec/unit/util/nagios_maker_spec.rb +0 -4
- data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
- data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
- data/spec/unit/util/network_device/config_spec.rb +5 -3
- data/spec/unit/util/rdoc/parser_spec.rb +7 -1
- data/spec/unit/util/run_mode_spec.rb +6 -2
- data/spec/unit/util/settings/file_setting_spec.rb +29 -2
- data/spec/unit/util/settings_spec.rb +28 -15
- data/spec/unit/util/storage_spec.rb +1 -1
- data/spec/unit/util/suidmanager_spec.rb +310 -0
- data/spec/unit/util/tagging_spec.rb +0 -4
- data/spec/unit/util_spec.rb +335 -0
- data/test/language/ast/variable.rb +0 -4
- data/test/lib/puppettest/support/resources.rb +0 -4
- data/test/lib/puppettest/testcase.rb +0 -4
- data/test/lib/puppettest.rb +0 -1
- data/test/network/handler/master.rb +0 -5
- data/test/network/server/webrick.rb +5 -22
- data/test/ral/manager/attributes.rb +0 -4
- data/test/ral/manager/instances.rb +0 -4
- data/test/ral/manager/manager.rb +0 -4
- data/test/ral/providers/cron/crontab.rb +1 -0
- data/test/ral/providers/service/base.rb +0 -4
- data/test/ral/type/filesources.rb +0 -1
- data/test/ral/type/resources.rb +0 -4
- data/test/util/utiltest.rb +0 -13
- metadata +36 -9
- data/spec/unit/network/client_spec.rb +0 -45
- data/test/puppet/tc_suidmanager.rb +0 -120
data/lib/puppet/util/cacher.rb
CHANGED
@@ -1,25 +1,6 @@
|
|
1
1
|
require 'monitor'
|
2
2
|
|
3
3
|
module Puppet::Util::Cacher
|
4
|
-
module Expirer
|
5
|
-
attr_reader :timestamp
|
6
|
-
|
7
|
-
# Cause all cached values to be considered expired.
|
8
|
-
def expire
|
9
|
-
@timestamp = Time.now
|
10
|
-
end
|
11
|
-
|
12
|
-
# Is the provided timestamp earlier than our expiration timestamp?
|
13
|
-
# If it is, then the associated value is expired.
|
14
|
-
def dependent_data_expired?(ts)
|
15
|
-
return false unless timestamp
|
16
|
-
|
17
|
-
timestamp > ts
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
extend Expirer
|
22
|
-
|
23
4
|
# Our module has been extended in a class; we can only add the Instance methods,
|
24
5
|
# which become *class* methods in the class.
|
25
6
|
def self.extended(other)
|
@@ -40,27 +21,26 @@ module Puppet::Util::Cacher
|
|
40
21
|
module ClassMethods
|
41
22
|
# Provide a means of defining an attribute whose value will be cached.
|
42
23
|
# Must provide a block capable of defining the value if it's flushed..
|
43
|
-
def cached_attr(name,
|
24
|
+
def cached_attr(name, ttl, &block)
|
44
25
|
init_method = "init_#{name}"
|
45
26
|
define_method(init_method, &block)
|
46
27
|
|
28
|
+
set_attr_ttl(name, ttl)
|
29
|
+
|
47
30
|
define_method(name) do
|
48
31
|
cached_value(name)
|
49
32
|
end
|
50
33
|
|
51
34
|
define_method(name.to_s + "=") do |value|
|
52
35
|
# Make sure the cache timestamp is set
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if ttl = options[:ttl]
|
58
|
-
set_attr_ttl(name, ttl)
|
36
|
+
value_cache.synchronize do
|
37
|
+
value_cache[name] = value
|
38
|
+
set_expiration(name)
|
39
|
+
end
|
59
40
|
end
|
60
41
|
end
|
61
42
|
|
62
43
|
def attr_ttl(name)
|
63
|
-
return nil unless @attr_ttls
|
64
44
|
@attr_ttls[name]
|
65
45
|
end
|
66
46
|
|
@@ -72,57 +52,25 @@ module Puppet::Util::Cacher
|
|
72
52
|
|
73
53
|
# Methods that get added to instances.
|
74
54
|
module InstanceMethods
|
75
|
-
|
76
|
-
def expire
|
77
|
-
# Only expire if we have an expirer. This is
|
78
|
-
# mostly so that we can comfortably handle cases
|
79
|
-
# like Puppet::Type instances, which use their
|
80
|
-
# catalog as their expirer, and they often don't
|
81
|
-
# have a catalog.
|
82
|
-
if e = expirer
|
83
|
-
e.expire
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def expirer
|
88
|
-
Puppet::Util::Cacher
|
89
|
-
end
|
90
|
-
|
91
55
|
private
|
92
56
|
|
93
|
-
def cache_timestamp
|
94
|
-
@cache_timestamp ||= Time.now
|
95
|
-
end
|
96
|
-
|
97
57
|
def cached_value(name)
|
98
58
|
value_cache.synchronize do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
@cache_timestamp = Time.now
|
103
|
-
elsif expired_by_ttl?(name)
|
104
|
-
value_cache.delete(name)
|
59
|
+
if value_cache[name].nil? or expired_by_ttl?(name)
|
60
|
+
value_cache[name] = send("init_#{name}")
|
61
|
+
set_expiration(name)
|
105
62
|
end
|
106
|
-
value_cache[name] = send("init_#{name}") unless value_cache.include?(name)
|
107
63
|
value_cache[name]
|
108
64
|
end
|
109
65
|
end
|
110
66
|
|
111
|
-
def expired_by_expirer?(name)
|
112
|
-
if expirer.nil?
|
113
|
-
return true unless self.class.attr_ttl(name)
|
114
|
-
end
|
115
|
-
expirer.dependent_data_expired?(cache_timestamp)
|
116
|
-
end
|
117
|
-
|
118
67
|
def expired_by_ttl?(name)
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
@ttl_timestamps ||= {}
|
123
|
-
@ttl_timestamps[name] ||= Time.now
|
68
|
+
@attr_expirations[name] < Time.now
|
69
|
+
end
|
124
70
|
|
125
|
-
|
71
|
+
def set_expiration(name)
|
72
|
+
@attr_expirations ||= {}
|
73
|
+
@attr_expirations[name] = Time.now + self.class.attr_ttl(name)
|
126
74
|
end
|
127
75
|
|
128
76
|
def value_cache
|
data/lib/puppet/util/feature.rb
CHANGED
data/lib/puppet/util/graph.rb
CHANGED
data/lib/puppet/util/ldap.rb
CHANGED
@@ -70,7 +70,8 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
|
|
70
70
|
|
71
71
|
IF={
|
72
72
|
:FastEthernet => %w{FastEthernet FastEth Fast FE Fa F},
|
73
|
-
:
|
73
|
+
:GigabitEthernet => %w{GigabitEthernet GigEthernet GigEth GE Gi G},
|
74
|
+
:TenGigabitEthernet => %w{TenGigabitEthernet TE Te},
|
74
75
|
:Ethernet => %w{Ethernet Eth E},
|
75
76
|
:Serial => %w{Serial Se S},
|
76
77
|
:PortChannel => %w{PortChannel Port-Channel Po},
|
@@ -63,7 +63,7 @@ class Puppet::Util::NetworkDevice::Cisco::Facts
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def uptime_to_seconds(uptime)
|
66
|
-
captures = (uptime.match /^(?:(
|
66
|
+
captures = (uptime.match /^(?:(\d+) years?,)?\s*(?:(\d+) weeks?,)?\s*(?:(\d+) days?,)?\s*(?:(\d+) hours?,)?\s*(\d+) minutes?$/).captures
|
67
67
|
seconds = captures.zip([31536000, 604800, 86400, 3600, 60]).inject(0) do |total, (x,y)|
|
68
68
|
total + (x.nil? ? 0 : x.to_i * y)
|
69
69
|
end
|
data/lib/puppet/util/pidlock.rb
CHANGED
@@ -59,9 +59,13 @@ class Puppet::Util::Pidlock
|
|
59
59
|
def clear_if_stale
|
60
60
|
return if lock_pid.nil?
|
61
61
|
|
62
|
+
errors = [Errno::ESRCH]
|
63
|
+
# Process::Error can only happen, and is only defined, on Windows
|
64
|
+
errors << Process::Error if defined? Process::Error
|
65
|
+
|
62
66
|
begin
|
63
67
|
Process.kill(0, lock_pid)
|
64
|
-
rescue
|
68
|
+
rescue *errors
|
65
69
|
File.unlink(@lockfile)
|
66
70
|
end
|
67
71
|
end
|
@@ -113,7 +113,9 @@ class Parser
|
|
113
113
|
Puppet::Module.modulepath.each do |mp|
|
114
114
|
# check that fullpath is a descendant of mp
|
115
115
|
dirname = fullpath
|
116
|
-
|
116
|
+
previous = dirname
|
117
|
+
while (dirname = File.dirname(previous)) != previous
|
118
|
+
previous = dirname
|
117
119
|
return nil if File.identical?(dirname,mp)
|
118
120
|
end
|
119
121
|
end
|
data/lib/puppet/util/run_mode.rb
CHANGED
@@ -27,14 +27,14 @@ module Puppet
|
|
27
27
|
|
28
28
|
def conf_dir
|
29
29
|
which_dir(
|
30
|
-
(Puppet.features.microsoft_windows? ? File.join(Dir::
|
30
|
+
(Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") : "/etc/puppet"),
|
31
31
|
"~/.puppet"
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
35
|
def var_dir
|
36
36
|
which_dir(
|
37
|
-
(Puppet.features.microsoft_windows? ? File.join(Dir::
|
37
|
+
(Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") : "/var/lib/puppet"),
|
38
38
|
"~/.puppet/var"
|
39
39
|
)
|
40
40
|
end
|
@@ -86,14 +86,15 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
|
|
86
86
|
path = File.expand_path(path)
|
87
87
|
|
88
88
|
return nil unless type == :directory or create_files? or File.exist?(path)
|
89
|
-
return nil if path =~ /^\/dev/
|
89
|
+
return nil if path =~ /^\/dev/ or path =~ /^[A-Z]:\/dev/i
|
90
90
|
|
91
91
|
resource = Puppet::Resource.new(:file, path)
|
92
92
|
|
93
93
|
if Puppet[:manage_internal_file_permissions]
|
94
94
|
resource[:mode] = self.mode if self.mode
|
95
95
|
|
96
|
-
|
96
|
+
# REMIND fails on Windows because chown/chgrp functionality not supported yet
|
97
|
+
if Puppet.features.root? and !Puppet.features.microsoft_windows?
|
97
98
|
resource[:owner] = self.owner if self.owner
|
98
99
|
resource[:group] = self.group if self.group
|
99
100
|
end
|
data/lib/puppet/util/settings.rb
CHANGED
@@ -2,13 +2,11 @@ require 'puppet'
|
|
2
2
|
require 'sync'
|
3
3
|
require 'getoptlong'
|
4
4
|
require 'puppet/external/event-loop'
|
5
|
-
require 'puppet/util/cacher'
|
6
5
|
require 'puppet/util/loadedfile'
|
7
6
|
|
8
7
|
# The class for handling configuration files.
|
9
8
|
class Puppet::Util::Settings
|
10
9
|
include Enumerable
|
11
|
-
include Puppet::Util::Cacher
|
12
10
|
|
13
11
|
require 'puppet/util/settings/setting'
|
14
12
|
require 'puppet/util/settings/file_setting'
|
@@ -401,11 +399,10 @@ class Puppet::Util::Settings
|
|
401
399
|
}
|
402
400
|
end
|
403
401
|
|
404
|
-
|
405
|
-
|
406
|
-
cached_attr(:file) do
|
402
|
+
def file
|
403
|
+
return @file if @file
|
407
404
|
if path = self[:config] and FileTest.exist?(path)
|
408
|
-
Puppet::Util::LoadedFile.new(path)
|
405
|
+
@file = Puppet::Util::LoadedFile.new(path)
|
409
406
|
end
|
410
407
|
end
|
411
408
|
|
@@ -783,6 +780,7 @@ if @config.include?(:run_mode)
|
|
783
780
|
# Create the transportable objects for users and groups.
|
784
781
|
def add_user_resources(catalog, sections)
|
785
782
|
return unless Puppet.features.root?
|
783
|
+
return if Puppet.features.microsoft_windows?
|
786
784
|
return unless self[:mkusers]
|
787
785
|
|
788
786
|
@config.each do |name, setting|
|
@@ -36,37 +36,84 @@ module Puppet::Util::SUIDManager
|
|
36
36
|
end
|
37
37
|
module_function :groups=
|
38
38
|
|
39
|
-
if Facter['kernel'].value == 'Darwin'
|
40
|
-
# Cannot change real UID on Darwin so we set euid
|
41
|
-
alias :uid :euid
|
42
|
-
alias :gid :egid
|
43
|
-
end
|
44
|
-
|
45
39
|
def self.root?
|
46
|
-
Process.uid == 0
|
40
|
+
return Process.uid == 0 unless Puppet.features.microsoft_windows?
|
41
|
+
|
42
|
+
require 'sys/admin'
|
43
|
+
require 'win32/security'
|
44
|
+
require 'facter'
|
45
|
+
|
46
|
+
majversion = Facter.value(:kernelmajversion)
|
47
|
+
return false unless majversion
|
48
|
+
|
49
|
+
# if Vista or later, check for unrestricted process token
|
50
|
+
return Win32::Security.elevated_security? unless majversion.to_f < 6.0
|
51
|
+
|
52
|
+
group = Sys::Admin.get_group("Administrators", :sid => Win32::Security::SID::BuiltinAdministrators)
|
53
|
+
group and group.members.index(Sys::Admin.get_login) != nil
|
47
54
|
end
|
48
55
|
|
49
56
|
# Runs block setting uid and gid if provided then restoring original ids
|
50
57
|
def asuser(new_uid=nil, new_gid=nil)
|
51
58
|
return yield if Puppet.features.microsoft_windows? or !root?
|
52
59
|
|
53
|
-
# We set both because some programs like to drop privs, i.e. bash.
|
54
|
-
old_uid, old_gid = self.uid, self.gid
|
55
60
|
old_euid, old_egid = self.euid, self.egid
|
56
|
-
old_groups = self.groups
|
57
61
|
begin
|
58
|
-
|
59
|
-
|
60
|
-
self.euid = convert_xid :uid, new_uid if new_uid
|
62
|
+
change_group(new_gid) if new_gid
|
63
|
+
change_user(new_uid) if new_uid
|
61
64
|
|
62
65
|
yield
|
63
66
|
ensure
|
64
|
-
|
65
|
-
|
67
|
+
change_group(old_egid)
|
68
|
+
change_user(old_euid)
|
66
69
|
end
|
67
70
|
end
|
68
71
|
module_function :asuser
|
69
72
|
|
73
|
+
def change_group(group, permanently=false)
|
74
|
+
gid = convert_xid(:gid, group)
|
75
|
+
raise Puppet::Error, "No such group #{group}" unless gid
|
76
|
+
|
77
|
+
if permanently
|
78
|
+
begin
|
79
|
+
Process::GID.change_privilege(gid)
|
80
|
+
rescue NotImplementedError
|
81
|
+
Process.egid = gid
|
82
|
+
Process.gid = gid
|
83
|
+
end
|
84
|
+
else
|
85
|
+
Process.egid = gid
|
86
|
+
end
|
87
|
+
end
|
88
|
+
module_function :change_group
|
89
|
+
|
90
|
+
def change_user(user, permanently=false)
|
91
|
+
uid = convert_xid(:uid, user)
|
92
|
+
raise Puppet::Error, "No such user #{user}" unless uid
|
93
|
+
|
94
|
+
if permanently
|
95
|
+
begin
|
96
|
+
Process::UID.change_privilege(uid)
|
97
|
+
rescue NotImplementedError
|
98
|
+
# If changing uid, we must be root. So initgroups first here.
|
99
|
+
initgroups(uid)
|
100
|
+
Process.euid = uid
|
101
|
+
Process.uid = uid
|
102
|
+
end
|
103
|
+
else
|
104
|
+
# If we're already root, initgroups before changing euid. If we're not,
|
105
|
+
# change euid (to root) first.
|
106
|
+
if Process.euid == 0
|
107
|
+
initgroups(uid)
|
108
|
+
Process.euid = uid
|
109
|
+
else
|
110
|
+
Process.euid = uid
|
111
|
+
initgroups(uid)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
module_function :change_user
|
116
|
+
|
70
117
|
# Make sure the passed argument is a number.
|
71
118
|
def convert_xid(type, id)
|
72
119
|
map = {:gid => :group, :uid => :user}
|