flashpolicyd.rb
# The main logic of client handling, waits for @timeout seconds to receive a null terminated
# request containing "policy-file-request" and sends back the data, else marks the client as
# bogus and close the connection.
#
# Any exception caught during this should mark a client as bogus
The main logic of client handling, waits for @timeout seconds to receive a null terminated
request containing "policy-file-request" and sends back the data, else marks the client as
bogus and close the connection.

Any exception caught during this should mark a client as bogus
The main logic of client handling waits for @timeout seconds to receive a null terminated request containing " policy - file - request " and sends back the data else marks the client as bogus and close the connection . Any exception caught during this should mark a client as bogus
def serve(connection)
    client = connection.client
    $/ = "\000"
    begin
      Timeout.timeout(@timeout.to_i) do
        loop do
          request = client.gets
          if request =~ /policy-file-request/
            client.puts(@xml)
            debug("Sent xml data to client")
            break
          end
        end
      end
    rescue Timeout::Error
      bogusclient("connection timed out after #{@timeout} seconds", connection)
    rescue Errno::ENOTCONN => e
      warn("Unexpected disconnection while handling request")
    rescue Errno::ECONNRESET => e
      warn("Connection reset by peer")
    rescue Exception => e
      bogusclient("Unexpected #{e.class} exception: #{e}", connection)
    end
  end
def serve ( connection ) client = connection . client $/ = "\000" begin Timeout . timeout ( @timeout . to_i ) do loop do request = client . gets if request =~ / policy-file-request / client . puts ( @xml ) debug ( "Sent xml data to client" ) break end end end rescue Timeout :: Error bogusclient ( "connection timed out after #{@timeout} seconds" , connection ) rescue Errno :: ENOTCONN => e warn ( "Unexpected disconnection while handling request" ) rescue Errno :: ECONNRESET => e warn ( "Connection reset by peer" ) rescue Exception => e bogusclient ( "Unexpected #{e.class} exception: #{e}" , connection ) end end
The main logic of client handling, waits for @timeout seconds to receive a null terminated
request containing "policy-file-request" and sends back the data, else marks the client as
bogus and close the connection.
The main logic of client handling waits for @timeout seconds to receive a null terminated request containing " policy - file - request " and sends back the data else marks the client as bogus and close the connection .
# Flash clients send a null terminate request # run this in a timeout block, clients will have --timeout seconds to complete the transaction or go away
connection
<not_specific>