~ubuntu-branches/ubuntu/saucy/debsigs/saucy

« back to all changes in this revision

Viewing changes to debsigs-installer

  • Committer: Bazaar Package Importer
  • Author(s): Branden Robinson
  • Date: 2002-09-19 17:55:29 UTC
  • Revision ID: james.westby@ubuntu.com-20020919175529-8cjsoswzc882un47
Tags: 0.1.14
* debsigs, debsigs-autosign: you can't use a module and run one of its
  methods at the same time; do these things separately (thanks, Joey Hess)
  (Closes: #161542)
* debsigs: stop hard-coding the path to gpg (thanks, Joey Hess)
  (Closes: #161543)
* debsigs: update $VERSION
* debsigs: add FUTURE DIRECTIONS section to POD
* debsigs-signchanges: only dig into @ARGV if it's defined (thanks, Joey
  Hess) (Closes: #161540)
* debsigs-installer: wrote rudimentary manpage

* debian/control:
  - bump Standards-Version to 3.5.7 (no changes needed)
  - add dependency on gnupg (Closes: #161544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
# $Progeny: debsigs-installer,v 1.4 2001/05/30 13:27:21 jgoerzen Exp $
 
4
 
 
5
use File::Copy;
 
6
 
 
7
# What we need to add:
 
8
 
 
9
my $KEY = 'E435EC07';
 
10
my $KEYTYPE = 'origin';
 
11
my $KEYRING = '/usr/local/debsigs/origin-secring.gpg';
 
12
my $TMPDIR = "/tmp/debsigs-installer.$$";
 
13
my $COUNTER = 0;
 
14
 
 
15
my $file;
 
16
 
 
17
my %copyfiles;
 
18
 
 
19
mkdir($TMPDIR, 0700) or die
 
20
  "Couldn't mkdir $TMPDIR: $!";
 
21
 
 
22
foreach $file (@ARGV) {
 
23
  $COUNTER++;
 
24
  processfile($file);
 
25
}
 
26
 
 
27
copyfiles();
 
28
cleanup($TMPDIR);
 
29
exit(0);
 
30
 
 
31
sub processfile {
 
32
  my ($file) = shift @_;
 
33
 
 
34
  my $TMPFILE = "$TMPDIR/file-$COUNTER.deb";
 
35
 
 
36
  # Copy the file to $TMPDIR.
 
37
 
 
38
  copy($file, $TMPFILE) or die
 
39
    "Couldn't copy file to $TMPFILE: $!";
 
40
 
 
41
  # Add the signature to it.
 
42
 
 
43
  (system("debsigs", "-K", $KEYRING,
 
44
          "--default-key=$KEY", "--sign=$KEYTYPE", $TMPFILE) == 0) or die
 
45
            "Error signing!";
 
46
 
 
47
  # Now verify the result.
 
48
 
 
49
  if (system("debsig-verify", "-q", $TMPFILE) != 0) {
 
50
    print STDERR "Error validating $file!\n";
 
51
    cleanup($TMPDIR, $TMPFILE);
 
52
    exit(2);
 
53
  }
 
54
 
 
55
  # We're OK here, so flag the file for copying.
 
56
 
 
57
  $copyfiles{$TMPFILE} = $file;
 
58
}
 
59
 
 
60
sub cleanup {
 
61
  my ($dir, $file) = @_;
 
62
 
 
63
  # Let them pass in a file to unlink too, in case it's being
 
64
  # called before being added to %copyfiles.
 
65
 
 
66
 
 
67
  if (defined($file)) {
 
68
    # print STDERR "Deleting $file\n";
 
69
    unlink($file);
 
70
  }
 
71
 
 
72
  foreach $file (keys %copyfiles) {
 
73
    # print STDERR "Deleting $file\n";
 
74
    unlink($file);
 
75
  }
 
76
 
 
77
  # print STDERR "Removing $dir\n";
 
78
  rmdir($dir);
 
79
 
 
80
}
 
81
 
 
82
sub copyfiles {
 
83
  my ($source, $dest);
 
84
 
 
85
  foreach $source (keys %copyfiles) {
 
86
    copy($source, $copyfiles{$source}) or die
 
87
      "Couldn't copy $source to " . $copyfiles{$source} . ": $!";
 
88
  #  print STDERR "Copied $source to " . $copyfiles{$source} . "\n";
 
89
  }
 
90
}
 
91
 
 
92
__END__
 
93
 
 
94
=head1 NAME
 
95
 
 
96
debsigs-installer - process signatures in .deb packages
 
97
 
 
98
=head1 SYNOPSIS
 
99
 
 
100
B<debsigs-installer> file [file...]
 
101
 
 
102
=head1 DESCRIPTION
 
103
 
 
104
B<debsigs-installer> is designed to be called in an automated fashion from
 
105
an installer.  It is given one or more files on the command line.  For each
 
106
file, it will apply the origin signature and make sure that the resulting
 
107
package verifies (it will fail to verify if it is missing one of the other
 
108
required signatures).  It will try its best to do either an all or nothing
 
109
approach; that is, if there is a problem with any .deb, all of them will be
 
110
unmodified and error code is returned.  It can assure this for all except
 
111
system call failures (can't copy files, etc.)  If success is returned, all
 
112
files should be assumed to have succeeded.  If failure is returned, all
 
113
files should be assumed to have failed.
 
114
 
 
115
=head1 OPTIONS
 
116
 
 
117
None.
 
118
 
 
119
=head1 BUGS
 
120
 
 
121
This program isn't finished yet.  It uses hard-coded values for the key ID,
 
122
key type (see debsigs(1)), keyring file, and temporary directory.
 
123
 
 
124
=head1 AUTHOR
 
125
 
 
126
John Goerzen <jgoerzen@progenylinux.com>
 
127
 
 
128
=head1 SEE ALSO
 
129
 
 
130
debsig-verify(1), gpg(1)
 
131
 
 
132
=cut