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-05-04 17:10:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/postsrsd (Old)
 and      /work/SRC/openSUSE:Factory/.postsrsd.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "postsrsd"

Thu May  4 17:10:49 2023 rev:8 rq:1084493 version:2.0.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/postsrsd/postsrsd.changes        2023-03-12 
16:26:58.885487563 +0100
+++ /work/SRC/openSUSE:Factory/.postsrsd.new.1533/postsrsd.changes      
2023-05-04 17:11:12.408587075 +0200
@@ -1,0 +2,7 @@
+Wed May  3 23:02:52 UTC 2023 - Jan Engelhardt <jeng...@inai.de>
+
+- Update to release 2.0.4
+  * Added new CLI option -h to print a summary of CLI options
+  * Improved error logging
+
+-------------------------------------------------------------------

Old:
----
  2.0.3.tar.gz

New:
----
  2.0.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ postsrsd.spec ++++++
--- /var/tmp/diff_new_pack.AfTt4X/_old  2023-05-04 17:11:12.880589838 +0200
+++ /var/tmp/diff_new_pack.AfTt4X/_new  2023-05-04 17:11:12.884589862 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           postsrsd
-Version:        2.0.3
+Version:        2.0.4
 Release:        0
 Summary:        Sender Rewriting Support for postfix
 License:        GPL-2.0-only

++++++ 2.0.3.tar.gz -> 2.0.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/.clang-format.license 
new/postsrsd-2.0.4/.clang-format.license
--- old/postsrsd-2.0.3/.clang-format.license    1970-01-01 01:00:00.000000000 
+0100
+++ new/postsrsd-2.0.4/.clang-format.license    2023-05-03 23:12:26.000000000 
+0200
@@ -0,0 +1,3 @@
+PostSRSd - Sender Rewriting Scheme daemon for Postfix
+Copyright 2012-2022 Timo Röhling <t...@gaussglocke.de>
+SPDX-License-Identifier: FSFUL
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/.cmake-format.json.license 
new/postsrsd-2.0.4/.cmake-format.json.license
--- old/postsrsd-2.0.3/.cmake-format.json.license       1970-01-01 
01:00:00.000000000 +0100
+++ new/postsrsd-2.0.4/.cmake-format.json.license       2023-05-03 
23:12:26.000000000 +0200
@@ -0,0 +1,3 @@
+PostSRSd - Sender Rewriting Scheme daemon for Postfix
+Copyright 2012-2022 Timo Röhling <t...@gaussglocke.de>
+SPDX-License-Identifier: FSFUL
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/.github/workflows/ci.yml 
new/postsrsd-2.0.4/.github/workflows/ci.yml
--- old/postsrsd-2.0.3/.github/workflows/ci.yml 2023-03-03 13:29:57.000000000 
+0100
+++ new/postsrsd-2.0.4/.github/workflows/ci.yml 2023-05-03 23:12:26.000000000 
+0200
@@ -26,7 +26,7 @@
       - name: Install dependencies
         run: |
           sudo apt-get update -qq
-          sudo apt-get install -y cmake faketime postfix redis
+          sudo apt-get install -y cmake postfix redis
       - name: Build PostSRSd
         run: |
           mkdir _build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/.pre-commit-config.yaml.license 
new/postsrsd-2.0.4/.pre-commit-config.yaml.license
--- old/postsrsd-2.0.3/.pre-commit-config.yaml.license  1970-01-01 
01:00:00.000000000 +0100
+++ new/postsrsd-2.0.4/.pre-commit-config.yaml.license  2023-05-03 
23:12:26.000000000 +0200
@@ -0,0 +1,3 @@
+PostSRSd - Sender Rewriting Scheme daemon for Postfix
+Copyright 2012-2022 Timo Röhling <t...@gaussglocke.de>
+SPDX-License-Identifier: FSFUL
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/CHANGELOG.rst 
new/postsrsd-2.0.4/CHANGELOG.rst
--- old/postsrsd-2.0.3/CHANGELOG.rst    2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/CHANGELOG.rst    2023-05-03 23:12:26.000000000 +0200
@@ -1,7 +1,35 @@
+..
+    PostSRSd - Sender Rewriting Scheme daemon for Postfix
+    Copyright 2012-2022 Timo Röhling <t...@gaussglocke.de>
+    SPDX-License-Identifier: GPL-3.0-only
+
 #########
 Changelog
 #########
 
