Leser: 1
7 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/usr/bin/perl # # in.flashpolicyd.pl # Simple socket policy file server # # Usage: in.flashpolicyd.pl -file=FILE # Logs to stderr # use strict; my $NULLBYTE = pack( 'c', 0 ); my $filePath; my $content; ### READ ARGS while ( my $arg = shift @ARGV ) { if ( $arg =~ m/^--file=(.*)/ ) { $filePath = $1; } } unless ( $filePath ) { die "Usage: in.flashpolicyd.pl --file=FILE\n"; } ### READ FILE -f $filePath or die "No such file: '$filePath'\n"; -s $filePath < 10_000 or die "File probably too large to be a policy file: '$filePath'\n"; local $/ = undef; open POLICYFILE, "<$filePath" or die "Can't open '$filePath': $!\n"; $content = <POLICYFILE>; close POLICYFILE; $content =~ m/cross-domain-policy/ or die "Not a valid policy file: '$filePath'\n"; ### HANDLE CONNECTIONS local $/ = $NULLBYTE; my $request = <STDIN>; chomp $request; if ( $request eq '<policy-file-request/>' ) { print STDERR "Valid request received\n"; } else { print STDERR "Unrecognized request: $request\n\n"; exit; } print STDOUT $content; print STDERR "Sent policy file\n\n"; # End of file.
echo '<policy-file-request/>' | /usr/local/sbin/in.flashpolicyd.pl --file=/stuff/flashpolicy.xml
Unrecognized request: <policy-file-request/>
1 2 3 4 5 6 7 8 9 10 11 12 13
local $/ = $NULLBYTE; my $request = <STDIN>; chomp $request; if ( $request eq '<policy-file-request/>' ) { print STDERR "Valid request received\n"; } else { print STDERR "Unrecognized request: $request\n\n"; exit; }
1 2 3 4 5 6
{ local $/ = undef; open POLICYFILE, "<$filePath" or die "Can't open '$filePath': $!\n"; $content = <POLICYFILE>; close POLICYFILE; }
1
2
3
4
5
6
08/5/5@16:02:24: START: flashpolicy from=xxx.xxx.xxx.xxx
08/5/5@16:06:44: EXIT: flashpolicy status=0 duration=260(sec)
08/5/5@16:08:04: START: flashpolicy from=xxx.xxx.xxx.xxx
08/5/5@16:08:50: EXIT: flashpolicy status=0 duration=46(sec)
08/5/5@16:10:06: START: flashpolicy from=xxx.xxx.xxx.xxx
08/5/5@16:11:10: START: flashpolicy from=xxx.xxx.xxx.xxx
print STDOUT $content;
perl -e 'print "<policy-file-request/>\0"' | /usr/local/sbin/in.flashpolicyd.pl --file=/stuff/flashpolicy.xml
7 Einträge, 1 Seite |