summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/file_serving/base.rb5
-rw-r--r--lib/puppet/file_serving/indirection_hooks.rb1
-rw-r--r--lib/puppet/indirector/request.rb4
-rw-r--r--lib/puppet/type/file.rb20
-rwxr-xr-xlib/puppet/type/file/source.rb4
5 files changed, 28 insertions, 6 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index 1927b95d6..e936b5e75 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -49,7 +49,10 @@ class Puppet::FileServing::Base
# Set our base path.
attr_reader :path
def path=(path)
- raise ArgumentError.new("Paths must be fully qualified") unless path =~ /^#{::File::SEPARATOR}/
+ unless path =~ /^#{::File::SEPARATOR}/ or path =~ /^[a-z]:[\/\\]/i
+ raise ArgumentError.new("Paths must be fully qualified")
+ end
+
@path = path
end
diff --git a/lib/puppet/file_serving/indirection_hooks.rb b/lib/puppet/file_serving/indirection_hooks.rb
index 499767c41..bdcc8865e 100644
--- a/lib/puppet/file_serving/indirection_hooks.rb
+++ b/lib/puppet/file_serving/indirection_hooks.rb
@@ -13,6 +13,7 @@ module Puppet::FileServing::IndirectionHooks
# Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol.
return PROTOCOL_MAP["file"] if request.key =~ /^#{::File::SEPARATOR}/
+ return PROTOCOL_MAP["file"] if request.key =~ /^[a-z]:[\/\\]/i
return PROTOCOL_MAP["file"] if request.protocol == "file"
# We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet'
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index fd8d654dd..0388bd31a 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -76,7 +76,9 @@ class Puppet::Indirector::Request
# because it rewrites the key. We could otherwise strip server/port/etc
# info out in the REST class, but it seemed bad design for the REST
# class to rewrite the key.
- if key.to_s =~ /^\w+:\/\// # it's a URI
+ if key.to_s =~ /^[a-z]:[\/\\]/i # It's an absolute path for Windows.
+ @key = key
+ elsif key.to_s =~ /^\w+:\/\// # it's a URI
set_uri_key(key)
else
@key = key
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 5398621f5..d3c66bc02 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -23,7 +23,7 @@ Puppet::Type.newtype(:file) do
location, rather than using native resources, please contact
Puppet Labs and we can hopefully work with you to develop a
native resource to support what you are doing.
-
+
**Autorequires:** If Puppet is managing the user or group that owns a file, the file resource will autorequire them. If Puppet is managing any parent directories of a file, the file resource will autorequire them."
def self.title_patterns
@@ -36,7 +36,7 @@ Puppet::Type.newtype(:file) do
validate do |value|
# accept various path syntaxes: lone slash, posix, win32, unc
- unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^[A-Za-z]:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
+ unless (Puppet.features.posix? and value =~ /^\//) or (value =~ /^[A-Za-z]:\// or value =~ /^\/\/[^\/]+\/[^\/]+/)
fail Puppet::Error, "File paths must be fully qualified, not '#{value}'"
end
end
@@ -44,7 +44,21 @@ Puppet::Type.newtype(:file) do
# convert the current path in an index into the collection and the last
# path name. The aim is to use less storage for all common paths in a hierarchy
munge do |value|
- path, name = ::File.split(value.gsub(/\/+/,'/'))
+ # We need to save off, and remove the volume designator in the
+ # path if it is there, since File.split does not handle paths
+ # with volume designators properly, except when run on Windows.
+ # Since we are potentially compiling a catalog for a Windows
+ # machine on a non-Windows master, we need to handle this
+ # ourselves.
+ optional_volume_designator = value.match(/^([a-z]:)[\/\\].*/i)
+ value_without_designator = value.sub(/^(?:[a-z]:)?(.*)/i, '\1')
+
+ path, name = ::File.split(value_without_designator.gsub(/\/+/,'/'))
+
+ if optional_volume_designator
+ path = optional_volume_designator[1] + path
+ end
+
{ :index => Puppet::FileCollection.collection.index(path), :name => name }
end
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 39f85e2ad..8653a8f7a 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -72,7 +72,7 @@ module Puppet
self.fail "Could not understand source #{source}: #{detail}"
end
- self.fail "Cannot use URLs of type '#{uri.scheme}' as source for fileserving" unless uri.scheme.nil? or %w{file puppet}.include?(uri.scheme)
+ self.fail "Cannot use URLs of type '#{uri.scheme}' as source for fileserving" unless uri.scheme.nil? or %w{file puppet}.include?(uri.scheme) or (Puppet.features.microsoft_windows? and uri.scheme =~ /^[a-z]$/i)
end
end
@@ -180,6 +180,8 @@ module Puppet
private
def uri
+ return nil if metadata.source =~ /^[a-z]:[\/\\]/i # Abspath for Windows
+
@uri ||= URI.parse(URI.escape(metadata.source))
end
end