summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/modules.rb5
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb49
2 files changed, 44 insertions, 10 deletions
diff --git a/lib/puppet/modules.rb b/lib/puppet/modules.rb
index 2d48a6a4e..3d071b05a 100644
--- a/lib/puppet/modules.rb
+++ b/lib/puppet/modules.rb
@@ -2,6 +2,7 @@
class Puppet::Module
TEMPLATES = "templates"
+ FILES = "files"
# Return an array of paths by splitting the +modulepath+ config
# parameter. Only consider paths that are absolute and existing
@@ -68,5 +69,9 @@ class Puppet::Module
return File::join(path, TEMPLATES, strip(file))
end
+ def files
+ return File::join(path, FILES)
+ end
+
private :initialize
end
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 6def09837..1dd6ad793 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -11,6 +11,9 @@ class Puppet::Network::Handler
CHECKPARAMS = [:mode, :type, :owner, :group, :checksum]
+ # Special filserver module for puppet's module system
+ MODULES = "modules"
+
@interface = XMLRPC::Service::Interface.new("fileserver") { |iface|
iface.add_method("string describe(string, string)")
iface.add_method("string list(string, string, boolean, array)")
@@ -263,12 +266,16 @@ class Puppet::Network::Handler
value = $2
case var
when "path":
- begin
- mount.path = value
- rescue FileServerError => detail
- Puppet.err "Removing mount %s: %s" %
- [mount.name, detail]
- newmounts.delete(mount.name)
+ if mount.name == MODULES
+ Puppet.warning "The '#{MODULES}' module can not have a path. Ignoring attempt to set it"
+ else
+ begin
+ mount.path = value
+ rescue FileServerError => detail
+ Puppet.err "Removing mount %s: %s" %
+ [mount.name, detail]
+ newmounts.delete(mount.name)
+ end
end
when "allow":
value.split(/\s*,\s*/).each { |val|
@@ -312,6 +319,12 @@ class Puppet::Network::Handler
# Puppet.err "FileServer error: %s" % detail
end
+ unless newmounts[MODULES]
+ mount = Mount.new(MODULES)
+ mount.allow("*")
+ newmounts[MODULES] = mount
+ end
+
# Verify each of the mounts are valid.
# We let the check raise an error, so that it can raise an error
# pointing to the specific problem.
@@ -375,8 +388,13 @@ class Puppet::Network::Handler
tmp = $1
path = dir.sub(%r{/#{tmp}/?}, '')
- unless mount = @mounts[tmp]
- raise FileServerError, "Fileserver module '%s' not mounted" % tmp
+ mod = Puppet::Module::find(tmp)
+ if mod
+ mount = @mounts[MODULES].copy(mod, mod.files)
+ else
+ unless mount = @mounts[tmp]
+ raise FileServerError, "Fileserver module '%s' not mounted" % tmp
+ end
end
else
raise FileServerError, "Fileserver error: Invalid path '%s'" % dir
@@ -579,9 +597,20 @@ class Puppet::Network::Handler
# Verify our configuration is valid. This should really check to
# make sure at least someone will be allowed, but, eh.
def valid?
- return false unless @path
+ if name == MODULES
+ return @path.nil?
+ else
+ return ! @path.nil?
+ end
+ end
- return true
+ # Return a new mount with the same properties as +self+, except
+ # with a different name and path.
+ def copy(name, path)
+ result = self.clone
+ result.path = path
+ result.instance_variable_set(:@name, name)
+ return result
end
end
end