Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package postsrsd for openSUSE:Factory checked in at 2023-08-13 19:17:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/postsrsd (Old) and /work/SRC/openSUSE:Factory/.postsrsd.new.11712 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "postsrsd" Sun Aug 13 19:17:48 2023 rev:11 rq:1103615 version:2.0.7 Changes: -------- --- /work/SRC/openSUSE:Factory/postsrsd/postsrsd.changes 2023-07-17 19:24:01.861996232 +0200 +++ /work/SRC/openSUSE:Factory/.postsrsd.new.11712/postsrsd.changes 2023-08-13 19:17:59.484119542 +0200 @@ -1,0 +2,8 @@ +Sat Aug 12 15:27:29 UTC 2023 - Jan Engelhardt <jeng...@inai.de> + +- Update to release 2.0.7 + * The parser callback for the original-envelope option used the + wrong return type, which could prevent the database mode from + activating. + +------------------------------------------------------------------- Old: ---- 2.0.6.tar.gz New: ---- 2.0.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ postsrsd.spec ++++++ --- /var/tmp/diff_new_pack.az1LI7/_old 2023-08-13 19:18:00.656127041 +0200 +++ /var/tmp/diff_new_pack.az1LI7/_new 2023-08-13 19:18:00.660127066 +0200 @@ -17,7 +17,7 @@ Name: postsrsd -Version: 2.0.6 +Version: 2.0.7 Release: 0 Summary: Sender Rewriting Support for postfix License: GPL-2.0-only ++++++ 2.0.6.tar.gz -> 2.0.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/.github/workflows/bsd.yml new/postsrsd-2.0.7/.github/workflows/bsd.yml --- old/postsrsd-2.0.6/.github/workflows/bsd.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/postsrsd-2.0.7/.github/workflows/bsd.yml 2023-08-12 17:20:07.000000000 +0200 @@ -0,0 +1,30 @@ +# Copyright 2022 Timo Röhling <t...@gaussglocke.de> +# SPDX-License-Identifier: FSFAP +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice and +# this notice are preserved. This file is offered as-is, without any warranty. +# +name: BSD +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + freebsd: + runs-on: macos-12 + name: FreeBSD + steps: + - uses: actions/checkout@v3 + - uses: vmactions/freebsd-vm@v0 + with: + usesh: true + prepare: | + pkg install -y cmake git gmake autoconf automake + run: | + mkdir _build + cd _build + cmake .. -DDEVELOPER_BUILD=ON -DWITH_SQLITE=ON -DWITH_REDIS=ON && gmake VERBOSE=ON && ctest --output-on-failure diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/.github/workflows/ci.yml new/postsrsd-2.0.7/.github/workflows/ci.yml --- old/postsrsd-2.0.6/.github/workflows/ci.yml 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/.github/workflows/ci.yml 2023-08-12 17:20:07.000000000 +0200 @@ -5,7 +5,7 @@ # permitted in any medium without royalty provided the copyright notice and # this notice are preserved. This file is offered as-is, without any warranty. # -name: CI +name: Continuous Integration on: push: branches: @@ -14,7 +14,7 @@ branches: - main jobs: - build: + test: runs-on: ubuntu-20.04 strategy: matrix: @@ -22,7 +22,7 @@ sqlite: [OFF, ON] redis: [OFF, ON] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install dependencies run: | sudo apt-get update -qq diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/.github/workflows/musl.yml new/postsrsd-2.0.7/.github/workflows/musl.yml --- old/postsrsd-2.0.6/.github/workflows/musl.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/postsrsd-2.0.7/.github/workflows/musl.yml 2023-08-12 17:20:07.000000000 +0200 @@ -0,0 +1,38 @@ +# Copyright 2022 Timo Röhling <t...@gaussglocke.de> +# SPDX-License-Identifier: FSFAP +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice and +# this notice are preserved. This file is offered as-is, without any warranty. +# +name: Build statically linked PostSRSd +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y cmake musl-dev musl-tools + - name: Build PostSRSd + run: | + mkdir _build + cd _build + cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_C_COMPILER=musl-gcc -DCMAKE_EXE_LINKER_FLAGS=-static -DBUILD_TESTING=OFF -DWITH_SQLITE=ON -DWITH_REDIS=ON -DGENERATE_SRS_SECRET=OFF + make VERBOSE=ON + - name: Install PostSRSd + run: | + cd _build + make install DESTDIR=$PWD/_install + - name: Create TAR + run: tar -C_build/_install -cvf postsrsd_static.tar ./ + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: prebuilt + path: postsrsd_static.tar diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/.pre-commit-config.yaml new/postsrsd-2.0.7/.pre-commit-config.yaml --- old/postsrsd-2.0.6/.pre-commit-config.yaml 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/.pre-commit-config.yaml 2023-08-12 17:20:07.000000000 +0200 @@ -9,11 +9,11 @@ - id: check-yaml - id: check-added-large-files - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v15.0.7 + rev: v16.0.6 hooks: - id: clang-format - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.7.0 hooks: - id: black - repo: https://github.com/cheshirekow/cmake-format-precommit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/CHANGELOG.rst new/postsrsd-2.0.7/CHANGELOG.rst --- old/postsrsd-2.0.6/CHANGELOG.rst 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/CHANGELOG.rst 2023-08-12 17:20:07.000000000 +0200 @@ -7,6 +7,17 @@ Changelog ######### +2.0.7 +===== + +Fixed +----- + +* the parser callback for the ``original-envelope`` option used the + wrong return type, which could prevent the ``database`` mode from + activating +* PostSRSd is confirmed to build and run on FreeBSD now + 2.0.6 ===== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/CMakeLists.txt new/postsrsd-2.0.7/CMakeLists.txt --- old/postsrsd-2.0.6/CMakeLists.txt 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/CMakeLists.txt 2023-08-12 17:20:07.000000000 +0200 @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.14...3.26) project( postsrsd - VERSION 2.0.6 + VERSION 2.0.7 LANGUAGES C DESCRIPTION "Sender Rewriting Scheme daemon for Postfix" HOMEPAGE_URL "https://github.com/roehling/postsrsd" @@ -142,7 +142,7 @@ ) set(saved_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") -list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") +list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64") check_include_file(alloca.h HAVE_ALLOCA_H) check_include_file(errno.h HAVE_ERRNO_H) @@ -163,10 +163,12 @@ check_include_file(syslog.h HAVE_SYSLOG_H) check_include_file(time.h HAVE_TIME_H) check_include_file(unistd.h HAVE_UNISTD_H) +check_symbol_exists(chroot unistd.h HAVE_CHROOT) check_symbol_exists(close_range unistd.h HAVE_CLOSE_RANGE) -check_symbol_exists(strcasecmp string.h HAVE_STRCASECMP) +check_symbol_exists(setgroups grp.h HAVE_SETGROUPS) +check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP) check_symbol_exists(_stricmp string.h HAVE__STRICMP) -check_symbol_exists(strncasecmp string.h HAVE_STRNCASECMP) +check_symbol_exists(strncasecmp strings.h HAVE_STRNCASECMP) check_symbol_exists(_strnicmp string.h HAVE__STRNICMP) check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) test_big_endian(HAVE_BIG_ENDIAN) @@ -274,7 +276,15 @@ sqlite3 PRIVATE SQLITE_DQS=0 SQLITE_THREADSAFE=$<IF:$<BOOL:${WITH_MILTER}>,2,0> - SQLITE_DEFAULT_MEMSTATUS=0 SQLITE_OMIT_PROGRESS_CALLBACK + SQLITE_DEFAULT_MEMSTATUS=0 + SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 + SQLITE_LIKE_DOESNT_MATCH_BLOBS + SQLITE_MAX_EXPR_DEPTH=0 + SQLITE_OMIT_DECLTYPE + SQLITE_OMIT_DEPRECATED + SQLITE_OMIT_PROGRESS_CALLBACK + SQLITE_OMIT_SHARED_CACHE + SQLITE_USE_ALLOCA ) if(WITH_MILTER AND TARGET Threads::Threads) target_link_libraries(sqlite3 PRIVATE Threads::Threads) @@ -307,9 +317,7 @@ src/util.c ) -target_compile_definitions( - postsrsd PRIVATE _GNU_SOURCE _POSIX_C_SOURCE _FILE_OFFSET_BITS=64 -) +target_compile_definitions(postsrsd PRIVATE _GNU_SOURCE _FILE_OFFSET_BITS=64) target_include_directories(postsrsd PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") target_compile_features(postsrsd PRIVATE c_std_99) target_link_libraries( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/cmake/utils.cmake new/postsrsd-2.0.7/cmake/utils.cmake --- old/postsrsd-2.0.6/cmake/utils.cmake 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/cmake/utils.cmake 2023-08-12 17:20:07.000000000 +0200 @@ -38,7 +38,7 @@ CONFIGURE_COMMAND <SOURCE_DIR>/configure --disable-shared --prefix=<INSTALL_DIR> "CC=${cc_executable}" "AR=${ar_executable}" - "RANLIB=${CMAKE_RANLIB}" + "RANLIB=${CMAKE_RANLIB}" "MAKE=${MAKE_EXECUTABLE}" "CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uc_build_type}}" BUILD_COMMAND ${MAKE_EXECUTABLE} -j INSTALL_COMMAND ${MAKE_EXECUTABLE} -j install diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/config.c new/postsrsd-2.0.7/src/config.c --- old/postsrsd-2.0.6/src/config.c 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/config.c 2023-08-12 17:20:07.000000000 +0200 @@ -24,6 +24,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #include <unistd.h> #ifndef HAVE_STRCASECMP @@ -36,9 +37,9 @@ const char* value, void* result) { if (strcasecmp(value, "embedded") == 0) - *(int*)result = SRS_ENVELOPE_EMBEDDED; + *(long*)result = SRS_ENVELOPE_EMBEDDED; else if (strcasecmp(value, "database") == 0) - *(int*)result = SRS_ENVELOPE_DATABASE; + *(long*)result = SRS_ENVELOPE_DATABASE; else { cfg_error(cfg, "option '%s' must be either 'embedded' or 'database'", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/main.c new/postsrsd-2.0.7/src/main.c --- old/postsrsd-2.0.6/src/main.c 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/main.c 2023-08-12 17:20:07.000000000 +0200 @@ -26,6 +26,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef HAVE_FCNTL_H +# include <fcntl.h> +#endif #ifdef HAVE_ERRNO_H # include <errno.h> #endif @@ -86,6 +89,7 @@ } if (chroot_dir && *chroot_dir) { +#ifdef HAVE_CHROOT if (chdir(chroot_dir) < 0) { log_perror(errno, @@ -97,10 +101,14 @@ log_perror(errno, "cannot drop privileges: chroot"); return false; } +#else + log_error("chroot is not supported on this system"); + return false; +#endif } if (target_uid != 0 || target_gid != 0) { -#ifdef HAVE_GRP_H +#ifdef HAVE_SETGROUPS if (setgroups(0, NULL) < 0) { log_perror(errno, "cannot drop privileges: setgroups"); @@ -159,12 +167,23 @@ const char* srs_domain, domain_set_t* local_domains, int conn) { - FILE* fp_read = fdopen(conn, "r"); - if (fp_read == NULL) - return; +#ifdef HAVE_FCNTL_H + int flags = fcntl(conn, F_GETFL); + if (flags & O_NONBLOCK) + { + if (fcntl(conn, F_SETFL, flags & ~O_NONBLOCK) < 0) + { + log_error("failed to make socket connection blocking"); + return; + } + } +#endif FILE* fp_write = fdopen(dup(conn), "w"); if (fp_write == NULL) return; + FILE* fp_read = fdopen(conn, "r"); + if (fp_read == NULL) + return; database_t* db = NULL; if (cfg_getint(cfg, "original-envelope") == SRS_ENVELOPE_DATABASE) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/milter.c new/postsrsd-2.0.7/src/milter.c --- old/postsrsd-2.0.6/src/milter.c 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/milter.c 2023-08-12 17:20:07.000000000 +0200 @@ -21,18 +21,19 @@ #include "srs.h" #include "util.h" -#ifndef HAVE_STRNCASECMP -# ifdef HAVE__STRNICMP -# define strncasecmp _strnicmp -# endif -#endif - #ifdef WITH_MILTER # include <libmilter/mfapi.h> # ifdef HAVE_UNISTD_H # include <unistd.h> # endif # include <string.h> +# include <strings.h> + +# ifndef HAVE_STRNCASECMP +# ifdef HAVE__STRNICMP +# define strncasecmp _strnicmp +# endif +# endif static char* milter_uri = NULL; static char* milter_path = NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/postsrsd_build_config.h.in new/postsrsd-2.0.7/src/postsrsd_build_config.h.in --- old/postsrsd-2.0.6/src/postsrsd_build_config.h.in 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/postsrsd_build_config.h.in 2023-08-12 17:20:07.000000000 +0200 @@ -31,7 +31,10 @@ #cmakedefine WITH_SQLITE 1 #cmakedefine HAVE_BIG_ENDIAN 1 +#cmakedefine HAVE_CHROOT 1 #cmakedefine HAVE_CLOSE_RANGE 1 +#cmakedefine HAVE_CLOSE_RANGE_GNU 1 +#cmakedefine HAVE_SETGROUPS 1 #cmakedefine HAVE_STRCASECMP 1 #cmakedefine HAVE__STRICMP 1 #cmakedefine HAVE_STRNCASECMP 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/srs2.c new/postsrsd-2.0.7/src/srs2.c --- old/postsrsd-2.0.6/src/srs2.c 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/srs2.c 2023-08-12 17:20:07.000000000 +0200 @@ -18,15 +18,12 @@ * information. */ -#include <postsrsd_build_config.h> -#include <stdarg.h> -#include <string.h> /* memcpy, strcpy, memset */ -#ifdef HAVE_ALLOCA_H -# include <alloca.h> -#endif +#include "srs2.h" #include "sha1.h" -#include "srs2.h" + +#include <postsrsd_build_config.h> +#include <stdarg.h> #ifndef HAVE_STRCASECMP # ifdef HAVE__STRICMP @@ -139,6 +136,7 @@ srs_f_free(srs->secrets[i]); srs->secrets[i] = 0; } + srs_f_free(srs->secrets); srs_f_free(srs); } @@ -265,7 +263,6 @@ char* secret; char* data; int len; - char* lcdata; unsigned char* hp; char* bp; int i; @@ -284,7 +281,7 @@ { data = va_arg(ap, char*); len = strlen(data); - lcdata = alloca(len + 1); + char lcdata[len + 1]; for (j = 0; j < len; j++) { if (isupper(data[j])) @@ -359,8 +356,6 @@ int srs_hash_check(srs_t* srs, char* hash, int nargs, ...) { va_list ap; - char* srshash; - char* tmp; int len; int i; @@ -369,17 +364,13 @@ return SRS_EHASHTOOSHORT; if (len > srs->hashlength) { - tmp = alloca(srs->hashlength + 1); - strncpy(tmp, hash, srs->hashlength); - tmp[srs->hashlength] = '\0'; - hash = tmp; len = srs->hashlength; } + char srshash[srs->hashlength + 1]; for (i = 0; i < srs->numsecrets; i++) { va_start(ap, nargs); - srshash = alloca(srs->hashlength + 1); srs_hash_create_v(srs, i, srshash, nargs, ap); va_end(ap); if (strncasecmp(hash, srshash, len) == 0) @@ -392,7 +383,6 @@ int srs_compile_shortcut(srs_t* srs, char* buf, int buflen, char* sendhost, char* senduser, const char* aliashost) { - char* srshash; char srsstamp[SRS_TIME_SIZE + 1]; int len; int ret; @@ -418,7 +408,7 @@ srs->faketime ? srs->faketime : time(NULL)); if (ret != SRS_SUCCESS) return ret; - srshash = alloca(srs->hashlength + 1); + char srshash[srs->hashlength + 1]; ret = srs_hash_create(srs, srshash, 3, srsstamp, sendhost, senduser); if (ret != SRS_SUCCESS) return ret; @@ -434,7 +424,6 @@ { char* srshost; char* srsuser; - char* srshash; int len; int ret; @@ -442,11 +431,11 @@ && (strchr(srs_separators, senduser[4]) != NULL)) { /* Used as a temporary convenience var */ - srshash = senduser + 5; - if (*srshash == '\0') + char* tmp = senduser + 5; + if (*tmp == '\0') return SRS_ENOSRS1HASH; /* Used as a temporary convenience var */ - srshost = strchr(srshash, SRSSEP); + srshost = strchr(tmp, SRSSEP); if (!STRINGP(srshost)) return SRS_ENOSRS1HOST; *srshost++ = '\0'; @@ -454,7 +443,7 @@ if (!STRINGP(srsuser)) return SRS_ENOSRS1USER; *srsuser++ = '\0'; - srshash = alloca(srs->hashlength + 1); + char srshash[srs->hashlength + 1]; ret = srs_hash_create(srs, srshash, 2, srshost, srsuser); if (ret != SRS_SUCCESS) return ret; @@ -471,7 +460,7 @@ { srsuser = senduser + 4; srshost = sendhost; - srshash = alloca(srs->hashlength + 1); + char srshash[srs->hashlength + 1]; ret = srs_hash_create(srs, srshash, 2, srshost, srsuser); if (ret != SRS_SUCCESS) return ret; @@ -564,7 +553,6 @@ int srs_forward(srs_t* srs, char* buf, unsigned buflen, const char* sender, const char* alias) { - char* senduser; char* sendhost; char* tmp; unsigned len; @@ -594,8 +582,7 @@ } } - /* Reconstruct the whole show into our alloca() buffer. */ - senduser = alloca(len + 1); + char senduser[len + 1]; strcpy(senduser, sender); tmp = (senduser + (tmp - sender)); sendhost = tmp + 1; @@ -635,7 +622,6 @@ int srs_reverse(srs_t* srs, char* buf, unsigned buflen, const char* sender) { - char* senduser; char* tmp; unsigned len; @@ -648,7 +634,7 @@ len = strlen(sender); if (len >= buflen) return SRS_EBUFTOOSMALL; - senduser = alloca(len + 1); + char senduser[len + 1]; strcpy(senduser, sender); /* We don't really care about the host for reversal. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/srs2.h new/postsrsd-2.0.7/src/srs2.h --- old/postsrsd-2.0.6/src/srs2.h 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/srs2.h 2023-08-12 17:20:07.000000000 +0200 @@ -25,6 +25,8 @@ #include <postsrsd_build_config.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <strings.h> #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/src/util.c new/postsrsd-2.0.7/src/util.c --- old/postsrsd-2.0.6/src/util.c 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/src/util.c 2023-08-12 17:20:07.000000000 +0200 @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <strings.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> #endif @@ -202,6 +203,7 @@ int acquire_lock(const char* path) { + MAYBE_UNUSED(path); #if defined(LOCK_EX) && defined(LOCK_NB) size_t len = strlen(path); char* lock_path = malloc(len + 6); /* ".lock" + "\0" */ @@ -224,6 +226,8 @@ void release_lock(const char* path, int fd) { + MAYBE_UNUSED(path); + MAYBE_UNUSED(fd); #if defined(LOCK_EX) && defined(LOCK_NB) size_t len = strlen(path); char* lock_path = malloc(len + 6); /* ".lock" + "\0" */ @@ -549,11 +553,11 @@ void log_perror(int err, const char* prefix) { - char buffer[256]; + char* msg = strerror(err); if (prefix) - log_error("%s: %s", prefix, strerror_r(err, buffer, sizeof(buffer))); + log_error("%s: %s", prefix, msg); else - log_error("%s", strerror_r(err, buffer, sizeof(buffer))); + log_error("%s", msg); } void log_fatal(const char* fmt, ...) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/tests/blackbox/socketmap.py new/postsrsd-2.0.7/tests/blackbox/socketmap.py --- old/postsrsd-2.0.6/tests/blackbox/socketmap.py 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/tests/blackbox/socketmap.py 2023-08-12 17:20:07.000000000 +0200 @@ -26,22 +26,44 @@ import time -def write_netstring(sock, data): +class SockStream: + def __init__(self, sock): + self._sock = sock + self._rdbuf = b"" + + def read(self, size): + result = b"" + remaining = size + while remaining > len(self._rdbuf): + result += self._rdbuf + remaining -= len(self._rdbuf) + self._rdbuf = self._sock.recv(4096) + if len(self._rdbuf) == 0: + raise ConnectionError("no data") + result += self._rdbuf[:remaining] + self._rdbuf = self._rdbuf[remaining:] + return result + + def write(self, data): + self._sock.sendall(data) + + +def write_netstring(sock_stream, data): data_bytes = data.encode() - sock.send(f"{len(data_bytes)}:".encode() + data_bytes + b",") + sock_stream.write(f"{len(data_bytes)}:".encode() + data_bytes + b",") -def read_netstring(sock): - digit = sock.recv(1) +def read_netstring(sock_stream): + digit = sock_stream.read(1) data_size = 0 while digit >= b"0" and digit <= b"9": data_size = 10 * data_size + int(digit) - digit = sock.recv(1) + digit = sock_stream.read(1) if digit != b":": print("ERR: ':' expected") return None - data = sock.recv(data_size) - comma = sock.recv(1) + data = sock_stream.read(data_size) + comma = sock_stream.read(1) if comma != b",": print("ERR: ',' expected") return None @@ -55,7 +77,7 @@ with open(tmpdir / "postsrsd.conf", "w") as f: f.write( 'domains = {"example.com"}\n' - "keep-alive = 2\n" + "keep-alive = 10\n" 'chroot-dir = ""\n' 'unprivileged-user = ""\n' f'original-envelope = {"database" if use_database else "embedded"}\n' @@ -87,10 +109,11 @@ assert st.st_mode & 0o777 == 0o666 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) sock.connect(endpoint) + sock_stream = SockStream(sock) try: for nr, query in enumerate(queries, start=1): - write_netstring(sock, query[0]) - result = read_netstring(sock) + write_netstring(sock_stream, query[0]) + result = read_netstring(sock_stream) if result != query[1]: raise AssertionError( f"query[{query[0]}]: FAILED: Expected reply {query[1]!r}, got: {result!r}" @@ -107,15 +130,16 @@ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) sock.settimeout(10) sock.connect(endpoint) - sock.send(query) - result = read_netstring(sock) + sock_stream = SockStream(sock) + sock_stream.write(query) + result = read_netstring(sock_stream) if result != "PERM Invalid query.": raise AssertionError( f"death_test[{query}]: FAILED: Expected reply 'PERM Invalid query.', got: {result!r}" ) try: - write_netstring(sock, "forward t...@example.com") - result = read_netstring(sock) + write_netstring(sock_stream, "forward t...@example.com") + result = read_netstring(sock_stream) raise AssertionError( f"death_test[{query}]: FAILED: Expected connection closed, got: {result!r}" ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/tests/unit/CMakeLists.txt new/postsrsd-2.0.7/tests/unit/CMakeLists.txt --- old/postsrsd-2.0.6/tests/unit/CMakeLists.txt 2023-07-15 20:53:41.000000000 +0200 +++ new/postsrsd-2.0.7/tests/unit/CMakeLists.txt 2023-08-12 17:20:07.000000000 +0200 @@ -20,9 +20,11 @@ ${name}_executable PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ) target_compile_definitions( - ${name}_executable PRIVATE _GNU_SOURCE _POSIX_C_SOURCE - _FILE_OFFSET_BITS=64 + ${name}_executable PRIVATE _GNU_SOURCE _FILE_OFFSET_BITS=64 ) + if(HAVE_CLOSE_RANGE_GNU AND NOT HAVE_CLOSE_RANGE) + target_compile_definitions(${name}_executable PRIVATE _GNU_SOURCE) + endif() target_link_libraries(${name}_executable PRIVATE Check::check) target_compile_features(${name}_executable PRIVATE c_std_99) if(TESTS_WITH_ASAN) @@ -46,3 +48,4 @@ test_database_executable PRIVATE $<$<BOOL:${WITH_SQLITE}>:sqlite3::sqlite3> $<$<BOOL:${WITH_REDIS}>:${HIREDIS_TARGET}> ) +add_postsrsd_test(test_srs2 ${SRCDIR}/srs2.c ${SRCDIR}/sha1.c) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/postsrsd-2.0.6/tests/unit/test_srs2.c new/postsrsd-2.0.7/tests/unit/test_srs2.c --- old/postsrsd-2.0.6/tests/unit/test_srs2.c 1970-01-01 01:00:00.000000000 +0100 +++ new/postsrsd-2.0.7/tests/unit/test_srs2.c 2023-08-12 17:20:07.000000000 +0200 @@ -0,0 +1,77 @@ +/* PostSRSd - Sender Rewriting Scheme daemon for Postfix + * Copyright 2012-2022 Timo Röhling <t...@gaussglocke.de> + * SPDX-License-Identifier: GPL-3.0-only + * + * This program 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, version 3. + * + * This program 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 program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "common.h" +#include "srs2.h" + +#include <check.h> + +srs_t* create_srs_t() +{ + srs_t* srs = srs_new(); + srs->faketime = 1577836860; /* 2020-01-01 00:01:00 UTC */ + srs_add_secret(srs, "tops3cr3t"); + return srs; +} + +START_TEST(srs2_forwarding) +{ + srs_t* srs = create_srs_t(); + char* output = NULL; + int result; + + result = srs_forward_alloc(srs, &output, "t...@example.com", "example.com"); + ck_assert_int_eq(result, SRS_SUCCESS); + ck_assert_str_eq(output, "t...@example.com"); + free(output); + + result = + srs_forward_alloc(srs, &output, "t...@otherdomain.com", "example.com"); + ck_assert_int_eq(result, SRS_SUCCESS); + ck_assert_str_eq(output, "SRS0=vmyz=2W=otherdomain.com=t...@example.com"); + free(output); + + result = srs_forward_alloc(srs, &output, "foo", "example.com"); + ck_assert_int_eq(result, SRS_ENOSENDERATSIGN); + + srs_free(srs); +} +END_TEST + +START_TEST(srs2_reversing) +{ + srs_t* srs = create_srs_t(); + char* output = NULL; + int result; + + result = srs_reverse_alloc(srs, &output, "t...@example.com"); + ck_assert_int_eq(result, SRS_ENOTSRSADDRESS); + + result = srs_reverse_alloc(srs, &output, + "SRS0=vmyz=2W=otherdomain.com=t...@example.com"); + ck_assert_int_eq(result, SRS_SUCCESS); + ck_assert_str_eq(output, "t...@otherdomain.com"); + free(output); + + srs_free(srs); +} +END_TEST + +BEGIN_TEST_SUITE(srs2) +ADD_TEST(srs2_forwarding); +ADD_TEST(srs2_reversing); +END_TEST_SUITE() +TEST_MAIN(srs2)