… | |
… | |
52 | while (@_) { |
52 | while (@_) { |
53 | my $type = shift; |
53 | my $type = shift; |
54 | |
54 | |
55 | my $fd = $type =~ s/^(\d+)// ? $1 : undef; |
55 | my $fd = $type =~ s/^(\d+)// ? $1 : undef; |
56 | |
56 | |
57 | # fd> |
|
|
58 | if ($type eq ">") { |
57 | if ($type eq ">") { |
59 | my ($pr, $pw) = AnyEvent::Util::portable_pipe; |
58 | my ($pr, $pw) = AnyEvent::Util::portable_pipe; |
60 | my $cb = shift; |
59 | my $cb = shift; |
61 | |
60 | |
62 | $cv->begin; |
61 | $cv->begin; |
… | |
… | |
74 | undef $w; $cv->end; |
73 | undef $w; $cv->end; |
75 | } |
74 | } |
76 | ; |
75 | ; |
77 | $redir{defined $fd ? $fd : 1} = $pw; |
76 | $redir{defined $fd ? $fd : 1} = $pw; |
78 | |
77 | |
|
|
78 | } elsif ($type eq "<") { |
|
|
79 | my ($pr, $pw) = AnyEvent::Util::portable_pipe; |
|
|
80 | my $cb = shift; |
|
|
81 | |
|
|
82 | #TODO |
|
|
83 | # $cv->begin; |
|
|
84 | # my $w; $w = AE::io $pw, 0, |
|
|
85 | # "SCALAR" eq ref $cb |
|
|
86 | # ? sub { |
|
|
87 | # my $len = syswrite $pr, $$cb, 8192, length $$cb |
|
|
88 | # and return; |
|
|
89 | # undef $w; $cv->end; |
|
|
90 | # } |
|
|
91 | # : sub { |
|
|
92 | # my $buf; |
|
|
93 | # sysread $pr, $buf, 8192 |
|
|
94 | # and return $cb->($buf); |
|
|
95 | # undef $w; $cv->end; |
|
|
96 | # } |
|
|
97 | # ; |
|
|
98 | # $redir{defined $fd ? $fd : 0} = $pr; |
|
|
99 | |
79 | } elsif ($type =~ s/^>//) { |
100 | } elsif ($type =~ s/^>//) { |
80 | push @exe, sub { |
101 | push @exe, sub { |
81 | open my $fh, ">", $type |
102 | open my $fh, ">", $type |
82 | or POSIX::_exit (125); |
103 | or POSIX::_exit (125); |
83 | $redir{defined $fd ? $fd : 1} = $fh; |
104 | $redir{defined $fd ? $fd : 1} = $fh; |
… | |
… | |
149 | $status |
170 | $status |
150 | and die "@$cmd: command failed with exit status $status."; |
171 | and die "@$cmd: command failed with exit status $status."; |
151 | } |
172 | } |
152 | |
173 | |
153 | sub gen_cert { |
174 | sub gen_cert { |
154 | my_run_cmd [qw(openssl req -new -nodes -x509 -days 3650 -batch -newkey rsa:2048 -keyout /dev/fd/3)], |
175 | my_run_cmd [qw(openssl req |
|
|
176 | -new -nodes -x509 -days 3650 |
|
|
177 | -newkey rsa:2048 -keyout /dev/fd/3 |
|
|
178 | -batch -subj /CN=AnyEvent::MP |
|
|
179 | )], |
155 | "</dev/null", |
180 | "</dev/null", |
156 | ">" , \my $cert, |
181 | ">" , \my $cert, |
157 | "3>", \my $key, |
182 | "3>", \my $key, |
158 | "2>/dev/null"; |
183 | "2>/dev/null"; |
159 | |
184 | |