]> git.proxmox.com Git - pve-storage.git/blame - PVE/Storage/DirPlugin.pm
Dir storage creation: check for a sane path
[pve-storage.git] / PVE / Storage / DirPlugin.pm
CommitLineData
1dc01b9f
DM
1package PVE::Storage::DirPlugin;
2
3use strict;
4use warnings;
5use File::Path;
6use PVE::Storage::Plugin;
7use PVE::JSONSchema qw(get_standard_option);
8
9use base qw(PVE::Storage::Plugin);
10
11# Configuration
12
13sub type {
14 return 'dir';
15}
16
17sub plugindata {
18 return {
19 content => [ { images => 1, rootdir => 1, vztmpl => 1, iso => 1, backup => 1, none => 1 },
20 { images => 1, rootdir => 1 }],
21 format => [ { raw => 1, qcow2 => 1, vmdk => 1 } , 'raw' ],
22 };
23}
24
25sub properties {
26 return {
27 path => {
28 description => "File system path.",
29 type => 'string', format => 'pve-storage-path',
30 },
31 };
32}
33
34sub options {
35 return {
36 path => { fixed => 1 },
37 nodes => { optional => 1 },
38 shared => { optional => 1 },
39 disable => { optional => 1 },
40 maxfiles => { optional => 1 },
41 content => { optional => 1 },
42 format => { optional => 1 },
43 };
44}
45
46# Storage implementation
47
48sub activate_storage {
49 my ($class, $storeid, $scfg, $cache) = @_;
50
51 my $path = $scfg->{path};
52 mkpath $path;
53
54 $class->SUPER::activate_storage($storeid, $scfg, $cache);
55}
56
85f1c791
WB
57sub check_config {
58 my ($self, $sectionId, $config, $create, $skipSchemaCheck) = @_;
59 my $opts = PVE::SectionConfig::check_config($self, $sectionId, $config, $create, $skipSchemaCheck);
60 return $opts if !$create;
61 if ($opts->{path} !~ m@^/[-/a-zA-Z0-9_.]+$@) {
62 die "illegal path for directory storage: $opts->{path}\n";
63 }
64 return $opts;
65}
1dc01b9f
DM
66
671;