From 43216f633409410bfae9cf59d84582407bace9e3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 21 Mar 2017 06:03:40 +0100 Subject: make generation of boundary not break any pipes --- sendmailadvanced.in | 22 +++++++++++++++------- 1 file 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' -- cgit v1.2.3-70-g09d2