#! /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 # # 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 . set -e usage() { echo "Usage: $0 " 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