X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/3e290ce7eef9de6bad7d30b5855de14090b5edd2..8063bc3402bb1beab8ed85ecc25d19204e892060:/IkiWiki/Wrapper.pm diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index 8a6340f58..cf85738d6 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -38,11 +38,12 @@ sub gen_wrapper () { EOF } - my $test_receive=""; if ($config{test_receive}) { require IkiWiki::Receive; - $test_receive=IkiWiki::Receive::gen_wrapper(); } + + my @wrapper_hooks; + run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() }); my $check_commit_hook=""; my $pre_exec=""; @@ -93,10 +94,7 @@ EOF $configstring=~s/"/\\"/g; $configstring=~s/\n/\\n/g; - #translators: The first parameter is a filename, and the second is - #translators: a (probably not translated) error message. - open(OUT, ">$wrapper.c") || error(sprintf(gettext("failed to write %s: %s"), "$wrapper.c", $!));; - print OUT <<"EOF"; + writefile(basename("$wrapper.c"), dirname($wrapper), <<"EOF"); /* A wrapper for ikiwiki, can be safely made suid. */ #include #include @@ -123,7 +121,7 @@ int main (int argc, char **argv) { char *s; $check_commit_hook -$test_receive +@wrapper_hooks $envsave newenviron[i++]="HOME=$ENV{HOME}"; newenviron[i++]="WRAPPED_OPTIONS=$configstring"; @@ -147,7 +145,6 @@ $pre_exec exit(1); } EOF - close OUT; my $cc=exists $ENV{CC} ? possibly_foolish_untaint($ENV{CC}) : 'cc'; if (system($cc, "$wrapper.c", "-o", "$wrapper.new") != 0) {