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
|
#!/bin/sh
########################################################
## ez-pine-gpg-sign ##
## part of ez-pine-gpg v0.4h // gpg filters for pine ##
## http://Business-PHP.com/opensource/ez-pine-gpg/ ##
## (c) 13 Feb 2004, Atom Emet ##
## (c) 16 Dec 2004, Atom Emet ##
## Atom {at} Business-PHP.com ##
## Distributed under the GNU General Public License ##
## http://www.gnu.org/copyleft/gpl.html ##
## ##
## ################################################ ##
## ##
## 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. ##
########################################################
#########################################
## PATH is configured during installation
PATH=/bin:/usr/bin:/home/bnewbold/bin
###################
## clear the screen
clear 1>&2
######################################################
## this compensates for an un-acknowledged bug in pine
stty -f /dev/tty echo
###############################################################
## display notices and give the user an opportunity to bail out
##
echo '#########################################################################' 1>&2
echo '## This message is being processed by ez-pine-gpg v0.4h ##' 1>&2
echo '## http://Business-PHP.com/opensource/ez-pine-gpg/ ##' 1>&2
echo '## (c) 13 Feb 2004, Atom Emet ##' 1>&2
echo '## (c) 16 Dec 2004, Atom Emet ##' 1>&2
echo '## Distributed under the GNU General Public License ##' 1>&2
echo '## See source for details ##' 1>&2
echo '## ##' 1>&2
echo '## THIS FILTER SIGNS BUT DOES NOT ENCRYPT YOUR MESSAGE! ##' 1>&2
echo '## ##' 1>&2
echo '## Are you sure you want to send this message without encrypting it? ##' 1>&2
echo '## If you want to cancel sending press ^C ##' 1>&2
echo '#########################################################################' 1>&2
##########################################################
## the variable "msg" is the full headers and message body
##
msg="`cat`"
########################################################################
## use "ez-pine-gpg-helper-sender" to find what role is sending the mail
##
from=`echo "${msg}" | ez-pine-gpg-helper-sender`
###################################################
## we don't need to process any more of the headers
## this assigns the body of the message to the var "body"
##
cr=`printf '\015'`
body=`echo "${msg}" | sed "1,/^${cr}\$/d"`
###########################
## unset the "msg" variable
##
msg=
#######################################
## function to gracefully handle errors
## if something goes wrong display an error message
## that includes the sender
##
gpg_failed () {
echo '#########################################################################' 1>&2
echo '## Something went wrong #### See above for more info ##' 1>&2
echo '#########################################################################' 1>&2
echo "## Tried signing message from: ${from}" 1>&2
echo '#########################################################################' 1>&2
########################################
## unset variables we don't need anymore
body= ; from=
#############################################################################
## a non-zero exit status will force pine to recognize that the script failed
## forcing an acknowledgment here will leave diagnostic info visible to user
echo '/////////////////////// Press <ENTER> to continue ///////////////////////' 1>&2
read dead < /dev/tty
clear 1>&2
exit 1
}
###########################################
## do the right thing even if ^C is pressed
##
trap 'gpg_failed' 2
#######################################################
## pipe the message body into the gpg clearsign command
## pine will read the signed message from STDOUT
##
{ echo "${body}" ; echo ; } | gpg --local-user "${from}" --clearsign || gpg_failed
#############################################
## unset variables that we don't need anymore
##
body= ; from=
#############
## we're done
##
exit 0
|