summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorDavid Schmitt <david@dasz.at>2010-04-30 11:34:52 +0200
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit97c043f440115fcfd9d3ddaad59af5c8da875329 (patch)
tree8839b56dd3713b69e88b82f2031e41857615bc18 /lib/puppet
parentf80b4c73bb17af8b103cbc2562f8617755e93d3f (diff)
downloadpuppet-97c043f440115fcfd9d3ddaad59af5c8da875329.tar.gz
puppet-97c043f440115fcfd9d3ddaad59af5c8da875329.tar.xz
puppet-97c043f440115fcfd9d3ddaad59af5c8da875329.zip
Fix path handling
*) Use File.expand_path as indicator for being an absolute path *) Use basename instead of parsing the path manually
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type/file.rb3
-rw-r--r--lib/puppet/util/command_line.rb2
-rw-r--r--lib/puppet/util/settings/file_setting.rb6
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 2e249ad41..51865ef49 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -29,7 +29,8 @@ Puppet::Type.newtype(:file) do
isnamevar
validate do |value|
- unless value =~ /^#{File::SEPARATOR}/
+ # use underlying platform's convention to check for relative paths
+ unless File.expand_path(value) == value
fail Puppet::Error,"File paths must be fully qualified, not '#{value}'"
end
end
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 9003a0c1a..8a010bb76 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -62,7 +62,7 @@ module Puppet
private
def subcommand_and_args( zero, argv, stdin )
- zero = zero.gsub(/.*#{File::SEPARATOR}/,'').sub(/\.rb$/, '')
+ zero = File.basename(zero, '.rb')
if zero == 'puppet'
case argv.first
diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb
index 2dfbcf46e..732af0b09 100644
--- a/lib/puppet/util/settings/file_setting.rb
+++ b/lib/puppet/util/settings/file_setting.rb
@@ -49,9 +49,9 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
# the variable 'dir', or adding a slash at the end.
def munge(value)
# If it's not a fully qualified path...
- if value.is_a?(String) and value !~ /^\$/ and value !~ /^\// and value != 'false'
+ if value.is_a?(String) and value !~ /^\$/ and value != 'false'
# Make it one
- value = File.join(Dir.getwd, value)
+ value = File.expand_path(value)
end
if value.to_s =~ /\/$/
@type = :directory
@@ -83,7 +83,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
return nil unless path.is_a?(String)
# Make sure the paths are fully qualified.
- path = File.join(Dir.getwd, path) unless path =~ /^\//
+ path = File.expand_path(path)
return nil unless type == :directory or create_files? or File.exist?(path)
return nil if path =~ /^\/dev/