From c2d3c481f88cef886e4966c1eae53e532f6ac1cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 23 Aug 2016 16:27:17 +0200 Subject: [PATCH] aplinfo: replace system() with run_command/rename --- PVE/API2/Nodes.pm | 2 +- PVE/APLInfo.pm | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index 8487518c..93e793e8 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -1133,7 +1133,7 @@ __PACKAGE__->register_method({ die "wrong checksum: $md5 != $pd->{md5sum}\n"; } - if (system ('mv', $tmpdest, $dest) != 0) { + if (!rename($tmpdest, $dest)) { die "unable to save file - $!\n"; } }; diff --git a/PVE/APLInfo.pm b/PVE/APLInfo.pm index 1f51918e..be5060ae 100644 --- a/PVE/APLInfo.pm +++ b/PVE/APLInfo.pm @@ -3,6 +3,7 @@ package PVE::APLInfo; use strict; use IO::File; use PVE::SafeSyslog; +use PVE::Tools; use LWP::UserAgent; use POSIX qw(strftime); @@ -181,9 +182,10 @@ sub download_aplinfo { die "update failed - no data file '$aplsrcurl'\n"; } - if (system("zcat -f $tmpgz >$tmp 2>/dev/null") != 0) { - die "update failed: unable to unpack '$tmpgz'\n"; - } + eval { + PVE::Tools::run_command(["gunzip", "-f", $tmpgz]); + }; + die "update failed: unable to unpack '$tmpgz'\n" if $@; # verify signature @@ -226,7 +228,7 @@ sub download_aplinfo { }; die "update failed: $@" if $@; - if (system("mv $tmp $aplinfodir/$host 2>/dev/null") != 0) { + if (!rename($tmp, "$aplinfodir/$host")) { die "update failed: unable to store data\n"; } @@ -256,7 +258,7 @@ sub update { my $size; if (($size = (-s $logfile) || 0) > (1024*50)) { - system ("mv $logfile $logfile.0"); + rename($logfile, "$logfile.0"); } my $logfd = IO::File->new (">>$logfile"); logmsg($logfd, "starting update"); -- 2.39.5