Debian Codegraph @

src/stunnel3.in

raw
1 #!/usr/bin/perl
2 #
3 # stunnel3 Perl wrapper to use stunnel 3.x syntax in stunnel >=4.05
4 # Copyright (C) 1998-2018 Michal Trojnara <[email protected]>
5 # Version: 2.03
6 # Date: 2011.10.22
7 #
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by the
10 # Free Software Foundation; either version 2 of the License, or (at your
11 # option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, see <http://www.gnu.org/licenses>.
20
21 use POSIX;
22 use Getopt::Std;
23
24 # Configuration - path to stunnel (version >=4.05)
25 $stunnel_bin='@bindir@/stunnel';
26
27 # stunnel3 script body begins here
28 ($read_fd, $write_fd)=POSIX::pipe();
29 $pid=fork;
30 die "Can't fork" unless defined $pid;
31 if($pid) { # parent
32 POSIX::close($write_fd);
33 exec "$stunnel_bin -fd $read_fd";
34 die "$stunnel_bin exec failed";
35 }
36 # child
37 POSIX::close($read_fd);
38 open(STUNNEL, ">&$write_fd");
39 # comment out the next line to see the config file
40 select(STUNNEL);
41
42 getopts('cTWfD:O:o:C:p:v:a:A:t:N:u:n:E:R:B:I:d:s:g:P:r:L:l:');
43
44 print("client = yes\n") if defined $opt_c;
45 print("transparent = yes\n") if defined $opt_T;
46 print("RNDoverwrite = yes\n") if defined $opt_W;
47 print("foreground = yes\n") if defined $opt_f;
48 print("debug = $opt_D\n") if defined $opt_D;
49 print("socket = $opt_O\n") if defined $opt_O;
50 print("output = $opt_o\n") if defined $opt_o;
51 print("ciphers = $opt_C\n") if defined $opt_C;
52 print("cert = $opt_p\n") if defined $opt_p;
53 print("verify = $opt_v\n") if defined $opt_v;
54 print("CApath = $opt_a\n") if defined $opt_a;
55 print("CAfile = $opt_A\n") if defined $opt_A;
56 print("session = $opt_t\n") if defined $opt_t;
57 print("service = $opt_N\n") if defined $opt_N;
58 print("ident = $opt_u\n") if defined $opt_u;
59 print("protocol = $opt_n\n") if defined $opt_n;
60 print("EGD = $opt_E\n") if defined $opt_E;
61 print("RNDfile = $opt_R\n") if defined $opt_R;
62 print("RNDbytes = $opt_B\n") if defined $opt_B;
63 print("local = $opt_I\n") if defined $opt_I;
64 print("accept = $opt_d\n") if defined $opt_d;
65 print("setuid = $opt_s\n") if defined $opt_s;
66 print("setgid = $opt_g\n") if defined $opt_g;
67 print("pid = $opt_P\n") if defined $opt_P;
68 print("connect = $opt_r\n") if defined $opt_r;
69 print("pty = yes\n"), $opt_l=$opt_L if defined $opt_L;
70 print("exec = $opt_l\nexecArgs = " . join(' ', $opt_l, @ARGV) . "\n") if defined $opt_l;
71 print("[stunnel3]\n") if defined $opt_d;
72
73 close(STUNNEL);
74
75 # stunnel3 script body ends here