puppet 2.7.19 → 2.7.20.rc1
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/CONTRIBUTING.md +61 -238
- data/Gemfile +32 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +1 -1
- data/README_DEVELOPER.md +300 -5
- data/Rakefile +41 -37
- data/ext/build_defaults.yaml +20 -0
- data/ext/debian/README.Debian +8 -0
- data/ext/debian/README.source +2 -0
- data/ext/debian/TODO.Debian +1 -0
- data/ext/debian/changelog.erb +1104 -0
- data/ext/debian/compat +1 -0
- data/ext/debian/control +142 -0
- data/ext/debian/copyright +361 -0
- data/ext/debian/docs +1 -0
- data/ext/debian/fileserver.conf +17 -0
- data/ext/debian/puppet-common.dirs +8 -0
- data/ext/debian/puppet-common.install +3 -0
- data/ext/debian/puppet-common.lintian-overrides +7 -0
- data/ext/debian/puppet-common.manpages +2 -0
- data/ext/debian/puppet-common.postinst +35 -0
- data/ext/debian/puppet-common.postrm +32 -0
- data/ext/debian/puppet-el.dirs +1 -0
- data/ext/debian/puppet-el.emacsen-install +25 -0
- data/ext/debian/puppet-el.emacsen-remove +11 -0
- data/ext/debian/puppet-el.emacsen-startup +9 -0
- data/ext/debian/puppet-el.install +1 -0
- data/ext/debian/puppet-testsuite.install +3 -0
- data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
- data/ext/debian/puppet.NEWS +86 -0
- data/ext/debian/puppet.conf +14 -0
- data/ext/debian/puppet.default +7 -0
- data/ext/debian/puppet.dirs +1 -0
- data/ext/debian/puppet.init +118 -0
- data/ext/debian/puppet.install +4 -0
- data/ext/debian/puppet.lintian-overrides +3 -0
- data/ext/debian/puppet.logrotate +11 -0
- data/ext/debian/puppet.manpages +36 -0
- data/ext/debian/puppet.postinst +20 -0
- data/ext/debian/puppet.postrm +20 -0
- data/ext/debian/puppet.preinst +20 -0
- data/ext/debian/puppetmaster-common.install +5 -0
- data/ext/debian/puppetmaster-common.manpages +5 -0
- data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
- data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
- data/ext/debian/puppetmaster-passenger.dirs +4 -0
- data/ext/debian/puppetmaster-passenger.postinst +66 -0
- data/ext/debian/puppetmaster-passenger.postrm +33 -0
- data/ext/debian/puppetmaster.NEWS +13 -0
- data/ext/debian/puppetmaster.README.debian +16 -0
- data/ext/debian/puppetmaster.default +38 -0
- data/ext/debian/puppetmaster.dirs +1 -0
- data/ext/debian/puppetmaster.init +158 -0
- data/ext/debian/puppetmaster.install +1 -0
- data/ext/debian/puppetmaster.lintian-overrides +3 -0
- data/ext/debian/puppetmaster.manpages +1 -0
- data/ext/debian/puppetmaster.postinst +20 -0
- data/ext/debian/puppetmaster.postrm +5 -0
- data/ext/debian/puppetmaster.preinst +22 -0
- data/ext/debian/rules +127 -0
- data/ext/debian/source/format +1 -0
- data/ext/debian/source/options +1 -0
- data/ext/debian/vim-puppet.README.Debian +13 -0
- data/ext/debian/vim-puppet.dirs +3 -0
- data/ext/debian/vim-puppet.yaml +5 -0
- data/ext/debian/watch +2 -0
- data/ext/emacs/puppet-mode.el +1 -0
- data/{conf → ext}/osx/PackageInfo.plist +0 -0
- data/{conf → ext}/osx/createpackage.sh +0 -0
- data/ext/osx/file_mapping.yaml +38 -0
- data/ext/osx/preflight.erb +37 -0
- data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
- data/ext/packaging/README-Solaris.md +117 -0
- data/ext/packaging/README.md +255 -0
- data/ext/packaging/spec/spec_helper.rb +12 -0
- data/ext/packaging/spec/tasks/00_utils_spec.rb +66 -0
- data/ext/packaging/tasks/00_utils.rake +382 -0
- data/ext/packaging/tasks/10_setupvars.rake +71 -0
- data/ext/packaging/tasks/20_setupextravars.rake +25 -0
- data/ext/packaging/tasks/apple.rake +201 -0
- data/ext/packaging/tasks/clean.rake +5 -0
- data/ext/packaging/tasks/deb.rake +108 -0
- data/ext/packaging/tasks/doc.rake +20 -0
- data/ext/packaging/tasks/fetch.rake +18 -0
- data/ext/packaging/tasks/gem.rake +68 -0
- data/ext/packaging/tasks/ips.rake +80 -0
- data/ext/packaging/tasks/mock.rake +126 -0
- data/ext/packaging/tasks/pe_deb.rake +9 -0
- data/ext/packaging/tasks/pe_remote.rake +45 -0
- data/ext/packaging/tasks/pe_rpm.rake +21 -0
- data/ext/packaging/tasks/pe_ship.rake +30 -0
- data/ext/packaging/tasks/pe_sign.rake +27 -0
- data/ext/packaging/tasks/pe_sles.rake +96 -0
- data/ext/packaging/tasks/release.rake +73 -0
- data/ext/packaging/tasks/remote_build.rake +78 -0
- data/ext/packaging/tasks/rpm.rake +52 -0
- data/ext/packaging/tasks/ship.rake +78 -0
- data/ext/packaging/tasks/sign.rake +82 -0
- data/ext/packaging/tasks/tag.rake +8 -0
- data/ext/packaging/tasks/tar.rake +68 -0
- data/ext/packaging/tasks/template.rake +13 -0
- data/ext/packaging/tasks/update.rake +16 -0
- data/ext/packaging/tasks/version.rake +21 -0
- data/ext/project_data.yaml +24 -0
- data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +18 -10
- data/install.rb +8 -8
- data/lib/puppet.rb +2 -6
- data/lib/puppet/agent/locker.rb +2 -0
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +1 -1
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/cert.rb +5 -6
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +1 -1
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/defaults.rb +21 -3
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/help/global.erb +1 -1
- data/lib/puppet/face/module/install.rb +1 -1
- data/lib/puppet/face/module/list.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/node/clean.rb +23 -18
- data/lib/puppet/face/parser.rb +11 -2
- data/lib/puppet/file_collection.rb +16 -27
- data/lib/puppet/file_collection/lookup.rb +6 -16
- data/lib/puppet/file_serving/base.rb +4 -4
- data/lib/puppet/indirector/catalog/static_compiler.rb +3 -4
- data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/face.rb +2 -2
- data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/node/exec.rb +13 -1
- data/lib/puppet/indirector/request.rb +4 -0
- data/lib/puppet/metatype/manager.rb +17 -10
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/rights.rb +1 -2
- data/lib/puppet/node/environment.rb +1 -0
- data/lib/puppet/parameter/value.rb +9 -3
- data/lib/puppet/parser/ast.rb +1 -4
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +68 -22
- data/lib/puppet/parser/functions/create_resources.rb +2 -3
- data/lib/puppet/parser/functions/shellquote.rb +21 -25
- data/lib/puppet/parser/lexer.rb +40 -6
- data/lib/puppet/parser/relationship.rb +3 -1
- data/lib/puppet/parser/resource.rb +2 -3
- data/lib/puppet/parser/resource/param.rb +3 -5
- data/lib/puppet/parser/scope.rb +7 -4
- data/lib/puppet/property.rb +5 -3
- data/lib/puppet/provider.rb +5 -5
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +10 -29
- data/lib/puppet/provider/group/groupadd.rb +2 -3
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/ldap.rb +5 -1
- data/lib/puppet/provider/nameservice.rb +3 -3
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/gem.rb +6 -2
- data/lib/puppet/provider/package/portage.rb +4 -2
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/base.rb +2 -41
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/redhat.rb +6 -5
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/service/service.rb +43 -0
- data/lib/puppet/provider/service/windows.rb +1 -8
- data/lib/puppet/provider/user/user_role_add.rb +2 -1
- data/lib/puppet/provider/user/useradd.rb +8 -3
- data/lib/puppet/provider/user/windows_adsi.rb +12 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/inventory_node.rb +26 -13
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +20 -5
- data/lib/puppet/resource/status.rb +1 -1
- data/lib/puppet/ssl/certificate_authority.rb +2 -0
- data/lib/puppet/ssl/host.rb +31 -6
- data/lib/puppet/test/test_helper.rb +3 -1
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +30 -25
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/cron.rb +2 -2
- data/lib/puppet/type/exec.rb +6 -6
- data/lib/puppet/type/file.rb +5 -15
- data/lib/puppet/type/file/content.rb +1 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/selcontext.rb +6 -2
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/package.rb +1 -1
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/whit.rb +16 -9
- data/lib/puppet/util.rb +27 -11
- data/lib/puppet/util/adsi.rb +25 -23
- data/lib/puppet/util/autoload.rb +1 -1
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/feature.rb +3 -1
- data/lib/puppet/util/fileparsing.rb +9 -9
- data/lib/puppet/util/filetype.rb +55 -40
- data/lib/puppet/util/instance_loader.rb +5 -5
- data/lib/puppet/util/instrumentation.rb +3 -5
- data/lib/puppet/util/log_paths.rb +1 -3
- data/lib/puppet/util/monkey_patches.rb +34 -8
- data/lib/puppet/util/platform.rb +7 -0
- data/lib/puppet/util/posix.rb +3 -3
- data/lib/puppet/util/provider_features.rb +2 -3
- data/lib/puppet/util/rdoc.rb +4 -3
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/selinux.rb +31 -36
- data/lib/puppet/util/tagging.rb +28 -6
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/process.rb +3 -3
- data/lib/puppet/util/windows/security.rb +9 -46
- data/lib/puppet/util/windows/sid.rb +96 -0
- data/lib/puppet/util/windows/user.rb +65 -2
- data/lib/puppet/util/zaml.rb +109 -59
- data/lib/puppet/version.rb +18 -0
- data/spec/fixtures/unit/util/filetype/aixtab_output +44 -0
- data/spec/fixtures/unit/util/filetype/suntab_output +9 -0
- data/spec/integration/defaults_spec.rb +26 -7
- data/spec/integration/parser/functions_spec.rb +0 -4
- data/spec/integration/util/file_locking_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +3 -23
- data/spec/lib/puppet_spec/files.rb +3 -3
- data/spec/shared_contexts/platform.rb +8 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/application/queue_spec.rb +2 -1
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/face/{instrumentation_data.rb → instrumentation_data_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_listener.rb → instrumentation_listener_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_probe.rb → instrumentation_probe_spec.rb} +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/request_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +0 -7
- data/spec/unit/node/environment_spec.rb +8 -8
- data/spec/unit/parser/ast_spec.rb +0 -5
- data/spec/unit/parser/collector_spec.rb +1 -0
- data/spec/unit/parser/files_spec.rb +2 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +3 -4
- data/spec/unit/parser/functions/require_spec.rb +0 -6
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -5
- data/spec/unit/parser/functions/template_spec.rb +6 -1
- data/spec/unit/parser/functions_spec.rb +73 -23
- data/spec/unit/parser/lexer_spec.rb +133 -8
- data/spec/unit/parser/relationship_spec.rb +24 -0
- data/spec/unit/parser/resource_spec.rb +0 -4
- data/spec/unit/parser/scope_spec.rb +2 -2
- data/spec/unit/property_spec.rb +21 -1
- data/spec/unit/provider/exec/posix_spec.rb +7 -6
- data/spec/unit/provider/file/windows_spec.rb +29 -29
- data/spec/unit/provider/group/groupadd_spec.rb +36 -30
- data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +12 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
- data/spec/unit/provider/service/redhat_spec.rb +11 -1
- data/spec/unit/provider/service/windows_spec.rb +19 -0
- data/spec/unit/provider/user/ldap_spec.rb +22 -8
- data/spec/unit/provider/user/user_role_add_spec.rb +12 -0
- data/spec/unit/provider/user/useradd_spec.rb +146 -118
- data/spec/unit/provider/user/windows_adsi_spec.rb +24 -2
- data/spec/unit/puppet_spec.rb +10 -0
- data/spec/unit/resource/status_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +73 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +25 -1
- data/spec/unit/ssl/host_spec.rb +73 -27
- data/spec/unit/ssl/key_spec.rb +0 -4
- data/spec/unit/transaction/event_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +1 -1
- data/spec/unit/type/file/content_spec.rb +6 -4
- data/spec/unit/type/file/{ctime.rb → ctime_spec.rb} +0 -0
- data/spec/unit/type/file/{mtime.rb → mtime_spec.rb} +0 -0
- data/spec/unit/type/file/{type.rb → type_spec.rb} +0 -0
- data/spec/unit/type/file_spec.rb +2 -12
- data/spec/unit/type/host_spec.rb +14 -5
- data/spec/unit/type/mount_spec.rb +8 -0
- data/spec/unit/type/scheduled_task_spec.rb +2 -2
- data/spec/unit/util/adsi_spec.rb +23 -8
- data/spec/unit/util/command_line_spec.rb +11 -2
- data/spec/unit/util/feature_spec.rb +12 -1
- data/spec/unit/util/filetype_spec.rb +161 -55
- data/spec/unit/util/log_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +7 -0
- data/spec/unit/util/rdoc_spec.rb +8 -2
- data/spec/unit/util/selinux_spec.rb +24 -32
- data/spec/unit/util/windows/sid_spec.rb +100 -0
- data/spec/unit/util/zaml_spec.rb +165 -25
- data/spec/unit/util_spec.rb +3 -9
- data/spec/watchr.rb +2 -6
- data/tasks/rake/gem.rake +4 -2
- data/tasks/rake/sign.rake +1 -1
- data/test/language/parser.rb +1 -0
- data/test/language/scope.rb +0 -5
- data/test/language/snippets.rb +1 -2
- data/test/lib/puppettest.rb +16 -27
- data/test/lib/puppettest/parsertesting.rb +0 -1
- data/test/network/authstore.rb +2 -4
- data/test/puppet/defaults.rb +0 -4
- data/test/util/fileparsing.rb +2 -6
- metadata +1706 -1617
- data/conf/osx/preflight +0 -24
- data/spec/spec.opts +0 -4
- data/spec/unit/file_collection/lookup_spec.rb +0 -45
- data/spec/unit/file_collection_spec.rb +0 -52
- data/tasks/rake/apple.rake +0 -176
- data/test/puppet/errortest.rb +0 -19
data/lib/puppet/util/tagging.rb
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
# Copyright Luke Kanies
|
3
3
|
|
4
4
|
# A common module to handle tagging.
|
5
|
+
#
|
6
|
+
# So, do you want the bad news or the good news first?
|
7
|
+
#
|
8
|
+
# The bad news is that using an array here is hugely costly compared to using
|
9
|
+
# a hash. Like, the same speed empty, 50 percent slower with one item, and
|
10
|
+
# 300 percent slower at 6 - one of our common peaks for tagging items.
|
11
|
+
#
|
12
|
+
# ...and that assumes an efficient implementation, just using include?. These
|
13
|
+
# methods have even more costs hidden in them.
|
14
|
+
#
|
15
|
+
# The good news is that this module has no API. Various objects directly
|
16
|
+
# interact with their `@tags` member as an array, or dump it directly in YAML,
|
17
|
+
# or whatever.
|
18
|
+
#
|
19
|
+
# So, er, you can't actually change this. No matter how much you want to be
|
20
|
+
# cause it is inefficient in both CPU and object allocation terms.
|
21
|
+
#
|
22
|
+
# Good luck, my friend. --daniel 2012-07-17
|
5
23
|
module Puppet::Util::Tagging
|
6
24
|
# Add a tag to our current list. These tags will be added to all
|
7
25
|
# of the objects contained in this scope.
|
@@ -38,19 +56,23 @@ module Puppet::Util::Tagging
|
|
38
56
|
|
39
57
|
tags = tags.strip.split(/\s*,\s*/) if tags.is_a?(String)
|
40
58
|
|
41
|
-
tags.each
|
42
|
-
tag(t)
|
43
|
-
end
|
59
|
+
tags.each {|t| tag(t) }
|
44
60
|
end
|
45
61
|
|
46
62
|
private
|
47
63
|
|
48
|
-
def handle_qualified_tags(
|
64
|
+
def handle_qualified_tags(qualified)
|
49
65
|
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
|
50
|
-
|
66
|
+
x = 1
|
67
|
+
qualified.each do |name|
|
68
|
+
name.split("::").each do |tag|
|
69
|
+
@tags << tag unless @tags.include?(tag)
|
70
|
+
end
|
71
|
+
end
|
51
72
|
end
|
52
73
|
|
74
|
+
ValidTagRegex = /^\w[-\w:.]*$/
|
53
75
|
def valid_tag?(tag)
|
54
|
-
tag =~
|
76
|
+
tag.is_a?(String) and tag =~ ValidTagRegex
|
55
77
|
end
|
56
78
|
end
|
data/lib/puppet/util/windows.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'puppet/util/windows'
|
2
2
|
|
3
3
|
module Puppet::Util::Windows::Process
|
4
|
-
extend Windows::Process
|
5
|
-
extend Windows::Handle
|
6
|
-
extend Windows::Synchronize
|
4
|
+
extend ::Windows::Process
|
5
|
+
extend ::Windows::Handle
|
6
|
+
extend ::Windows::Synchronize
|
7
7
|
|
8
8
|
def execute(command, arguments, stdin, stdout, stderr)
|
9
9
|
Process.create( :command_line => command, :startup_info => {:stdin => stdin, :stdout => stdout, :stderr => stderr}, :close_handles => false )
|
@@ -72,13 +72,15 @@ require 'windows/memory'
|
|
72
72
|
require 'windows/volume'
|
73
73
|
|
74
74
|
module Puppet::Util::Windows::Security
|
75
|
-
include Windows::File
|
76
|
-
include Windows::Handle
|
77
|
-
include Windows::Security
|
78
|
-
include Windows::Process
|
79
|
-
include Windows::Memory
|
80
|
-
include Windows::MSVCRT::Buffer
|
81
|
-
include Windows::Volume
|
75
|
+
include ::Windows::File
|
76
|
+
include ::Windows::Handle
|
77
|
+
include ::Windows::Security
|
78
|
+
include ::Windows::Process
|
79
|
+
include ::Windows::Memory
|
80
|
+
include ::Windows::MSVCRT::Buffer
|
81
|
+
include ::Windows::Volume
|
82
|
+
|
83
|
+
include Puppet::Util::Windows::SID
|
82
84
|
|
83
85
|
extend Puppet::Util::Windows::Security
|
84
86
|
|
@@ -553,45 +555,6 @@ module Puppet::Util::Windows::Security
|
|
553
555
|
end
|
554
556
|
end
|
555
557
|
|
556
|
-
# Convert a SID pointer to a string, e.g. "S-1-5-32-544".
|
557
|
-
def sid_ptr_to_string(psid)
|
558
|
-
sid_buf = 0.chr * 256
|
559
|
-
str_ptr = 0.chr * 4
|
560
|
-
|
561
|
-
raise Puppet::Util::Windows::Error.new("Invalid SID") unless IsValidSid(psid)
|
562
|
-
|
563
|
-
raise Puppet::Util::Windows::Error.new("Failed to convert binary SID") unless ConvertSidToStringSid(psid, str_ptr)
|
564
|
-
|
565
|
-
begin
|
566
|
-
strncpy(sid_buf, str_ptr.unpack('L')[0], sid_buf.size - 1)
|
567
|
-
sid_buf[sid_buf.size - 1] = 0.chr
|
568
|
-
return sid_buf.strip
|
569
|
-
ensure
|
570
|
-
LocalFree(str_ptr.unpack('L')[0])
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
# Convert a SID string, e.g. "S-1-5-32-544" to a pointer (containing the
|
575
|
-
# address of the binary SID structure). The returned value can be used in
|
576
|
-
# Win32 APIs that expect a PSID, e.g. IsValidSid.
|
577
|
-
def string_to_sid_ptr(string)
|
578
|
-
sid_buf = 0.chr * 80
|
579
|
-
string_addr = [string].pack('p*').unpack('L')[0]
|
580
|
-
|
581
|
-
raise Puppet::Util::Windows::Error.new("Failed to convert string SID: #{string}") unless ConvertStringSidToSid(string_addr, sid_buf)
|
582
|
-
|
583
|
-
sid_ptr = sid_buf.unpack('L')[0]
|
584
|
-
begin
|
585
|
-
if block_given?
|
586
|
-
yield sid_ptr
|
587
|
-
else
|
588
|
-
true
|
589
|
-
end
|
590
|
-
ensure
|
591
|
-
LocalFree(sid_ptr)
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
558
|
# Open an existing file with the specified access mode, and execute a
|
596
559
|
# block with the opened file HANDLE.
|
597
560
|
def open_file(path, access)
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'puppet/util/windows'
|
2
|
+
|
3
|
+
module Puppet::Util::Windows
|
4
|
+
module SID
|
5
|
+
require 'windows/security'
|
6
|
+
include ::Windows::Security
|
7
|
+
|
8
|
+
require 'windows/memory'
|
9
|
+
include ::Windows::Memory
|
10
|
+
|
11
|
+
require 'windows/msvcrt/string'
|
12
|
+
include ::Windows::MSVCRT::String
|
13
|
+
|
14
|
+
# missing from Windows::Error
|
15
|
+
ERROR_NONE_MAPPED = 1332
|
16
|
+
ERROR_INVALID_SID_STRUCTURE = 1337
|
17
|
+
|
18
|
+
# Convert an account name, e.g. 'Administrators' into a SID string,
|
19
|
+
# e.g. 'S-1-5-32-544'. The name can be specified as 'Administrators',
|
20
|
+
# 'BUILTIN\Administrators', or 'S-1-5-32-544', and will return the
|
21
|
+
# SID. Returns nil if the account doesn't exist.
|
22
|
+
def name_to_sid(name)
|
23
|
+
# Apparently, we accept a symbol..
|
24
|
+
name = name.to_s if name
|
25
|
+
|
26
|
+
# if it's in SID string form, return it, otherwise, lookup sid
|
27
|
+
is_sid = Win32::Security::SID.string_to_sid(name) rescue nil
|
28
|
+
|
29
|
+
is_sid ? name : Win32::Security::SID.new(name).to_s
|
30
|
+
rescue
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Convert a SID string, e.g. "S-1-5-32-544" to a name,
|
35
|
+
# e.g. 'BUILTIN\Administrators'. Returns nil if an account
|
36
|
+
# for that SID does not exist.
|
37
|
+
def sid_to_name(value)
|
38
|
+
sid = Win32::Security::SID.new(Win32::Security::SID.string_to_sid(value))
|
39
|
+
|
40
|
+
if sid.domain and sid.domain.length > 0
|
41
|
+
"#{sid.domain}\\#{sid.account}"
|
42
|
+
else
|
43
|
+
sid.account
|
44
|
+
end
|
45
|
+
rescue
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# Convert a SID pointer to a SID string, e.g. "S-1-5-32-544".
|
50
|
+
def sid_ptr_to_string(psid)
|
51
|
+
sid_buf = 0.chr * 256
|
52
|
+
str_ptr = 0.chr * 4
|
53
|
+
|
54
|
+
raise Puppet::Util::Windows::Error.new("Invalid SID") unless IsValidSid(psid)
|
55
|
+
|
56
|
+
raise Puppet::Util::Windows::Error.new("Failed to convert binary SID") unless ConvertSidToStringSid(psid, str_ptr)
|
57
|
+
|
58
|
+
begin
|
59
|
+
strncpy(sid_buf, str_ptr.unpack('L')[0], sid_buf.size - 1)
|
60
|
+
sid_buf[sid_buf.size - 1] = 0.chr
|
61
|
+
return sid_buf.strip
|
62
|
+
ensure
|
63
|
+
LocalFree(str_ptr.unpack('L')[0])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Convert a SID string, e.g. "S-1-5-32-544" to a pointer (containing the
|
68
|
+
# address of the binary SID structure). The returned value can be used in
|
69
|
+
# Win32 APIs that expect a PSID, e.g. IsValidSid. The account for this
|
70
|
+
# SID may or may not exist.
|
71
|
+
def string_to_sid_ptr(string, &block)
|
72
|
+
sid_buf = 0.chr * 80
|
73
|
+
string_addr = [string].pack('p*').unpack('L')[0]
|
74
|
+
|
75
|
+
raise Puppet::Util::Windows::Error.new("Failed to convert string SID: #{string}") unless ConvertStringSidToSid(string_addr, sid_buf)
|
76
|
+
|
77
|
+
sid_ptr = sid_buf.unpack('L')[0]
|
78
|
+
begin
|
79
|
+
yield sid_ptr
|
80
|
+
ensure
|
81
|
+
LocalFree(sid_ptr)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Return true if the string is a valid SID, e.g. "S-1-5-32-544", false otherwise.
|
86
|
+
def valid_sid?(string)
|
87
|
+
string_to_sid_ptr(string) { |ptr| true }
|
88
|
+
rescue Puppet::Util::Windows::Error => e
|
89
|
+
if e.code == ERROR_INVALID_SID_STRUCTURE
|
90
|
+
false
|
91
|
+
else
|
92
|
+
raise
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -4,8 +4,8 @@ require 'win32/security'
|
|
4
4
|
require 'facter'
|
5
5
|
|
6
6
|
module Puppet::Util::Windows::User
|
7
|
-
include Windows::Security
|
8
|
-
extend Windows::Security
|
7
|
+
include ::Windows::Security
|
8
|
+
extend ::Windows::Security
|
9
9
|
|
10
10
|
def admin?
|
11
11
|
majversion = Facter.value(:kernelmajversion)
|
@@ -40,4 +40,67 @@ module Puppet::Util::Windows::User
|
|
40
40
|
member.unpack('L')[0] == 1
|
41
41
|
end
|
42
42
|
module_function :check_token_membership
|
43
|
+
|
44
|
+
def password_is?(name, password)
|
45
|
+
logon_user(name, password)
|
46
|
+
true
|
47
|
+
rescue Puppet::Util::Windows::Error => e
|
48
|
+
false
|
49
|
+
end
|
50
|
+
module_function :password_is?
|
51
|
+
|
52
|
+
def logon_user(name, password, &block)
|
53
|
+
fLOGON32_LOGON_NETWORK = 3
|
54
|
+
fLOGON32_PROVIDER_DEFAULT = 0
|
55
|
+
|
56
|
+
logon_user = Win32API.new("advapi32", "LogonUser", ['P', 'P', 'P', 'L', 'L', 'P'], 'L')
|
57
|
+
close_handle = Win32API.new("kernel32", "CloseHandle", ['P'], 'V')
|
58
|
+
|
59
|
+
token = 0.chr * 4
|
60
|
+
if logon_user.call(name, ".", password, fLOGON32_LOGON_NETWORK, fLOGON32_PROVIDER_DEFAULT, token) == 0
|
61
|
+
raise Puppet::Util::Windows::Error.new("Failed to logon user #{name.inspect}")
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
yield token.unpack('L')[0] if block_given?
|
66
|
+
ensure
|
67
|
+
close_handle.call(token.unpack('L')[0])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
module_function :logon_user
|
71
|
+
|
72
|
+
def load_profile(user, password)
|
73
|
+
logon_user(user, password) do |token|
|
74
|
+
# Set up the PROFILEINFO structure that will be used to load the
|
75
|
+
# new user's profile
|
76
|
+
# typedef struct _PROFILEINFO {
|
77
|
+
# DWORD dwSize;
|
78
|
+
# DWORD dwFlags;
|
79
|
+
# LPTSTR lpUserName;
|
80
|
+
# LPTSTR lpProfilePath;
|
81
|
+
# LPTSTR lpDefaultPath;
|
82
|
+
# LPTSTR lpServerName;
|
83
|
+
# LPTSTR lpPolicyPath;
|
84
|
+
# HANDLE hProfile;
|
85
|
+
# } PROFILEINFO, *LPPROFILEINFO;
|
86
|
+
fPI_NOUI = 1
|
87
|
+
profile = 0.chr * 4
|
88
|
+
pi = [4 * 8, fPI_NOUI, user, nil, nil, nil, nil, profile].pack('LLPPPPPP')
|
89
|
+
|
90
|
+
load_user_profile = Win32API.new('userenv', 'LoadUserProfile', ['L', 'P'], 'L')
|
91
|
+
unload_user_profile = Win32API.new('userenv', 'UnloadUserProfile', ['L', 'P'], 'L')
|
92
|
+
|
93
|
+
# Load the profile. Since it doesn't exist, it will be created
|
94
|
+
if load_user_profile.call(token, pi) == 0
|
95
|
+
raise Puppet::Util::Windows::Error.new("Failed to load user profile #{user.inspect}")
|
96
|
+
end
|
97
|
+
|
98
|
+
Puppet.debug("Loaded profile for #{user}")
|
99
|
+
|
100
|
+
if unload_user_profile.call(token, pi.unpack('LLLLLLLL').last) == 0
|
101
|
+
raise Puppet::Util::Windows::Error.new("Failed to unload user profile #{user.inspect}")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
module_function :load_profile
|
43
106
|
end
|
data/lib/puppet/util/zaml.rb
CHANGED
@@ -18,13 +18,35 @@
|
|
18
18
|
#
|
19
19
|
# http://github.com/hallettj/zaml
|
20
20
|
#
|
21
|
-
#
|
21
|
+
# ## License (from upstream)
|
22
22
|
#
|
23
|
+
# Copyright (c) 2008-2009 ZAML contributers
|
24
|
+
#
|
25
|
+
# This program is dual-licensed under the GNU General Public License
|
26
|
+
# version 3 or later and under the Apache License, version 2.0.
|
27
|
+
#
|
28
|
+
# This program is free software: you can redistribute it and/or modify it
|
29
|
+
# under the terms of the GNU General Public License as published by the
|
30
|
+
# Free Software Foundation, either version 3 of the License, or (at your
|
31
|
+
# option) any later version; or under the terms of the Apache License,
|
32
|
+
# Version 2.0.
|
33
|
+
#
|
34
|
+
# This program is distributed in the hope that it will be useful, but
|
35
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
36
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
37
|
+
# General Public License and the Apache License for more details.
|
38
|
+
#
|
39
|
+
# You should have received a copy of the GNU General Public License
|
40
|
+
# along with this program. If not, see
|
41
|
+
# <http://www.gnu.org/licenses/>.
|
42
|
+
#
|
43
|
+
# You may obtain a copy of the Apache License at
|
44
|
+
# <https://www.apache.org/licenses/LICENSE-2.0.html>.
|
23
45
|
|
24
46
|
require 'yaml'
|
25
47
|
|
26
48
|
class ZAML
|
27
|
-
VERSION = "0.1.
|
49
|
+
VERSION = "0.1.3"
|
28
50
|
#
|
29
51
|
# Class Methods
|
30
52
|
#
|
@@ -33,6 +55,7 @@ class ZAML
|
|
33
55
|
stuff.to_zaml(z)
|
34
56
|
where << z.to_s
|
35
57
|
end
|
58
|
+
|
36
59
|
#
|
37
60
|
# Instance Methods
|
38
61
|
#
|
@@ -44,12 +67,14 @@ class ZAML
|
|
44
67
|
@next_free_label_number = 0
|
45
68
|
emit('--- ')
|
46
69
|
end
|
70
|
+
|
47
71
|
def nested(tail=' ')
|
48
72
|
old_indent = @indent
|
49
73
|
@indent = "#{@indent || "\n"}#{tail}"
|
50
74
|
yield
|
51
75
|
@indent = old_indent
|
52
76
|
end
|
77
|
+
|
53
78
|
class Label
|
54
79
|
#
|
55
80
|
# YAML only wants objects in the datastream once; if the same object
|
@@ -68,51 +93,69 @@ class ZAML
|
|
68
93
|
# it can be handled).
|
69
94
|
#
|
70
95
|
attr_accessor :this_label_number
|
96
|
+
|
71
97
|
def initialize(obj,indent)
|
72
98
|
@indent = indent
|
73
99
|
@this_label_number = nil
|
74
100
|
@obj = obj # prevent garbage collection so that object id isn't reused
|
75
101
|
end
|
102
|
+
|
76
103
|
def to_s
|
77
104
|
@this_label_number ? ('&id%03d%s' % [@this_label_number, @indent]) : ''
|
78
105
|
end
|
106
|
+
|
79
107
|
def reference
|
80
108
|
@reference ||= '*id%03d' % @this_label_number
|
81
109
|
end
|
82
110
|
end
|
111
|
+
|
83
112
|
def label_for(obj)
|
84
113
|
@previously_emitted_object[obj.object_id]
|
85
114
|
end
|
115
|
+
|
86
116
|
def new_label_for(obj)
|
87
117
|
label = Label.new(obj,(Hash === obj || Array === obj) ? "#{@indent || "\n"} " : ' ')
|
88
118
|
@previously_emitted_object[obj.object_id] = label
|
89
119
|
label
|
90
120
|
end
|
121
|
+
|
91
122
|
def first_time_only(obj)
|
92
123
|
if label = label_for(obj)
|
93
124
|
label.this_label_number ||= (@next_free_label_number += 1)
|
94
125
|
emit(label.reference)
|
95
126
|
else
|
96
|
-
|
127
|
+
with_structured_prefix(obj) do
|
128
|
+
emit(new_label_for(obj))
|
129
|
+
yield
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def with_structured_prefix(obj)
|
135
|
+
if @structured_key_prefix
|
136
|
+
unless obj.is_a?(String) and obj !~ /\n/
|
97
137
|
emit(@structured_key_prefix)
|
98
138
|
@structured_key_prefix = nil
|
99
139
|
end
|
100
|
-
emit(new_label_for(obj))
|
101
|
-
yield
|
102
140
|
end
|
141
|
+
yield
|
103
142
|
end
|
143
|
+
|
104
144
|
def emit(s)
|
105
145
|
@result << s
|
106
146
|
@recent_nl = false unless s.kind_of?(Label)
|
107
147
|
end
|
108
|
-
|
148
|
+
|
149
|
+
def nl(s = nil)
|
109
150
|
emit(@indent || "\n") unless @recent_nl
|
110
|
-
emit(s)
|
151
|
+
emit(s) if s
|
111
152
|
@recent_nl = true
|
112
153
|
end
|
154
|
+
|
113
155
|
def to_s
|
114
156
|
@result.join
|
115
157
|
end
|
158
|
+
|
116
159
|
def prefix_structured_keys(x)
|
117
160
|
@structured_key_prefix = x
|
118
161
|
yield
|
@@ -129,7 +172,7 @@ end
|
|
129
172
|
|
130
173
|
class Object
|
131
174
|
def to_yaml_properties
|
132
|
-
instance_variables
|
175
|
+
instance_variables # default YAML behaviour.
|
133
176
|
end
|
134
177
|
def yaml_property_munge(x)
|
135
178
|
x
|
@@ -172,7 +215,8 @@ end
|
|
172
215
|
|
173
216
|
class Symbol
|
174
217
|
def to_zaml(z)
|
175
|
-
z.emit(
|
218
|
+
z.emit("!ruby/sym ")
|
219
|
+
to_s.to_zaml(z)
|
176
220
|
end
|
177
221
|
end
|
178
222
|
|
@@ -227,64 +271,70 @@ class Exception
|
|
227
271
|
end
|
228
272
|
|
229
273
|
class String
|
230
|
-
ZAML_ESCAPES =
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
# each byte of the character results in an escaped string emitted to the
|
236
|
-
# YAML stream. When the YAML is de-serialized back into a String the bytes
|
237
|
-
# will be reconstructed properly into the unicode character.
|
238
|
-
self.to_ascii8bit.gsub( /\x5C/n, "\\\\\\" ). # Demi-kludge for Maglev/rubinius; the regexp should be /\\/ but parsetree chokes on that.
|
239
|
-
gsub( /"/n, "\\\"" ).
|
240
|
-
gsub( /([\x00-\x1F])/n ) { |x| ZAML_ESCAPES[ x.unpack("C")[0] ] }.
|
241
|
-
gsub( /([\x80-\xFF])/n ) { |x| "\\x#{x.unpack("C")[0].to_s(16)}" }
|
242
|
-
end
|
274
|
+
ZAML_ESCAPES = {
|
275
|
+
"\a" => "\\a", "\e" => "\\e", "\f" => "\\f", "\n" => "\\n",
|
276
|
+
"\r" => "\\r", "\t" => "\\t", "\v" => "\\v"
|
277
|
+
}
|
278
|
+
|
243
279
|
def to_zaml(z)
|
244
|
-
z.
|
245
|
-
hex_num = '0x[a-f\d]+'
|
246
|
-
float = '\d+\.?\d*'
|
247
|
-
num = "[-+]?(?:#{float}|#{hex_num})"
|
280
|
+
z.with_structured_prefix(self) do
|
248
281
|
case
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
282
|
+
when self == ''
|
283
|
+
z.emit('""')
|
284
|
+
when self.to_ascii8bit !~ /\A(?: # ?: non-capturing group (grouping with no back references)
|
285
|
+
[\x09\x0A\x0D\x20-\x7E] # ASCII
|
286
|
+
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|
287
|
+
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|
288
|
+
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|
289
|
+
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|
290
|
+
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
291
|
+
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|
292
|
+
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
293
|
+
)*\z/mnx
|
294
|
+
# Emit the binary tag, then recurse. Ruby splits BASE64 output at the 60
|
295
|
+
# character mark when packing strings, and we can wind up a multi-line
|
296
|
+
# string here. We could reimplement the multi-line string logic,
|
297
|
+
# but why would we - this does just as well for producing solid output.
|
298
|
+
z.emit("!binary ")
|
299
|
+
[self].pack("m*").to_zaml(z)
|
300
|
+
|
301
|
+
# Only legal UTF-8 characters can make it this far, so we are safe
|
302
|
+
# against emitting something dubious. That means we don't need to mess
|
303
|
+
# about, just emit them directly. --daniel 2012-07-14
|
304
|
+
when ((self =~ /\A[a-zA-Z\/][-\[\]_\/.a-zA-Z0-9]*\z/) and
|
305
|
+
(self !~ /^(?:true|false|yes|no|on|null|off)$/i))
|
306
|
+
# simple string literal, safe to emit unquoted.
|
307
|
+
z.emit(self)
|
308
|
+
when (self =~ /\n/ and self !~ /\A\s/ and self !~ /\s\z/)
|
309
|
+
# embedded newline, split line-wise in quoted string block form.
|
310
|
+
if self[-1..-1] == "\n" then z.emit('|+') else z.emit('|-') end
|
311
|
+
z.nested { split("\n",-1).each { |line| z.nl; z.emit(line) } }
|
312
|
+
else
|
313
|
+
# ...though we still have to escape unsafe characters.
|
314
|
+
escaped = gsub(/[\\"\x00-\x1F]/) do |c|
|
315
|
+
ZAML_ESCAPES[c] || "\\x#{c[0].ord.to_s(16)}"
|
316
|
+
end
|
317
|
+
z.emit("\"#{escaped}\"")
|
273
318
|
end
|
274
|
-
|
319
|
+
end
|
275
320
|
end
|
276
321
|
|
277
322
|
# Return a guranteed ASCII-8BIT encoding for Ruby 1.9 This is a helper
|
278
323
|
# method for other methods that perform regular expressions against byte
|
279
324
|
# sequences deliberately rather than dealing with characters.
|
280
325
|
# The method may or may not return a new instance.
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
326
|
+
if String.method_defined?(:encoding)
|
327
|
+
ASCII_ENCODING = Encoding.find("ASCII-8BIT")
|
328
|
+
def to_ascii8bit
|
329
|
+
if self.encoding == ASCII_ENCODING
|
330
|
+
self
|
331
|
+
else
|
332
|
+
self.dup.force_encoding(ASCII_ENCODING)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
else
|
336
|
+
def to_ascii8bit
|
337
|
+
self
|
288
338
|
end
|
289
339
|
end
|
290
340
|
end
|
@@ -325,7 +375,7 @@ end
|
|
325
375
|
class Time
|
326
376
|
def to_zaml(z)
|
327
377
|
# 2008-12-06 10:06:51.373758 -07:00
|
328
|
-
ms = ("%0.6f" % (usec * 1e-6))
|
378
|
+
ms = ("%0.6f" % (usec * 1e-6))[2..-1]
|
329
379
|
offset = "%+0.2i:%0.2i" % [utc_offset / 3600, (utc_offset / 60) % 60]
|
330
380
|
z.emit(self.strftime("%Y-%m-%d %H:%M:%S.#{ms} #{offset}"))
|
331
381
|
end
|