+2.0.4
+=====
+
+Fixed
+-----
+
+* Worked around EXCLUDE_FROM_ALL bug in CMake 3.20.x and older
+* Fixed a few compiler warnings in the test suite
+
+Added
+-----
+
+* Added support for musl as libc alternative
+* Added support for CPack to generate installable packages
+* Added new CLI option -h to print a summary of CLI options
+
+Changed
+-------
+
+* The test suite no longer requires ``faketime`` as dependency
+* Improved error logging
+
+
 2.0.3
 =====
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/CMakeLists.txt 
new/postsrsd-2.0.4/CMakeLists.txt
--- old/postsrsd-2.0.3/CMakeLists.txt   2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/CMakeLists.txt   2023-05-03 23:12:26.000000000 +0200
@@ -17,10 +17,19 @@
 cmake_minimum_required(VERSION 3.14...3.25)
 project(
     postsrsd
-    VERSION 2.0.3
+    VERSION 2.0.4
     LANGUAGES C
+    DESCRIPTION "Sender Rewriting Scheme daemon for Postfix"
+    HOMEPAGE_URL "https://github.com/roehling/postsrsd";
 )
 
+if(CMAKE_VERSION VERSION_LESS 3.21.0)
+    # Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/22234
+    if(POLICY CMP0082)
+        cmake_policy(SET CMP0082 OLD)
+    endif()
+endif()
+
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 
 include(utils)
