diff options
author | Erich Eckner <git@eckner.net> | 2017-03-21 06:03:40 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2017-03-21 06:04:48 +0100 |
commit | 43216f633409410bfae9cf59d84582407bace9e3 (patch) | |
tree | 54470b6e087d249b67fd4790f2ee2c54aecb3f27 | |
parent | 3e344da67af088fe2147ce57db25d1771c10ce74 (diff) | |
download | sendmailadvanced-43216f633409410bfae9cf59d84582407bace9e3.tar.xz |
make generation of boundary not break any pipes
-rwxr-xr-x | sendmailadvanced.in | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sendmailadvanced.in b/sendmailadvanced.in index 5608ed2..f362500 100755 --- a/sendmailadvanced.in +++ b/sendmailadvanced.in @@ -68,6 +68,20 @@ gpgAdressaten() { done } +gen_boundary() { + [ -n "$1" ] && len=$1 || len=33 + local bnd + bnd='' + while [ "${#bnd}" -lt ${len} ]; do + bnd="${bnd}$( + head -c1 /dev/urandom | \ + base64 -w0 | \ + tr -d '/+=' + )" + done + echo "${bnd}" +} + datei="" encrypt=true stamp=true @@ -250,13 +264,7 @@ fi echo "${body}" | \ grep -q "${boundary}" do - boundary="$( - set +o pipefail - base64 -w0 < /dev/urandom | \ - tr -d [/+] | \ - head -c 33 - )" - true + boundary="$(gen_boundary)" done echo 'MIME-Version: 1.0' |