From db8b3116f44dfa1d452286e71d11dc255e4d3322 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 25 Sep 2021 21:51:21 -0400 Subject: network/ssmtp: Clean up build. Signed-off-by: B. Watson Signed-off-by: Willy Sudiarto Raharjo --- network/ssmtp/README | 23 ++- network/ssmtp/doinst.sh | 20 ++- network/ssmtp/patches/01-configure_lcrypto.diff.gz | Bin 226 -> 0 bytes .../ssmtp/patches/02-configure_in_lcrypto.diff.gz | Bin 295 -> 0 bytes network/ssmtp/patches/03-557741-remote-addr.patch | 28 +++ network/ssmtp/patches/04-508759-garbage.patch | 23 +++ network/ssmtp/patches/fix-tls1.3-handshake.patch | 24 +++ network/ssmtp/patches/ssmtp-bug584162-fix.patch | 120 +++++++++++++ network/ssmtp/patches/zzz_fix_warnings.patch | 189 +++++++++++++++++++++ network/ssmtp/ssmtp.SlackBuild | 68 ++++---- 10 files changed, 455 insertions(+), 40 deletions(-) delete mode 100644 network/ssmtp/patches/01-configure_lcrypto.diff.gz delete mode 100644 network/ssmtp/patches/02-configure_in_lcrypto.diff.gz create mode 100644 network/ssmtp/patches/03-557741-remote-addr.patch create mode 100644 network/ssmtp/patches/04-508759-garbage.patch create mode 100644 network/ssmtp/patches/fix-tls1.3-handshake.patch create mode 100644 network/ssmtp/patches/ssmtp-bug584162-fix.patch create mode 100644 network/ssmtp/patches/zzz_fix_warnings.patch (limited to 'network/ssmtp') diff --git a/network/ssmtp/README b/network/ssmtp/README index 515b0d4d4622..bc2832f72725 100644 --- a/network/ssmtp/README +++ b/network/ssmtp/README @@ -1,8 +1,17 @@ -sSMTP, replaces sendmail on workstations that should send their mail via the -departmental mailhub from which they pick up their mail (via pop, imap, rsmtp, -pop_fetch, NFS... or the like). This program accepts mail and sends it to the -mailhub, optionally replacing the domain in the From: line with a different -one. +ssmtp (extremely simple MTA to get mail off the system to a mail hub) -NOTE: -After installing, please run /usr/sbin/generate_config /etc/ssmtp/ssmtp.conf +sSMTP, replaces sendmail on workstations that should send their mail +via the departmental mailhub from which they pick up their mail (via +pop, imap, rsmtp, pop_fetch, NFS... or the like). This program accepts +mail and sends it to the mailhub, optionally replacing the domain in +the From: line with a different one. + +Normally, when using ssmtp, you want to remove the OS's MTA +package(s), sendmail and/or postfix. In this case, ssmtp will +be symlinked to /usr/sbin/sendmail, and software that sends mail +shouldn't have to be modified. If you keep sendmail/postfix installed, +there's no conflict, but any software that sends mail will have to be +configured or modified to use /usr/sbin/ssmtp. + +NOTE: After installing, you'll want to edit "/etc/ssmtp/ssmtp.conf". +There's a man page for it (man ssmtp.conf). diff --git a/network/ssmtp/doinst.sh b/network/ssmtp/doinst.sh index a96179b56ec4..ec579a954328 100644 --- a/network/ssmtp/doinst.sh +++ b/network/ssmtp/doinst.sh @@ -1,5 +1,17 @@ -if [ ! -e /usr/sbin/sendmail ];then - ln -s ssmtp /usr/sbin/sendmail -else - echo '/usr/sbin/sendmail already exists!' +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + rm $NEW + fi +} + +config etc/ssmtp/revaliases.new +config etc/ssmtp/ssmtp.conf.new + +# If there's no sendmail link, take over: +if [ ! -r usr/sbin/sendmail ]; then + ( cd usr/sbin ; ln -sf ssmtp sendmail ) fi diff --git a/network/ssmtp/patches/01-configure_lcrypto.diff.gz b/network/ssmtp/patches/01-configure_lcrypto.diff.gz deleted file mode 100644 index a819caf67033..000000000000 Binary files a/network/ssmtp/patches/01-configure_lcrypto.diff.gz and /dev/null differ diff --git a/network/ssmtp/patches/02-configure_in_lcrypto.diff.gz b/network/ssmtp/patches/02-configure_in_lcrypto.diff.gz deleted file mode 100644 index ea8d2e48f6d4..000000000000 Binary files a/network/ssmtp/patches/02-configure_in_lcrypto.diff.gz and /dev/null differ diff --git a/network/ssmtp/patches/03-557741-remote-addr.patch b/network/ssmtp/patches/03-557741-remote-addr.patch new file mode 100644 index 000000000000..03efa81cd6cf --- /dev/null +++ b/network/ssmtp/patches/03-557741-remote-addr.patch @@ -0,0 +1,28 @@ +http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=557741 + +Patch by Victor Sudakov +Modified by Anibal Monsalve Salazar + +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -1421,6 +1421,7 @@ ssmtp() -- send the message (exactly one + int ssmtp(char *argv[]) + { + char b[(BUF_SZ + 2)], *buf = b+1, *p, *q; ++ char *remote_addr; + #ifdef MD5AUTH + char challenge[(BUF_SZ + 1)]; + #endif +@@ -1624,6 +1625,10 @@ int ssmtp(char *argv[]) + outbytes += smtp_write(sock, "From: %s", from); + } + ++ if(remote_addr=getenv("REMOTE_ADDR")) { ++ outbytes += smtp_write(sock, "X-Originating-IP: %s", remote_addr); ++ } ++ + if(have_date == False) { + outbytes += smtp_write(sock, "Date: %s", arpadate); + } diff --git a/network/ssmtp/patches/04-508759-garbage.patch b/network/ssmtp/patches/04-508759-garbage.patch new file mode 100644 index 000000000000..3e53f8bcb8b0 --- /dev/null +++ b/network/ssmtp/patches/04-508759-garbage.patch @@ -0,0 +1,23 @@ +Common subdirectories: ssmtp-original/debian and ssmtp-2.62/debian +Common subdirectories: ssmtp-original/md5auth and ssmtp-2.62/md5auth +Common subdirectories: ssmtp-original/.pc and ssmtp-2.62/.pc +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -1674,12 +1674,12 @@ int ssmtp(char *argv[]) + outbytes += smtp_write(sock, "%s", leadingdot ? b : buf); + } else { + if (log_level > 0) { +- log_event(LOG_INFO, "Sent a very long line in chunks"); ++ log_event(LOG_INFO, "Sending a partial line"); + } + if (leadingdot) { +- outbytes += fd_puts(sock, b, sizeof(b)); ++ outbytes += fd_puts(sock, b, strlen(b)); + } else { +- outbytes += fd_puts(sock, buf, bufsize); ++ outbytes += fd_puts(sock, buf, strlen(buf)); + } + } + (void)alarm((unsigned) MEDWAIT); diff --git a/network/ssmtp/patches/fix-tls1.3-handshake.patch b/network/ssmtp/patches/fix-tls1.3-handshake.patch new file mode 100644 index 000000000000..a84f45b84a2d --- /dev/null +++ b/network/ssmtp/patches/fix-tls1.3-handshake.patch @@ -0,0 +1,24 @@ +Subject: Fix TLS 1.3 handshake +From: Jeff King +Bug-Debian: https://bugs.debian.org/932605 +Last-Update: 2019-08-13 + +diff --git a/ssmtp.c b/ssmtp.c +index 7ab79ab..6b2b9d0 100644 +--- a/ssmtp.c ++++ b/ssmtp.c +@@ -1291,8 +1291,12 @@ fd_getc() -- Read a character from an fd + ssize_t fd_getc(int fd, void *c) + { + #ifdef HAVE_SSL +- if(use_tls == True) { +- return(SSL_read(ssl, c, 1)); ++ if(use_tls == True) { ++ int attempt = 3; ++ int ret = 0; ++ while (attempt-- > 0 && ret == 0) ++ ret = SSL_read(ssl, c, 1); ++ return ret; + } + #endif + return(read(fd, c, 1)); diff --git a/network/ssmtp/patches/ssmtp-bug584162-fix.patch b/network/ssmtp/patches/ssmtp-bug584162-fix.patch new file mode 100644 index 000000000000..17ab1d908e1d --- /dev/null +++ b/network/ssmtp/patches/ssmtp-bug584162-fix.patch @@ -0,0 +1,120 @@ +Bug-Debian: http://bugs.debian.org/584162 +Reported-By: Christoph Biedl +Forwarded: not-needed +Reviewed-By: Anibal Monsalve Salazar +Last-Update: 2014-08-15 + +From: "Daniel Richard G." +Subject: Re: ssmtp: Partial loss of message body, sending message to wrong recipicients +Date: Thu, 19 Jun 2014 14:44:30 -0400 + +Attached is a patch against the original 2.64 source that should address +this bug, and hopefully not break anything. An overview of my changes: + +* Added code to standarise() to drop the trailing '\r' if the line + originally ended with "\r\n". + +* Added a check to header_parse() that effectively converts an "\r\n" in + the input into '\n'. + +* Added a conditional so that header_parse() doesn't pass the empty + string to header_save()---a behavior I observed in testing, at the end + of a header block with "\r\n" line endings. + +* Simplified the last if(in_header) conditional in header_parse(), + because it erroneously assumes that if in_header == True, then c could + have some value other than EOF. (See the condition on the previous + "while" loop, and the lack of any other way to exit said loop.) + + header_parse() will now properly grab a header if fed a message + without a body (i.e. no "\n\n" ending the header block), although this + code will still drop a header if there is no newline at the end. + +Christoph, thank you for your excellent analysis, and the test cases. I +made use of them, and with my changes sSMTP appears to do the right +thing. + +Index: ssmtp-2.64/ssmtp.c +=================================================================== +--- ssmtp-2.64.orig/ssmtp.c ++++ ssmtp-2.64/ssmtp.c +@@ -375,6 +375,12 @@ bool_t standardise(char *str, bool_t *li + if((p = strchr(str, '\n'))) { + *p = (char)NULL; + *linestart = True; ++ ++ /* If the line ended in "\r\n", then drop the '\r' too */ ++ sl = strlen(str); ++ if(sl >= 1 && str[sl - 1] == '\r') { ++ str[sl - 1] = (char)NULL; ++ } + } + return(leadingdot); + } +@@ -768,6 +774,14 @@ void header_parse(FILE *stream) + } + len++; + ++ if(l == '\r' && c == '\n') { ++ /* Properly handle input that already has "\r\n" ++ line endings; see https://bugs.debian.org/584162 */ ++ l = (len >= 2 ? *(q - 2) : '\n'); ++ q--; ++ len--; ++ } ++ + if(l == '\n') { + switch(c) { + case ' ': +@@ -790,7 +804,9 @@ void header_parse(FILE *stream) + if((q = strrchr(p, '\n'))) { + *q = (char)NULL; + } +- header_save(p); ++ if(len > 0) { ++ header_save(p); ++ } + + q = p; + len = 0; +@@ -800,35 +816,12 @@ void header_parse(FILE *stream) + + l = c; + } +- if(in_header) { +- if(l == '\n') { +- switch(c) { +- case ' ': +- case '\t': +- /* Must insert '\r' before '\n's embedded in header +- fields otherwise qmail won't accept our mail +- because a bare '\n' violates some RFC */ +- +- *(q - 1) = '\r'; /* Replace previous \n with \r */ +- *q++ = '\n'; /* Insert \n */ +- len++; +- +- break; +- +- case '\n': +- in_header = False; +- +- default: +- *q = (char)NULL; +- if((q = strrchr(p, '\n'))) { +- *q = (char)NULL; +- } +- header_save(p); +- +- q = p; +- len = 0; +- } ++ if(in_header && l == '\n') { ++ /* Got EOF while reading the header */ ++ if((q = strrchr(p, '\n'))) { ++ *q = (char)NULL; + } ++ header_save(p); + } + (void)free(p); + } diff --git a/network/ssmtp/patches/zzz_fix_warnings.patch b/network/ssmtp/patches/zzz_fix_warnings.patch new file mode 100644 index 000000000000..936dc0d4c449 --- /dev/null +++ b/network/ssmtp/patches/zzz_fix_warnings.patch @@ -0,0 +1,189 @@ +diff -Naur ssmtp-2.64/ssmtp.c ssmtp-2.64.patched/ssmtp.c +--- ssmtp-2.64/ssmtp.c 2021-09-25 20:31:20.120006571 -0400 ++++ ssmtp-2.64.patched/ssmtp.c 2021-09-25 20:42:51.453926150 -0400 +@@ -55,21 +55,21 @@ + + #define ARPADATE_LENGTH 32 /* Current date in RFC format */ + char arpadate[ARPADATE_LENGTH]; +-char *auth_user = (char)NULL; +-char *auth_pass = (char)NULL; +-char *auth_method = (char)NULL; /* Mechanism for SMTP authentication */ +-char *mail_domain = (char)NULL; +-char *from = (char)NULL; /* Use this as the From: address */ ++char *auth_user = (char *)NULL; ++char *auth_pass = (char *)NULL; ++char *auth_method = (char *)NULL; /* Mechanism for SMTP authentication */ ++char *mail_domain = (char *)NULL; ++char *from = (char *)NULL; /* Use this as the From: address */ + char *hostname; + char *mailhost = "mailhub"; +-char *minus_f = (char)NULL; +-char *minus_F = (char)NULL; ++char *minus_f = (char *)NULL; ++char *minus_F = (char *)NULL; + char *gecos; +-char *prog = (char)NULL; ++char *prog = (char *)NULL; + char *root = NULL; + char *tls_cert = "/etc/ssl/certs/ssmtp.pem"; /* Default Certificate */ +-char *uad = (char)NULL; +-char *config_file = (char)NULL; /* alternate configuration file */ ++char *uad = (char *)NULL; ++char *config_file = (char *)NULL; /* alternate configuration file */ + + headers_t headers, *ht; + +@@ -261,7 +261,7 @@ + + p = (str + strlen(str)); + while(isspace(*--p)) { +- *p = (char)NULL; ++ *p = '\0'; + } + + return(p); +@@ -287,7 +287,7 @@ + q++; + + if((p = strchr(q, '>'))) { +- *p = (char)NULL; ++ *p = '\0'; + } + + #if 0 +@@ -310,7 +310,7 @@ + q = strip_post_ws(p); + if(*q == ')') { + while((*--q != '(')); +- *q = (char)NULL; ++ *q = '\0'; + } + (void)strip_post_ws(p); + +@@ -363,13 +363,13 @@ + *linestart = False; + + if((p = strchr(str, '\n'))) { +- *p = (char)NULL; ++ *p = '\0'; + *linestart = True; + + /* If the line ended in "\r\n", then drop the '\r' too */ + sl = strlen(str); + if(sl >= 1 && str[sl - 1] == '\r') { +- str[sl - 1] = (char)NULL; ++ str[sl - 1] = '\0'; + } + } + return(leadingdot); +@@ -390,7 +390,7 @@ + while(fgets(buf, sizeof(buf), fp)) { + /* Make comments invisible */ + if((p = strchr(buf, '#'))) { +- *p = (char)NULL; ++ *p = '\0'; + } + + /* Ignore malformed lines and comments */ +@@ -525,7 +525,7 @@ + #endif + + /* Ignore missing usernames */ +- if(*str == (char)NULL) { ++ if(*str == '\0') { + return; + } + +@@ -582,7 +582,7 @@ + } + + /* End of string? */ +- if(*(q + 1) == (char)NULL) { ++ if(*(q + 1) == '\0') { + got_addr = True; + } + +@@ -590,7 +590,7 @@ + if((*q == ',') && (in_quotes == False)) { + got_addr = True; + +- *q = (char)NULL; ++ *q = '\0'; + } + + if(got_addr) { +@@ -682,7 +682,7 @@ + if(strncasecmp(ht->string, "From:", 5) == 0) { + #if 1 + /* Hack check for NULL From: line */ +- if(*(p + 6) == (char)NULL) { ++ if(*(p + 6) == '\0') { + return; + } + #endif +@@ -747,7 +747,7 @@ + size_t size = BUF_SZ, len = 0; + char *p = (char *)NULL, *q; + bool_t in_header = True; +- char l = (char)NULL; ++ char l = '\0'; + int c; + + while(in_header && ((c = fgetc(stream)) != EOF)) { +@@ -790,9 +790,9 @@ + in_header = False; + + default: +- *q = (char)NULL; ++ *q = '\0'; + if((q = strrchr(p, '\n'))) { +- *q = (char)NULL; ++ *q = '\0'; + } + if(len > 0) { + header_save(p); +@@ -809,7 +809,7 @@ + if(in_header && l == '\n') { + /* Got EOF while reading the header */ + if((q = strrchr(p, '\n'))) { +- *q = (char)NULL; ++ *q = '\0'; + } + header_save(p); + } +@@ -869,7 +869,7 @@ + char *rightside; + /* Make comments invisible */ + if((p = strchr(buf, '#'))) { +- *p = (char)NULL; ++ *p = '\0'; + } + + /* Ignore malformed lines and comments */ +@@ -1113,7 +1113,7 @@ + + /* Init SSL stuff */ + SSL_CTX *ctx; +- SSL_METHOD *meth; ++ const SSL_METHOD *meth; + X509 *server_cert; + + SSL_load_error_strings(); +@@ -1307,7 +1307,7 @@ + buf[i++] = c; + } + } +- buf[i] = (char)NULL; ++ buf[i] = '\0'; + + return(buf); + } +@@ -1739,7 +1739,7 @@ + j = 0; + + add = 1; +- while(argv[i][++j] != (char)NULL) { ++ while(argv[i][++j] != '\0') { + switch(argv[i][j]) { + #ifdef INET6 + case '6': diff --git a/network/ssmtp/ssmtp.SlackBuild b/network/ssmtp/ssmtp.SlackBuild index 45d6a5ef32c0..d75306bc87a5 100644 --- a/network/ssmtp/ssmtp.SlackBuild +++ b/network/ssmtp/ssmtp.SlackBuild @@ -24,13 +24,23 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# 20210925 bkw: BUILD=4 +# - get rid of unneeded configure lcrypto patches. +# - add bugfix patches from Debian. +# - don't install useless INSTALL in doc dir. +# - fix compiler warnings caused by such brain damage as: +# char *foo = (char)NULL; +# - install ssmptd.conf.new and (comment-only) revaliases.new. +# - *don't* install generate_config script. +# - fix doinst.sh. + # 20200129 bkw: take over maintenance, no script changes yet. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=ssmtp VERSION=${VERSION:-2.64} -BUILD=${BUILD:-3} +BUILD=${BUILD:-4} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} @@ -42,9 +52,6 @@ if [ -z "$ARCH" ]; then esac fi -# If the variable PRINT_PACKAGE_NAME is set, then this script will report what -# the name of the created package would be, and then exit. This information -# could be useful to other scripts. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" exit 0 @@ -77,42 +84,45 @@ rm -rf $PRGNAM-$VERSION tar xvf $CWD/${PRGNAM}_${VERSION}.orig.tar.bz2 cd $PRGNAM-$VERSION chown -R root:root . -find -L . \ - \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ - -o -perm 511 \) -exec chmod 755 {} \; -o \ - \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ - -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; - -for diff in "${CWD}"/patches/*.diff.gz;do - gzip -dc "${diff}" |patch -p0 +find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \ + \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+ + +for i in $CWD/patches/*.patch; do + patch -p1 < $i done +LIBS="-lcrypto" \ +CFLAGS="$SLKCFLAGS -Wl,-s" \ ./configure \ - --prefix=/usr \ - --sysconfdir='$(DESTDIR)/etc' \ - --mandir=/usr/man \ - --enable-ssl + --prefix=/usr \ + --sysconfdir='$(DESTDIR)/etc' \ + --mandir=/usr/man \ + --enable-ssl + +# Make generate_config non-interactive (just take the defaults). +# Also don't install it as part of the package. The config file is +# simple enough to edit, well-commented, and has its own man page. +sed -i '/^read/d' generate_config -sed -i -e's,prefix=/usr,prefix=$(DESTDIR)/usr,' \ - -e'/\$(GEN_CONFIG) \$(INSTALLED_CONFIGURATION_FILE)/d' \ - Makefile -CFLAGS="$SLKCFLAGS" make -make install DESTDIR=$PKG -install -D -m644 -o root -g root ssmtp.conf.5 $PKG/usr/man/man5/ssmtp.conf.5 +make +make install prefix=$PKG/usr DESTDIR=$PKG -strip --strip-unneeded $PKG/usr/sbin/ssmtp -gzip -9 $PKG/usr/man/man8/ssmtp.8 $PKG/usr/man/man5/ssmtp.conf.5 +gzip -9 $PKG/usr/man/man?/*.* + +# upstream wrote this handy man page, but forgot to install it +mkdir -p $PKG/usr/man/man5 +gzip -9c < ssmtp.conf.5 > $PKG/usr/man/man5/ssmtp.conf.5.gz + +for i in $PKG/etc/$PRGNAM/*; do + mv $i $i.new +done mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION -cp README INSTALL COPYING COPYRIGHT TLS $PKG/usr/doc/$PRGNAM-$VERSION/ +cp -a README COPY* CHANGE* Change* TLS $PKG/usr/doc/$PRGNAM-$VERSION/ cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild -find $PKG/usr/doc -type f -exec chmod 0644 {} \; -cp generate_config $PKG/usr/sbin -chmod 755 $PKG/usr/sbin/generate_config mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc -sed -i -e"s,,${VERSION}," $CWD/doinst.sh cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG -- cgit v1.2.3