@@ -102,7 +111,8 @@
 FetchContent_Declare(
     Confuse
     URL 
https://github.com/libconfuse/libconfuse/releases/download/v3.3/confuse-3.3.tar.gz
-    URL_HASH MD5=f590564c6ea4879db0c8f692bf12f42a
+    URL_HASH
+        
SHA3_256=da895d91a7755941872e73ff6522fd16810f1599862990df569459a0eee94515
 )
 
 FetchContent_Declare(
@@ -119,14 +129,16 @@
 
 FetchContent_Declare(
     sqlite3
-    URL https://sqlite.org/2022/sqlite-amalgamation-3400000.zip
-    URL_HASH MD5=bcb55322db69efd9d82185ccda6c9733
+    URL https://sqlite.org/2023/sqlite-amalgamation-3410200.zip
+    URL_HASH
+        
SHA3_256=c51ca72411b8453c64e0980be23bc9b9530bdc3ec1513e06fbf022ed0fd02463
 )
 
 FetchContent_Declare(
     Check
     URL 
https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz
-    URL_HASH MD5=50fcafcecde5a380415b12e9c574e0b2
+    URL_HASH
+        
SHA3_256=bfb856a68c0ea4d930803f6bd16c1eed38910a231c9e0f0009e69310e35e7a5d
 )
 
 set(saved_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
@@ -151,7 +163,6 @@
 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_include_file(wait.h HAVE_WAIT_H)
 check_symbol_exists(close_range unistd.h HAVE_CLOSE_RANGE)
 check_symbol_exists(strcasecmp string.h HAVE_STRCASECMP)
 check_symbol_exists(_stricmp string.h HAVE__STRICMP)
@@ -181,6 +192,10 @@
         ON
         CACHE BOOL "" FORCE
     )
+    set(BUILD_SHARED_LIBS
+        OFF
+        CACHE BOOL "" FORCE
+    )
     FetchContent_MakeAvailable(Hiredis)
     if(IS_DIRECTORY "${hiredis_SOURCE_DIR}")
         set_property(
@@ -378,3 +393,27 @@
 endif()
 
 feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
+
+set(CPACK_SET_DESTDIR ON)
+set(CPACK_PACKAGE_NAME "postsrsd")
+set(CPACK_PACKAGE_VENDOR "Timo Röhling")
+set(CPACK_PACKAGE_RELOCATABLE OFF)
+set(CPACK_PACKAGE_DESCRIPTION
+    "\
+The Sender Rewriting Scheme (SRS) is a technique to forward mails from domains
+which deploy the Sender Policy Framework (SPF) to prohibit other Mail Transfer
+Agents (MTAs) from sending mails on their behalf.
+
+PostSRSd implements SRS for the Postfix MTA."
+)
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Timo Röhling <t...@gaussglocke.de>")
+set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
+set(CPACK_DEBIAN_PACKAGE_SECTION "mail")
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
+set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
+set(CPACK_RPM_PACKAGE_AUTOREQ ON)
+set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
+set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
+set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
+include(CPack)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/README.rst 
new/postsrsd-2.0.4/README.rst
--- old/postsrsd-2.0.3/README.rst       2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/README.rst       2023-05-03 23:12:26.000000000 +0200
@@ -65,7 +65,7 @@
   enable it with ``-DWITH_MILTER=ON``.
 - check_ is needed if you want to build and run the unit test suite;
   otherwise disable it with ``-DBUILD_TESTING=OFF``.
-- Python_ and faketime_ are needed for the optional blackbox tests.
+- Python_ is needed for the optional blackbox tests.
 
 PostSRSd relies on the FetchContent_ module of CMake for its dependency
 resolution. Please refer to its documentation if you wish to tweak the
@@ -81,7 +81,6 @@
 .. _check: https://github.com/libcheck/check
 .. _FetchContent: https://cmake.org/cmake/help/latest/module/FetchContent.html
 .. _Python: https://www.python.org
-.. _faketime: https://github.com/wolfcw/libfaketime
 
 Configuration
 -------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/cmake/utils.cmake 
new/postsrsd-2.0.4/cmake/utils.cmake
--- old/postsrsd-2.0.3/cmake/utils.cmake        2023-03-03 13:29:57.000000000 
+0100
+++ new/postsrsd-2.0.4/cmake/utils.cmake        2023-05-03 23:12:26.000000000 
+0200
@@ -18,12 +18,28 @@
             
"${CMAKE_STATIC_LIBRARY_PREFIX}${arg_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}"
         )
         string(TOLOWER "${name}" lc_name)
+        string(TOUPPER "${CMAKE_BUILD_TYPE}" uc_build_type)
+        if(CMAKE_C_COMPILER_AR)
+            set(ar_executable "${CMAKE_C_COMPILER_AR}")
+        else()
+            set(ar_executable "${CMAKE_AR}")
+        endif()
+        if(CMAKE_C_COMPILER_LAUNCHER)
+            set(cc_executable
+                "${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER}"
+            )
+        else()
+            set(cc_executable "${CMAKE_C_COMPILER}")
+        endif()
         ExternalProject_Add(
             Ext${name}
             SOURCE_DIR "${${lc_name}_SOURCE_DIR}"
             UPDATE_DISCONNECTED TRUE
-            CONFIGURE_COMMAND <SOURCE_DIR>/configure --disable-shared
-                              --prefix=<INSTALL_DIR>
+            CONFIGURE_COMMAND
+                <SOURCE_DIR>/configure --disable-shared --prefix=<INSTALL_DIR>
+                "CC=${cc_executable}" "AR=${ar_executable}"
+                "RANLIB=${CMAKE_RANLIB}"
+                "CFLAGS=${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uc_build_type}}"
             BUILD_COMMAND ${MAKE_EXECUTABLE} -j
             INSTALL_COMMAND ${MAKE_EXECUTABLE} -j install
             TEST_COMMAND ""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/config.c 
new/postsrsd-2.0.4/src/config.c
--- old/postsrsd-2.0.3/src/config.c     2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/config.c     2023-05-03 23:12:26.000000000 +0200
@@ -22,6 +22,7 @@
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -104,6 +105,42 @@
     return 0;
 }
 
+static void show_help()
+{
+    puts(
+        "PostSRSd - Sender Rewriting Scheme daemon for Postfix\n"
+        "\n"
+        "Available command line options:\n"
+        "  -h           show this help\n"
+        "  -C <FILE>    load configuration from <FILE>\n"
+        "               (default: " DEFAULT_CONFIG_FILE
+        ")\n"
+        "  -c <DIR>     use <DIR> as chroot directory\n"
+        "               (default: " DEFAULT_CHROOT_DIR
+        ")\n"
+        "  -D           daemonize by forking into background\n"
+        "  -p <FILE>    write PostSRSd process ID into <FILE>\n"
+        "  -u <USER>    drop root privileges and run as <USER>\n"
+        "               (default: " DEFAULT_POSTSRSD_USER
+        ")\n"
+        "  -v           show version number (" POSTSRSD_VERSION
+        ")\n"
+#if defined(WITH_SQLITE) || defined(WITH_REDIS) || defined(WITH_MILTER)
+        "\n"
+        "This binary has been compiled with\n"
+#    ifdef WITH_SQLITE
+        "* SQLite database storage support\n"
+#    endif
+#    ifdef WITH_REDIS
+        "* Redis database storage support\n"
+#    endif
+#    ifdef WITH_MILTER
+        "* Milter support (experimental)\n"
+#    endif
+#endif
+    );
+}
+
 cfg_t* config_from_commandline(int argc, char* const* argv)
 {
     static cfg_opt_t opts[] = {
@@ -142,7 +179,7 @@
     int ok = 1;
     if (file_exists(DEFAULT_CONFIG_FILE))
         set_string(&config_file, strdup(DEFAULT_CONFIG_FILE));
-    while ((opt = getopt(argc, argv, "C:c:Dp:u:v")) != -1)
+    while ((opt = getopt(argc, argv, "C:c:Dhp:u:v")) != -1)
     {
         switch (opt)
         {
@@ -157,6 +194,10 @@
             case 'D':
                 daemonize = 1;
                 break;
+            case 'h':
+                show_help();
+                exit(0);
+                break;
             case 'p':
                 set_string(&pid_file, strdup(optarg));
                 break;
@@ -240,6 +281,26 @@
             srs_free(srs);
             return NULL;
         }
+    }
+    char* faketime = getenv("POSTSRSD_FAKETIME");
+    if (faketime)
+    {
+        char* eptr;
+        long stamp = strtol(faketime, &eptr, 10);
+        if (eptr && !*eptr)
+        {
+            srs->faketime = stamp;
+            log_warn(
+                "POSTSRSD_FAKETIME=%s overrides system clock. DO NOT USE IN "
+                "PRODUCTION!",
+                faketime);
+        }
+        else
+        {
+            log_error("POSTSRSD_FAKETIME must be an integer");
+            srs_free(srs);
+            return NULL;
+        }
     }
     return srs;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/main.c 
new/postsrsd-2.0.4/src/main.c
--- old/postsrsd-2.0.3/src/main.c       2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/main.c       2023-05-03 23:12:26.000000000 +0200
@@ -38,9 +38,6 @@
 #ifdef HAVE_SYS_WAIT_H
 #    include <sys/wait.h>
 #endif
-#ifdef HAVE_WAIT_H
-#    include <wait.h>
-#endif
 #ifdef HAVE_SIGNAL_H
 #    include <signal.h>
 #endif
@@ -357,8 +354,12 @@
                 {
                     int conn = accept(fds[i].fd, NULL, NULL);
                     if (conn < 0)
+                    {
+                        log_perror(errno, "accept");
                         continue;
-                    if (fork() == 0)
+                    }
+                    pid_t pid = fork();
+                    if (pid == 0)
                     {
                         for (unsigned j = 0; j < (unsigned)num_sockets; ++j)
                             close(socketmaps[j]);
@@ -366,6 +367,10 @@
                                                 local_domains, conn);
                         exit(EXIT_SUCCESS);
                     }
+                    if (pid < 0)
+                    {
+                        log_perror(errno, "fork");
+                    }
                     close(conn);
                 }
             }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/postsrsd_build_config.h.in 
new/postsrsd-2.0.4/src/postsrsd_build_config.h.in
--- old/postsrsd-2.0.3/src/postsrsd_build_config.h.in   2023-03-03 
13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/postsrsd_build_config.h.in   2023-05-03 
23:12:26.000000000 +0200
@@ -56,6 +56,5 @@
 #cmakedefine HAVE_SYSLOG_H 1
 #cmakedefine HAVE_TIME_H 1
 #cmakedefine HAVE_UNISTD_H 1
-#cmakedefine HAVE_WAIT_H 1
 
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/srs.c new/postsrsd-2.0.4/src/srs.c
--- old/postsrsd-2.0.3/src/srs.c        2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/srs.c        2023-05-03 23:12:26.000000000 +0200
@@ -35,7 +35,7 @@
     {
         if (info)
             *info = "No domain.";
-        log_info("<%s> not forward-rewritten: no domain", addr);
+        log_info("<%s> not rewritten: no domain", addr);
         return NULL;
     }
     const char* input_domain = at + 1;
@@ -43,7 +43,7 @@
     {
         if (info)
             *info = "Need not rewrite local domain.";
-        log_info("<%s> not forward-rewritten: local domain", addr);
+        log_info("<%s> not rewritten: local domain", addr);
         return NULL;
     }
     char db_alias_buf[35];
@@ -56,7 +56,7 @@
         db_alias = b32h_encode(digest, 20, db_alias_buf, sizeof(db_alias_buf));
         if (!db_alias)
         {
-            log_warn("<%s> not forward-rewritten: aliasing error", addr);
+            log_warn("<%s> not rewritten: aliasing error", addr);
             if (error)
                 *error = true;
             if (info)
@@ -85,7 +85,7 @@
     free(output);
     if (info)
         *info = srs_strerror(result);
-    log_info("<%s> not forward-rewritten: %s", addr, srs_strerror(result));
+    log_info("<%s> not rewritten: %s", addr, srs_strerror(result));
     return NULL;
 }
 
@@ -102,13 +102,13 @@
     {
         if (info)
             *info = srs_strerror(result);
-        log_info("<%s> not reverse-rewritten: %s", addr, srs_strerror(result));
+        log_info("<%s> not reversed: %s", addr, srs_strerror(result));
         return NULL;
     }
     const char* at = strchr(buffer, '@');
     if (!at)
     {
-        log_info("<%s> not reverse-rewritten: internal error", addr);
+        log_info("<%s> not reversed: internal error", addr);
         if (error)
             *error = true;
         if (info)
@@ -128,7 +128,7 @@
             char* sender = database_read(db, buffer);
             if (!sender)
             {
-                log_info("<%s> not reverse-rewritten: unknown alias", addr);
+                log_info("<%s> not reversed: unknown alias", addr);
                 if (info)
                     *info = "Unknown alias.";
                 return NULL;
@@ -138,7 +138,7 @@
         }
         else
         {
-            log_info("<%s> not reverse-rewritten: no database for alias", 
addr);
+            log_info("<%s> not reversed: no database for alias", addr);
             if (error)
                 *error = true;
             if (info)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/srs2.c 
new/postsrsd-2.0.4/src/srs2.c
--- old/postsrsd-2.0.3/src/srs2.c       2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/srs2.c       2023-05-03 23:12:26.000000000 +0200
@@ -127,6 +127,7 @@
     srs->hashlength = 4;
     srs->hashmin = srs->hashlength;
     srs->alwaysrewrite = FALSE;
+    srs->faketime = 0;
 }
 
 void srs_free(srs_t* srs)
@@ -232,7 +233,10 @@
         then = (then << SRS_TIME_BASEBITS) | off;
     }
 
-    time(&now);
+    if (srs->faketime)
+        now = srs->faketime;
+    else
+        time(&now);
     now = (now / SRS_TIME_PRECISION) % SRS_TIME_SLOTS;
     while (now < then)
         now = now + SRS_TIME_SLOTS;
@@ -410,7 +414,8 @@
     if (len >= buflen)
         return SRS_EBUFTOOSMALL;
 
-    ret = srs_timestamp_create(srs, srsstamp, time(NULL));
+    ret = srs_timestamp_create(srs, srsstamp,
+                               srs->faketime ? srs->faketime : time(NULL));
     if (ret != SRS_SUCCESS)
         return ret;
     srshash = alloca(srs->hashlength + 1);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/srs2.h 
new/postsrsd-2.0.4/src/srs2.h
--- old/postsrsd-2.0.3/src/srs2.h       2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/srs2.h       2023-05-03 23:12:26.000000000 +0200
@@ -123,6 +123,8 @@
     srs_bool noforward;     /* Never perform forwards rewriting */
     srs_bool noreverse;     /* Never perform reverse rewriting */
     char** neverrewrite;    /* A list of non-rewritten domains */
+
+    time_t faketime; /* Added for testing purposes */
 } srs_t;
 
 /* Interface */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/src/util.c 
