summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler/fileserver.rb
diff options
context:
space:
mode:
authorlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-09 00:49:35 +0000
committerlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-09 00:49:35 +0000
commit38975de420bfd2f1350e7e55a996db40bc05d0b8 (patch)
tree3b063f4dd72af8ba4e3221c01b0f94542e313f90 /lib/puppet/network/handler/fileserver.rb
parentebcb6b6df7af42632a6c1beaa1b60171ff32b61e (diff)
downloadpuppet-38975de420bfd2f1350e7e55a996db40bc05d0b8.tar.gz
puppet-38975de420bfd2f1350e7e55a996db40bc05d0b8.tar.xz
puppet-38975de420bfd2f1350e7e55a996db40bc05d0b8.zip
Introduces a new implicit 'modules' fileserver module, whose allow/deny can
be set from the fileserver.conf, but whose path is ignored and can therefore not be used directly in puppet:// URL's. When the fileserver looks for a file/directory, it first checks if the first part of the URL references an existing module. If one is found, a new temporary mount for that module is generated with the same permissions as the 'modules' module. If no matching puppet module is found, the fileserver behaves as it always has. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2278 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/network/handler/fileserver.rb')
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb49
1 files changed, 39 insertions, 10 deletions
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