}
}
+sub volume_send {
+ my ($cfg, $volid, $snap, $ip, $incremental_snap, $verbose, $limit,
+ $target_path) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid, 1);
+ if ($storeid) {
+ my $scfg = storage_config($cfg, $storeid);
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ return $plugin->volume_send($scfg, $storeid, $volname, $ip, $snap,
+ $incremental_snap, $verbose, $limit, $target_path);
+
+ } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+ die "send file/device '$volid' is not possible\n";
+ } else {
+ die "unable to parse volume ID '$volid'\n";
+ }
+}
+
sub volume_snapshot_rollback {
my ($cfg, $volid, $snap) = @_;
}
}
+sub volume_snapshot_list {
+ my ($cfg, $volid, $prefix, $ip) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid, 1);
+ if ($storeid) {
+ my $scfg = storage_config($cfg, $storeid);
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ return $plugin->volume_snapshot_list($scfg, $storeid, $volname, $prefix, $ip);
+ } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+ die "send file/device '$volid' is not possible\n";
+ } else {
+ die "unable to parse volume ID '$volid'\n";
+ }
+ # return an empty array if dataset does not exist.
+ # youngest snap first
+}
+
sub get_image_dir {
my ($cfg, $storeid, $vmid) = @_;
return PVE::Storage::Plugin::parse_volume_id($volid, $noerr);
}
+# test if we have read access to volid
+sub check_volume_access {
+ my ($rpcenv, $user, $cfg, $vmid, $volid) = @_;
+
+ my ($sid, $volname) = parse_volume_id($volid, 1);
+ if ($sid) {
+ my ($vtype, undef, $ownervm) = parse_volname($cfg, $volid);
+ if ($vtype eq 'iso' || $vtype eq 'vztmpl') {
+ # we simply allow access
+ } elsif (defined($ownervm) && defined($vmid) && ($ownervm == $vmid)) {
+ # we are owner - allow access
+ } elsif ($vtype eq 'backup' && $ownervm) {
+ $rpcenv->check($user, "/storage/$sid", ['Datastore.AllocateSpace']);
+ $rpcenv->check($user, "/vms/$ownervm", ['VM.Backup']);
+ } else {
+ # allow if we are Datastore administrator
+ $rpcenv->check($user, "/storage/$sid", ['Datastore.Allocate']);
+ }
+ } else {
+ die "Only root can pass arbitrary filesystem paths."
+ if $user ne 'root@pam';
+ }
+
+ return undef;
+}
+
my $volume_is_base_and_used__no_lock = sub {
my ($scfg, $storeid, $plugin, $volname) = @_;
my $file;
while (defined($file = <$fh>)) {
- if ($file =~ m!$conf_re!) {
+ if ($file =~ $conf_re) {
$file = $1; # untaint
last;
}
my $rerr = $@;
# use exit code if no stderr output and not just broken pipe
- if (!$errstring && !$broken_pipe && $rc > 0 && $rc != 141) {
+ if (!$errstring && !$broken_pipe && $rc != 0 && $rc != 141) {
die "$rerr\n" if $rerr;
die "config extraction failed with exit code $rc\n";
}
my $archive = abs_filesystem_path($cfg, $volid);
- if ($volid =~ /\/vzdump-(lxc|openvz)-\d+-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|(tar(\.(gz|lzo))?))$/) {
- return extract_vzdump_config_tar($archive,'^(\./etc/vzdump/(pct|vps)\.conf)$');
- } elsif ($volid =~ /\/vzdump-qemu-\d+-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|((tar|vma)(\.(gz|lzo))?))$/) {
+ if ($volid =~ /vzdump-(lxc|openvz)-\d+-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|(tar(\.(gz|lzo))?))$/) {
+ return extract_vzdump_config_tar($archive, qr!^(\./etc/vzdump/(pct|vps)\.conf)$!);
+ } elsif ($volid =~ /vzdump-qemu-\d+-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|((tar|vma)(\.(gz|lzo))?))$/) {
my $format;
my $comp;
if ($7 eq 'tgz') {