new/postsrsd-2.0.4/src/util.c
--- old/postsrsd-2.0.3/src/util.c       2023-03-03 13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/src/util.c       2023-05-03 23:12:26.000000000 +0200
@@ -23,6 +23,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_FCNTL_H
+#    include <fcntl.h>
+#endif
 #ifdef HAVE_SYS_FILE_H
 #    include <sys/file.h>
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/tests/blackbox/CMakeLists.txt 
new/postsrsd-2.0.4/tests/blackbox/CMakeLists.txt
--- old/postsrsd-2.0.3/tests/blackbox/CMakeLists.txt    2023-03-03 
13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/tests/blackbox/CMakeLists.txt    2023-05-03 
23:12:26.000000000 +0200
@@ -14,23 +14,21 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-find_program(FAKETIME_EXECUTABLE NAMES faketime)
 find_package(Python3 3.3 QUIET)
 
-if(FAKETIME_EXECUTABLE AND Python3_EXECUTABLE)
+if(Python3_EXECUTABLE)
     add_test(
         NAME test_socketmap
         COMMAND
             "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/socketmap.py"
-            "${FAKETIME_EXECUTABLE}" "$<TARGET_FILE:postsrsd>"
-            "$<BOOL:${WITH_SQLITE}>"
+            "$<TARGET_FILE:postsrsd>" "$<BOOL:${WITH_SQLITE}>"
     )
     if(WITH_MILTER)
         add_test(
             NAME test_milter
             COMMAND
                 "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/milter.py"
-                "${FAKETIME_EXECUTABLE}" "$<TARGET_FILE:postsrsd>"
+                "$<TARGET_FILE:postsrsd>"
         )
     endif()
 endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/tests/blackbox/milter.py 
