2010-03-01 01:28:13 +01:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'sbdb'
|
|
|
|
|
|
|
|
# Secure Worker. Unsafe code in a sandbox.
|
|
|
|
class Worker
|
|
|
|
class Box
|
|
|
|
def self.start e, c
|
|
|
|
Thread.new c, &new( e).method( :run)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
this.untaint
|
|
|
|
e.taint
|
|
|
|
$SAFE = 4
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize e
|
|
|
|
@emit = e
|
|
|
|
end
|
|
|
|
|
|
|
|
def emit f, k, v
|
|
|
|
@emit.emit f, k, v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def emit f, k, v
|
|
|
|
@out.push [f, k, v]
|
|
|
|
end
|
|
|
|
|
|
|
|
def initalize i, o
|
|
|
|
@in, @out, @funcs = i, o, {}
|
|
|
|
super method(:run)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
$SAFE = 3
|
|
|
|
@in.each do |o|
|
|
|
|
@funcs[:]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
SBDB::Env.new 'conf' do |conf|
|
|
|
|
SBDB::Env.new 'logs' do |logs|
|
2010-03-17 13:22:00 +01:00
|
|
|
SBDB::Env.new 'persist' do |persist|
|
2010-03-02 00:51:15 +01:00
|
|
|
test = cache[ 'test']
|
2010-03-01 01:28:13 +01:00
|
|
|
while line = logs[ 'newids'].get( nil, "\0\0\0\0", nil, SBDB::CONSUME_WAIT)
|
2010-03-17 13:22:00 +01:00
|
|
|
type, obj = line.unpack 'Na*'
|
|
|
|
case type
|
|
|
|
when 11
|
|
|
|
sid, log = obj.unpack 'Na*'
|
|
|
|
parser = conf[ 'sids.cnf', 'parser'][sid]
|
|
|
|
end
|
2010-03-01 01:28:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|