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/filetype.rb
CHANGED
@@ -19,12 +19,10 @@ class Puppet::Util::FileType
|
|
19
19
|
def self.newfiletype(name, &block)
|
20
20
|
@filetypes ||= {}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
name,
|
22
|
+
klass = genclass(
|
23
|
+
name,
|
25
24
|
:block => block,
|
26
25
|
:prefix => "FileType",
|
27
|
-
|
28
26
|
:hash => @filetypes
|
29
27
|
)
|
30
28
|
|
@@ -81,6 +79,17 @@ class Puppet::Util::FileType
|
|
81
79
|
@path = path
|
82
80
|
end
|
83
81
|
|
82
|
+
# Arguments that will be passed to the execute method. Will set the uid
|
83
|
+
# to the target user if the target user and the current user are not
|
84
|
+
# the same
|
85
|
+
def cronargs
|
86
|
+
if uid = Puppet::Util.uid(@path) and uid == Puppet::Util::SUIDManager.uid
|
87
|
+
{:failonfail => true, :combine => true}
|
88
|
+
else
|
89
|
+
{:failonfail => true, :combine => true, :uid => @path}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
84
93
|
# Operate on plain files.
|
85
94
|
newfiletype(:flat) do
|
86
95
|
# Back the file up before replacing it.
|
@@ -155,7 +164,7 @@ class Puppet::Util::FileType
|
|
155
164
|
begin
|
156
165
|
@uid = Puppet::Util.uid(user)
|
157
166
|
rescue Puppet::Error => detail
|
158
|
-
raise Puppet::Error, "Could not retrieve user #{user}"
|
167
|
+
raise Puppet::Error, "Could not retrieve user #{user}: #{detail}", detail.backtrace
|
159
168
|
end
|
160
169
|
|
161
170
|
# XXX We have to have the user name, not the uid, because some
|
@@ -204,39 +213,41 @@ class Puppet::Util::FileType
|
|
204
213
|
newfiletype(:suntab) do
|
205
214
|
# Read a specific @path's cron tab.
|
206
215
|
def read
|
207
|
-
|
208
|
-
return "" if output.include?("can't open your crontab")
|
209
|
-
raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("you are not authorized to use cron")
|
210
|
-
return output
|
216
|
+
Puppet::Util.execute(%w{crontab -l}, cronargs)
|
211
217
|
rescue => detail
|
212
|
-
|
218
|
+
case detail.to_s
|
219
|
+
when /can't open your crontab/
|
220
|
+
return ""
|
221
|
+
when /you are not authorized to use cron/
|
222
|
+
raise Puppet::Error, "User #{@path} not authorized to use cron", detail.backtrace
|
223
|
+
else
|
224
|
+
raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}", detail.backtrace
|
225
|
+
end
|
213
226
|
end
|
214
227
|
|
215
228
|
# Remove a specific @path's cron tab.
|
216
229
|
def remove
|
217
|
-
|
230
|
+
Puppet::Util.execute(%w{crontab -r}, cronargs)
|
218
231
|
rescue => detail
|
219
|
-
|
232
|
+
raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}", detail.backtrace
|
220
233
|
end
|
221
234
|
|
222
235
|
# Overwrite a specific @path's cron tab; must be passed the @path name
|
223
236
|
# and the text with which to create the cron tab.
|
224
237
|
def write(text)
|
225
|
-
|
226
|
-
output_file = Tempfile.new("puppet")
|
227
|
-
fh = output_file.open
|
228
|
-
fh.print text
|
229
|
-
fh.close
|
230
|
-
|
231
|
-
# We have to chown the stupid file to the user.
|
232
|
-
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
233
|
-
|
238
|
+
output_file = Tempfile.new("puppet_suntab")
|
234
239
|
begin
|
235
|
-
|
240
|
+
output_file.print text
|
241
|
+
output_file.close
|
242
|
+
# We have to chown the stupid file to the user.
|
243
|
+
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
244
|
+
Puppet::Util.execute(["crontab", output_file.path], cronargs)
|
236
245
|
rescue => detail
|
237
|
-
raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}"
|
246
|
+
raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}", detail.backtrace
|
247
|
+
ensure
|
248
|
+
output_file.close
|
249
|
+
output_file.unlink
|
238
250
|
end
|
239
|
-
output_file.delete
|
240
251
|
end
|
241
252
|
end
|
242
253
|
|
@@ -244,37 +255,41 @@ class Puppet::Util::FileType
|
|
244
255
|
newfiletype(:aixtab) do
|
245
256
|
# Read a specific @path's cron tab.
|
246
257
|
def read
|
247
|
-
|
248
|
-
raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("You are not authorized to use the cron command")
|
249
|
-
return output
|
258
|
+
Puppet::Util.execute(%w{crontab -l}, cronargs)
|
250
259
|
rescue => detail
|
251
|
-
|
260
|
+
case detail.to_s
|
261
|
+
when /Cannot open a file in the .* directory/
|
262
|
+
return ""
|
263
|
+
when /You are not authorized to use the cron command/
|
264
|
+
raise Puppet::Error, "User #{@path} not authorized to use cron", detail.backtrace
|
265
|
+
else
|
266
|
+
raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}", detail.backtrace
|
267
|
+
end
|
252
268
|
end
|
253
269
|
|
254
270
|
# Remove a specific @path's cron tab.
|
255
271
|
def remove
|
256
|
-
|
272
|
+
Puppet::Util.execute(%w{crontab -r}, cronargs)
|
257
273
|
rescue => detail
|
258
|
-
|
274
|
+
raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}", detail.backtrace
|
259
275
|
end
|
260
276
|
|
261
277
|
# Overwrite a specific @path's cron tab; must be passed the @path name
|
262
278
|
# and the text with which to create the cron tab.
|
263
279
|
def write(text)
|
264
|
-
output_file = Tempfile.new("
|
265
|
-
fh = output_file.open
|
266
|
-
fh.print text
|
267
|
-
fh.close
|
268
|
-
|
269
|
-
# We have to chown the stupid file to the user.
|
270
|
-
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
280
|
+
output_file = Tempfile.new("puppet_aixtab")
|
271
281
|
|
272
282
|
begin
|
273
|
-
|
283
|
+
output_file.print text
|
284
|
+
output_file.close
|
285
|
+
# We have to chown the stupid file to the user.
|
286
|
+
File.chown(Puppet::Util.uid(@path), nil, output_file.path)
|
287
|
+
Puppet::Util.execute(["crontab", output_file.path], cronargs)
|
274
288
|
rescue => detail
|
275
|
-
raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}"
|
289
|
+
raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}", detail.backtrace
|
276
290
|
ensure
|
277
|
-
output_file.
|
291
|
+
output_file.close
|
292
|
+
output_file.unlink
|
278
293
|
end
|
279
294
|
end
|
280
295
|
end
|
@@ -8,14 +8,14 @@ module Puppet::Util::InstanceLoader
|
|
8
8
|
|
9
9
|
# Are we instance-loading this type?
|
10
10
|
def instance_loading?(type)
|
11
|
-
defined?(@autoloaders) and @autoloaders.include?(
|
11
|
+
defined?(@autoloaders) and @autoloaders.include?(type.intern)
|
12
12
|
end
|
13
13
|
|
14
14
|
# Define a new type of autoloading.
|
15
15
|
def instance_load(type, path, options = {})
|
16
16
|
@autoloaders ||= {}
|
17
17
|
@instances ||= {}
|
18
|
-
type =
|
18
|
+
type = type.intern
|
19
19
|
@instances[type] = {}
|
20
20
|
@autoloaders[type] = Puppet::Util::Autoload.new(self, path, options)
|
21
21
|
|
@@ -52,17 +52,17 @@ module Puppet::Util::InstanceLoader
|
|
52
52
|
|
53
53
|
# Return the instance hash for our type.
|
54
54
|
def instance_hash(type)
|
55
|
-
@instances[
|
55
|
+
@instances[type.intern]
|
56
56
|
end
|
57
57
|
|
58
58
|
# Return the Autoload object for a given type.
|
59
59
|
def instance_loader(type)
|
60
|
-
@autoloaders[
|
60
|
+
@autoloaders[type.intern]
|
61
61
|
end
|
62
62
|
|
63
63
|
# Retrieve an alread-loaded instance, or attempt to load our instance.
|
64
64
|
def loaded_instance(type, name)
|
65
|
-
name =
|
65
|
+
name = name.intern
|
66
66
|
return nil unless instances = instance_hash(type)
|
67
67
|
unless instances.include? name
|
68
68
|
if instance_loader(type).load(name)
|
@@ -96,7 +96,7 @@ class Puppet::Util::Instrumentation
|
|
96
96
|
# If no pattern is provided, then the listener will be called for every events
|
97
97
|
def self.new_listener(name, options = {}, &block)
|
98
98
|
Puppet.debug "new listener called #{name}"
|
99
|
-
name =
|
99
|
+
name = name.intern
|
100
100
|
listener = genclass(name, :hash => instance_hash(:listener), :block => block)
|
101
101
|
listener.send(:define_method, :name) do
|
102
102
|
name
|
@@ -144,15 +144,13 @@ class Puppet::Util::Instrumentation
|
|
144
144
|
|
145
145
|
def self.[](key)
|
146
146
|
synchronize {
|
147
|
-
key
|
148
|
-
@listeners[key]
|
147
|
+
@listeners[key.intern]
|
149
148
|
}
|
150
149
|
end
|
151
150
|
|
152
151
|
def self.[]=(key, value)
|
153
152
|
synchronize {
|
154
|
-
key =
|
155
|
-
@listeners[key] = value
|
153
|
+
@listeners[key.intern] = value
|
156
154
|
rehash
|
157
155
|
}
|
158
156
|
end
|
@@ -2,9 +2,7 @@ module Puppet::Util::LogPaths
|
|
2
2
|
# return the full path to us, for logging and rollback
|
3
3
|
# some classes (e.g., FileTypeRecords) will have to override this
|
4
4
|
def path
|
5
|
-
@path ||= pathbuilder
|
6
|
-
|
7
|
-
"/" + @path.join("/")
|
5
|
+
@path ||= '/' + pathbuilder.join('/')
|
8
6
|
end
|
9
7
|
|
10
8
|
def source_descriptors
|
@@ -17,13 +17,13 @@ require "yaml"
|
|
17
17
|
require "puppet/util/zaml.rb"
|
18
18
|
|
19
19
|
class Symbol
|
20
|
-
def to_zaml(z)
|
21
|
-
z.emit("!ruby/sym ")
|
22
|
-
to_s.to_zaml(z)
|
23
|
-
end
|
24
20
|
def <=> (other)
|
25
21
|
self.to_s <=> other.to_s
|
26
|
-
end
|
22
|
+
end unless method_defined? '<=>'
|
23
|
+
|
24
|
+
def intern
|
25
|
+
self
|
26
|
+
end unless method_defined? 'intern'
|
27
27
|
end
|
28
28
|
|
29
29
|
[Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls|
|
@@ -91,6 +91,14 @@ if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2'
|
|
91
91
|
}
|
92
92
|
end
|
93
93
|
|
94
|
+
class Fixnum
|
95
|
+
# Returns the int itself. This method is intended for compatibility to
|
96
|
+
# character constant in Ruby 1.9. 1.8.5 is missing it; add it.
|
97
|
+
def ord
|
98
|
+
self
|
99
|
+
end unless method_defined? 'ord'
|
100
|
+
end
|
101
|
+
|
94
102
|
class Array
|
95
103
|
# Ruby < 1.8.7 doesn't have this method but we use it in tests
|
96
104
|
def combination(num)
|
@@ -109,9 +117,27 @@ end
|
|
109
117
|
|
110
118
|
|
111
119
|
class Symbol
|
112
|
-
|
113
|
-
|
114
|
-
|
120
|
+
# So, it turns out that one of the biggest memory allocation hot-spots in
|
121
|
+
# our code was using symbol-to-proc - because it allocated a new instance
|
122
|
+
# every time it was called, rather than caching.
|
123
|
+
#
|
124
|
+
# Changing this means we can see XX memory reduction...
|
125
|
+
if method_defined? :to_proc
|
126
|
+
alias __original_to_proc to_proc
|
127
|
+
def to_proc
|
128
|
+
@my_proc ||= __original_to_proc
|
129
|
+
end
|
130
|
+
else
|
131
|
+
def to_proc
|
132
|
+
@my_proc ||= Proc.new {|*args| args.shift.__send__(self, *args) }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Defined in 1.9, absent in 1.8, and used for compatibility in various
|
137
|
+
# places, typically in third party gems.
|
138
|
+
def intern
|
139
|
+
return self
|
140
|
+
end unless method_defined? :intern
|
115
141
|
end
|
116
142
|
|
117
143
|
|
data/lib/puppet/util/platform.rb
CHANGED
data/lib/puppet/util/posix.rb
CHANGED
@@ -60,7 +60,7 @@ module Puppet::Util::POSIX
|
|
60
60
|
|
61
61
|
# Determine what the field name is for users and groups.
|
62
62
|
def idfield(space)
|
63
|
-
case
|
63
|
+
case space.intern
|
64
64
|
when :gr, :group; return :gid
|
65
65
|
when :pw, :user, :passwd; return :uid
|
66
66
|
else
|
@@ -70,7 +70,7 @@ module Puppet::Util::POSIX
|
|
70
70
|
|
71
71
|
# Determine what the method is to get users and groups by id
|
72
72
|
def methodbyid(space)
|
73
|
-
case
|
73
|
+
case space.intern
|
74
74
|
when :gr, :group; return :getgrgid
|
75
75
|
when :pw, :user, :passwd; return :getpwuid
|
76
76
|
else
|
@@ -80,7 +80,7 @@ module Puppet::Util::POSIX
|
|
80
80
|
|
81
81
|
# Determine what the method is to get users and groups by name
|
82
82
|
def methodbyname(space)
|
83
|
-
case
|
83
|
+
case space.intern
|
84
84
|
when :gr, :group; return :getgrnam
|
85
85
|
when :pw, :user, :passwd; return :getpwnam
|
86
86
|
else
|
@@ -25,7 +25,7 @@ module Puppet::Util::ProviderFeatures
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize(name, docs, hash)
|
28
|
-
self.name =
|
28
|
+
self.name = name.intern
|
29
29
|
self.docs = docs
|
30
30
|
hash = symbolize_options(hash)
|
31
31
|
set_options(hash)
|
@@ -149,8 +149,7 @@ module Puppet::Util::ProviderFeatures
|
|
149
149
|
@feature_module.send(:define_method, :has_features) do |*names|
|
150
150
|
@declared_features ||= []
|
151
151
|
names.each do |name|
|
152
|
-
|
153
|
-
@declared_features << name
|
152
|
+
@declared_features << name.intern
|
154
153
|
end
|
155
154
|
end
|
156
155
|
# Aaah, grammatical correctness
|
data/lib/puppet/util/rdoc.rb
CHANGED
@@ -24,9 +24,10 @@ module Puppet::Util::RDoc
|
|
24
24
|
|
25
25
|
# specify our own format & where to output
|
26
26
|
options = [ "--fmt", "puppet",
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
"--quiet",
|
28
|
+
"--exclude", "/modules/[^/]*/files/.*$",
|
29
|
+
"--exclude", "/modules/[^/]*/templates/.*$",
|
30
|
+
"--op", outputdir ]
|
30
31
|
|
31
32
|
options << "--force-update" if Options::OptionList.options.any? { |o| o[0] == "--force-update" }
|
32
33
|
options += [ "--charset", charset] if charset
|
data/lib/puppet/util/selinux.rb
CHANGED
@@ -136,6 +136,21 @@ module Puppet::Util::SELinux
|
|
136
136
|
nil
|
137
137
|
end
|
138
138
|
|
139
|
+
########################################################################
|
140
|
+
# Internal helper methods from here on in, kids. Don't fiddle.
|
141
|
+
private
|
142
|
+
|
143
|
+
# Check filesystem a path resides on for SELinux support against
|
144
|
+
# whitelist of known-good filesystems.
|
145
|
+
# Returns true if the filesystem can support SELinux labels and
|
146
|
+
# false if not.
|
147
|
+
def selinux_label_support?(file)
|
148
|
+
fstype = find_fs(file)
|
149
|
+
return false if fstype.nil?
|
150
|
+
filesystems = ['ext2', 'ext3', 'ext4', 'gfs', 'gfs2', 'xfs', 'jfs']
|
151
|
+
filesystems.include?(fstype)
|
152
|
+
end
|
153
|
+
|
139
154
|
# Internal helper function to read and parse /proc/mounts
|
140
155
|
def read_mounts
|
141
156
|
mounts = ""
|
@@ -171,46 +186,26 @@ module Puppet::Util::SELinux
|
|
171
186
|
mntpoint
|
172
187
|
end
|
173
188
|
|
174
|
-
|
175
|
-
|
176
|
-
path, rest = path.dirname, [path.basename] + rest while ! path.exist?
|
177
|
-
File.join( path.realpath, *rest )
|
178
|
-
end
|
179
|
-
|
180
|
-
def parent_directory(path)
|
181
|
-
Pathname.new(path).dirname.to_s
|
182
|
-
end
|
183
|
-
|
184
|
-
# Internal helper function to return which type of filesystem a
|
185
|
-
# given file path resides on
|
189
|
+
# Internal helper function to return which type of filesystem a given file
|
190
|
+
# path resides on
|
186
191
|
def find_fs(path)
|
187
|
-
unless
|
188
|
-
|
192
|
+
return nil unless mounts = read_mounts
|
193
|
+
|
194
|
+
# cleanpath eliminates useless parts of the path (like '.', or '..', or
|
195
|
+
# multiple slashes), without touching the filesystem, and without
|
196
|
+
# following symbolic links. This gives the right (logical) tree to follow
|
197
|
+
# while we try and figure out what file-system the target lives on.
|
198
|
+
path = Pathname(path).cleanpath
|
199
|
+
unless path.absolute?
|
200
|
+
raise Puppet::DevError, "got a relative path in SELinux find_fs: #{path}"
|
189
201
|
end
|
190
202
|
|
191
|
-
#
|
192
|
-
|
193
|
-
|
194
|
-
# Just in case: return something if you're down to "/" or ""
|
195
|
-
# Remove the last slash and everything after it,
|
196
|
-
# and repeat with that as the file for the next loop through.
|
197
|
-
path = realpath(path)
|
198
|
-
while not path.empty?
|
199
|
-
return mnts[path] if mnts.has_key?(path)
|
200
|
-
path = parent_directory(path)
|
203
|
+
# Now, walk up the tree until we find a match for that path in the hash.
|
204
|
+
path.ascend do |segment|
|
205
|
+
return mounts[segment.to_s] if mounts.has_key?(segment.to_s)
|
201
206
|
end
|
202
|
-
mnts['/']
|
203
|
-
end
|
204
207
|
|
205
|
-
|
206
|
-
|
207
|
-
# Returns true if the filesystem can support SELinux labels and
|
208
|
-
# false if not.
|
209
|
-
def selinux_label_support?(file)
|
210
|
-
fstype = find_fs(file)
|
211
|
-
return false if fstype.nil?
|
212
|
-
filesystems = ['ext2', 'ext3', 'ext4', 'gfs', 'gfs2', 'xfs', 'jfs']
|
213
|
-
filesystems.include?(fstype)
|
208
|
+
# Should never be reached...
|
209
|
+
return mounts['/']
|
214
210
|
end
|
215
|
-
|
216
211
|
end
|