]> git.proxmox.com Git - pve-container.git/commitdiff
followup: code cleanup and uninitialized value access fix
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Jul 2019 16:48:33 +0000 (18:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Jul 2019 16:48:33 +0000 (18:48 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC.pm
src/PVE/LXC/Config.pm

index 13ead7fd505d89ed5f2eea3dfb4e50af464b095e..2252685be47f19dc4a5e8ad024462bd1ce3d662e 100644 (file)
@@ -1415,11 +1415,11 @@ sub mountpoint_mount {
 
     die "unknown snapshot path for '$volid'" if !$storage && defined($snapname);
 
-    my @mountoptions= split(/;/, $mountpoint->{mountoptions});
     my $optlist = [];
-    my $allowed_options = PVE::LXC::Config::get_mount_options();
-    foreach my $opt (@mountoptions) {
-       push @$optlist, $opt if $opt =~ $allowed_options
+
+    if (my $mountopts = $mountpoint->{mountoptions}) {
+       my @opts = split(/;/, $mountpoint->{mountoptions});
+       push @$optlist, grep { PVE::LXC::Config::is_valid_mount_option($_) } @opts;
     }
 
     my $acl = $mountpoint->{acl};
index 71788bae2cf0e989e1003fae015093b22a37d0f0..49f234594ced907fdd712a10450bc275f4a8ceab 100644 (file)
@@ -216,10 +216,12 @@ sub __snapshot_foreach_volume {
 
 cfs_register_file('/lxc/', \&parse_pct_config, \&write_pct_config);
 
-my $mount_option = qr/(noatime|nodev|nosuid|noexec)/;
 
-sub get_mount_options {
-    return $mount_option;
+my $valid_mount_option_re = qr/(noatime|nodev|nosuid|noexec)/;
+
+sub is_valid_mount_option {
+    my ($option) = @_;
+    return $option =~ $valid_mount_option_re;
 }
 
 my $rootfs_desc = {
@@ -247,7 +249,7 @@ my $rootfs_desc = {
        type => 'string',
        description => 'Extra mount options for rootfs/mps.',
        format_description => 'opt[;opt...]',
-       pattern => qr/$mount_option(;$mount_option)*/,
+       pattern => qr/$valid_mount_option_re(;$valid_mount_option_re)*/,
     },
     ro => {
        type => 'boolean',