Permalink
Browse files

very minor changes in queue names were all that is required to use ne…

…w rabbitmq ACL's

for making nanites secure. Mappers will now have root on the system and must be
started before any nanites are started, and now nanites can only publish messages
to the public queues like registration and heartbeat but cannot bind to them
so cannot read any other nanites messages this way. So now we can run multi-tenant
clusters where the mappers are root on everthing but each nanite is self contained
and separate form the others.
  • Loading branch information...
1 parent 777a715 commit f6df48f6a3658b970df68e2253447b1e0f152ae7 Ezra Zygmuntowicz committed Feb 1, 2009
Showing with 23 additions and 3 deletions.
  1. +20 −0 lib/nanite.rb
  2. +3 −3 lib/nanite/agent.rb
View
@@ -17,6 +17,26 @@
require 'nanite/console'
require 'nanite/agent'
+
+# monkey patch to the amqp gem that adds :no_declare => true option for new
+# Exchange objects. This allows us to send messeages to exchanges that are
+# declared by the mappers and that we have no configuration priviledges on.
+# temporary uyntil we get this into amqp proper
+MQ::Exchange.class_eval do
+ def initialize mq, type, name, opts = {}
+ @mq = mq
+ @type, @name = type, name
+ @mq.exchanges[@name = name] ||= self
+ @key = opts[:key]
+
+ @mq.callback{
+ @mq.send Protocol::Exchange::Declare.new({ :exchange => name,
+ :type => type,
+ :nowait => true }.merge(opts))
+ } unless name == "amq.#{type}" or name == '' or opts[:no_declare]
+ end
+end
+
module Nanite
VERSION = '0.2.0' unless defined?(Nanite::VERSION)
View
@@ -14,15 +14,15 @@ class Agent
# 'fanout'.
def send_ping
ping = Ping.new(identity, status_proc.call, identity)
- amq.fanout('heartbeat').publish(dump_packet(ping))
+ amq.fanout('heartbeat', :no_declare => true).publish(dump_packet(ping))
end
# Sends a services advertisement message to the 'registration' exchange of type
# 'fanout'.
def advertise_services
log.debug "advertise_services: #{dispatcher.all_services.inspect}"
reg = Register.new(identity, dispatcher.all_services, status_proc.call)
- amq.fanout('registration').publish(dump_packet(reg))
+ amq.fanout('registration', :no_declare => true).publish(dump_packet(reg))
end
# Starts interactive Nanite shell.
@@ -91,7 +91,7 @@ def initialize(options = {})
@log = opts[:log]
@log_dir = opts[:log_dir]
@format = opts[:format] || :marshal
- @identity = opts[:identity] || Nanite.gensym
+ @identity = "nanite-#{opts[:identity] || Nanite.gensym}"
@host = opts[:host] || '0.0.0.0'
@vhost = opts[:vhost]
@file_root = opts[:file_root] || "#{root}/files"

0 comments on commit f6df48f

Please sign in to comment.