summary refs log tree commit diff
path: root/nixos/modules/services/networking/flashpolicyd.nix
blob: 9c51b88ef6776d94fe86863023cb3b24b3419854 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.services.flashpolicyd;

  flashpolicyd = pkgs.stdenv.mkDerivation {
    name = "flashpolicyd-0.6";

    src = pkgs.fetchurl {
      name = "flashpolicyd_v0.6.zip";
      url = "https://download.adobe.com/pub/adobe/devnet/flashplayer/articles/socket_policy_files/flashpolicyd_v0.6.zip";
      sha256 = "16zk237233npwfq1m4ksy4g5lzy1z9fp95w7pz0cdlpmv0fv9sm3";
    };

    buildInputs = [ pkgs.unzip pkgs.perl ];

    installPhase = "mkdir $out; cp -pr * $out/; chmod +x $out/*/*.pl";
  };

  flashpolicydWrapper = pkgs.writeScriptBin "flashpolicyd"
    ''
      #! ${pkgs.runtimeShell}
      exec ${flashpolicyd}/Perl_xinetd/in.flashpolicyd.pl \
        --file=${pkgs.writeText "flashpolixy.xml" cfg.policy} \
        2> /dev/null
    '';

in

{

  ###### interface

  options = {

    services.flashpolicyd = {

      enable = mkOption {
        default = false;
        description =
          ''
            Whether to enable the Flash Policy server.  This is
            necessary if you want Flash applications to make
            connections to your server.
          '';
      };

      policy = mkOption {
        default =
          ''
            <?xml version="1.0"?>
            <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
            <cross-domain-policy>
              <site-control permitted-cross-domain-policies="master-only"/>
              <allow-access-from domain="*" to-ports="*" />
            </cross-domain-policy>
          '';
        description = "The policy to be served.  The default is to allow connections from any domain to any port.";
      };

    };

  };


  ###### implementation

  config = mkIf cfg.enable {

    services.xinetd.enable = true;

    services.xinetd.services = singleton
      { name = "flashpolicy";
        port = 843;
        unlisted = true;
        server = "${flashpolicydWrapper}/bin/flashpolicyd";
      };

  };

}