* Fix a forkbomb in various calls to IPC::Open2, which has a highly
braindead interface. Closes: #389383master
parent
48e004acb1
commit
9f45c3080e
|
@ -4,7 +4,6 @@ package IkiWiki::Plugin::googlecalendar;
|
|||
use warnings;
|
||||
use strict;
|
||||
use IkiWiki;
|
||||
use IPC::Open2;
|
||||
|
||||
sub import { #{{{
|
||||
hook(type => "preprocess", id => "googlecalendar",
|
||||
|
|
|
@ -19,19 +19,11 @@ sub import { #{{{
|
|||
sub sanitize (@) { #{{{
|
||||
my %params=@_;
|
||||
|
||||
my $tries=10;
|
||||
my $pid;
|
||||
while (1) {
|
||||
eval {
|
||||
my $sigpipe=0;
|
||||
$SIG{PIPE}=sub { $sigpipe=1 };
|
||||
$pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no');
|
||||
};
|
||||
last unless $@;
|
||||
$tries--;
|
||||
if ($tries < 1) {
|
||||
debug("failed to run tidy: $@");
|
||||
return $params{content};
|
||||
}
|
||||
}
|
||||
|
||||
# open2 doesn't respect "use open ':utf8'"
|
||||
binmode (IN, ':utf8');
|
||||
binmode (OUT, ':utf8');
|
||||
|
@ -44,6 +36,9 @@ sub sanitize (@) { #{{{
|
|||
close IN;
|
||||
waitpid $pid, 0;
|
||||
|
||||
return $params{content} if $sigpipe;
|
||||
$SIG{PIPE}="DEFAULT";
|
||||
|
||||
return $ret;
|
||||
} # }}}
|
||||
|
||||
|
|
|
@ -63,18 +63,11 @@ sub genmap ($) { #{{{
|
|||
# TODO: should really add the png to renderedfiles and call
|
||||
# check_overwrite, but currently renderedfiles
|
||||
# only supports listing one file per page.
|
||||
my $tries=10;
|
||||
my $pid;
|
||||
while (1) {
|
||||
eval {
|
||||
my $sigpipe=0;;
|
||||
$SIG{PIPE}=sub { $sigpipe=1 };
|
||||
$pid=open2(*IN, *OUT, "dot -Tpng -o '$config{destdir}/$params{page}.png' -Tcmapx");
|
||||
};
|
||||
last unless $@;
|
||||
$tries--;
|
||||
if ($tries < 1) {
|
||||
return "failed to run dot: $@";
|
||||
}
|
||||
}
|
||||
|
||||
# open2 doesn't respect "use open ':utf8'"
|
||||
binmode (IN, ':utf8');
|
||||
binmode (OUT, ':utf8');
|
||||
|
@ -101,7 +94,13 @@ sub genmap ($) { #{{{
|
|||
<IN>.
|
||||
"</object>";
|
||||
close IN;
|
||||
|
||||
waitpid $pid, 0;
|
||||
$SIG{PIPE}="DEFAULT";
|
||||
if ($sigpipe) {
|
||||
return "[[linkmap failed to run dot]]";
|
||||
}
|
||||
|
||||
return $ret;
|
||||
} #}}}
|
||||
|
||||
|
|
|
@ -43,21 +43,11 @@ sub htmlize (@) { #{{{
|
|||
my %params=@_;
|
||||
my $content=$params{content};
|
||||
|
||||
my $tries=10;
|
||||
my $pid;
|
||||
while (1) {
|
||||
eval {
|
||||
# Try to call python and run our command
|
||||
$pid=open2(*IN, *OUT, "python", "-c", $pyCmnd)
|
||||
or return $content;
|
||||
};
|
||||
last unless $@;
|
||||
$tries--;
|
||||
if ($tries < 1) {
|
||||
debug("failed to run python to convert rst: $@");
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
my $sigpipe=0;
|
||||
$SIG{PIPE}=sub { $sigpipe=1 };
|
||||
$pid=open2(*IN, *OUT, "python", "-c", $pyCmnd);
|
||||
|
||||
# open2 doesn't respect "use open ':utf8'"
|
||||
binmode (IN, ':utf8');
|
||||
binmode (OUT, ':utf8');
|
||||
|
@ -70,6 +60,9 @@ sub htmlize (@) { #{{{
|
|||
close IN;
|
||||
waitpid $pid, 0;
|
||||
|
||||
return $content if $sigpipe;
|
||||
$SIG{PIPE}="DEFAULT";
|
||||
|
||||
return $ret;
|
||||
} # }}}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ ikiwiki (1.28) UNRELEASED; urgency=low
|
|||
|
||||
* inline: Add ability to sort by page name, based on a patch from
|
||||
Benjamin A'Lee.
|
||||
* Fix a forkbomb in various calls to IPC::Open2, which has a highly
|
||||
braindead interface. Closes: #389383
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 25 Sep 2006 17:06:39 -0400
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 25 Sep 2006 17:22:52 -0400
|
||||
|
||||
ikiwiki (1.27) unstable; urgency=low
|
||||
|
||||
|
|
Loading…
Reference in New Issue