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
|
#! /bin/bash
# Sign a DSA generated by gen-D{L,S}A
#
# This allows for any number of headers below the regular 3 that
# gen-DSA generates (From, To, Subject).
#
# This can be useful if the advisory contains non-ASCII characters,
# like in first and last names for credits, and we need to send it as
# UTF-8. In that case, the signature will still be OK, and all the
# headers retained, even if we manually added those two to the DSA:
#
# Content-Transfer-Encoding: 8bit
# Content-type: text/plain; charset=UTF-8
#
# Copyright (C) 2016 Sebastien Delafond <seb@debian.org>
#
# This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>.
set -e
usage() {
echo "Usage: $0 </path/to/DSA-nnnn-m>"
echo " this will create /path/to/DSA-nnnn-m.signed"
}
if [[ $# != 1 ]] ; then
usage
exit 1
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]] ; then
usage
exit 0
fi
dsa=$1
signed_dsa=${dsa}.signed
# figure out the offset for actual DSA text, after headers
n=$(awk '/^$/ {print NR+1 ; exit}' $dsa)
# keep headers, and sign the content
{ head -n $(($n - 1)) $dsa ; tail -n +$n $dsa | gpg --clearsign ; } >| $signed_dsa
|