]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - debian/scripts/config-check
3 # check-config -- check the current config for issues
7 my $P = 'check-config';
10 if ($ARGV[0] eq '--test') {
12 } elsif ($#ARGV != 4) {
13 die "Usage: $P <config> <arch> <flavour> <commonconfig> <warn-only>\n";
16 my ($config, $arch, $flavour, $commonconfig, $warn_only) = @ARGV;
20 # If we are in overridden then still perform the checks and emit the messages
21 # but do not return failure. Those items marked FATAL will alway trigger
24 $fail_exit = 0 if ($warn_only eq 'true' || $warn_only eq '1');
27 # Load up the current configuration values -- FATAL if this fails
28 print "$P: $config: loading config\n";
29 open(CONFIG
, "<$config") || die "$P: $config: open failed -- $! -- aborting\n";
32 /^#*\s*(CONFIG_\w+)[\s=](.*)$/ or next;
33 if ($2 eq 'is not set') {
41 # ANNOTATIONS: check any annotations marked for enforcement
44 my $annotations = "$commonconfig/annotations";
45 my ($config, $value, $options, $option, $value, $check, $policy);
46 print "$P: $annotations loading annotations\n";
49 open(ANNOTATIONS
, "<$annotations") || die "$P: $annotations: open failed -- $! -- aborting\n";
50 while (<ANNOTATIONS
>) {
51 if (/^# FORMAT: (\S+)/) {
52 die "$P: $1: unknown annotations format\n" if ($1 != 2);
63 ($config, $value, $options) = split(' ', $_, 3);
64 } elsif ($form == 2) {
65 ($config, $options) = split(' ', $_, 2);
68 $annot{$config} = $annot{$config} . ' ' . $options;
73 for $config (keys %annot) {
75 $options = $annot{$config};
78 while ($options =~ /\s*(\S+)<(.*?)?>/g) {
79 ($option, $value) = ($1, $2);
81 if ($option eq 'mark' && $value eq 'ENFORCED') {
84 } elsif ($option eq 'policy') {
87 $policy = eval($value);
88 warn "$config: $@" if ($@);
94 if ($check == 1 && !defined($policy)) {
95 print "$P: INVALID POLICY (use policy<{...}>) $config$options\n";
101 $is = $values{$config} if (defined $values{$config});
104 for my $which ("$arch-$flavour", "$arch-*", "*-$flavour", "$arch", "*") {
105 if (defined $policy->{$which}) {
106 $value = $policy->{$which};
113 print "$P: FAIL ($is != $value): $config$options\n";
114 $exit_val = $fail_exit;
120 print "$P: $pass/$total checks passed -- exit $exit_val\n";