I looked into fixing the temporary file exploits in the Perl tools (bug
1599), but I didn't really get the point of using temporary files at
all. You can just build the script in a string. See the attached
patch for an example. If this is acceptable, I'll fix up the other
scripts as well.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
diff -ur ../slony1-1.2.0.orig/tools/altperl/slonik_subscribe_set.pl ./tools/altperl/slonik_subscribe_set.pl
--- ../slony1-1.2.0.orig/tools/altperl/slonik_subscribe_set.pl 2005-05-31 18:11:05.000000000 +0200
+++ ./tools/altperl/slonik_subscribe_set.pl 2006-10-20 19:50:47.000000000 +0200
@@ -45,10 +45,10 @@
get_set($set) or die "Non-existent set specified.\n";
-$FILE="/tmp/slonik-subscribe.$$";
-open(SLONIK, ">$FILE");
-print SLONIK genheader();
-print SLONIK " try {\n";
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " try {\n";
if ($DSN[$node]) {
my $provider = $SET_ORIGIN;
@@ -61,15 +61,14 @@
} else {
$forward = "yes";
}
- print SLONIK " subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
+ $slonik .= " subscribe set (id = $set, provider = $provider, receiver = $node, forward = $forward);\n";
} else {
die "Node $node not found\n";
}
-print SLONIK " }\n";
-print SLONIK " on error {\n";
-print SLONIK " exit 1;\n";
-print SLONIK " }\n";
-print SLONIK " echo 'Subscribed nodes to set $set';\n";
-close SLONIK;
-run_slonik_script($FILE);
+$slonik .= " }\n";
+$slonik .= " on error {\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'Subscribed nodes to set $set';\n";
+run_slonik_script($slonik);
diff -ur ../slony1-1.2.0.orig/tools/altperl/slon-tools.pm ./tools/altperl/slon-tools.pm
--- ../slony1-1.2.0.orig/tools/altperl/slon-tools.pm 2005-11-15 19:09:59.000000000 +0100
+++ ./tools/altperl/slon-tools.pm 2006-10-20 20:03:13.000000000 +0200
@@ -83,18 +83,15 @@
# then invokes it and deletes it
sub run_slonik_script {
my ($script) = @_;
- chomp $script;
open(OUT, ">>$LOGDIR/slonik_scripts.log");
my $now = `date`;
chomp $now;
print OUT "# -------------------------------------------------------------\n";
print OUT "# Script: $script submitted at $now \n";
print OUT "# -------------------------------------------------------------\n";
+ print OUT $script;
close OUT;
- `cat $script >> $LOGDIR/slonik_scripts.log`;
- #print `slonik < $script`;
- print `cat $script`;
- unlink($script);
+ print $script;
}
sub ps_args {
_______________________________________________
Slony1-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/slony1-general