]> ruderich.org/simon Gitweb - blhc/blhc.git/blob - bin/blhc
Differentiate between CFLAGS and CPPFLAGS.
[blhc/blhc.git] / bin / blhc
1 #!/usr/bin/perl
2
3 # Build log hardening check, checks build logs for missing hardening flags.
4
5 # Copyright (C) 2012  Simon Ruderich
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 use strict;
22 use warnings;
23
24 use Getopt::Long ();
25 use Term::ANSIColor ();
26 use Text::ParseWords ();
27
28 our $VERSION = '0.01';
29
30
31 # CONSTANTS/VARIABLES
32
33 # Regex to catch compiler commands.
34 my $cc_regex = qr/(?:[a-z0-9_]+-(?:linux-|kfreebsd-)?gnu(?:eabi|eabihf)?-)?
35                   (?<!\.)(?:cc|gcc|g\+\+|c\+\+)
36                   (?:-[\d.]+)?/x;
37 # Regex to catch (GCC) compiler warnings.
38 my $warning_regex = qr/^(.+?):([0-9]+):[0-9]+: warning: (.+?) \[(.+?)\]$/;
39
40 # Regex for source files which require preprocessing.
41 my $source_preprocess_compile_cpp_regex = qr/
42     # C++
43       cc | cp | cxx | cpp | CPP | c\+\+ | C
44     # Objective-C++
45     | mm | M
46     /x;
47 my $source_preprocess_compile_regex = qr/
48     # C
49       c
50     # Objective-C
51     | m
52     # (Objective-)C++
53     | $source_preprocess_compile_cpp_regex
54     # Fortran
55     | F | FOR | fpp | FPP | FTN | F90 | F95 | F03 | F08
56     /x;
57 my $source_preprocess_no_compile_regex = qr/
58     # Assembly
59       s
60     /x;
61 my $source_preprocess_regex = qr/
62       $source_preprocess_compile_regex
63     | $source_preprocess_no_compile_regex
64     /x;
65 # Regex for source files which don't require preprocessing.
66 my $source_no_preprocess_compile_cpp_regex = qr/
67     # C++
68       ii
69     # Objective-C++
70     | mii
71     /x;
72 my $source_no_preprocess_compile_regex = qr/
73     # C
74       i
75     # (Objective-)C++
76     | $source_no_preprocess_compile_cpp_regex
77     # Objective-C
78     | mi
79     # Fortran
80     | f | for | ftn | f90 | f95 | f03 | f08
81     /x;
82 my $source_no_preprocess_no_compile_regex = qr/
83     # Assembly
84       S | sx
85     /x;
86 my $source_no_preprocess_regex = qr/
87       $source_no_preprocess_compile_regex
88     | $source_no_preprocess_no_compile_regex
89     /x;
90 # Regex for header files which require preprocessing.
91 my $header_preprocess_regex = qr/
92     # C, C++, Objective-C, Objective-C++
93       h
94     # C++
95     | hh | H | hp | hxx | hpp | HPP | h\+\+ | tcc
96     /x;
97 # Regexps to match files with the given characteristics.
98 my $file_no_preprocess_regex = qr/
99     $cc_regex.+?
100     \.(?: $source_no_preprocess_regex)\b
101     /x;
102 my $file_preprocess_regex = qr/
103     $cc_regex.+?
104     \.(?: $header_preprocess_regex
105         | $source_preprocess_regex)\b
106     /x;
107 my $file_compile_link_regex = qr/
108     $cc_regex.+?
109     \.(?: $source_preprocess_regex
110         | $source_no_preprocess_regex)\b
111     /x;
112 my $file_compile_regex = qr/
113     $cc_regex.+?
114     \.(?: $source_preprocess_compile_regex
115         | $source_no_preprocess_compile_regex)\b
116     /x;
117 my $file_no_compile_regex = qr/
118     $cc_regex.+
119     \.(?: $source_preprocess_no_compile_regex
120         | $source_no_preprocess_no_compile_regex)\b
121     /x;
122 my $file_compile_cpp_regex = qr/
123     $cc_regex.+
124     \.(?: $source_preprocess_compile_cpp_regex
125         | $source_no_preprocess_compile_cpp_regex)\b
126     /x;
127
128 # Expected (hardening) flags. All flags are used as regexps.
129 my @cflags = (
130     '-g',
131     '-O(?:2|3)',
132 );
133 my @cflags_format = (
134     '-Wformat',
135     '-Wformat-security',
136     '-Werror=format-security',
137 );
138 my @cflags_fortify = (
139     # fortify needs at least -O1, but -O2 is recommended anyway
140 );
141 my @cflags_stack = (
142     '-fstack-protector',
143     '--param=ssp-buffer-size=4',
144 );
145 my @cflags_pie = (
146     '-fPIE',
147 );
148 my @cxxflags = (
149     '-g',
150     '-O(?:2|3)',
151 );
152 # @cxxflags_* is the same as @cflags_*.
153 my @cppflags = ();
154 my @cppflags_fortify = (
155     '-D_FORTIFY_SOURCE=2',
156 );
157 my @ldflags = ();
158 my @ldflags_relro = (
159     '-Wl,(-z,)?relro',
160 );
161 my @ldflags_bindnow = (
162     '-Wl,(-z,)?now',
163 );
164 my @ldflags_pie = (
165     '-fPIE',
166     '-pie',
167 );
168 # Renaming rules for the output so the regex parts are not visible.
169 my %flag_renames = (
170     '-O(?:2|3)'       => '-O2',
171     '-Wl,(-z,)?relro' => '-Wl,-z,relro',
172     '-Wl,(-z,)?now'   => '-Wl,-z,now',
173 );
174
175 # Use colored (ANSI) output?
176 my $option_color;
177
178
179 # FUNCTIONS
180
181 sub error_flags {
182     my ($message, $missing_flags_ref, $flag_renames_ref, $line) = @_;
183
184     # Rename flags if requested.
185     my @missing_flags = map {
186         (exists $flag_renames_ref->{$_})
187             ? $flag_renames_ref->{$_}
188             : $_
189     } @{$missing_flags_ref};
190
191     my $flags = join ' ', @missing_flags;
192     printf "%s (%s)%s %s",
193            error_color($message, 'red'), $flags, error_color(':', 'yellow'),
194            $line;
195 }
196 sub error_non_verbose_build {
197     my ($line) = @_;
198
199     printf "%s%s %s",
200            error_color('NONVERBOSE BUILD', 'red'),
201            error_color(':', 'yellow'),
202            $line;
203 }
204 sub error_hardening_wrapper {
205     printf "%s%s %s\n",
206             error_color('HARDENING WRAPPER', 'red'),
207             error_color(':', 'yellow'),
208             'no checks possible, aborting';
209 }
210 sub error_color {
211     my ($message, $color) = @_;
212
213     if ($option_color) {
214         return Term::ANSIColor::colored($message, $color);
215     } else {
216         return $message;
217     }
218 }
219
220 sub any_flags_used {
221     my ($line, @flags) = @_;
222
223     foreach my $flag (@flags) {
224         return 1 if $line =~ /\s$flag(?:\s|\\)/;
225     }
226
227     return 0;
228 }
229 sub all_flags_used {
230     my ($line, $missing_flags_ref, @flags) = @_;
231
232     my @missing_flags = ();
233     foreach my $flag (@flags) {
234         if ($line !~ /\s$flag(?:\s|\\)/) {
235             push @missing_flags, $flag;
236         }
237     }
238
239     return 1 if scalar @missing_flags == 0;
240
241     @{$missing_flags_ref} = @missing_flags;
242     return 0;
243 }
244
245 # Modifies $missing_flags_ref array.
246 sub pic_pie_conflict {
247     my ($line, $pie, $missing_flags_ref, @flags_pie) = @_;
248
249     return 0 if not $pie;
250     return 0 if not any_flags_used($line, ('-fPIC', '-fpic'));
251
252     my %flags = map { $_ => 1 } @flags_pie;
253
254     # Remove all PIE flags from @missing_flags as they are not required with
255     # -fPIC.
256     my @result = grep {
257         not exists $flags{$_}
258     } @{$missing_flags_ref};
259     @{$missing_flags_ref} = @result;
260
261     # We got a conflict when no flags are left, thus only PIE flags were
262     # missing. If other flags were missing abort because the conflict is not
263     # the problem.
264     return scalar @result == 0;
265 }
266
267 sub is_non_verbose_build {
268     my ($line, $next_line, $skip_ref) = @_;
269
270     if (not ($line =~ /^checking if you want to see long compiling messages\.\.\. no/
271                 or $line =~ /^\s*\[?(?:CC|CCLD|CXX|CXXLD|LD|LINK)\]?\s+(.+?)$/
272                 or $line =~ /^\s*(?:C|c)ompiling\s+(.+?)(?:\.\.\.)?$/
273                 or $line =~ /^\s*(?:B|b)uilding (?:program|shared library)\s+(.+?)$/
274                 or $line =~ /^\s*\[[\d ]+%\] Building (?:C|CXX) object (.+?)$/)) {
275         return 0;
276     }
277
278     my $file = $1;
279
280     # On the first pass we only check if this line is verbose or not.
281     return 1 if not defined $next_line;
282
283     # Second pass, we have access to the next line.
284     ${$skip_ref} = 0;
285
286     # CMake and other build systems print the non-verbose messages also when
287     # building verbose. If a compiler and the file name occurs in the next
288     # line, treat it as verbose build.
289     if (defined $file) {
290         # Get filename, we can't use the complete path as only parts of it are
291         # used in the real compiler command.
292         $file =~ m{/([a-zA-Z0-9._-]+)$};
293         $file = $1;
294
295         if ($next_line =~ /\Q$file\E/ and $next_line =~ /$cc_regex/) {
296             # We still have to skip the current line as it doesn't contain any
297             # compiler commands.
298             ${$skip_ref} = 1;
299             return 0;
300         }
301     }
302
303     return 1;
304 }
305
306
307 # MAIN
308
309 # Hardening options. Not all architectures support all hardening options.
310 my $harden_format  = 1;
311 my $harden_fortify = 1;
312 my $harden_stack   = 1;
313 my $harden_relro   = 1;
314 my $harden_bindnow = 0;
315 my $harden_pie     = 0;
316
317 # Parse command line arguments.
318 my $option_help    = 0;
319 my $option_version = 0;
320 my $option_all     = 0;
321 my $option_arch    = undef;
322 my $option_buildd  = 0;
323    $option_color   = 0;
324 if (not Getopt::Long::GetOptions(
325             'help|h|?' => \$option_help,
326             'version'  => \$option_version,
327             # Hardening options.
328             'pie'      => \$harden_pie,
329             'bindnow'  => \$harden_bindnow,
330             'all'      => \$option_all,
331             # Misc.
332             'color'    => \$option_color,
333             'arch=s'   => \$option_arch,
334             'buildd'   => \$option_buildd,
335         )) {
336     require Pod::Usage;
337     Pod::Usage::pod2usage(2);
338 }
339 if ($option_help) {
340     require Pod::Usage;
341     Pod::Usage::pod2usage(1);
342 }
343 if ($option_version) {
344     print "blhc $VERSION  Copyright (C) 2012  Simon Ruderich
345
346 This program is free software: you can redistribute it and/or modify
347 it under the terms of the GNU General Public License as published by
348 the Free Software Foundation, either version 3 of the License, or
349 (at your option) any later version.
350
351 This program is distributed in the hope that it will be useful,
352 but WITHOUT ANY WARRANTY; without even the implied warranty of
353 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
354 GNU General Public License for more details.
355
356 You should have received a copy of the GNU General Public License
357 along with this program.  If not, see <http://www.gnu.org/licenses/>.
358 ";
359     exit 0;
360 }
361
362 if ($option_all) {
363     $harden_pie     = 1;
364     $harden_bindnow = 1;
365 }
366
367 # Final exit code.
368 my $exit = 0;
369
370 # Input lines, contain only the lines with compiler commands.
371 my @input = ();
372
373 my $start = 0;
374 my $continuation = 0;
375 my $complete_line = undef;
376 while (my $line = <>) {
377     # dpkg-buildflags only provides hardening flags since 1.16.1, don't check
378     # for hardening flags in buildd mode if an older dpkg-dev is used. Default
379     # flags (-g -O2) are still checked.
380     #
381     # Packages which were built before 1.16.1 but used their own hardening
382     # flags are not checked.
383     if ($option_buildd and not $start
384             and $line =~ /^Toolchain package versions: /) {
385         require Dpkg::Version;
386         if ($line !~ /dpkg-dev_(\S+)/
387                 or Dpkg::Version::version_compare($1, '1.16.1') < 0) {
388             $harden_format  = 0;
389             $harden_fortify = 0;
390             $harden_stack   = 0;
391             $harden_relro   = 0;
392             $harden_bindnow = 0;
393             $harden_pie     = 0;
394         }
395     }
396
397     # If hardening wrapper is used (wraps calls to gcc and adds hardening
398     # flags automatically) we can't perform any checks, abort.
399     if (not $start and $line =~ /^Build-Depends: .*\bhardening-wrapper\b/) {
400         error_hardening_wrapper();
401         $exit |= 1 << 4;
402         exit $exit;
403     }
404
405     # We skip over unimportant lines at the beginning of the log to prevent
406     # false positives.
407     $start = 1 if $line =~ /^dpkg-buildpackage:/;
408     next if not $start;
409     # And stop at the end of the build log. Package details (reported by the
410     # buildd logs) are not important for us. This also prevents false
411     # positives.
412     last if $line =~ /^Build finished at \d{8}-\d{4}$/;
413
414     # Detect architecture automatically unless overridden.
415     if (not $option_arch
416             and $line =~ /^dpkg-buildpackage: host architecture (.+)$/) {
417         $option_arch = $1;
418     }
419
420     # Ignore compiler warnings for now.
421     next if $line =~ /$warning_regex/;
422
423     # Remove all ANSI color sequences which are sometimes used in non-verbose
424     # builds.
425     $line = Term::ANSIColor::colorstrip($line);
426     # Also strip '\0xf' (delete previous character), used by Elinks' build
427     # system.
428     $line =~ s/\x0f//g;
429     # And "ESC(B" which seems to be used on armhf and hurd (not sure what it
430     # does).
431     $line =~ s/\033\(B//g;
432
433     # Check if this line indicates a non verbose build.
434     my $non_verbose = is_non_verbose_build($line);
435
436     # One line may contain multiple commands (";"). Treat each one as single
437     # line. parse_line() is slow, only use it when necessary.
438     my @line = (not $line =~ /;/)
439              ? ($line)
440              : Text::ParseWords::parse_line(';', 1, $line);
441     foreach $line (@line) {
442         # Add newline, drop all other whitespace at the end of a line.
443         $line =~ s/\s+$//;
444         $line .= "\n";
445
446         if ($continuation) {
447             $continuation = 0;
448
449             # Join lines, but leave the "\" in place so it's clear where the
450             # original line break was.
451             chomp $complete_line;
452             $complete_line .= ' ' . $line;
453         }
454         # Line continuation, line ends with "\".
455         if ($line =~ /\\\s*$/) {
456             $continuation = 1;
457             # Start line continuation.
458             if (not defined $complete_line) {
459                 $complete_line = $line;
460             }
461             next;
462         }
463
464         if (not $continuation) {
465             # Use the complete line if a line continuation occurred.
466             if (defined $complete_line) {
467                 $line = $complete_line;
468                 $complete_line = undef;
469             }
470
471             # Ignore lines with no compiler commands.
472             next if $line !~ /\b$cc_regex(?:\s|\\)/ and not $non_verbose;
473
474             # Ignore false positives.
475             #
476             # `./configure` output.
477             next if not $non_verbose
478                     and $line =~ /^(?:checking|(?:C|c)onfigure:) /;
479             next if $line =~ /^\s*(?:Host\s+)?(?:C\s+)?
480                                (?:C|c)ompiler[\s.]*:?\s+
481                                $cc_regex
482                                (?:\s-std=[a-z0-9:+]+)?\s*$
483                              /x
484                     or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex\s*$/
485                     or $line =~ /^\s*-- Check for working (?:C|CXX) compiler: /
486                     or $line =~ /^\s*(?:echo )?Using [A-Z_]+\s*=\s*/;
487             # `make` output.
488             next if $line =~ /^Making [a-z]+ in \S+/; # e.g. "[...] in c++"
489
490             # Check if additional hardening options were used. Used to ensure
491             # they are used for the complete build.
492             $harden_pie     = 1 if any_flags_used($line, @cflags_pie, @ldflags_pie);
493             $harden_bindnow = 1 if any_flags_used($line, @ldflags_bindnow);
494
495             push @input, $line;
496         }
497     }
498 }
499
500 if (scalar @input == 0) {
501     print "No compiler commands!\n";
502     $exit |= 1;
503     exit $exit;
504 }
505
506 # Option or auto detected.
507 if ($option_arch) {
508     # The following was partially copied from dpkg-dev 1.16.1.2
509     # (/usr/share/perl5/Dpkg/Vendor/Debian.pm, add_hardening_flags()),
510     # copyright RaphaĆ«l Hertzog <hertzog@debian.org>, Kees Cook
511     # <kees@debian.org>, Canonical, Ltd. licensed under GPL version 2 or
512     # later. Keep it in sync.
513
514     require Dpkg::Arch;
515     my ($abi, $os, $cpu) = Dpkg::Arch::debarch_to_debtriplet($option_arch);
516
517     # Disable unsupported hardening options.
518     if ($cpu =~ /^(ia64|alpha|mips|mipsel|hppa)$/ or $option_arch eq 'arm') {
519         $harden_stack = 0;
520     }
521     if ($cpu =~ /^(ia64|hppa|avr32)$/) {
522         $harden_relro   = 0;
523         $harden_bindnow = 0;
524     }
525 }
526
527 # Check the specified hardening options, same order as dpkg-buildflags.
528 if ($harden_pie) {
529     @cflags  = (@cflags,  @cflags_pie);
530     @cxxflags = (@cxxflags, @cflags_pie);
531     @ldflags = (@ldflags, @ldflags_pie);
532 }
533 if ($harden_stack) {
534     @cflags = (@cflags, @cflags_stack);
535     @cxxflags = (@cxxflags, @cflags_stack);
536 }
537 if ($harden_fortify) {
538     @cflags   = (@cflags,   @cflags_fortify);
539     @cxxflags = (@cxxflags, @cflags_fortify);
540     @cppflags = (@cppflags, @cppflags_fortify);
541 }
542 if ($harden_format) {
543     @cflags = (@cflags, @cflags_format);
544     @cxxflags = (@cxxflags, @cflags_format);
545 }
546 if ($harden_relro) {
547     @ldflags = (@ldflags, @ldflags_relro);
548 }
549 if ($harden_bindnow) {
550     @ldflags = (@ldflags, @ldflags_bindnow);
551 }
552
553 for (my $i = 0; $i < scalar @input; $i++) {
554     my $line = $input[$i];
555
556     my $skip = 0;
557     if (is_non_verbose_build($line, $input[$i + 1], \$skip)) {
558         error_non_verbose_build($line);
559         $exit |= 1 << 2;
560         next;
561     }
562     # Even if it's a verbose build, we might have to skip this line.
563     next if $skip;
564
565     # Skip unnecessary tests when only preprocessing.
566     my $flag_preprocess = 0;
567
568     my $preprocess = 0;
569     my $compile    = 0;
570     my $link       = 0;
571
572     # Preprocess, compile, assemble.
573     if ($line =~ /$cc_regex.*?\s(-E|-S|-c)\b/) {
574         $preprocess      = 1;
575         $flag_preprocess = 1 if $1 eq '-E';
576         $compile         = 1 if $1 eq '-S' or $1 eq '-c';
577     # Otherwise assume we are linking.
578     } else {
579         $link = 1;
580     }
581
582     # These file types don't require preprocessing.
583     if ($line =~ /$file_no_preprocess_regex/) {
584         $preprocess = 0;
585     }
586     # These file types require preprocessing.
587     if ($line =~ /$file_preprocess_regex/) {
588         $preprocess = 1;
589     }
590
591     # If there are source files then it's compiling/linking in one step and we
592     # must check both. We only check for source files here, because header
593     # files cause too many false positives.
594     if (not $flag_preprocess and $line =~ /$file_compile_link_regex/) {
595         # Assembly files don't need CFLAGS.
596         if (not $line =~ /$file_compile_regex/
597                 and $line =~ /$file_no_compile_regex/) {
598             $compile = 0;
599         # But the rest does.
600         } else {
601             $compile = 1;
602         }
603     }
604
605     # Assume CXXFLAGS are required when a C++ file is specified in the
606     # compiler line.
607     my $compile_cpp = 0;
608     if ($compile and $line =~ /$file_compile_cpp_regex/) {
609         $compile     = 0;
610         $compile_cpp = 1;
611     }
612
613     # Check hardening flags.
614     my @missing;
615     if ($compile and not all_flags_used($line, \@missing, @cflags)
616             # Libraries linked with -fPIC don't have to (and can't) be linked
617             # with -fPIE as well. It's no error if only PIE flags are missing.
618             and not pic_pie_conflict($line, $harden_pie, \@missing, @cflags_pie)
619             # Assume dpkg-buildflags returns the correct flags.
620             and not $line =~ /`dpkg-buildflags --get CFLAGS`/) {
621         error_flags('CFLAGS missing', \@missing, \%flag_renames, $line);
622         $exit |= 1 << 3;
623     } elsif ($compile_cpp and not all_flags_used($line, \@missing, @cflags)
624             # Libraries linked with -fPIC don't have to (and can't) be linked
625             # with -fPIE as well. It's no error if only PIE flags are missing.
626             and not pic_pie_conflict($line, $harden_pie, \@missing, @cflags_pie)
627             # Assume dpkg-buildflags returns the correct flags.
628             and not $line =~ /`dpkg-buildflags --get CXXFLAGS`/) {
629         error_flags('CXXFLAGS missing', \@missing, \%flag_renames, $line);
630         $exit |= 1 << 3;
631     }
632     if ($preprocess and not all_flags_used($line, \@missing, @cppflags)
633             # Assume dpkg-buildflags returns the correct flags.
634             and not $line =~ /`dpkg-buildflags --get CPPFLAGS`/) {
635         error_flags('CPPFLAGS missing', \@missing, \%flag_renames, $line);
636         $exit |= 1 << 3;
637     }
638     if ($link and not all_flags_used($line, \@missing, @ldflags)
639             # Same here, -fPIC conflicts with -fPIE.
640             and not pic_pie_conflict($line, $harden_pie, \@missing, @ldflags_pie)
641             # Assume dpkg-buildflags returns the correct flags.
642             and not $line =~ /`dpkg-buildflags --get LDFLAGS`/) {
643         error_flags('LDFLAGS missing', \@missing, \%flag_renames, $line);
644         $exit |= 1 << 3;
645     }
646 }
647
648 exit $exit;
649
650
651 __END__
652
653 =head1 NAME
654
655 blhc - build log hardening check, checks build logs for missing hardening flags
656
657 =head1 SYNOPSIS
658
659 B<blhc> [options] <dpkg-buildpackage build log file>
660
661     --all                   force +all (+pie, +bindnow) check
662     --arch                  set architecture (autodetected)
663     --bindnow               force +bindbow check
664     --buildd                parser mode for buildds
665     --color                 use colored output
666     --pie                   force +pie check
667     --help                  available options
668     --version               version number and license
669
670 =head1 DESCRIPTION
671
672 blhc is a small tool which checks build logs for missing hardening flags and
673 other important warnings. It's licensed under the GPL 3 or later.
674
675 =head1 OPTIONS
676
677 =over 8
678
679 =item B<--all>
680
681 Force check for all +all (+pie, +bindnow) hardening flags. By default it's
682 auto detected.
683
684 =item B<--arch>
685
686 Set the specific architecture (e.g. amd64, armel, etc.), automatically
687 disables hardening flags not available on this architecture. Is detected
688 automatically if dpkg-buildpackage is used.
689
690 =item B<--bindnow>
691
692 Force check for all +bindnow hardening flags. By default it's auto detected.
693
694 =item B<--buildd>
695
696 Special mode for buildds when automatically parsing log files. The following
697 changes are in effect:
698
699 =over 2
700
701 =item
702
703 Don't check hardening flags in old log files (if dpkg-dev << 1.16.1 is
704 detected).
705
706 =back
707
708 =item B<--color>
709
710 Use colored (ANSI) output for warning messages.
711
712 =item B<--pie>
713
714 Force check for all +pie hardening flags. By default it's auto detected.
715
716 =item B<-h -? --help>
717
718 Print available options.
719
720 =item B<--version>
721
722 Print version number and license.
723
724 =back
725
726 Auto detection for B<--pie> and B<--bindnow> only works if at least one
727 command uses the required hardening flag (e.g. -fPIE). Then it's required for
728 all other commands as well.
729
730 =head1 EXIT STATUS
731
732 The exit status is a "bit mask", each listed status is ORed when the error
733 condition occurs to get the result.
734
735 =over 4
736
737 =item B<0>
738
739 Success.
740
741 =item B<1>
742
743 No compiler commands were found.
744
745 =item B<2>
746
747 Invalid arguments/options given to blhc.
748
749 =item B<4>
750
751 Non verbose build.
752
753 =item B<8>
754
755 Missing hardening flags.
756
757 =item B<16>
758
759 Hardening wrapper detected, no tests performed.
760
761 =back
762
763 =head1 AUTHOR
764
765 Simon Ruderich, E<lt>simon@ruderich.orgE<gt>
766
767 =head1 COPYRIGHT AND LICENSE
768
769 Copyright (C) 2012 by Simon Ruderich
770
771 This program is free software: you can redistribute it and/or modify
772 it under the terms of the GNU General Public License as published by
773 the Free Software Foundation, either version 3 of the License, or
774 (at your option) any later version.
775
776 This program is distributed in the hope that it will be useful,
777 but WITHOUT ANY WARRANTY; without even the implied warranty of
778 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
779 GNU General Public License for more details.
780
781 You should have received a copy of the GNU General Public License
782 along with this program.  If not, see <http://www.gnu.org/licenses/>.
783
784 =cut