summaryrefslogtreecommitdiff
path: root/libpiny/lib
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2018-09-27 18:24:00 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2018-09-27 18:24:00 -0700
commit407c6763f8f7e3838bd5e17c3bb5b039bdbfc92f (patch)
tree4be383d3b3a8ac112f2581d6174dc7285fb7ff6f /libpiny/lib
parent9f5b32d7833cce9171bc0035657693c7d73afc84 (diff)
downloadpiny-code-407c6763f8f7e3838bd5e17c3bb5b039bdbfc92f.tar.gz
piny-code-407c6763f8f7e3838bd5e17c3bb5b039bdbfc92f.zip
Arrange for Tempfiles to be safely written in-dir
The default File::Temp DIR is not necessarily the same filesystem as the destination, which makes atomic linking impossible.
Diffstat (limited to 'libpiny/lib')
-rw-r--r--libpiny/lib/Piny/Repo.pm18
1 files changed, 9 insertions, 9 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index a319255..d2dfc19 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -331,23 +331,23 @@ sub rebuild_apache {
my ( $s ) = @_;
- my $globaltemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ my $globaltemp = File::Temp->new( DIR => "/etc/apache2/piny/global/" ) or die "Could not create temporary file: $!";
$globaltemp->unlink_on_destroy( 0 );
print $globaltemp $s->apache_global_config;
$globaltemp->close or die "Could not close new wikilist: $!";
- rename( $globaltemp->filename, "/etc/apache2/piny/global/" . $s->name ) or die "Could not rename apache config: $!";
+ rename( $globaltemp->filename, "/etc/apache2/piny/global/" . $s->name . ".conf" ) or die "Could not rename apache config: $!";
- my $securetemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ my $securetemp = File::Temp->new( DIR => "/etc/apache2/piny/secure/" ) or die "Could not create temporary file: $!";
$securetemp->unlink_on_destroy( 0 );
print $securetemp $s->apache_secure_config;
$securetemp->close or die "Could not close new wikilist: $!";
- rename( $securetemp->filename, "/etc/apache2/piny/secure/" . $s->name ) or die "Could not rename apache config: $!";
+ rename( $securetemp->filename, "/etc/apache2/piny/secure/" . $s->name . ".conf" ) or die "Could not rename apache config: $!";
- my $wwwtemp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ my $wwwtemp = File::Temp->new( DIR => "/etc/apache2/piny/www/" ) or die "Could not create temporary file: $!";
$wwwtemp->unlink_on_destroy( 0 );
print $wwwtemp $s->apache_www_config;
$wwwtemp->close or die "Could not close new wikilist: $!";
- rename( $wwwtemp->filename, "/etc/apache2/piny/www/" . $s->name ) or die "Could not rename apache config: $!";
+ rename( $wwwtemp->filename, "/etc/apache2/piny/www/" . $s->name . ".conf" ) or die "Could not rename apache config: $!";
if ( $s->config->piny_apachereload =~ /^(1|true)$/ ) {
system( "/etc/init.d/apache2", "reload" ) and die "Could not reload apache config!";
@@ -387,7 +387,7 @@ sub rebuild_ikiwiki {
system( "/usr/bin/sudo", "-H", "-u", $ikiuser->name, "/usr/bin/git", "clone", "--quiet", $s->path, $s->ikiwiki_srcdir ) and die "Could not clone repo to ikiwiki srcdir!";
};
- open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $s->name ) or die "Could not create wikilist.d file: $!";
+ open( WIKILIST, ">", "/etc/ikiwiki/wikilist.d/" . $s->name . ".conf" ) or die "Could not create wikilist.d file: $!";
print WIKILIST $ikiuser->name . " /etc/ikiwiki/piny/" . $s->name . ".setup\n";
close( WIKILIST ) or die "Could not close wikilist.d file: $!";
@@ -397,12 +397,12 @@ sub rebuild_ikiwiki {
};
sub rebuild_wikilist {
- my $temp = File::Temp->new( ) or die "Could not create temporary file: $!";
+ my $temp = File::Temp->new( DIR => "/etc/ikiwiki/wikilist.d/" ) or die "Could not create temporary file: $!";
$temp->unlink_on_destroy( 0 );
my $dh = IO::Dir->new( "/etc/ikiwiki/wikilist.d" ) or die "Could not open wikilist.d directory: $!";
while ( defined ( my $entry = $dh->read ) ) {
- next if ( $entry =~ /^\./ );
+ next if ( $entry !~ /.conf$/ );
open( FILE, "<", "/etc/ikiwiki/wikilist.d/" . $entry ) or die "Could not open wikilist.d entry $entry: $!";
print $temp <FILE>;
close( FILE ) or die "Could not close wikilist.d entry $entry: $!";