[pve-devel] [PATCH storage 1/1] Fix #318: Delete vzdump log when deleting a backup

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Apr 3 12:45:02 CEST 2019


On 4/3/19 12:39 PM, Dominik Csapak wrote:
> On 4/3/19 12:27 PM, Dominic Jaeger wrote:
>> Signed-off-by: Dominic Jaeger <d.jaeger at proxmox.com>
>> ---
>>   PVE/API2/Storage/Content.pm | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
>> index e941cb6..cbee77d 100644
>> --- a/PVE/API2/Storage/Content.pm
>> +++ b/PVE/API2/Storage/Content.pm
>> @@ -308,6 +308,11 @@ __PACKAGE__->register_method ({
>>         PVE::Storage::vdisk_free ($cfg, $volid);
>>   +    # Delete not only image but also logfile
>> +    my $logpath = substr $path, 0, index($path, '.');
> 
> i don't think this is correct, since index returns the *first* occurence of the substr, meaning that
> 
> '/my/path.with.dots/vzdump....'
> 
> leads to the deletion of
> 
> '/my/path.log'
> 

additionally, guarding this with a ($vtype eq 'backup') check would make sense,
to ensure that no file not under our control gets deleted here...

>> +    $logpath = "$logpath.log";
>> +    unlink($logpath) || die "unlink '$logpath' failed - $!\n";
>> +
>>       return undef;
>>       }});
>>  





More information about the pve-devel mailing list