new/postsrsd-2.0.4/tests/blackbox/milter.py
--- old/postsrsd-2.0.3/tests/blackbox/milter.py 2023-03-03 13:29:57.000000000 
+0100
+++ new/postsrsd-2.0.4/tests/blackbox/milter.py 2023-05-03 23:12:26.000000000 
+0200
@@ -75,7 +75,7 @@
 
 
 @contextlib.contextmanager
-def postsrsd_instance(faketime, postsrsd, when):
+def postsrsd_instance(postsrsd, when):
     with tempfile.TemporaryDirectory() as tmpdirname:
         tmpdir = pathlib.Path(tmpdirname)
         with open(tmpdir / "postsrsd.conf", "w") as f:
@@ -92,12 +92,15 @@
             )
         with open(tmpdir / "postsrsd.secret", "w") as f:
             f.write("tops3cr3t\n")
+        os.environ["POSTSRSD_FAKETIME"] = when
         proc = subprocess.Popen(
-            [faketime, when, postsrsd, "-C", str(tmpdir / "postsrsd.conf")],
+            [postsrsd, "-C", str(tmpdir / "postsrsd.conf")],
             start_new_session=True,
         )
-        while not (tmpdir / "postsrsd.sock").exists():
+        wait = 50
+        while not (tmpdir / "postsrsd.sock").exists() and wait > 0:
             time.sleep(0.1)
