~ubuntu-branches/ubuntu/saucy/devscripts/saucy

« back to all changes in this revision

Viewing changes to scripts/dscverify.pl

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung, Christoph Berg, James McCoy, Dmitry Smirnov, Paul Wise, Benjamin Drung, Cyril Brulebois, Tony Mancill, David Prévot, Josselin Mouette, Raphael Geissert, Regid Ichira, Colin Watson
  • Date: 2013-02-18 21:50:11 UTC
  • mfrom: (10.7.8 squeeze)
  • mto: (10.10.1 sid)
  • mto: This revision was merged to the branch mainline in revision 132.
  • Revision ID: package-import@ubuntu.com-20130218215011-efervwilveqwzzzx
Tags: 2.13.0
[ Christoph Berg ]
* origtargz: New script: fetch the orig tarball of a Debian package from
  various sources, and unpack it
* debcommit: --changelog-info will pass --author and --date for git commits.

[ James McCoy ]
* licensecheck: Recognize MPL 2.0 licenses.  Thanks to Ryan Pavlik for the
  patch.  (Closes: #687664)
* namecheck: Check Apache's projects page for names.  (Closes: #686862)
* debcommit:
  + Drop checks for old dpkg versions and always use the necessary Perl
    modules (Dpkg::Changelog::Parse, Dpkg::Vendor::Ubuntu,
    Dpkg::Changelog::Entry::Debian).
  + Add changelog info support for hg and bzr.
* annotate-output:
  + Handle an incomplete line of output.  (Closes: #695609)
  + Don't treat backslashes in the command's output as an escape.  (Closes:
    #695613)
  + Don't swallow leading whitespace.  (Closes: #695612, LP: #1120917)
* dscverify: Use "gpg --status-fd" to determine if a valid signature is
  found and only use the signed content.  (Closes: #695914)
* wrap-and-sort: Fix repeated word in man page.  (Closes: #696363)

[ Dmitry Smirnov ]
* licensecheck:
  + Remove any regular comments pattern. (Closes: #526698)
  + Improve command line parsing.
  + Fix GPL license version detection bug.
  + Fix BSD-3-clause detection.

[ Paul Wise ]
* checkbashisms: When examining a bash script, indicate the lack of use of
  bashisms.
* uscan:
  + Access GitHub directly instead of using githubredir.debian.net in
    example GitHub watch URL.
  + Add an example watch URL that matches the various file extensions used
    by common archive formats.
  + Add an example watch URL for Google Code projects.

[ Benjamin Drung ]
* Add bashism test cases from Raphael Geissert.
* Add autopkgtest support. (LP: #1073330)
* suspicious-source: Add inode/symlink and image/x-xpmi to whitelisted
  mime-types.
* wrap-and-sort:
  + Put special entries (variables and placeholders) at the end of the list.
  + Sort debian/control*.in files too.
* licensecheck: detect (L)GPL licenses more permissively. Thanks to
  Laurent Rineau for the patch. (Closes: #659231)
* Bump Standards-Version to 3.9.4 (no changes needed).

[ Cyril Brulebois ]
* Don't auto reverse diffs when DEBDIFF_AUTO_VER_SORT is set to yes, and
  when the version in both packages is the same. (Closes: #650732)

[ Tony Mancill ]
* debsnap: Escape the package name when used in regex.  (Closes: #696018)

[ David Prévot ]
* Minor manpages convention fix: do not terminate the SEE ALSO lists with a
  period. (Closes: #696416)
* French translation update.

[ Josselin Mouette ]
* nmudiff: Use dpkg-parsechangelog to fix manual parsing bug (Closes: #700584)

[ Raphael Geissert ]
* checkbashisms:
  + allow -FOO- as heredoc delimiter
  + simplify mixed single/double balanced quotes correctly
  + correct description of 'setvar'
  + detect traps for DEBUG, ERRNO, or RETURN
  + check for incorrect args. to 'exit' (Closes: #687450)
  + fix handling of # characters in quoted strings
  + detect use of $FUNCNAME, $TMOUT, and $TIMEFORMAT
  + detect uses of sleep with anything other than an int.
  + detect the use of the hash utility and $_
  + check for other forms of brace expansion
  + check for use of non-standard tilde expansion
  + check for case modification expansions
  + check for the use of $GLOBIGNORE

[ Regid Ichira ]
* rc-alert: Support using curl as alternative to wget. (Closes: #690024)
* wnpp-alert: Support using curl as alternative to wget. (Closes: #690056)
* wnpp-check: Support using curl as alternative to wget. (Closes: #690059)

[ Colin Watson ]
* debian/control: Mark devscripts Multi-Arch: foreign. (Closes: #694760)
* debchange, debcommit: Set the timestamp of temporary editor files back
  one second, to make modification detection more reliable in the absence
  of subsecond granularity. (Closes: #697923)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
use 5.004;      # correct pipe close behavior
25
25
use strict;
26
26
use Cwd;
 
27
use Fcntl;
27
28
use Dpkg::IPC;
 
29
use File::Spec;
 
30
use File::Temp;
28
31
use File::Basename;
29
32
use POSIX       qw(:errno_h);
30
33
use Getopt::Long qw(:config gnu_getopt);
110
113
    xdie "can't find any system keyrings\n";
111
114
}
112
115
 
113
 
sub check_signature {
114
 
    my ($file, @rings) = @_;
115
 
 
116
 
    my @cmd = qw(gpg --batch --no-options --no-default-keyring --always-trust);
117
 
    foreach (@rings) { push @cmd, '--keyring'; push @cmd, $_; }
 
116
sub check_signature($\@;\$) {
 
117
    my ($file, $rings, $outref) = @_;
 
118
 
 
119
    my $fh = eval { File::Temp->new() }
 
120
        or xdie "unable to open status file for gpg: $@\n";
 
121
 
 
122
    # Allow the status file descriptor to pass on to the child process
 
123
    my $flags = fcntl($fh, F_GETFD, 0);
 
124
    fcntl($fh, F_SETFD, $flags & ~FD_CLOEXEC);
 
125
 
 
126
    my $fd = fileno $fh;
 
127
    my @cmd;
 
128
    push @cmd, qw(gpg --status-fd), $fd,
 
129
               qw(--batch --no-options --no-default-keyring --always-trust);
 
130
    foreach (@$rings) { push @cmd, '--keyring'; push @cmd, $_; }
118
131
 
119
132
    my ($out, $err) = ('', '');
120
133
    eval {
129
142
        print $out if ($verbose);
130
143
        return $err || $@;
131
144
    }
 
145
 
 
146
    seek($fh, 0, SEEK_SET);
 
147
    my $status;
 
148
    $status .= $_ while <$fh>;
 
149
    close $fh;
 
150
 
 
151
    if ($status !~ m/^\[GNUPG:\] VALIDSIG/m) {
 
152
        return $out;
 
153
    }
 
154
 
 
155
    if (defined $outref) {
 
156
        $$outref = $out;
 
157
    }
 
158
 
132
159
    return '';
133
160
}
134
161
 
152
179
        $filebase = $file;
153
180
    }
154
181
 
155
 
    if (!open SIGNED, '<', $filebase) {
156
 
        xwarn "can't open $file:";
157
 
        return;
 
182
    my $out;
 
183
    if ($verify_sigs) {
 
184
        $sigcheck = check_signature $filebase, @rings, $out;
 
185
        if ($sigcheck) {
 
186
            xwarn "$file failed signature check:\n$sigcheck";
 
187
            return;
 
188
        } else {
 
189
            print "      Good signature found\n";
 
190
        }
158
191
    }
159
 
    my $out = do { local $/; <SIGNED> };
160
 
    if (!close SIGNED) {
161
 
        xwarn "problem reading $file:";
162
 
        return;
 
192
    else {
 
193
        if (!open SIGNED, '<', $filebase) {
 
194
            xwarn "can't open $file:";
 
195
            return;
 
196
        }
 
197
        $out = do { local $/; <SIGNED> };
 
198
        if (!close SIGNED) {
 
199
            xwarn "problem reading $file:";
 
200
            return;
 
201
        }
163
202
    }
164
203
 
165
204
    if ($file =~ /\.changes$/ and $out =~ /^Format:\s*(.*)$/mi) {
177
216
        }
178
217
    }
179
218
 
180
 
    if ($verify_sigs == 1) {
181
 
        $sigcheck = check_signature $filebase, @rings;
182
 
        if ($sigcheck) {
183
 
            xwarn "$file failed signature check:\n$sigcheck";
184
 
            return;
185
 
        } else {
186
 
            print "      Good signature found\n";
187
 
        }
188
 
    }
189
 
 
190
219
    my @spec = map { split /\n/ } $out =~ /^Files:\s*\n((?:[ \t]+.*\n)+)/mgi;
191
220
    unless (@spec) {
192
221
        xwarn "no file spec lines in $file\n";
316
345
 
317
346
        close FILE;
318
347
 
319
 
        if ($filename =~ /\.dsc$/ && $verify_sigs == 1) {
 
348
        if ($filename =~ /\.dsc$/ && $verify_sigs) {
320
349
            $sigcheck = check_signature $filename, @rings;
321
350
            if ($sigcheck) {
322
351
                xwarn "$filename failed signature check:\n$sigcheck";