flashpolicyd.rb

Path: flashpolicyd.rb
Last Update: Wed Oct 07 21:43:09 +0100 2009

Synopsis

flashpolicyd: Serve Adobe Flash Policy XML files to clients

Description

Server to serve up flash policy xml files for flash clients since player version 9,0,124,0. (Player 9 update 3)

See www.adobe.com/devnet/flashplayer/articles/fplayer9_security_04.html for more information, this needs to run as root since it should listen on port 843 which on a unix machine needs root to listen on that socket.

Signals

  • USR1 signal prints a single line stat message, during normal running this stat will be printed every 30 minutes by default, settable using —logfreq
  • USR2 signal dumps the current threads and their statusses
  • HUP signal will toggle debug mode which will print more lines in the log file
  • TERM signal will exit the process closing all the sockets

Usage

flashpolicyd [OPTIONS]

—help, -h:

  Show Help

—verbose

  Turns on verbose logging to log file - can also be turned on and off at runtime using -HUP signals

—xml

  XML File to Serve to clients, read at startup only

—timeout, -t

  If a request does not complete within this time, close the socket,
  default is 10 seconds

—logfreq, -l

  How often to log stats to log file, default 1800 seconds

—logfile

  Where to write log lines too

Download and Further Information

Latest versions, installation documentation and other related info can be found at www.devco.net/pubwiki/FlashPolicyd

Author

R.I.Pienaar <rip@devco.net>

Required files

socket   logger   ostruct   thread   timeout   getoptlong   rdoc/ri/ri_paths   rdoc/usage  

Methods

Public Instance methods

Goes into the background, chdir‘s to /tmp, and redirect all input/output to null Beginning Ruby p. 489-490

[Source]

     # File flashpolicyd.rb, line 353
353: def daemonize
354:   fork do
355:     Process.setsid
356:     exit if fork
357:     Dir.chdir('/tmp')
358:     STDIN.reopen('/dev/null')
359:     STDOUT.reopen('/dev/null', 'a')
360:     STDERR.reopen('/dev/null', 'a')
361: 
362:     trap("TERM") { 
363:       @logger.debug("Caught TERM signal") 
364:       exit
365:     }
366:     yield
367:   end
368: end

Returns an array of days, hrs, mins and seconds given a second figure The Ruby Way - Page 227

[Source]

     # File flashpolicyd.rb, line 372
372: def sec2dhms(secs)
373:   time = secs.round
374:   sec = time % 60
375:   time /= 60
376:   
377:   mins = time % 60
378:   time /= 60
379: 
380:   hrs = time % 24
381:   time /= 24
382: 
383:   days = time
384:   [days, hrs, mins, sec]
385: end

[Validate]