+            wait -= 1
         try:
             yield str(tmpdir / "postsrsd.sock").encode()
         finally:
@@ -105,8 +108,8 @@
             proc.wait()
 
 
-def execute_queries(faketime, postsrsd, when, queries):
-    with postsrsd_instance(faketime, postsrsd, when) as endpoint:
+def execute_queries(postsrsd, when, queries):
+    with postsrsd_instance(postsrsd, when) as endpoint:
         for query in queries:
             orig_from, orig_rcpt = query[0]
             new_from, new_rcpt = query[1]
@@ -130,8 +133,7 @@
 if __name__ == "__main__":
     execute_queries(
         sys.argv[1],
-        sys.argv[2],
-        when="2020-01-01 00:01:00 UTC",
+        when="1577836860",  # 2020-01-01 00:01:00 UTC
         queries=[
             (("sen...@example.com", "recipi...@example.com"), (None, None)),
             (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/tests/blackbox/socketmap.py 
new/postsrsd-2.0.4/tests/blackbox/socketmap.py
--- old/postsrsd-2.0.3/tests/blackbox/socketmap.py      2023-03-03 
13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/tests/blackbox/socketmap.py      2023-05-03 
23:12:26.000000000 +0200
@@ -49,7 +49,7 @@
 
 
 @contextlib.contextmanager
-def postsrsd_instance(faketime, postsrsd, when, use_database):
+def postsrsd_instance(postsrsd, when, use_database):
     with tempfile.TemporaryDirectory() as tmpdirname:
         tmpdir = pathlib.Path(tmpdirname)
         with open(tmpdir / "postsrsd.conf", "w") as f:
@@ -65,8 +65,9 @@
             )
         with open(tmpdir / "postsrsd.secret", "w") as f:
             f.write("tops3cr3t\n")
+        os.environ["POSTSRSD_FAKETIME"] = when
         proc = subprocess.Popen(
-            [faketime, when, postsrsd, "-C", str(tmpdir / "postsrsd.conf")],
+            [postsrsd, "-C", str(tmpdir / "postsrsd.conf")],
             start_new_session=True,
         )
         wait = 50
@@ -80,8 +81,8 @@
             proc.wait()
 
 
-def execute_queries(faketime, postsrsd, when, use_database, queries):
-    with postsrsd_instance(faketime, postsrsd, when, use_database) as endpoint:
+def execute_queries(postsrsd, when, use_database, queries):
+    with postsrsd_instance(postsrsd, when, use_database) as endpoint:
         st = os.stat(endpoint)
         assert st.st_mode & 0o777 == 0o666
         sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
@@ -99,8 +100,8 @@
             sock.close()
 
 
-def execute_death_tests(faketime, postsrsd, when, use_database, queries):
-    with postsrsd_instance(faketime, postsrsd, when, use_database) as endpoint:
+def execute_death_tests(postsrsd, when, use_database, queries):
+    with postsrsd_instance(postsrsd, when, use_database) as endpoint:
         for nr, query in enumerate(queries, start=1):
             try:
                 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
@@ -118,7 +119,7 @@
                     raise AssertionError(
                         f"death_test[{query}]: FAILED: Expected connection 
closed, got: {result!r}"
                     )
-                except ConnectionResetError:
+                except ConnectionError:
                     # Expected behavior
                     pass
                 sys.stderr.write(f"death_test[{query}]: Passed\n")
@@ -129,8 +130,7 @@
 if __name__ == "__main__":
     execute_queries(
         sys.argv[1],
-        sys.argv[2],
-        when="2020-01-01 00:01:00 UTC",
+        when="1577836860",  # 2020-01-01 00:01:00 UTC
         use_database=False,
         queries=[
             # No rewrite for local domain
@@ -256,8 +256,7 @@
     )
     execute_death_tests(
         sys.argv[1],
-        sys.argv[2],
-        when="2020-01-01 00:01:00 UTC",
+        when="1577836860",  # 2020-01-01 00:01:00 UTC
         use_database=False,
         queries=[
             # Empty query
@@ -272,11 +271,10 @@
             b"28:forward t...@otherdomain.com;",
         ],
     )
-    if sys.argv[3] == "1":
+    if sys.argv[2] == "1":
         execute_queries(
             sys.argv[1],
-            sys.argv[2],
-            when="2020-01-01 00:01:00 UTC",
+            when="1577836860",  # 2020-01-01 00:01:00 UTC
             use_database=True,
             queries=[
                 # Regular rewrite
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/postsrsd-2.0.3/tests/unit/test_netstring.c 
new/postsrsd-2.0.4/tests/unit/test_netstring.c
--- old/postsrsd-2.0.3/tests/unit/test_netstring.c      2023-03-03 
13:29:57.000000000 +0100
+++ new/postsrsd-2.0.4/tests/unit/test_netstring.c      2023-05-03 
23:12:26.000000000 +0200
@@ -105,7 +105,7 @@
     written = netstring_write(f, "0123456789abcdefgh", 17);
     ck_assert_int_eq(written, 21);
 
-    fseek(f, 0, SEEK_SET);
+    ck_assert_int_eq(fseek(f, 0, SEEK_SET), 0);
 
     data = netstring_read(f, buffer, sizeof(buffer), &length);
     ck_assert_ptr_nonnull(data);
@@ -119,11 +119,11 @@
     data = netstring_read(f, buffer, sizeof(buffer), &length);
     ck_assert_ptr_null(data);
 
-    fseek(f, 0, SEEK_SET);
-    ftruncate(fileno(f), 0);
+    ck_assert_int_eq(fseek(f, 0, SEEK_SET), 0);
+    ck_assert_int_eq(ftruncate(fileno(f), 0), 0);
     fwrite("3:abc,4:abcde", 1, 13, f);
 
-    fseek(f, 0, SEEK_SET);
+    ck_assert_int_eq(fseek(f, 0, SEEK_SET), 0);
     data = netstring_read(f, buffer, sizeof(buffer), &length);
     ck_assert_ptr_nonnull(data);
     ck_assert_uint_eq(length, 3);
@@ -132,11 +132,11 @@
     data = netstring_read(f, buffer, sizeof(buffer), &length);
     ck_assert_ptr_null(data);
 
-    fseek(f, 0, SEEK_SET);
-    ftruncate(fileno(f), 0);
+    ck_assert_int_eq(fseek(f, 0, SEEK_SET), 0);
+    ck_assert_int_eq(ftruncate(fileno(f), 0), 0);
     fwrite("999:obviously too short,", 1, 4, f);
 
-    fseek(f, 0, SEEK_SET);
+    ck_assert_int_eq(fseek(f, 0, SEEK_SET), 0);
     data = netstring_read(f, buffer, sizeof(buffer), &length);
     ck_assert_ptr_null(data);
     fclose(f);

Reply via email to