summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-05-16 17:48:28 +0000
committerLuke Kanies <luke@madstop.com>2005-05-16 17:48:28 +0000
commit3a07a4d2f5a66b3919958c6bc8269b09c333cc8d (patch)
tree3f97f06152b6808593a7e7321e7acb8786331e05
parent12418e1c29895d96a756b2febc73e34b615d58d1 (diff)
downloadpuppet-3a07a4d2f5a66b3919958c6bc8269b09c333cc8d.tar.gz
puppet-3a07a4d2f5a66b3919958c6bc8269b09c333cc8d.tar.xz
puppet-3a07a4d2f5a66b3919958c6bc8269b09c333cc8d.zip
typesettings now correctly pass all the way through and can only run specified methods, using "allowedmethods"
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@254 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/blink/transportable.rb6
-rw-r--r--lib/blink/type.rb10
-rw-r--r--lib/blink/type/service.rb30
-rw-r--r--test/types/tc_basic.rb2
-rw-r--r--test/types/tc_service.rb2
5 files changed, 40 insertions, 10 deletions
diff --git a/lib/blink/transportable.rb b/lib/blink/transportable.rb
index 6154bf559..35f76ca7a 100644
--- a/lib/blink/transportable.rb
+++ b/lib/blink/transportable.rb
@@ -85,7 +85,11 @@ module Blink
@evalcount += 0
if type = Blink::Type.type(self.type)
# call the settings
- type.send(self.name,self.args)
+ if type.allowedmethod(self.name)
+ type.send(self.name,self.args)
+ else
+ Blink.error("%s does not respond to %s" % [self.type,self.name])
+ end
else
raise "Could not find object type %s" % setting.type
end
diff --git a/lib/blink/type.rb b/lib/blink/type.rb
index 1ea652182..50061047d 100644
--- a/lib/blink/type.rb
+++ b/lib/blink/type.rb
@@ -77,6 +77,16 @@ class Blink::Type < Blink::Element
#---------------------------------------------------------------
#---------------------------------------------------------------
+ def Type.allowedmethod(method)
+ if defined? @allowedmethods and @allowedmethods.include?(method)
+ return true
+ else
+ return false
+ end
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
# this is meant to be run multiple times, e.g., when a new
# type is defined at run-time
def Type.buildtypehash
diff --git a/lib/blink/type/service.rb b/lib/blink/type/service.rb
index ff2d1af56..d55efe76f 100644
--- a/lib/blink/type/service.rb
+++ b/lib/blink/type/service.rb
@@ -107,13 +107,7 @@ module Blink
@namevar = :name
@searchpaths = Array.new
-
- def Service.addpath(path)
- unless @searchpaths.include?(path)
- # XXX should we check to see if the path exists?
- @searchpaths.push(path)
- end
- end
+ @allowedmethods = [:setpath]
def Service.search(name)
@searchpaths.each { |path|
@@ -133,6 +127,28 @@ module Blink
raise "Could not find init script for '%s'" % name
end
+ def Service.setpath(*ary)
+ # verify each of the paths exists
+ @searchpaths = ary.find_all { |dir|
+ retvalue = false
+ begin
+ retvalue = ::File.stat(dir).directory?
+ rescue => detail
+ Blink.notice("Directory %s does not exist: %s" % [dir,detail])
+ # just ignore it
+ end
+ # disallow relative paths
+ #if dir !~ /^\//
+ # retvalue = false
+ #end
+ retvalue
+ }
+ #unless @searchpaths.include?(path)
+ # # XXX should we check to see if the path exists?
+ # @searchpaths.push(path)
+ #end
+ end
+
# it'd be nice if i didn't throw the output away...
# this command returns true if the exit code is 0, and returns
# false otherwise
diff --git a/test/types/tc_basic.rb b/test/types/tc_basic.rb
index f0030b950..b67cc0599 100644
--- a/test/types/tc_basic.rb
+++ b/test/types/tc_basic.rb
@@ -39,7 +39,7 @@ class TestBasic < Test::Unit::TestCase
:name => "sleeper",
:running => 1
)
- Blink::Type::Service.addpath(
+ Blink::Type::Service.setpath(
File.join($blinkbase,"examples/root/etc/init.d")
)
end
diff --git a/test/types/tc_service.rb b/test/types/tc_service.rb
index 4ea4faee1..d0e18cb25 100644
--- a/test/types/tc_service.rb
+++ b/test/types/tc_service.rb
@@ -25,7 +25,7 @@ class TestService < Test::Unit::TestCase
:name => "sleeper",
:running => 1
)
- Blink::Type::Service.addpath(
+ Blink::Type::Service.setpath(
File.join($blinkbase,"examples/root/etc/init.d")
)
end