This file is indexed.

/usr/bin/gpgmailtunl is in libgnupg-perl 0.19-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
#
#    gpgmailtunl - Program that sends encrypted email.
#
#    This file is part of GnuPG.pm.
#
#    Author: Francis J. Lacoste <francis.lacoste@iNsu.COM>
#
#    Copyright (C) 1999, 2000 iNsu Innovations Inc.
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

use strict;

use GnuPG;
use Getopt::Long;

sub usage() {
    die <<EOF;
usage: gpgmailtunl [ options ] --encrypt        or
       gpgmailtunl [ options ] --decrypt
EOF
  exit(64);
}

sub bounce(@) {
    print STDERR "gpgmailtunl: ", @_, "\n";
    exit( 64 );
};

sub read_secret($) {
    open SECRET, shift
      or bounce( "error opening secret file for reading: $!" );
    my $secret = <SECRET>;
    close SECRET;
    chomp $secret;

    return $secret;
}

sub encrypt($\%) {
    my ( $gpg, $opts ) = @_;

    my $from = $opts->{from};
    $opts->{subject}	||= "Encrypted mail";
    $opts->{recipient}	||= $opts->{to};
    my $cmd = "/usr/sbin/sendmail -oi -t";
    $cmd .= " -F\"$from\"" if $from;
    open( SENDMAIL, "|". $cmd )
      or bounce( "error opening pipe to sendmail: $!" );
    select SENDMAIL; $| = 1;
    print SENDMAIL "From: $from\n" if $from;
    print SENDMAIL <<EOF;
To:	    $opts->{to}
Subject:    $opts->{subject}


EOF
    eval {
	$gpg->encrypt( output => \*SENDMAIL, armor => 1,
		       sign		=> $opts->{sign}, 
		       passphrase	=> $opts->{passphrase},
		       recipient	=> $opts->{recipient},
		       "local-user"	=> $opts->{"local-user"},
		     );
    };
    bounce ( $@ ) if $@;
    close SENDMAIL
      or bounce( "error while waiting for sendmail: $!" );
    exit 0;
};

sub decrypt($\%) {
    my ( $gpg, $opts ) = @_;

    open( SENDMAIL, "|/usr/sbin/sendmail -oi -t" )
      or bounce( "error opening pipe to sendmail: $!" );
    select SENDMAIL; $| = 1;
    eval {
	$gpg->decrypt( output => \*SENDMAIL,
		       passphrase => $opts->{passphrase},
		     );
    };
    bounce ( $@ ) if $@;
    close SENDMAIL
      or bounce( "error while waiting for sendmail: $!" );
    exit 0;
}

my %opt = ();

GetOptions( \%opt, "encrypt", "decrypt", "sign", "secret-file=s",
	    "from=s", "to=s", "subject=s", "homedir=s", "local-user=s",
	    "recipient=s",
	  )
  or usage;

bounce( "can't use encrypt and decrypt at the same time" )
  if $opt{encrypt} and $opt{decrypt};

if ( $opt{decrypt} ) {
    map { bounce( "conflicting options with encrypt: $_" )
	    if $opt{$_} } qw( to from subject sign recipient local-user );
} elsif ( $opt{encrypt} ) {
    bounce( "missing to option" ) unless  $opt{to};
} else {
    bounce( "missing encrypt or decrypt" );
}

$opt{passphrase} = read_secret( $opt{"secret-file"})
  if $opt{"secret-file"};

my $gpg = new GnuPG( homedir => $opt{homedir} );

if ($opt{encrypt}) {
    encrypt $gpg, %opt;
} else {
    decrypt $gpg, %opt;
}

__END__

=pod

=head1 NAME

gpgmailtunl - Encrypts an email message into the body of another email.

=head1 SYNOPSIS

gpgmailtunl [options] --encrypt | --decrypt

=head1 DESCRIPTION

B<gpgmailtunl> is a filter program that either encrypts an email message
using the Gnu Privacy Guard and sends it to another recipient or decrypt
an email message and forwards unencrypted to another destination.

It can be used to exchange emails across an open network betweeen two
trusted systems.

=head1 TYPICAL USAGE

This program is intended to run from program like B<procmail> or
B<sendmail> to create an email tunnel between two systems.  Of course
this is not as secure as using B<gpg> as an end user program, it may
be convenient in certain case.

=head1 ENCRYPTION

To encapsulates an email within another you pipe the message to 
B<gpgmailtunl>.

=head2 OPTIONS

GetOptions( \%opt, "encrypt", "decrypt", "sign", "secret-file=s",
	    "from=s", "to=s", "subject=s", "homedir=s", "local-user=s",
	    "recipient=s",
	  )
  or usage;

=over

=item to

This is the address to which the encrypted message will be sent. This
is the only required fields. 

=item recipient

This sets the keyid that will be used to encrypt the outgoing message.
If unset, B<gpgmailtunl> will try to find a key matching the B<to> 
option.

=item subject

Sets the subject of the outgoing message. This defaults to 
"Encrypted mail".

=item from

Sets the From header line of the outgoing message which will contains
the encrypted one. B<sendmail> will provides a default one if this is
not set.

=item sign

If this option is used, the outgoing message will be signed. In this
case you should probably use to B<local-user> and B<secret-file>
options.

=item secret-file

File from which the secret to unlock the private used to sign the
message can be read.

=item local-user

The keyid of the user that should sign the outgoing message. The 
default user will be used if not specified.

=item homedir

Sets an alternate B<gpg> home directory. (This is where the
keyrings are stored.)

=back

=head1 DECRYPTION

To extract an email to be forwarded to the final user you pipe
the encrypted email to B<gpgmailtunl> using the B<decrypt> switch.

Once decrypted, the encapsulated email message will be sent to the
original destinator of the message.

=head2 OPTIONS

=over

=item homedir

Sets an alternate B<gpg> home directory. (This is where the
keyrings are stored.)

=item secret-file

File from which the secret to unlock the private used to decrypt the
message can be read.

=back

=head1 AUTHOR

Francis J. Lacoste <francis.lacoste@iNsu.COM>

=head1 COPYRIGHT

Copyright (c) 1999, 2000 iNsu Innovations Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

=head1 SEE ALSO

gpg(1) gpgmailtunl(1) GnuPG(3)

=cut