summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/network')
-rw-r--r--lib/puppet/network/authconfig.rb7
-rw-r--r--lib/puppet/network/authorization.rb12
-rwxr-xr-xlib/puppet/network/authstore.rb4
-rw-r--r--lib/puppet/network/client.rb18
-rw-r--r--lib/puppet/network/formats.rb4
-rw-r--r--lib/puppet/network/handler.rb5
-rw-r--r--lib/puppet/network/handler/ca.rb10
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb62
-rwxr-xr-xlib/puppet/network/handler/report.rb3
-rw-r--r--lib/puppet/network/http/handler.rb4
-rw-r--r--lib/puppet/network/http/mongrel.rb2
-rw-r--r--lib/puppet/network/http/webrick.rb2
-rw-r--r--lib/puppet/network/http_pool.rb2
-rw-r--r--lib/puppet/network/http_server/webrick.rb3
-rw-r--r--lib/puppet/network/rest_authconfig.rb5
-rw-r--r--lib/puppet/network/rest_authorization.rb2
-rw-r--r--lib/puppet/network/server.rb2
-rw-r--r--lib/puppet/network/xmlrpc/client.rb5
-rw-r--r--lib/puppet/network/xmlrpc/webrick_servlet.rb10
19 files changed, 82 insertions, 80 deletions
diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb
index bf037fbcc..3ee4df306 100644
--- a/lib/puppet/network/authconfig.rb
+++ b/lib/puppet/network/authconfig.rb
@@ -6,7 +6,7 @@ module Puppet
class Network::AuthConfig < Puppet::Util::LoadedFile
def self.main
- unless defined? @main
+ unless defined?(@main)
@main = self.new()
end
@main
@@ -105,7 +105,7 @@ module Puppet
count += 1
next
when /^(?:(\[[\w.]+\])|(path)\s+((?:~\s+)?[^ ]+))\s*$/ # "namespace" or "namespace.method" or "path /path" or "path ~ regex"
- name = $1
+ name = $1
if $2 == "path"
name = $3
end
@@ -123,8 +123,7 @@ module Puppet
Puppet.err "Configuration error: Cannot read %s; cannot serve" % @file
#raise Puppet::Error, "Cannot read %s" % @config
rescue Errno::ENOENT => detail
- Puppet.err "Configuration error: '%s' does not exit; cannot serve" %
- @file
+ Puppet.err "Configuration error: '%s' does not exit; cannot serve" % @file
#raise Puppet::Error, "%s does not exit" % @config
#rescue FileServerError => detail
# Puppet.err "FileServer error: %s" % detail
diff --git a/lib/puppet/network/authorization.rb b/lib/puppet/network/authorization.rb
index eb7690db4..d65aeeb6a 100644
--- a/lib/puppet/network/authorization.rb
+++ b/lib/puppet/network/authorization.rb
@@ -10,7 +10,7 @@ module Puppet::Network
# Create our config object if necessary. This works even if
# there's no configuration file.
def authconfig
- unless defined? @authconfig
+ unless defined?(@authconfig)
@authconfig = Puppet::Network::AuthConfig.main()
end
@@ -20,9 +20,7 @@ module Puppet::Network
# Verify that our client has access. We allow untrusted access to
# puppetca methods but no others.
def authorized?(request)
- msg = "%s client %s access to %s" %
- [request.authenticated? ? "authenticated" : "unauthenticated",
- request, request.call]
+ msg = "%s client %s access to %s" % [request.authenticated? ? "authenticated" : "unauthenticated", request, request.call]
if request.authenticated?
if authconfig.exists?
@@ -57,8 +55,7 @@ module Puppet::Network
if handler_loaded?(request.handler)
return true
else
- Puppet.warning "Client %s requested unavailable functionality %s" %
- [request, request.handler]
+ Puppet.warning "Client %s requested unavailable functionality %s" % [request, request.handler]
return false
end
end
@@ -72,8 +69,7 @@ module Puppet::Network
end
unless authorized?(request)
raise InvalidClientRequest.new(
- "Host %s not authorized to call %s" %
- [request, request.call]
+ "Host %s not authorized to call %s" % [request, request.call]
)
end
end
diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb
index a7029a0a0..eb3400dd9 100755
--- a/lib/puppet/network/authstore.rb
+++ b/lib/puppet/network/authstore.rb
@@ -127,7 +127,7 @@ module Puppet
# Sort the declarations most specific first.
def <=>(other)
- compare(exact?, other.exact?) ||
+ compare(exact?, other.exact?) ||
compare(ip?, other.ip?) ||
((length != other.length) && (other.length <=> length)) ||
compare(deny?, other.deny?) ||
@@ -230,7 +230,7 @@ module Puppet
@name,@exact,@length,@pattern = *case value
when /^(?:#{IP})\/(\d+)$/ # 12.34.56.78/24, a001:b002::efff/120, c444:1000:2000::9:192.168.0.1/112
[:ip,:inexact,$1.to_i,IPAddr.new(value)]
- when /^(#{IP})$/ # 10.20.30.40,
+ when /^(#{IP})$/ # 10.20.30.40,
[:ip,:exact,nil,IPAddr.new(value)]
when /^(#{Octet}\.){1,3}\*$/ # an ip address with a '*' at the end
segments = value.split(".")[0..-2]
diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb
index 429e2563f..f53dd3a79 100644
--- a/lib/puppet/network/client.rb
+++ b/lib/puppet/network/client.rb
@@ -14,7 +14,7 @@ require 'net/http'
# us to never use ssl. Yay.
class Net::HTTP
def use_ssl?
- if defined? @use_ssl
+ if defined?(@use_ssl)
@use_ssl
else
false
@@ -50,7 +50,7 @@ class Puppet::Network::Client
# Determine what clients look for when being passed an object for local
# client/server stuff. E.g., you could call Client::CA.new(:CA => ca).
def self.drivername
- unless defined? @drivername
+ unless defined?(@drivername)
@drivername = self.name
end
@drivername
@@ -58,7 +58,7 @@ class Puppet::Network::Client
# Figure out the handler for our client.
def self.handler
- unless defined? @handler
+ unless defined?(@handler)
@handler = Puppet::Network::Handler.handler(self.name)
end
@handler
@@ -66,7 +66,7 @@ class Puppet::Network::Client
# The class that handles xmlrpc interaction for us.
def self.xmlrpc_client
- unless defined? @xmlrpc_client
+ unless defined?(@xmlrpc_client)
@xmlrpc_client = Puppet::Network::XMLRPCClient.handler_class(self.handler)
end
@xmlrpc_client
@@ -112,7 +112,7 @@ class Puppet::Network::Client
# Are we a local client?
def local?
- if defined? @local and @local
+ if defined?(@local) and @local
true
else
false
@@ -140,8 +140,7 @@ class Puppet::Network::Client
end
def run
- raise Puppet::DevError, "Client type %s did not override run" %
- self.class
+ raise Puppet::DevError, "Client type %s did not override run" % self.class
end
def scheduled?
@@ -168,9 +167,12 @@ class Puppet::Network::Client
# timer events here.
def start
# Create our timer. Puppet will handle observing it and such.
- timer = Puppet.newtimer(
+
+ timer = Puppet.newtimer(
+
:interval => Puppet[:runinterval],
:tolerance => 1,
+
:start? => true
) do
begin
diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb
index eec632d72..dfdb4cc67 100644
--- a/lib/puppet/network/formats.rb
+++ b/lib/puppet/network/formats.rb
@@ -65,13 +65,13 @@ Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_ya
end
def encode(text)
- requiring_zlib do
+ requiring_zlib do
Base64.encode64(Zlib::Deflate.deflate(text, Zlib::BEST_COMPRESSION))
end
end
def decode(yaml)
- requiring_zlib do
+ requiring_zlib do
YAML.load(Zlib::Inflate.inflate(Base64.decode64(yaml)))
end
end
diff --git a/lib/puppet/network/handler.rb b/lib/puppet/network/handler.rb
index f6a658662..95e3101f2 100644
--- a/lib/puppet/network/handler.rb
+++ b/lib/puppet/network/handler.rb
@@ -19,11 +19,10 @@ module Puppet::Network
# Return the xmlrpc interface.
def self.interface
- if defined? @interface
+ if defined?(@interface)
return @interface
else
- raise Puppet::DevError, "Handler %s has no defined interface" %
- self
+ raise Puppet::DevError, "Handler %s has no defined interface" % self
end
end
diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb
index de7a976c8..20d971007 100644
--- a/lib/puppet/network/handler/ca.rb
+++ b/lib/puppet/network/handler/ca.rb
@@ -19,7 +19,7 @@ class Puppet::Network::Handler
}
def autosign
- if defined? @autosign
+ if defined?(@autosign)
@autosign
else
Puppet[:autosign]
@@ -35,12 +35,11 @@ class Puppet::Network::Handler
# we only otherwise know how to handle files
unless autosign =~ /^\//
- raise Puppet::Error, "Invalid autosign value %s" %
- autosign.inspect
+ raise Puppet::Error, "Invalid autosign value %s" % autosign.inspect
end
unless FileTest.exists?(autosign)
- unless defined? @@warnedonautosign
+ unless defined?(@@warnedonautosign)
@@warnedonautosign = true
Puppet.info "Autosign is enabled but %s is missing" % autosign
end
@@ -124,8 +123,7 @@ class Puppet::Network::Handler
if @ca.getclientcsr(hostname)
Puppet.info "Not replacing existing request from %s" % hostname
else
- Puppet.notice "Host %s has a waiting certificate request" %
- hostname
+ Puppet.notice "Host %s has a waiting certificate request" % hostname
@ca.storeclientcsr(csr)
end
return ["", ""]
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 84af5ac55..a48d05d91 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -107,8 +107,7 @@ class Puppet::Network::Handler
if hash.include?(:Mount)
@passedconfig = true
unless hash[:Mount].is_a?(Hash)
- raise Puppet::DevError, "Invalid mount hash %s" %
- hash[:Mount].inspect
+ raise Puppet::DevError, "Invalid mount hash %s" % hash[:Mount].inspect
end
hash[:Mount].each { |dir, name|
@@ -159,8 +158,7 @@ class Puppet::Network::Handler
def mount(path, name)
if @mounts.include?(name)
if @mounts[name] != path
- raise FileServerError, "%s is already mounted at %s" %
- [@mounts[name].path, name]
+ raise FileServerError, "%s is already mounted at %s" % [@mounts[name].path, name]
else
# it's already mounted; no problem
return
@@ -219,8 +217,7 @@ class Puppet::Network::Handler
clientip = nil
end
unless mount.allowed?(client, clientip)
- mount.warning "%s cannot access %s" %
- [client, file]
+ mount.warning "%s cannot access %s" % [client, file]
raise Puppet::AuthorizationError, "Cannot access %s" % mount
end
end
@@ -283,8 +280,7 @@ class Puppet::Network::Handler
when /\[([-\w]+)\]/
name = $1
if newmounts.include?(name)
- raise FileServerError, "%s is already mounted as %s in %s" %
- [newmounts[name], name, @configuration.file]
+ raise FileServerError, "%s is already mounted as %s in %s" % [newmounts[name], name, @configuration.file]
end
mount = Mount.new(name)
newmounts[name] = mount
@@ -299,8 +295,7 @@ class Puppet::Network::Handler
begin
mount.path = value
rescue FileServerError => detail
- Puppet.err "Removing mount %s: %s" %
- [mount.name, detail]
+ Puppet.err "Removing mount %s: %s" % [mount.name, detail]
newmounts.delete(mount.name)
end
end
@@ -311,7 +306,10 @@ class Puppet::Network::Handler
mount.allow(val)
rescue AuthStoreError => detail
puts detail.backtrace if Puppet[:trace]
- raise FileServerError.new(detail.to_s,
+
+ raise FileServerError.new(
+ detail.to_s,
+
count, @configuration.file)
end
}
@@ -321,17 +319,18 @@ class Puppet::Network::Handler
mount.info "denying %s access" % val
mount.deny(val)
rescue AuthStoreError => detail
- raise FileServerError.new(detail.to_s,
+
+ raise FileServerError.new(
+ detail.to_s,
+
count, @configuration.file)
end
}
else
- raise FileServerError.new("Invalid argument '%s'" % var,
- count, @configuration.file)
+ raise FileServerError.new("Invalid argument '%s'" % var, count, @configuration.file)
end
else
- raise FileServerError.new("Invalid line '%s'" % line.chomp,
- count, @configuration.file)
+ raise FileServerError.new("Invalid line '%s'" % line.chomp, count, @configuration.file)
end
count += 1
}
@@ -340,8 +339,7 @@ class Puppet::Network::Handler
Puppet.err "FileServer error: Cannot read %s; cannot serve" % @configuration
#raise Puppet::Error, "Cannot read %s" % @configuration
rescue Errno::ENOENT => detail
- Puppet.err "FileServer error: '%s' does not exist; cannot serve" %
- @configuration
+ Puppet.err "FileServer error: '%s' does not exist; cannot serve" % @configuration
end
unless newmounts[MODULES]
@@ -368,9 +366,12 @@ class Puppet::Network::Handler
# object...
mount = PluginMount.new(PLUGINS)
# Yes, you're allowed to hate me for this.
- mount.instance_variable_set(:@declarations,
- newmounts[PLUGINS].instance_variable_get(:@declarations)
- )
+
+ mount.instance_variable_set(
+ :@declarations,
+
+ newmounts[PLUGINS].instance_variable_get(:@declarations)
+ )
newmounts[PLUGINS] = mount
end
@@ -379,8 +380,7 @@ class Puppet::Network::Handler
# pointing to the specific problem.
newmounts.each { |name, mount|
unless mount.valid?
- raise FileServerError, "Invalid mount %s" %
- name
+ raise FileServerError, "Invalid mount %s" % name
end
}
@mounts = newmounts
@@ -448,8 +448,7 @@ class Puppet::Network::Handler
if client
map = clientmap(client)
else
- Puppet.notice "No client; expanding '%s' with local host" %
- path
+ Puppet.notice "No client; expanding '%s' with local host" % path
# Else, use the local information
map = localmap()
end
@@ -465,7 +464,7 @@ class Puppet::Network::Handler
# Do we have any patterns in our path, yo?
def expandable?
- if defined? @expandable
+ if defined?(@expandable)
@expandable
else
false
@@ -515,8 +514,11 @@ class Puppet::Network::Handler
# the effort.
obj[:audit] = CHECKPARAMS
else
+
obj = Puppet::Type.type(:file).new(
+
:name => file_path(path, client),
+
:audit => CHECKPARAMS
)
@files[file_path(path, client)] = obj
@@ -542,11 +544,11 @@ class Puppet::Network::Handler
# Cache this manufactured map, since if it's used it's likely
# to get used a lot.
def localmap
- unless defined? @@localmap
+ unless defined?(@@localmap)
@@localmap = {
"h" => Facter.value("hostname"),
"H" => [Facter.value("hostname"),
- Facter.value("domain")].join("."),
+ Facter.value("domain")].join("."),
"d" => Facter.value("domain")
}
end
@@ -710,7 +712,7 @@ class Puppet::Network::Handler
end
def path_exists?(relpath, client = nil)
- !valid_modules(client).find { |mod| mod.plugin(relpath) }.nil?
+ !valid_modules(client).find { |mod| mod.plugin(relpath) }.nil?
end
def valid?
@@ -749,7 +751,7 @@ class Puppet::Network::Handler
end
def add_to_filetree(f, filetree)
- first, rest = f.split(File::SEPARATOR, 2)
+ first, rest = f.split(File::SEPARATOR, 2)
end
end
end
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index 8cfd8d83d..960b65f73 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -68,8 +68,7 @@ class Puppet::Network::Handler
if Puppet[:trace]
puts detail.backtrace
end
- Puppet.err "Report %s failed: %s" %
- [name, detail]
+ Puppet.err "Report %s failed: %s" % [name, detail]
end
else
Puppet.warning "No report named '%s'" % name
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index ab853665c..a76fefdcc 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -22,7 +22,7 @@ module Puppet::Network::HTTP::Handler
raise NotImplementedError
end
- # Which format to use when serializing our response or interpreting the request.
+ # Which format to use when serializing our response or interpreting the request.
# IF the client provided a Content-Type use this, otherwise use the Accept header
# and just pick the first value.
def format_to_use(request)
@@ -155,7 +155,7 @@ module Puppet::Network::HTTP::Handler
return result[:ip]
end
- private
+ private
def return_yaml_response(response, body)
set_content_type(response, Puppet::Network::FormatHandler.format("yaml"))
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb
index 6c39bb37f..8181600e3 100644
--- a/lib/puppet/network/http/mongrel.rb
+++ b/lib/puppet/network/http/mongrel.rb
@@ -33,7 +33,7 @@ class Puppet::Network::HTTP::Mongrel
@listening
end
- private
+ private
def setup_handlers
# Register our REST support at /
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index c0b736d44..effe92434 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -117,7 +117,7 @@ class Puppet::Network::HTTP::WEBrick
results
end
- private
+ private
def setup_handlers
# Set up the new-style protocols.
diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb
index 244f18b0d..980d3de13 100644
--- a/lib/puppet/network/http_pool.rb
+++ b/lib/puppet/network/http_pool.rb
@@ -62,7 +62,7 @@ module Puppet::Network::HttpPool
http.verify_callback = self.method(:ssl_verify_callback).to_proc
end
end
-
+
def self.ssl_verify_callback(peer_ok, x509_store_ctx)
if not peer_ok
Puppet.debug "OpenSSL: Error(#{x509_store_ctx.error}): #{x509_store_ctx.error_string}"
diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb
index e71d4ba14..fa7ce4872 100644
--- a/lib/puppet/network/http_server/webrick.rb
+++ b/lib/puppet/network/http_server/webrick.rb
@@ -108,8 +108,7 @@ module Puppet
# have a global state
# mount has to be called after the server is initialized
- servlet = Puppet::Network::XMLRPC::WEBrickServlet.new(
- handler_instances)
+ servlet = Puppet::Network::XMLRPC::WEBrickServlet.new( handler_instances)
self.mount("/RPC2", servlet)
end
diff --git a/lib/puppet/network/rest_authconfig.rb b/lib/puppet/network/rest_authconfig.rb
index 7c0ef9cf3..13ad8dbb4 100644
--- a/lib/puppet/network/rest_authconfig.rb
+++ b/lib/puppet/network/rest_authconfig.rb
@@ -35,7 +35,10 @@ module Puppet
# we're splitting the request in part because
# fail_on_deny could as well be called in the XMLRPC context
# with a ClientRequest.
- @rights.fail_on_deny(build_uri(request),
+
+ @rights.fail_on_deny(
+ build_uri(request),
+
:node => request.node,
:ip => request.ip,
:method => request.method,
diff --git a/lib/puppet/network/rest_authorization.rb b/lib/puppet/network/rest_authorization.rb
index 5dd4fb5e6..0cf4472f1 100644
--- a/lib/puppet/network/rest_authorization.rb
+++ b/lib/puppet/network/rest_authorization.rb
@@ -9,7 +9,7 @@ module Puppet::Network
# Create our config object if necessary. If there's no configuration file
# we install our defaults
def authconfig
- unless defined? @authconfig
+ unless defined?(@authconfig)
@authconfig = Puppet::Network::RestAuthConfig.main
end
diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb
index 01a55df36..2c899cf15 100644
--- a/lib/puppet/network/server.rb
+++ b/lib/puppet/network/server.rb
@@ -151,7 +151,7 @@ class Puppet::Network::Server
remove_pidfile
end
- private
+ private
def http_server
@http_server ||= http_server_class.new
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index f12d279d4..c5efe985d 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -174,12 +174,15 @@ module Puppet::Network
hash[:HTTPProxyPort] = nil
end
- super(
+
+ super(
+
hash[:Server],
hash[:Path],
hash[:Port],
hash[:HTTPProxyHost],
hash[:HTTPProxyPort],
+
nil, # user
nil, # password
true, # use_ssl
diff --git a/lib/puppet/network/xmlrpc/webrick_servlet.rb b/lib/puppet/network/xmlrpc/webrick_servlet.rb
index ec64c1c60..a03db01d1 100644
--- a/lib/puppet/network/xmlrpc/webrick_servlet.rb
+++ b/lib/puppet/network/xmlrpc/webrick_servlet.rb
@@ -10,7 +10,7 @@ module Puppet::Network::XMLRPC
# This is a hackish way to avoid an auth message every time we have a
# normal operation
def self.log(msg)
- unless defined? @logs
+ unless defined?(@logs)
@logs = {}
end
if @logs.include?(msg)
@@ -84,8 +84,11 @@ module Puppet::Network::XMLRPC
client = peer[2]
clientip = peer[3]
else
- raise ::XMLRPC::FaultException.new(
+
+ raise ::XMLRPC::FaultException.new(
+
ERR_UNCAUGHT_EXCEPTION,
+
"Could not retrieve client information"
)
end
@@ -103,8 +106,7 @@ module Puppet::Network::XMLRPC
Puppet.warning "Could not retrieve server name from cert"
else
unless client == nameary[1]
- Puppet.debug "Overriding %s with cert name %s" %
- [client, nameary[1]]
+ Puppet.debug "Overriding %s with cert name %s" % [client, nameary[1]]
client = nameary[1]
end
valid = true