OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: r...@openpkg.org Module: openpkg-src Date: 17-Sep-2009 22:07:27 Branch: HEAD Handle: 2009091721072700 Added files: openpkg-src/flashpolicyd flashpolicyd.pl flashpolicyd.spec flashpolicyd.xml rc.flashpolicyd Log: new package: flashpolicyd 20090917 (Adobe Flash Socket Policy Server) Summary: Revision Changes Path 1.1 +99 -0 openpkg-src/flashpolicyd/flashpolicyd.pl 1.1 +105 -0 openpkg-src/flashpolicyd/flashpolicyd.spec 1.1 +9 -0 openpkg-src/flashpolicyd/flashpolicyd.xml 1.1 +58 -0 openpkg-src/flashpolicyd/rc.flashpolicyd ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/flashpolicyd/flashpolicyd.pl ============================================================================ $ cvs diff -u -r0 -r1.1 flashpolicyd.pl --- /dev/null 2009-09-17 22:07:21 +0200 +++ flashpolicyd.pl 2009-09-17 22:07:27 +0200 @@ -0,0 +1,99 @@ +#!/usr/bin/env perl +## +## flashpolicyd.pl -- Adobe Flash Policy File Server +## Copyright (c) 2005 Adobe Systems Incorporated +## Copyright (c) 2009 Ralf S. Engelschall <r...@engelschall.com> +## + +use strict; +use Socket; + +my $NULLBYTE = pack('c', 0); +my $uid = 65534; +my $gid = 65534; +my $host = "0.0.0.0"; +my $port = 843; +my $cfgfile; +my $logfile; +my $content; + +while (my $arg = shift @ARGV) { + if ($arg =~ m/^--host=(\d+)$/) { + $host = $1; + } + elsif ($arg =~ m/^--port=(\d+)$/) { + $port = $1; + } + elsif ($arg =~ m/^--cfg=(.*)/) { + $cfgfile = $1; + } + elsif ($arg =~ m/^--log=(.*)/) { + $logfile = $1; + } + elsif ($arg =~ m/^--uid=(.*)/) { + $uid = $1; + } + elsif ($arg =~ m/^--gid=(.*)/) { + $gid = $1; + } +} +unless ($cfgfile) { + die "Usage: flashpolicyd [--host=IP] [--port=N] --cfg=FILE [--log=FILE] [--uid=N] [--gid=N]\n"; +} + +-f $cfgfile or die "No such file: '$cfgfile'\n"; +-s $cfgfile < 10_000 or die "File probably too large to be a policy file: '$cfgfile'\n"; + +local $/ = undef; +open POLICYFILE, "<$cfgfile" or die "Can't open '$cfgfile': $!\n"; +$content = <POLICYFILE>; +close POLICYFILE; + +$content =~ m/cross-domain-policy/ or die "Not a valid policy file: '$cfgfile'\n"; + +socket(LISTENSOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die "socket() error: $!"; +setsockopt(LISTENSOCK, SOL_SOCKET, SO_REUSEADDR, pack('l', 1)) or die "setsockopt() error: $!"; +bind(LISTENSOCK, sockaddr_in($port, $host eq "0.0.0.0" ? INADDR_ANY : inet_aton($host))) or die "bind() error: $!"; +listen(LISTENSOCK, SOMAXCONN) or die "listen() error: $!"; + +$< = $uid; +$( = $gid; +$> = $<; +$) = $(; +umask(022); + +sub logbook { + my ($msg) = @_; + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time()); + open LOGFILE, ">>$logfile" or die "Can't open '$logfile': $!\n"; + printf(LOGFILE "[%04d-%02d-%02dT%02d:%02d:%02d] %s\n", 1900+$year, $mon, $mday, $hour, $min, $sec, $msg); + close LOGFILE +} + +logbook("startup (listening at $host:$port, running under $uid/$gid)"); + +while (my $clientAddr = accept(CONNSOCK, LISTENSOCK)) { + my ($clientPort, $clientIp) = sockaddr_in($clientAddr); + my $clientIpStr = inet_ntoa($clientIp); + logbook("[$clientIpStr:$clientPort] connection opened"); + + local $/ = $NULLBYTE; + my $request = <CONNSOCK>; + chomp $request; + + if ($request ne '<policy-file-request/>') { + $request =~ s/([^a-zA-Z0-9<>\/]+)/sprintf("\\x%02x", ord($1))/sge; + logbook("[$clientIpStr:$clientPort] unrecognized request: \"$request\""); + close CONNSOCK; + next; + } + + logbook("[$clientIpStr:$clientPort] send response"); + + print CONNSOCK $content; + print CONNSOCK $NULLBYTE; + close CONNSOCK; + + logbook("[$clientIpStr:$clientPort] connection closed"); +} + @@ . patch -p0 <<'@@ .' Index: openpkg-src/flashpolicyd/flashpolicyd.spec ============================================================================ $ cvs diff -u -r0 -r1.1 flashpolicyd.spec --- /dev/null 2009-09-17 22:07:21 +0200 +++ flashpolicyd.spec 2009-09-17 22:07:27 +0200 @@ -0,0 +1,105 @@ +## +## flashpolicyd.spec -- OpenPKG RPM Package Specification +## Copyright (c) 2000-2009 OpenPKG Foundation e.V. <http://openpkg.net/> +## +## Permission to use, copy, modify, and distribute this software for +## any purpose with or without fee is hereby granted, provided that +## the above copyright notice and this permission notice appear in all +## copies. +## +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## SUCH DAMAGE. +## + +# package information +Name: flashpolicyd +Summary: Adobe Flash Socket Policy Server +URL: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html +Vendor: Adobe +Packager: OpenPKG Foundation e.V. +Distribution: OpenPKG Community +Class: EVAL +Group: Networking +License: Open Source +Version: 20090917 +Release: 20090917 + +# list of sources +Source0: flashpolicyd.pl +Source1: flashpolicyd.xml +Source2: rc.flashpolicyd + +# build information +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +BuildPreReq: OpenPKG, openpkg >= 20060823 +PreReq: OpenPKG, openpkg >= 20060823, perl +AutoReq: no +AutoReqProv: no + +%description + This is a standalone Adobe Flash Policy Server. + +%track + prog flashpolicyd = { + disable + version = %{version} + url = http://www.openpkg.org/ + regex = .* + } + +%prep + %setup -q -T -c + +%build + +%install + rm -rf $RPM_BUILD_ROOT + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/sbin \ + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ + $RPM_BUILD_ROOT%{l_prefix}/etc/flashpolicyd \ + $RPM_BUILD_ROOT%{l_prefix}/var/flashpolicyd + %{l_shtool} install -c -m 755 \ + -e 's;/usr/bin/env perl;%{l_prefix}/bin/perl;g' \ + %{SOURCE flashpolicyd.pl} $RPM_BUILD_ROOT%{l_prefix}/sbin/flashpolicyd + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE rc.flashpolicyd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ + %{l_shtool} install -c -m 755 \ + %{SOURCE flashpolicyd.xml} $RPM_BUILD_ROOT%{l_prefix}/etc/flashpolicyd/ + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ + %{l_files_std} \ + '%config %{l_prefix}/etc/flashpolicyd/*' \ + '%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/flashpolicyd' + +%files -f files + +%clean + rm -rf $RPM_BUILD_ROOT + +%post + if [ $1 -eq 2 ]; then + # after upgrade, restart service + eval `%{l_rc} flashpolicyd status 2>/dev/null` + [ ".$flashpolicyd_active" = .yes ] && %{l_rc} flashpolicyd restart + fi + exit 0 + +%preun + # before erase, stop service and remove log files + if [ $1 -eq 0 ]; then + %{l_rc} flashpolicyd stop 2>/dev/null + rm -f $RPM_INSTALL_PREFIX/var/flashpolicyd/* >/dev/null 2>&1 || true + fi + exit 0 + @@ . patch -p0 <<'@@ .' Index: openpkg-src/flashpolicyd/flashpolicyd.xml ============================================================================ $ cvs diff -u -r0 -r1.1 flashpolicyd.xml --- /dev/null 2009-09-17 22:07:21 +0200 +++ flashpolicyd.xml 2009-09-17 22:07:27 +0200 @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Adobe Cross-Domain Policy Specification + http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html --> +<cross-domain-policy + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd"> + <site-control permitted-cross-domain-policies="master-only"/> + <allow-access-from domain="*.example.com" to-ports="*"/> +</cross-domain-policy> @@ . patch -p0 <<'@@ .' Index: openpkg-src/flashpolicyd/rc.flashpolicyd ============================================================================ $ cvs diff -u -r0 -r1.1 rc.flashpolicyd --- /dev/null 2009-09-17 22:07:21 +0200 +++ rc.flashpolicyd 2009-09-17 22:07:27 +0200 @@ -0,0 +1,58 @@ +...@l_prefix@/bin/openpkg rc +## +## rc.flashpolicyd -- Run-Commands +## + +%config + flashpolicyd_enable="$openpkg_rc_def" + flashpolicyd_host="127.0.0.1" + flashpolicyd_port="843" + flashpolicyd_log_rotsteps="10" + flashpolicyd_log_rotminsize="10M" + flashpolicyd_log_rotcomplevel="9" + flashpolicyd_log_rotprolog="true" + flashpolicyd_log_rotepilog="true" + +%common + flashpolicyd_cfgfile="@l_prefix@/etc/flashpolicyd/flashpolicyd.xml" + flashpolicyd_pidfile="@l_prefix@/var/flashpolicyd/flashpolicyd.pid" + flashpolicyd_logfile="@l_prefix@/var/flashpolicyd/flashpolicyd.log" + flashpolicyd_signal () { + [ -f $flashpolicyd_pidfile ] && kill -$1 `cat $flashpolicyd_pidfile` + } + +%status -u @l_susr@ -o + flashpolicyd_usable="unknown" + flashpolicyd_active="no" + rcService flashpolicyd enable yes && \ + flashpolicyd_signal 0 && flashpolicyd_active="yes" + echo "flashpolicyd_enable=\"$flashpolicyd_enable\"" + echo "flashpolicyd_usable=\"$flashpolicyd_usable\"" + echo "flashpolicyd_active=\"$flashpolicyd_active\"" + +%start -u @l_susr@ + rcService flashpolicyd enable yes || exit 0 + rcService flashpolicyd active yes && exit 0 + ( nohup @l_prefix@/sbin/flashpolicyd \ + --host=$flashpolicyd_host \ + --port=$flashpolicyd_port \ + --cfg=$flashpolicyd_cfgfile \ + --log=$flashpolicyd_logfile \ + --uid="@l_nuid@" \ + --gid="@l_ngid@" \ + </dev/null >/dev/null 2>&1 & + echo $! >$flashpolicyd_pidfile + ) >/dev/null 2>&1 + +%stop -u @l_susr@ + rcService flashpolicyd enable yes || exit 0 + rcService flashpolicyd active no && exit 0 + flashpolicyd_signal TERM + sleep 2 + rm -f $flashpolicyd_pidfile >/dev/null 2>&1 || true + +%restart -u @l_susr@ + rcService flashpolicyd enable yes || exit 0 + rcService flashpolicyd active no && exit 0 + rc flashpolicyd stop start + @@ . ______________________________________________________________________ OpenPKG http://openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org