]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/SectionConfig.pm
bump version to 4.0-90
[pve-common.git] / src / PVE / SectionConfig.pm
index be13056eb1106468256fb05179f03b8b630d02b0..a6301e262598d0ee7886144ec104cb51301e5b24 100644 (file)
@@ -26,6 +26,9 @@ sub register {
     my $type = $class->type();
     my $pdata = $class->private();
 
+    die "duplicate plugin registration (type = $type)"
+       if defined($pdata->{plugins}->{$type});
+
     my $plugindata = $class->plugindata();
     $pdata->{plugindata}->{$type} = $plugindata;
     $pdata->{plugins}->{$type} = $class;
@@ -68,7 +71,6 @@ sub createSchema {
     };
 
     foreach my $p (keys %$propertyList) {
-       next if $p eq 'type';
        if (!$propertyList->{$p}->{optional}) {
            $props->{$p} = $propertyList->{$p};
            next;
@@ -182,7 +184,7 @@ sub init {
     }
 
     $propertyList->{type}->{type} = 'string';
-    $propertyList->{type}->{enum} = [keys %$plugins];
+    $propertyList->{type}->{enum} = [sort keys %$plugins];
 }
 
 sub lookup {
@@ -201,7 +203,7 @@ sub lookup_types {
 
     my $pdata = $class->private();
     
-    return [ keys %{$pdata->{plugins}} ];
+    return [ sort keys %{$pdata->{plugins}} ];
 }
 
 sub decode_value {
@@ -394,8 +396,12 @@ my $format_config_line = sub {
 
     my $ct = $schema->{type};
 
+    die "property '$key' contains a line feed\n"
+       if ($key =~ m/[\n\r]/) || ($value =~ m/[\n\r]/);
+
     if ($ct eq 'boolean') {
-       return $value ? "\t$key\n" : '';
+       return "\t$key " . ($value ? 1 : 0) . "\n"
+           if defined($value);
     } else {
        return "\t$key $value\n" if "$value" ne '';
     }