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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
Firma CHANGELOG
---------------
30/08/2005 - 0.3-cvs (rev 1.33) - rhatto
- Added GPL copyright notice and firma contact email
23/08/2005 - 0.3-cvs (rev 1.32) - luis - released as firma 0.2.5
- Fixed a possible infinite loop (added on rev 1.30) on function
GetMessageHeaders. It could be triggered, for example, by a
message without a body.
- Like the other header variables (FROM, SUBJECT), the variable
DATE now holds only the given date and no longer the entire
"Date:" line.
17/08/2005 - 0.3-cvs (rev 1.31) - luis
- On function GetMessage, renamed variable "STDIN"
to "stdin" and declared it as local.
17/08/2005 - 0.3-cvs (rev 1.30) - luis
- Changed project description to: "firma: GnuPG-based encrypted
mailing list manager"
- Declared/renamed/removed variables and arrays:
o Configuration file variables:
MAIL -> MAIL_AGENT
MAIL_ARGS -> MAIL_AGENT_ARGS
GPG -> GPG_BINARY
LISTNAME -> LIST_ADDRESS
LISTADMIN -> LIST_ADMIN
GPGDIR -> LIST_HOMEDIR
PASSWD -> PASSPHRASE
o GnuPG variables:
GPGFLAGS -> GPG_FLAGS
GPGCOMMAND -> GPG
GPGLIST -> GPG_LIST_KEYS
GPGDECRYPT -> GPG_DECRYPT
GPGENCRYPT -> GPG_ENCRYPT
o Other global variables:
FIRMA_LIST_PATH -> LISTS_DIR
FROMADD -> SENDER_ADDRESS
array -> ARRAY
CONFIG_FILE -> LIST_NAME
CONFIG_PATH -> LIST_PATH
CONFIG -> LIST_CONFIG_FILE
LINES, n, i -> ( removed )
( new ) -> FIRMA_CONFIG_FILE
o Global arrays:
MESSAGE -> ORIG_MESSAGE
GPG_MESSAGE -> ORIG_GPG_MESSAGE
LIST_MESSAGE -> MESSAGE_BODY
USED_ARRAYS -> GLOBAL_ARRAYS
ADMINCOMMANDS -> ( removed )
( new ) -> ORIG_MESSAGE_HEADERS
o Local variables:
ADMIN -> administrator
EMAIL -> email
KEYID -> keyid
signal -> ( removed )
( new ) -> element, i, j, uid_count, chosen_uid_number
- firma now uses two different configuration files: a general one,
containing the variables MAIL_AGENT, MAIL_AGENT_ARGS, GPG_BINARY and
LISTS_DIR, and a list specific file, containing the variables
LIST_ADDRESS, LIST_ADMIN, LIST_HOMEDIR and PASSPHRASE.
- Edited the comments at the beggining of the script to reflect the
change above.
- As suggested by the Advanced Bash-Scripting Guide (ABSG)[1], added
descriptive headers to all functions, describing its function, what
it expects as input, on what other functions it depends and what exit
codes it returns.
- Also as suggested by the ABSG[1], renamed all functions from
all_lower_case_names to MixedCaseNames.
- Renamed some functions to make their use more clear:
gpg_args -> DeclareGpgVars
check_config -> split into two: CheckFirmaConfigFile
and CheckListConfigFile
get_gpg_stderr -> GetGpgDecryptStderr
message_list -> SendListMessage
message_list_error -> SendWarningMessage
message_list_return -> SendBounceMessage
list_admin -> ListAdministration
- Added some more GnuPG flags:
o To the GPG_FLAGS variable: --no-options, --no-default-keyring,
--no-auto-check-trustdb
o And to the GPG_ENCRYPT variable: --local-user $LIST_ADDRESS,
--no-emit-version, --trust-model always
The last one replaced the "--always-trust" option, since its
deprecated according to GnuPG's manual.
- Minor changes on functions: Usage, Check*ConfigFile, GetMessage,
GetSubscribersList, SendListMessage, SendWarningMessage,
SendBounceMessage, ProcessMessage, NewList and ChooseUid
o Usage:
Explained what options expect an argument;
Commented out the -r (--list-request) option description, since
it's not implemented yet;
Added a description of the administrative tasks accepted by the
-a option;
Other minor changes.
o Check*ConfigFile:
Added a check to see if the LISTS_DIR is an existing directory;
Added a check to avoid more than 3 sequential repetitions of the
same character in the PASSPHRASE;
Other minor changes in the PASSPHRASE, LIST_ADDRESS and
LIST_ADMIN checks.
o GetMessage:
Added a check to see if the message was successfully stored in
the ORIG_MESSAGE array.
o GetSubscribersList:
Added a check to see if there are any subscribers to send
messages to in a given list.
o SendListMessage, SendWarningMessage, SendBounceMessage:
Just minor changes.
o ProcessMessage:
(* SECURITY FIX *) A public key with an UID containing GOODSIG
in its name, comment or email address would be able to send
messages to any list. And a UID containing BADSIG in any of
these fields, would be able to send messages to the list
administrator(s) of any list. Fixed.
o NewList:
Just minor changes.
o ChooseUid:
Declared keyid, uid_count and chosen_uid_number as local
variables, moving them to the beginning of the function;
Minor syntax changes in the checkings;
Added lots of comments, explaining what the checkings and the
expect script are doing.
- Major changes on functions: GetGpgMessage, GetMessageHeaders,
ListAdministration and "main"
o GetGpgMessage:
Improved function to run faster, specially when processing large
messages (over 50KB or so).
o GetMessageHeaders:
Improved to run faster independent of the size of the message
being processed.
o ListAdministration:
Structured function using the "case" bash builtin;
Made command parsing more consistent: checking if a given
command exists, if the right number of arguments were passed,
if the arguments are valid for this command, and, if anything
is wrong, showing descriptive and concise error messages;
New administrative tasks can be easily added to this new nested
"case" structure.
o "main":
Also structured using the "case" bash builtin;
The long options --admin-task, --create-newlist, --help,
--process-message and --version are now accepted;
Commented out the -r (--list-request) option, since it's not
implemented yet;
Made the command-line options parsing more consistent (read
explanation above);
Changed "umask" from 0777 to 0077. Otherwise, function NewList
cannot create configuration files for new lists;
Improved parsing of option -a (--admin-task), removing
unecessary commands and routines from this part of the code;
Again, new command-line options can be easily added to this new
nested "case" structure.
[1] http://www.tldp.org/LDP/abs/html/unofficialst.html
10/08/2005 - 0.3-cvs (rev 1.29) - rhatto
- Fix: Now LIST_MESSAGE _really_ works
09/08/2005 - 0.3-cvs (rev 1.28) - rhatto
- Deleted var 'x'
07/08/2005 - 0.3-cvs (rev 1.19) - rhatto
- Main function organization
- umask 0777 to prevent any files got wrong permissions
- Created USED_ARRAYS containing all the used array names
- Small routine to unset all arrays
07/05/2005 - 0.3-cvs (rev 1.13) - rhatto
- Firma now uses sendmail or any smtp wrapper directly:
- Specify your smtp wrapper through MAIL var, eg:
MAIL=/usr/sbin/sendmail
MAIL=/usr/bin/ssmtp
- Command-line arguments passed to the wrapper must
be specified in var MAIL_ARGS
- Change in functions get_message and get_gpg_message,
introducing the variable LINES (total lines of the
received message).
- New array: LIST_MESSAGE: keeps the encrypted message
sent to each subscriber; needed to the smtp wrapper
and will help PGP/MIME handling.
05/08/2005 - 0.3-cvs (rev 1.6) - luis
- New functions: list_admin, choose_uid and version.
- Renamed functions
GPGSTDERR -> get_gpg_stderr
SUBSCRIBERS -> get_subscribers_list
get_headers -> get_message_headers
- New args:
-h: chama a usage()
-v: chama a version()
- Option -a passes STDIN line by line to list_admin
- Added some checkings in the main procedure
- Some minor syntax changes
02/08/2005 - 0.3-cvs - rhatto
- Completed function newlist (still needs tests)
- New function: gpg_args
25/05/2005 - v0.2.x - rhatto
- Message is now stored in two arrays, MESSAGE and GPG_MESSAGE.
Temporary files are no longer needed. Deleted TMP var.
- Adapted firma to work with these two arrays. Lots of changes along
the code.
- Reorganized the code again, splitting part of the process_message
function into three new functions (get_message, get_gpg_message
and get_headers).
- new functions: get_message, get_gpg_message, get_headers,
- added export LANG=en_US
14/05/2005 - v0.2.3 - rhatto
- Changed project description.
- Two new variables: VERSION and CONFIG. The later stores the path
to the configuration file.
- Reorganized the code, splitting it into two functions
(check_config and process_message).
- An exit code of 1 is now given if an error occurs.
- Implemented a simple command line syntax: firma now has to be
called along with an option (e.g., -p to process a message),
followed by the path to the configuration file to be used.
- Created a new function (usage), which displays firma's usage if
its called without a command line option.
- Rearranged some comments along the code.
- New functions are: check_config, eval_config, usage, process_message and
splited the code into these routines
12/05/2005 - v0.2.2 - luis
major code cleanup and bug fix release
- New: Implemented size and complexity checks for the lists' passphrase.
- firma would not work as expected if the PASSWD variable contained
characters such as $, `, ', ", \. Fixed. Now PASSWD has to be
enclosed in single quotes and cannot contain any single quote in
its value.
- Checked the entire code and tried to make it clearer and more
consistent. Lots of small changes and minor fixes.
- BASH was looking for the configuration file first on its PATH and
only then on the current directory. Disabled sourcepath to avoid
this behavior.
- A From header containing more than one "<" would turn the variable
FROMADD useless. Fixed.
- When a message's signature is found invalid, the notification
about it is now sent separately for the sender and the list
administrators.
- Other minor fixes and improvements.
- fix LISTNAME and LISTADMIN case sensitiveness
18/04/2005 - v0.2.1 - luis
- Added some simple checks for the values entered in the
configuration file. If any of these checks fail, firma exits and
shows what should be corrected in the file.
- GPGLIST now lists public keys using the gpg option
"--with-colons". Definitely much easier to parse.
- added --no-permission-warning on $GPGCOMMAND.
- first tests with --hidden-recipient, but not added
- Fixed the FROMADD variable. It wasn't working on the last version
- FROMADD=$(echo $FROMADD \
| if grep -q "<" ; \
then echo $FROMADD | grep -o "<.*>" | sed -e "s/[<>]//g" ; \
else echo $FROMADD ; \
fi)
+ FROMADD=$(echo $FROM \
| if grep -q "<" ; \
then echo $FROM | grep -o "<.*>" | sed -e "s/[<>]//g" ; \
else echo $FROM ; \
fi)
- created routines to check config file vars
- changed SUBJECT to SUBJECT=$(grep -m 1 "^Subject:" $TMP | cut -d : -f 2- | sed "s/^ //")
- changed FROM to FROM=$(grep -m 1 "^From:" $TMP | cut -f 2 -d :)
17/04/2005 - v0.2 - luis
- Lists can now have a passphrase. Added option "--passphrase-fd 0"
to the GPGDECRYPT and GPGENCRYPT variables.
- Added a new variable to the configuration file: LISTADMIN. It
should contain the email address of one or more list
administrator(s).
- Added signature checking for received messages. If the signature
is found valid, the message is sent to the list. If its invalid,
its returned to the sender and to the list administrator(s). If
the message was not encrypted and/or signed, a note is returned
to the sender.
- Added a few options to the GPGCOMMAND variable: "--batch",
"--no-tty", "--no-use-agent" and "--no-permission-warning".
GPGCOMMAND="$GPG \
--quiet \
--homedir $GPGDIR \
--batch \
--no-tty \
--no-use-agent"
- Added two new functions: GPGSTDERR and SUBSCRIBERS. The first gets
gpg STDERR and discards its STDOUT and the later returns the
subscribers list.
function GPGSTDERR {
echo "$PASSWD" \
| ($GPGDECRYPT --status-fd 2 $TMP.gpg 1> /dev/null) 2>&1 ;
}
function SUBSCRIBERS {
$GPGLIST \
| sed -n '/$LISTNAME/d;/pub/p' \
| grep -o '<.*>' \
| sed -e 's/[<>]//g' ;
}
- Added a new variable, FROMADD, which contains the sender's email
address.
FROMADD=$(echo $FROMADD \
| if grep -q '<' ; \
then echo $FROMADD | grep -o '<.*>' | sed -e 's/[<>]//g' ; \
else echo $FROMADD ; \
fi)
TODO: find a better place to this var.
Feb 2005 - v0.1 - rhatto
- First public release and proof of concept
- Based on pgplist (http://www.rediris.es/app/pgplist/index.en.html),
but completely written from scratch
- Strips all mail headers
- Use keyring as database
- List variables are sourced from a configuration file.
- List subscription is managed through gpg public keyrings, one
keyring for each mailing list.
- Message is read from STDIN, passed to it by postfix or some
other MTA.
- Encrypted message is saved in a temporary file on disk. The
decrypted message though is not stored in disk, but passed to
the MTA through a pipe.
- Message is then decrypted, re-encrypted and sent separately to
each list subscriber.
|