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
@@ -3,6 +3,8 @@ require 'spec_helper'
|
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
5
|
describe Puppet::Util::Settings do
|
6
|
+
include PuppetSpec::Files
|
7
|
+
|
6
8
|
describe "when specifying defaults" do
|
7
9
|
before do
|
8
10
|
@settings = Puppet::Util::Settings.new
|
@@ -378,7 +380,7 @@ describe Puppet::Util::Settings do
|
|
378
380
|
end
|
379
381
|
|
380
382
|
it "should use its current ':config' value for the file to parse" do
|
381
|
-
myfile =
|
383
|
+
myfile = make_absolute("/my/file") # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it
|
382
384
|
@settings[:config] = myfile
|
383
385
|
|
384
386
|
File.expects(:read).with(myfile).returns "[main]"
|
@@ -445,25 +447,27 @@ describe Puppet::Util::Settings do
|
|
445
447
|
it "should support specifying all metadata (owner, group, mode) in the configuration file" do
|
446
448
|
@settings.setdefaults :section, :myfile => ["/myfile", "a"]
|
447
449
|
|
450
|
+
otherfile = make_absolute("/other/file")
|
448
451
|
text = "[main]
|
449
|
-
myfile =
|
452
|
+
myfile = #{otherfile} {owner = service, group = service, mode = 644}
|
450
453
|
"
|
451
454
|
@settings.expects(:read_file).returns(text)
|
452
455
|
@settings.parse
|
453
|
-
@settings[:myfile].should ==
|
456
|
+
@settings[:myfile].should == otherfile
|
454
457
|
@settings.metadata(:myfile).should == {:owner => "suser", :group => "sgroup", :mode => "644"}
|
455
458
|
end
|
456
459
|
|
457
460
|
it "should support specifying a single piece of metadata (owner, group, or mode) in the configuration file" do
|
458
461
|
@settings.setdefaults :section, :myfile => ["/myfile", "a"]
|
459
462
|
|
463
|
+
otherfile = make_absolute("/other/file")
|
460
464
|
text = "[main]
|
461
|
-
myfile =
|
465
|
+
myfile = #{otherfile} {owner = service}
|
462
466
|
"
|
463
467
|
file = "/some/file"
|
464
468
|
@settings.expects(:read_file).returns(text)
|
465
469
|
@settings.parse
|
466
|
-
@settings[:myfile].should ==
|
470
|
+
@settings[:myfile].should == otherfile
|
467
471
|
@settings.metadata(:myfile).should == {:owner => "suser"}
|
468
472
|
end
|
469
473
|
|
@@ -602,16 +606,6 @@ describe Puppet::Util::Settings do
|
|
602
606
|
@settings.reparse
|
603
607
|
end
|
604
608
|
|
605
|
-
it "should use a cached LoadedFile instance" do
|
606
|
-
first = mock 'first'
|
607
|
-
second = mock 'second'
|
608
|
-
Puppet::Util::LoadedFile.expects(:new).times(2).with("/test/file").returns(first).then.returns(second)
|
609
|
-
|
610
|
-
@settings.file.should equal(first)
|
611
|
-
Puppet::Util::Cacher.expire
|
612
|
-
@settings.file.should equal(second)
|
613
|
-
end
|
614
|
-
|
615
609
|
it "should replace in-memory values with on-file values" do
|
616
610
|
# Init the value
|
617
611
|
text = "[main]\none = disk-init\n"
|
@@ -726,9 +720,28 @@ describe Puppet::Util::Settings do
|
|
726
720
|
@settings.to_catalog
|
727
721
|
end
|
728
722
|
|
723
|
+
describe "on Microsoft Windows" do
|
724
|
+
before :each do
|
725
|
+
Puppet.features.stubs(:root?).returns true
|
726
|
+
Puppet.features.stubs(:microsoft_windows?).returns true
|
727
|
+
|
728
|
+
@settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"]
|
729
|
+
@settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"}
|
730
|
+
|
731
|
+
@catalog = @settings.to_catalog
|
732
|
+
end
|
733
|
+
|
734
|
+
it "it should not add users and groups to the catalog" do
|
735
|
+
@catalog.resource(:user, "suser").should be_nil
|
736
|
+
@catalog.resource(:group, "sgroup").should be_nil
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
729
740
|
describe "when adding users and groups to the catalog" do
|
730
741
|
before do
|
731
742
|
Puppet.features.stubs(:root?).returns true
|
743
|
+
Puppet.features.stubs(:microsoft_windows?).returns false
|
744
|
+
|
732
745
|
@settings.setdefaults :foo, :mkusers => [true, "e"], :user => ["suser", "doc"], :group => ["sgroup", "doc"]
|
733
746
|
@settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service"}
|
734
747
|
|
@@ -0,0 +1,310 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Puppet::Util::SUIDManager do
|
6
|
+
let :user do
|
7
|
+
Puppet::Type.type(:user).new(:name => 'name', :uid => 42, :gid => 42)
|
8
|
+
end
|
9
|
+
|
10
|
+
let :xids do
|
11
|
+
Hash.new {|h,k| 0}
|
12
|
+
end
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
Puppet::Util::SUIDManager.stubs(:convert_xid).returns(42)
|
16
|
+
Puppet::Util::SUIDManager.stubs(:initgroups)
|
17
|
+
|
18
|
+
[:euid, :egid, :uid, :gid, :groups].each do |id|
|
19
|
+
Process.stubs("#{id}=").with {|value| xids[id] = value}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#uid" do
|
24
|
+
it "should allow setting euid/egid" do
|
25
|
+
Puppet::Util::SUIDManager.egid = user[:gid]
|
26
|
+
Puppet::Util::SUIDManager.euid = user[:uid]
|
27
|
+
|
28
|
+
xids[:egid].should == user[:gid]
|
29
|
+
xids[:euid].should == user[:uid]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#asuser" do
|
34
|
+
it "should set euid/egid when root" do
|
35
|
+
Process.stubs(:uid).returns(0)
|
36
|
+
Puppet.features.stubs(:microsoft_windows?).returns(false)
|
37
|
+
|
38
|
+
Process.stubs(:egid).returns(51)
|
39
|
+
Process.stubs(:euid).returns(50)
|
40
|
+
|
41
|
+
Puppet::Util::SUIDManager.stubs(:convert_xid).with(:gid, 51).returns(51)
|
42
|
+
Puppet::Util::SUIDManager.stubs(:convert_xid).with(:uid, 50).returns(50)
|
43
|
+
|
44
|
+
yielded = false
|
45
|
+
Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) do
|
46
|
+
xids[:egid].should == user[:gid]
|
47
|
+
xids[:euid].should == user[:uid]
|
48
|
+
yielded = true
|
49
|
+
end
|
50
|
+
|
51
|
+
xids[:egid].should == 51
|
52
|
+
xids[:euid].should == 50
|
53
|
+
|
54
|
+
# It's possible asuser could simply not yield, so the assertions in the
|
55
|
+
# block wouldn't fail. So verify those actually got checked.
|
56
|
+
yielded.should be_true
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not get or set euid/egid when not root" do
|
60
|
+
Process.stubs(:uid).returns(1)
|
61
|
+
|
62
|
+
Process.stubs(:egid).returns(51)
|
63
|
+
Process.stubs(:euid).returns(50)
|
64
|
+
|
65
|
+
Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) {}
|
66
|
+
|
67
|
+
xids.should be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should not get or set euid/egid on Windows" do
|
71
|
+
Puppet.features.stubs(:microsoft_windows?).returns true
|
72
|
+
|
73
|
+
Puppet::Util::SUIDManager.asuser(user[:uid], user[:gid]) {}
|
74
|
+
|
75
|
+
xids.should be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#change_group" do
|
80
|
+
describe "when changing permanently" do
|
81
|
+
it "should try to change_privilege if it is supported" do
|
82
|
+
Process::GID.expects(:change_privilege).with do |gid|
|
83
|
+
Process.gid = gid
|
84
|
+
Process.egid = gid
|
85
|
+
end
|
86
|
+
|
87
|
+
Puppet::Util::SUIDManager.change_group(42, true)
|
88
|
+
|
89
|
+
xids[:egid].should == 42
|
90
|
+
xids[:gid].should == 42
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should change both egid and gid if change_privilege isn't supported" do
|
94
|
+
Process::GID.stubs(:change_privilege).raises(NotImplementedError)
|
95
|
+
|
96
|
+
Puppet::Util::SUIDManager.change_group(42, true)
|
97
|
+
|
98
|
+
xids[:egid].should == 42
|
99
|
+
xids[:gid].should == 42
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when changing temporarily" do
|
104
|
+
it "should change only egid" do
|
105
|
+
Puppet::Util::SUIDManager.change_group(42, false)
|
106
|
+
|
107
|
+
xids[:egid].should == 42
|
108
|
+
xids[:gid].should == 0
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#change_user" do
|
114
|
+
describe "when changing permanently" do
|
115
|
+
it "should try to change_privilege if it is supported" do
|
116
|
+
Process::UID.expects(:change_privilege).with do |uid|
|
117
|
+
Process.uid = uid
|
118
|
+
Process.euid = uid
|
119
|
+
end
|
120
|
+
|
121
|
+
Puppet::Util::SUIDManager.change_user(42, true)
|
122
|
+
|
123
|
+
xids[:euid].should == 42
|
124
|
+
xids[:uid].should == 42
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should change euid and uid and groups if change_privilege isn't supported" do
|
128
|
+
Process::UID.stubs(:change_privilege).raises(NotImplementedError)
|
129
|
+
|
130
|
+
Puppet::Util::SUIDManager.expects(:initgroups).with(42)
|
131
|
+
|
132
|
+
Puppet::Util::SUIDManager.change_user(42, true)
|
133
|
+
|
134
|
+
xids[:euid].should == 42
|
135
|
+
xids[:uid].should == 42
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "when changing temporarily" do
|
140
|
+
it "should change only euid and groups" do
|
141
|
+
Puppet::Util::SUIDManager.change_user(42, false)
|
142
|
+
|
143
|
+
xids[:euid].should == 42
|
144
|
+
xids[:uid].should == 0
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should set euid before groups if changing to root" do
|
148
|
+
Process.stubs(:euid).returns 50
|
149
|
+
|
150
|
+
when_not_root = sequence 'when_not_root'
|
151
|
+
|
152
|
+
Process.expects(:euid=).in_sequence(when_not_root)
|
153
|
+
Puppet::Util::SUIDManager.expects(:initgroups).in_sequence(when_not_root)
|
154
|
+
|
155
|
+
Puppet::Util::SUIDManager.change_user(0, false)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should set groups before euid if changing from root" do
|
159
|
+
Process.stubs(:euid).returns 0
|
160
|
+
|
161
|
+
when_root = sequence 'when_root'
|
162
|
+
|
163
|
+
Puppet::Util::SUIDManager.expects(:initgroups).in_sequence(when_root)
|
164
|
+
Process.expects(:euid=).in_sequence(when_root)
|
165
|
+
|
166
|
+
Puppet::Util::SUIDManager.change_user(50, false)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe "when running commands" do
|
172
|
+
before :each do
|
173
|
+
# We want to make sure $CHILD_STATUS is set
|
174
|
+
Kernel.system '' if $CHILD_STATUS.nil?
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "with #system" do
|
178
|
+
it "should set euid/egid when root" do
|
179
|
+
Process.stubs(:uid).returns(0)
|
180
|
+
Puppet.features.stubs(:microsoft_windows?).returns(false)
|
181
|
+
|
182
|
+
Process.stubs(:egid).returns(51)
|
183
|
+
Process.stubs(:euid).returns(50)
|
184
|
+
|
185
|
+
Puppet::Util::SUIDManager.stubs(:convert_xid).with(:gid, 51).returns(51)
|
186
|
+
Puppet::Util::SUIDManager.stubs(:convert_xid).with(:uid, 50).returns(50)
|
187
|
+
|
188
|
+
Puppet::Util::SUIDManager.expects(:change_group).with(user[:uid])
|
189
|
+
Puppet::Util::SUIDManager.expects(:change_user).with(user[:uid])
|
190
|
+
|
191
|
+
Puppet::Util::SUIDManager.expects(:change_group).with(51)
|
192
|
+
Puppet::Util::SUIDManager.expects(:change_user).with(50)
|
193
|
+
|
194
|
+
Kernel.expects(:system).with('blah')
|
195
|
+
Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid])
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should not get or set euid/egid when not root" do
|
199
|
+
Process.stubs(:uid).returns(1)
|
200
|
+
Kernel.expects(:system).with('blah')
|
201
|
+
|
202
|
+
Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid])
|
203
|
+
|
204
|
+
xids.should be_empty
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should not get or set euid/egid on Windows" do
|
208
|
+
Puppet.features.stubs(:microsoft_windows?).returns true
|
209
|
+
Kernel.expects(:system).with('blah')
|
210
|
+
|
211
|
+
Puppet::Util::SUIDManager.system('blah', user[:uid], user[:gid])
|
212
|
+
|
213
|
+
xids.should be_empty
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "with #run_and_capture" do
|
218
|
+
it "should capture the output and return process status" do
|
219
|
+
Puppet::Util.
|
220
|
+
expects(:execute).
|
221
|
+
with('yay', :combine => true, :failonfail => false, :uid => user[:uid], :gid => user[:gid]).
|
222
|
+
returns('output')
|
223
|
+
output = Puppet::Util::SUIDManager.run_and_capture 'yay', user[:uid], user[:gid]
|
224
|
+
|
225
|
+
output.first.should == 'output'
|
226
|
+
output.last.should be_a(Process::Status)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "#root?" do
|
232
|
+
describe "on POSIX systems" do
|
233
|
+
before :each do
|
234
|
+
Puppet.features.stubs(:posix?).returns(true)
|
235
|
+
Puppet.features.stubs(:microsoft_windows?).returns(false)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should be root if uid is 0" do
|
239
|
+
Process.stubs(:uid).returns(0)
|
240
|
+
|
241
|
+
Puppet::Util::SUIDManager.should be_root
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should not be root if uid is not 0" do
|
245
|
+
Process.stubs(:uid).returns(1)
|
246
|
+
|
247
|
+
Puppet::Util::SUIDManager.should_not be_root
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "on Microsoft Windows", :if => Puppet.features.microsoft_windows? do
|
252
|
+
describe "2003 without UAC" do
|
253
|
+
before :each do
|
254
|
+
Facter.stubs(:value).with(:kernelmajversion).returns("5.2")
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should be root if user is a member of the Administrators group" do
|
258
|
+
Sys::Admin.stubs(:get_login).returns("Administrator")
|
259
|
+
Sys::Group.stubs(:members).returns(%w[Administrator])
|
260
|
+
|
261
|
+
Win32::Security.expects(:elevated_security?).never
|
262
|
+
Puppet::Util::SUIDManager.should be_root
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should not be root if the process is running as Guest" do
|
266
|
+
Sys::Admin.stubs(:get_login).returns("Guest")
|
267
|
+
Sys::Group.stubs(:members).returns([])
|
268
|
+
|
269
|
+
Win32::Security.expects(:elevated_security?).never
|
270
|
+
Puppet::Util::SUIDManager.should_not be_root
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should raise an exception if the process fails to open the process token" do
|
274
|
+
Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Access denied.")
|
275
|
+
Sys::Admin.stubs(:get_login).returns("Administrator")
|
276
|
+
Sys::Group.expects(:members).never
|
277
|
+
|
278
|
+
lambda { Puppet::Util::SUIDManager.should raise_error(Win32::Security::Error, /Access denied./) }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe "2008 with UAC" do
|
283
|
+
before :each do
|
284
|
+
Facter.stubs(:value).with(:kernelmajversion).returns("6.0")
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should be root if user is running with elevated privileges" do
|
288
|
+
Win32::Security.stubs(:elevated_security?).returns(true)
|
289
|
+
Sys::Admin.expects(:get_login).never
|
290
|
+
|
291
|
+
Puppet::Util::SUIDManager.should be_root
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should not be root if user is not running with elevated privileges" do
|
295
|
+
Win32::Security.stubs(:elevated_security?).returns(false)
|
296
|
+
Sys::Admin.expects(:get_login).never
|
297
|
+
|
298
|
+
Puppet::Util::SUIDManager.should_not be_root
|
299
|
+
end
|
300
|
+
|
301
|
+
it "should raise an exception if the process fails to open the process token" do
|
302
|
+
Win32::Security.stubs(:elevated_security?).raises(Win32::Security::Error, "Access denied.")
|
303
|
+
Sys::Admin.expects(:get_login).never
|
304
|
+
|
305
|
+
lambda { Puppet::Util::SUIDManager.should raise_error(Win32::Security::Error, /Access denied./) }
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|