New version 3.8.2

spec file clean up

Resolves: RHEL-27603
This commit is contained in:
Martin Osvald 2024-04-05 09:25:59 +02:00
parent bb8d51e86a
commit a6ba61827f
10 changed files with 144 additions and 1009 deletions

2
.gitignore vendored
View File

@ -16,3 +16,5 @@
/cyrus-imapd-3.8.0.tar.gz.sig
/cyrus-imapd-3.8.1.tar.gz
/cyrus-imapd-3.8.1.tar.gz.sig
/cyrus-imapd-3.8.2.tar.gz
/cyrus-imapd-3.8.2.tar.gz.sig

View File

@ -1,18 +1,13 @@
%global testdata_commit ca669d4b76c71cbeb4fa840e263e2c031e19ea88
%global testdata_short %(echo %{testdata_commit} | cut -c -8)
# Cassandane was split into separate CI test:
# https://src.fedoraproject.org/tests/cyrus-imapd/blob/main/f/Sanity/cassandane
# Run: `rpmbuild '--with cassandane'` to enable it.
# Run: `echo '%%_with_cassandane 1' >> ~/.rpmmacros && dnf builddep rpmbuild/SPECS/cyrus-imapd.spec`
# to install dependencies for it.
%bcond_with cassandane
Name: cyrus-imapd
Version: 3.8.1
Release: 9%{?dist}
Version: 3.8.2
Release: 1%{?dist}
Summary: A high-performance email, contacts and calendar server
License: BSD-Attribution-HPND-disclaimer
URL: http://www.cyrusimap.org/
%define ssl_pem_file_prefix /etc/pki/%name/%name
# cyrus-imapd does not to support LTO
# https://github.com/cyrusimap/cyrus-imapd/pull/4679
%define _lto_cflags %{nil}
# UID/GID 76 have long been reserved for Cyrus
%define uid 76
@ -22,11 +17,17 @@ Release: 9%{?dist}
%define cyrusgroup mail
%define cyrexecdir %_libexecdir/%name
%define ssl_pem_file_prefix /etc/pki/%name/%name
%global __provides_exclude ^perl\\(AnnotateInlinedCIDs\\)$
Summary: A high-performance email, contacts and calendar server
License: BSD-Attribution-HPND-disclaimer
URL: http://www.cyrusimap.org/
# Cassandane testsuite now called from separate CI test and no longer executed during build time:
# https://src.fedoraproject.org/tests/cyrus-imapd/blob/main/f/Sanity/cassandane
# CASSANDANE* and CASSANDANE*_END used for extracting commands needed for running the testsuite.
# Run: `rpmbuild '--with cassandane'` to enable it.
# Run: `echo '%%_with_cassandane 1' >> ~/.rpmmacros && dnf builddep rpmbuild/SPECS/cyrus-imapd.spec`
# to install cassandane dependencies.
%bcond_with cassandane
Source0: https://github.com/cyrusimap/cyrus-imapd/releases/download/cyrus-imapd-%version/cyrus-imapd-%version.tar.gz
Source1: https://github.com/cyrusimap/cyrus-imapd/releases/download/cyrus-imapd-%version/cyrus-imapd-%version.tar.gz.sig
@ -43,27 +44,8 @@ Source17: cyrus-imapd-init.service
Source18: cyrus-imapd.tmpfiles.conf
Source19: cyrus-imapd.sysusers
# Source files for running the Cassandane test suite at build time.
Source80: https://github.com/brong/Net-CalDAVTalk/archive/%{testdata_commit}/cassandane-testdata-%{testdata_short}.tar.gz
# A template config file for cassandane; we will substitute in varions values.
Source81: cassandane.ini
# These are source files and not patches because you can't use autosetup to
# apply patches to secondary unpacked source files.
# Prevent cassandane from trying to syslog things
Source91: patch-cassandane-no-syslog
# Tell the annotator script to run as the current user/group
# Upstream ticket https://github.com/cyrusimap/cyrus-imapd/issues/1995
Source92: patch-cassandane-fix-annotator
# TODO libexec/cyrus-imapd path element got into upstream:
# https://github.com/cyrusimap/cyrus-imapd/commit/9233f70bf7a2872ab0b456ea294ce36e0e01e182
# try to get fixed the below upstream to work on Fedora:
# https://github.com/cyrusimap/cyrus-imapd/commit/f10eee167313418d84e63d215310477d4fe68e94
Source93: patch-cassandane-xapian-delve-path
# Syslog depending tests started to fail after perl fix:
# https://github.com/Perl/perl5/commit/80c1f1e45e8ef8c27d170fae7ade41971fe20218
# https://github.com/Perl/perl5/issues/21240
Source94: patch-cassandane-getsyslog-fix
# Adapt a timeout to handle our slower builders
Patch0: patch-cyrus-testsuite-timeout
@ -77,18 +59,19 @@ Patch2: patch-cyrus-rename-quota
# https://bugzilla.redhat.com/show_bug.cgi?id=1668723
# https://github.com/cyrusimap/cyrus-imapd/issues/2629#issuecomment-456925909
Patch3: patch-cyrus-perl-linking
# Remove attribute always_inline to fix compilation error:
# https://bugzilla.redhat.com/show_bug.cgi?id=2223951
# TODO: report upstream with patch
Patch4: patch-cyrus-remove-always-inline-for-buf-len
Patch5: patch-cyrus-rename-imtest
# Port to pcre2posix instead of the deprecated pcreposix
# https://github.com/cyrusimap/cyrus-imapd/pull/4736
Patch6: patch-cyrus-pcre2
# Fix build with libxml2 2.12.0
# https://github.com/cyrusimap/cyrus-imapd/pull/4745
# https://github.com/cyrusimap/cyrus-imapd/pull/4768
Patch7: patch-cyrus-libxml212
# Cassandane patches:
# Prevent cassandane from trying to syslog things
Patch91: patch-cassandane-no-syslog
# Tell the annotator script to run as the current user/group
# Upstream ticket https://github.com/cyrusimap/cyrus-imapd/issues/1995
Patch92: patch-cassandane-fix-annotator
# TODO libexec/cyrus-imapd path element got into upstream:
# https://github.com/cyrusimap/cyrus-imapd/commit/9233f70bf7a2872ab0b456ea294ce36e0e01e182
# try to get fixed the below upstream to work on Fedora:
# https://github.com/cyrusimap/cyrus-imapd/commit/f10eee167313418d84e63d215310477d4fe68e94
Patch93: patch-cassandane-xapian-delve-path
BuildRequires: autoconf automake bison flex gcc gcc-c++ git glibc-langpack-en
BuildRequires: groff libtool make pkgconfig rsync systemd transfig
@ -150,9 +133,6 @@ BuildRequires: perl(Module::Load::Conditional)
BuildRequires: cpan cld2-devel
BuildRequires: perl(Plack::Loader) perl(Test::TCP) perl(Data::GUID) perl(Digest::CRC) perl(Moo) perl(Types::Standard)
BuildRequires: perl(DBD::SQLite)
# These were only for JMAP-Tester
# perl(Moo), perl(Moose), perl(MooseX::Role::Parameterized) perl(Throwable), perl(Safe::Isa)
%endif
Requires(pre): shadow-utils
@ -240,36 +220,20 @@ Summary: Perl libraries for interfacing with Cyrus IMAPd
%description -n perl-Cyrus
This package contains Perl libraries used to interface with Cyrus IMAPd.
%prep
%if 0%{?fedora} || 0%{?rhel} > 8
%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
%endif
%autosetup -p1
# https://github.com/cyrusimap/cyrus-imapd/commit/216934c3f4884999206715db3499fc0162e1d65c
echo %version > VERSION
# Install the Fedora-specific documentation file
install -m 644 %SOURCE15 doc/
%if %{with cassandane}
pushd cassandane
mkdir work
tar xf %SOURCE80
patch -p1 < %SOURCE91
patch -p1 < %SOURCE92
patch -p1 < %SOURCE93
patch -p1 < %SOURCE94
cp %SOURCE81 cassandane.ini
# RF rpm-buildroot-usage
sed -i \
-e "s!CASSDIR!$(pwd)!" \
-e "s!BUILDROOT!%buildroot!" \
cassandane.ini
popd
%endif
# The pm files have shebang lines for some reason
sed -i -e '1{/usr.bin.perl/d}' perl/annotator/{Message,Daemon}.pm
@ -288,52 +252,33 @@ sed -i \
-e '/^#!perl/d' \
-e '/^#!\/bin\/sh/d' \
-e '/^#! \/bin\/sh/d' \
perl/sieve/scripts/installsieve.pl \
perl/sieve/scripts/sieveshell.pl perl/imap/cyradm.sh tools/config2header \
tools/masssievec tools/config2rst tools/mknewsgroups tools/config2sample \
tools/mkimap tools/translatesieve
# UPDATE: as of 3.4.2 most of the above files got the shabang fixed. Leaving
# the fixed files and this memo here temporarily:
# cyrus-imapd-*/nmp/snmpgen - no longer exists
# cyrus-imapd-*/perl/sieve/scripts/installsieve.pl - still contains shabang
# cyrus-imapd-*/perl/sieve/scripts/sieveshell.pl - fixed
# cyrus-imapd-*/perl/imap/cyradm.sh - still contains shabang
# cyrus-imapd-*/tools/config2header - fixed
# cyrus-imapd-*/tools/masssievec - fixed
# cyrus-imapd-*/tools/config2rst - fixed
# cyrus-imapd-*/tools/mknewsgroups - fixed
# cyrus-imapd-*/tools/config2sample - fixed
# cyrus-imapd-*/tools/mkimap - fixed
# cyrus-imapd-*/tools/translatesieve - still contains shabang
perl/sieve/scripts/installsieve.pl perl/imap/cyradm.sh tools/translatesieve
# TODO: let the above remnants get fixed upstream like it happened for previous occurences:
# https://github.com/cyrusimap/cyrus-imapd/commit/09fd77717044f96e900c38b1e361028ef39ba381
# https://github.com/cyrusimap/cyrus-imapd/commit/bbb7c68a6b55ffe9356d2033192fffbcafc4d73f
%if %{with cassandane}
pushd cassandane
mkdir work
cp %SOURCE81 cassandane.ini
# RF rpm-buildroot-usage
sed -i \
-e "s!CASSDIR!$(pwd)!" \
-e "s!BUILDROOT!%buildroot!" \
cassandane.ini
popd
%endif
%build
#autoreconf -vi
%if %{with cassandane}
# This module is not available in Fedora:
yes | cpan IO::File::fcntl
# This is the test suite, which doesn't build much but does verify its dependencies.
# If this is done after the configure call, the one thing it does build fails
# because the configure macro puts some hardening flags into the environment.
pushd cassandane
export NOCYRUS=1
make
popd
# Needed for Cyrus::FastMail tests to pass
export CLD2_CFLAGS="-I/usr/include/cld2"
export CLD2_LIBS="-lcld2"
%endif
# Needed because of Patch4.
autoreconf -vi
# Notes about configure options:
# --enable-objectstore
# It's experimental, and it doesn't appear that either openio or caringo are
# in Fedora.
# --with-cyrus-prefix and --with-service-path went away; use --with-libexecdir=
# instead.
%configure \
--disable-silent-rules \
\
@ -364,7 +309,8 @@ autoreconf -vi
--enable-replication \
--enable-unit-tests \
--enable-xapian \
#
`# Force use of pcre2 in case pcre still available` \
--disable-pcre
# Try to get rid of RPATH....
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
@ -379,14 +325,25 @@ for i in perl/annotator perl/imap perl/sieve/managesieve; do
popd
done
# rebuild for patch-cyrus-pcre2
rm -f sieve/sieve.c
%make_build
# This isn't built by default, but this package has always installed it.
make notifyd/notifytest
# CASSANDANE_BUILD
%if %{with cassandane}
# This module is not available in Fedora:
yes | cpan IO::File::fcntl
# This is the test suite, which doesn't build much but does verify its dependencies.
pushd cassandane
export NOCYRUS=1
make
popd
%endif
# CASSANDANE_BUILD_END
%install
make install DESTDIR=%buildroot
@ -518,9 +475,8 @@ find %buildroot -name ".packlist" -exec rm {} \;
# And this one gets installed with executable permission
chmod -x %buildroot/%perl_vendorlib/Cyrus/Annotator/Daemon.pm
%check
export LD_LIBRARY_PATH=%buildroot/%_libdir
%check
%if %{without cassandane}
exit 0
%endif
@ -531,7 +487,7 @@ exit 0
# TODO: The mime_boundary_extended cunit test fails due to LTO on ppc64le, skip it for now:
%ifnarch ppc64le
make %{?_smp_mflags} check || exit 1
make -j%{?_smp_build_ncpus} check || exit 1
%endif
# Cassandane cannot run solely as root because imap services would otherwise quit:
@ -540,8 +496,18 @@ make %{?_smp_mflags} check || exit 1
#imap/httpd.c: if (geteuid() == 0) fatal("must run as the Cyrus user", EX_USAGE);
#imap/pop3d.c: if (geteuid() == 0) fatal("must run as the Cyrus user", EX_USAGE);
getent group saslauth >/dev/null || /usr/sbin/groupadd -g %gid -r saslauth
# Set up shell and home directory for cyrus so that debugging of failing tests is easier.
getent passwd cyrus >/dev/null && /usr/sbin/usermod -s /bin/bash cyrus
getent passwd cyrus >/dev/null || /usr/sbin/useradd -c "Cyrus IMAP Server" -d /var/lib/imap -g %cyrusgroup \
-G saslauth -s /sbin/nologin -u %uid -r %cyrususer
-G saslauth -s /bin/bash -u %uid -r %cyrususer -m
# Set LD_LIBRARY_PATH for cyrus so that it points to cyrus-imapd libraries we just built.
[ -z "`grep LD_LIBRARY_PATH /var/lib/imap/.bashrc`" ] && echo "export LD_LIBRARY_PATH=%buildroot/%_libdir" >> /var/lib/imap/.bashrc
# CASSANDANE
# TODO: Temporary workaround for missing mail::IMAPTalk methods.
# https://github.com/robmueller/mail-imaptalk/commit/0cf2624edca6fc0dd1cdc851a8710af928ba1f1e
dnf downgrade -y https://kojipkgs.fedoraproject.org//packages/perl-Mail-IMAPTalk/4.04/22.fc39/noarch/perl-Mail-IMAPTalk-4.04-22.fc39.noarch.rpm
# Run the Cassandane test suite. This will exhaustively test the various
# server components, but running it in a mock chroot is rather an exercise.
@ -557,7 +523,7 @@ chown -R cyrus:mail .
# ---------------------------------------------------------
exclude=()
tests=(
# This exclusion list was verified on 2023-06-28.
# This exclusion list was verified on 2024-03-27.
# This tests coredumping and won't work on a machine where systemd
# intercepts coredumps, which includes our builders.
@ -567,12 +533,19 @@ tests=(
# https://github.com/cyrusimap/cyrus-imapd/issues/2386
Admin.imap_admins
# Failing with '405 Method Not Allowed':
Cyrus::FastMail.search_deleted_folder
Cyrus::JMAPCalendars.calendarevent_query_no_sched_inbox
# Failing with Perl exception: Cannot connect to server: hostname verification failed:
Cyrus::MboxEvent.tls_login_event
# TODO currently failing
Cyrus::Flags.userflags_crash
Cyrus::JMAPCore.eventsource
Cyrus::JMAPEmail.email_query_no_guidsearch_ignore_jmapuploads
Cyrus::JMAPEmail.email_query_seen_multimbox
Cyrus::JMAPEmail.email_query_unicodefdfx
Cyrus::JMAPMailbox.mailbox_ignore_notes_subfolders
Cyrus::JMAPMailbox.mailbox_set_create_specialuse_nochildren
Cyrus::JMAPMailbox.mailbox_set_sharewith_acl
Cyrus::JMAPSieve.getmetadata
Cyrus::SearchSquat.nonincremental
Cyrus::SearchSquat.incremental
Cyrus::SearchSquat.one_doc_per_message
)
for i in ${tests[@]}; do exclude+=("!$i"); done
@ -585,6 +558,7 @@ exclude+=(
"!Cyrus::FastMail.relocate_legacy_nodomain"
"!Cyrus::FastMail.relocate_legacy_nosearchdb"
"!Cyrus::FastMail.relocate_messages_still_exist"
"!Cyrus::FastMail.search_deleted_folder"
"!Cyrus::FastMail.sync_reset_legacy"
"!Cyrus::FastMail.sync_reset_nolegacy"
)
@ -599,7 +573,14 @@ exclude+=("!Master.maxforkrate")
%endif
# Add -vvv for too much output
sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags} -v -f pretty ${exclude[@]} 2>&1
sudo -u cyrus -g mail LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl -j%{?_smp_build_ncpus} -v -f pretty ${exclude[@]} 2>&1 || :
# CASSANDANE_END
if [ -s "work/failed" ]; then
cat work/failed
exit 1
fi
%pre
%sysusers_create_compat %{SOURCE19}
@ -613,6 +594,7 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%postun
%systemd_postun_with_restart cyrus-imapd.service
%files
%license COPYING
%doc README.md doc/README.* doc/examples doc/text
@ -661,6 +643,7 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_sbindir}/tls_prune
%{_sbindir}/unexpunge
%{_datadir}/cyrus-imapd
%{_mandir}/man1/dav_reconstruct.1*
%{_mandir}/man5/cyrus.conf.5*
%{_mandir}/man5/imapd.conf.5*
%{_mandir}/man5/krb.equiv.5*
@ -674,6 +657,7 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_mandir}/man8/ctl_mboxlist.8*
%{_mandir}/man8/ctl_zoneinfo.8*
%{_mandir}/man8/cvt_cyrusdb.8*
%{_mandir}/man8/cvt_xlist_specialuse.8*
%{_mandir}/man8/cyr_backup.8*
%{_mandir}/man8/cyr_buildinfo.8*
%{_mandir}/man8/cyr_dbtool.8*
@ -682,9 +666,13 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_mandir}/man8/cyr_expire.8*
%{_mandir}/man8/cyr_fetchnews.8*
%{_mandir}/man8/cyr_info.8*
%{_mandir}/man8/cyr_ls.8*
%{_mandir}/man8/cyr_quota.8*
%{_mandir}/man8/cyr_restore.8*
%{_mandir}/man8/cyr_synclog.8*
%{_mandir}/man8/cyr_userseen.8*
%{_mandir}/man8/cyradm.8*
%{_mandir}/man8/cyrdump.8*
%{_mandir}/man8/deliver.8*
%{_mandir}/man8/fud.8*
%{_mandir}/man8/httpd.8cyrus*
@ -692,14 +680,25 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_mandir}/man8/imapd.8cyrus*
%{_mandir}/man8/ipurge.8*
%{_mandir}/man8/lmtpd.8*
%{_mandir}/man8/lmtpproxyd.8*
%{_mandir}/man8/master.8cyrus*
%{_mandir}/man8/mbexamine.8*
%{_mandir}/man8/mbpath.8*
%{_mandir}/man8/mbtool.8*
%{_mandir}/man8/mupdate.8*
%{_mandir}/man8/nntpd.8*
%{_mandir}/man8/notifyd.8*
%{_mandir}/man8/pop3d.8cyrus*
%{_mandir}/man8/pop3proxyd.8*
%{_mandir}/man8/promstatsd.8*
%{_mandir}/man8/proxyd.8*
%{_mandir}/man8/ptdump.8*
%{_mandir}/man8/ptexpire.8*
%{_mandir}/man8/ptloader.8*
%{_mandir}/man8/reconstruct.8*
%{_mandir}/man8/relocate_by_id.8*
%{_mandir}/man8/sievec.8*
%{_mandir}/man8/sieved.8*
%{_mandir}/man8/smmapd.8*
%{_mandir}/man8/squatter.8*
%{_mandir}/man8/sync_client.8*
@ -808,6 +807,7 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_mandir}/man1/sieveshell.1*
%{_mandir}/man1/sivtest.1*
%{_mandir}/man1/smtptest.1*
%{_mandir}/man1/synctest.1*
%files virusscan
%{_sbindir}/cyr_virusscan
@ -828,7 +828,12 @@ sudo -u cyrus LD_LIBRARY_PATH=%buildroot/%_libdir ./testrunner.pl %{?_smp_mflags
%{_mandir}/man3/Cyrus::IMAP::Shell.3pm*
%{_mandir}/man3/Cyrus::SIEVE::managesieve.3pm*
%changelog
* Fri Apr 05 2024 Martin Osvald <mosvald@redhat.com> - 3.8.2-1
- New version 3.8.2 (RHEL-27603)
- spec file clean up
* Mon Mar 25 2024 Martin Osvald <mosvald@redhat.com> - 3.8.1-9
- Do not create mail group to prevent dependency loop (RHEL-27161)

View File

@ -1,7 +1,7 @@
diff --git a/utils/annotator.pl b/utils/annotator.pl
diff --git a/cassandane/utils/annotator.pl b/cassandane/utils/annotator.pl
index 265c73f..8af3d58 100755
--- a/utils/annotator.pl
+++ b/utils/annotator.pl
--- a/cassandane/utils/annotator.pl
+++ b/cassandane/utils/annotator.pl
@@ -140,6 +140,8 @@ GetOptions(
xlog "annotator $$ starting";
Cassandane::AnnotatorDaemon->run(

View File

@ -1,20 +0,0 @@
diff --git a/cassandane/Cassandane/Instance.pm b/cassandane/Cassandane/Instance.pm
index a2dc672..cc29490 100644
--- a/Cassandane/Instance.pm
+++ b/Cassandane/Instance.pm
@@ -2250,6 +2250,15 @@ sub getsyslog
my ($self) = @_;
my $logname = $self->{name};
if ($self->{have_syslog_replacement} && $self->{_syslogfh}) {
+ # https://github.com/Perl/perl5/issues/21240
+ # eof status is no longer cleared automatically in newer perls
+ if ($self->{_syslogfh}->eof()) {
+ $self->{_syslogfh}->clearerr();
+ }
+ if ($self->{_syslogfh}->error()) {
+ die "error reading $self->{syslog_fname}";
+ }
+
# hopefully unobtrusively, let busy log finish writing
usleep(100_000); # 100ms (0.1s) as us
my @lines = grep { m/$logname/ } $self->{_syslogfh}->getlines();

View File

@ -1,7 +1,7 @@
diff --git a/Cassandane/Util/Log.pm b/Cassandane/Util/Log.pm
diff --git a/cassandane/Cassandane/Util/Log.pm b/cassandane/Cassandane/Util/Log.pm
index a44005c..5bb5710 100644
--- a/Cassandane/Util/Log.pm
+++ b/Cassandane/Util/Log.pm
--- a/cassandane/Cassandane/Util/Log.pm
+++ b/cassandane/Cassandane/Util/Log.pm
@@ -51,9 +51,6 @@ our @EXPORT = qw(
my $verbose = 0;
@ -20,10 +20,10 @@ index a44005c..5bb5710 100644
}
sub set_verbose
diff --git a/utils/syslog.c b/utils/syslog.c
diff --git a/cassandane/utils/syslog.c b/cassandane/utils/syslog.c
index 20d3763..0238d82 100644
--- a/utils/syslog.c
+++ b/utils/syslog.c
--- a/cassandane/utils/syslog.c
+++ b/cassandane/utils/syslog.c
@@ -116,14 +116,28 @@ EXPORTED void syslog(int priority, const char *format, ...)
va_start(ap, format);
fake_vsyslog(priority, format, ap);

View File

@ -1,7 +1,7 @@
diff --git a/Cassandane/Instance.pm b/Cassandane/Instance.pm
diff --git a/cassandane/Cassandane/Instance.pm b/cassandane/Cassandane/Instance.pm
index 78e7100..edf6f5d 100644
--- a/Cassandane/Instance.pm
+++ b/Cassandane/Instance.pm
--- a/cassandane/Cassandane/Instance.pm
+++ b/cassandane/Cassandane/Instance.pm
@@ -492,9 +492,7 @@ sub _find_binary
my $base = $self->{cyrus_destdir} . $self->{cyrus_prefix};

View File

@ -1,102 +0,0 @@
From 37ceb82f0641b03d25d9a158423abbb270fe3867 Mon Sep 17 00:00:00 2001
From: David King <amigadave@amigadave.com>
Date: Mon, 27 Nov 2023 10:34:40 +0000
Subject: [PATCH] Add libxml/parser.h include
This is required for libxml2 2.12.0 and above.
---
imap/ctl_zoneinfo.c | 1 +
imap/http_dav.c | 1 +
imap/http_dav_sharing.c | 2 ++
imap/http_ischedule.c | 2 ++
imap/vcard_support.c | 1 +
imap/xcal.c | 1 +
6 files changed, 8 insertions(+)
diff --git a/imap/ctl_zoneinfo.c b/imap/ctl_zoneinfo.c
index 76e3cfdd17..f42cff3131 100644
--- a/imap/ctl_zoneinfo.c
+++ b/imap/ctl_zoneinfo.c
@@ -57,6 +57,7 @@
#include <sys/types.h>
#include <libical/ical.h>
+#include <libxml/parser.h>
#include <libxml/tree.h>
#include "annotate.h" /* for strlist functionality */
diff --git a/imap/http_dav.c b/imap/http_dav.c
index efa817a192..581b80e573 100644
--- a/imap/http_dav.c
+++ b/imap/http_dav.c
@@ -93,6 +93,7 @@
#include "imap/imap_err.h"
#include <errno.h>
+#include <libxml/parser.h>
#include <libxml/uri.h>
static const struct dav_namespace_t {
diff --git a/imap/http_dav_sharing.c b/imap/http_dav_sharing.c
index 5fff46eba4..26fe7f4e6a 100644
--- a/imap/http_dav_sharing.c
+++ b/imap/http_dav_sharing.c
@@ -59,6 +59,8 @@
#include "imap/http_err.h"
#include "imap/imap_err.h"
+#include <libxml/parser.h>
+
#define DAVNOTIFICATION_CONTENT_TYPE \
"application/davnotification+xml; charset=utf-8"
diff --git a/imap/http_ischedule.c b/imap/http_ischedule.c
index 24c30b48e1..9ac1b6fa7d 100644
--- a/imap/http_ischedule.c
+++ b/imap/http_ischedule.c
@@ -52,6 +52,8 @@
#include <libical/ical.h>
+#include <libxml/parser.h>
+
#include "global.h"
#include "httpd.h"
#include "http_caldav_sched.h"
diff --git a/imap/vcard_support.c b/imap/vcard_support.c
index aa9e15ac7e..f15824225e 100644
--- a/imap/vcard_support.c
+++ b/imap/vcard_support.c
@@ -42,6 +42,7 @@
*/
#include <config.h>
+#include <libxml/parser.h>
#include <libxml/tree.h>
#include "vcard_support.h"
diff --git a/imap/xcal.c b/imap/xcal.c
index 1f43d75488..cc749ab439 100644
--- a/imap/xcal.c
+++ b/imap/xcal.c
@@ -47,6 +47,7 @@
#include <stddef.h> /* for offsetof() macro */
#include <syslog.h>
+#include <libxml/parser.h>
#include <libxml/tree.h>
#include "httpd.h"
diff --git a/imap/jmap_calendar.c b/imap/jmap_calendar.c
index b60470e..553ef1c 100644
--- a/imap/jmap_calendar.c
+++ b/imap/jmap_calendar.c
@@ -52,6 +52,8 @@
#include <unistd.h>
#endif
+#include <libxml/parser.h>
+
#include "acl.h"
#include "annotate.h"
#include "append.h"

View File

@ -1,729 +0,0 @@
From 259f3c69bfffe5ccc999675f9edda5c99afc79a0 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Wed, 8 Nov 2023 14:23:10 +1100
Subject: [PATCH 1/5] various: add pcre2 support
without removing pcre1 support
Based on a patch from @yselkowitz in #4545
---
configure.ac | 21 +++++++++++++++++++++
docsrc/assets/cyrus-build-devpkg.rst | 2 +-
docsrc/assets/cyrus-build-reqpkg.rst | 2 +-
docsrc/imap/developer/compiling.rst | 3 ++-
docsrc/imap/download/upgrade.rst | 2 +-
imap/cyr_buildinfo.c | 5 +++++
lib/util.h | 21 ++++++++++++---------
ptclient/test3.c | 2 +-
sieve/bc_eval.c | 4 +++-
sieve/comparator.h | 21 ++++++++++++---------
sieve/sieve.y | 4 +++-
11 files changed, 62 insertions(+), 25 deletions(-)
diff --git a/configure.ac b/configure.ac
index cad8dd8f16..6b9f6a7a7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -678,6 +678,8 @@ AC_ARG_ENABLE(sieve,
[AS_HELP_STRING([--disable-sieve], [disable Sieve support])],,[enable_sieve="yes";])
AC_ARG_ENABLE(pcre,
[AS_HELP_STRING([--disable-pcre], [disable PCRE library])],[cyrus_cv_pcre_utf8="$enableval"])
+AC_ARG_ENABLE(pcre2,
+ [AS_HELP_STRING([--disable-pcre2], [disable PCRE2 library])],[cyrus_cv_pcre2_utf8="$enableval"])
if test "$enable_sieve" != "no"; then
AC_DEFINE(USE_SIEVE,[],[Build in Sieve support?])
@@ -717,11 +719,29 @@ if test "$enable_pcre" != "no"; then
fi
fi
+if test "$enable_pcre2" != "no"; then
+ AC_CHECK_HEADER(pcre2posix.h)
+ if test "$ac_cv_header_pcre2posix_h" = "yes"; then
+ AC_MSG_CHECKING(for utf8 enabled pcre2)
+ AC_CACHE_VAL(cyrus_cv_pcre2_utf8, AC_TRY_CPP([#include <pcre2posix.h>
+#ifndef REG_UTF
+#include </nonexistent>
+#endif],cyrus_cv_pcre2_utf8=yes,cyrus_cv_pcre2_utf8=no))
+ AC_MSG_RESULT($cyrus_cv_pcre2_utf8)
+ else
+ cyrus_cv_pcre2_utf8="no"
+ fi
+fi
+
LIB_REGEX=
if test "$cyrus_cv_pcre_utf8" = "yes"; then
LIB_REGEX="-lpcre -lpcreposix";
AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
+elif test "$cyrus_cv_pcre2_utf8" = "yes"; then
+ LIB_REGEX="-lpcre2-posix -lpcre2-8";
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+ AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?])
else
AC_CHECK_HEADERS(rxposix.h)
if test "$ac_cv_header_rxposix_h" = "yes"; then
@@ -2569,6 +2589,7 @@ External dependencies:
zlib: $with_zlib
jansson: $with_jansson
pcre: $cyrus_cv_pcre_utf8
+ pcre2: $cyrus_cv_pcre2_utf8
clamav: $with_clamav
-----------------------
caringo: $with_caringo
diff --git a/docsrc/assets/cyrus-build-devpkg.rst b/docsrc/assets/cyrus-build-devpkg.rst
index cf3eaef1b3..5c0156bb64 100644
--- a/docsrc/assets/cyrus-build-devpkg.rst
+++ b/docsrc/assets/cyrus-build-devpkg.rst
@@ -8,7 +8,7 @@ automated test facility.
debhelper flex g++ git gperf groff heimdal-dev libbsd-resource-perl libclone-perl libconfig-inifiles-perl \
libcunit1-dev libdatetime-perl libbsd-dev libdigest-sha-perl libencode-imaputf7-perl \ libfile-chdir-perl libglib2.0-dev libical-dev libio-socket-inet6-perl \
libio-stringy-perl libldap2-dev libmysqlclient-dev \
- libnet-server-perl libnews-nntpclient-perl libpam0g-dev libpcre3-dev libsasl2-dev \
+ libnet-server-perl libnews-nntpclient-perl libpam0g-dev libpcre2-dev libsasl2-dev \
libsqlite3-dev libssl-dev libtest-unit-perl libtool libunix-syslog-perl liburi-perl \
libxapian-dev libxml-generator-perl libxml-xpath-perl libxml2-dev libwrap0-dev libzephyr-dev lsb-base \
net-tools perl php-cli php-curl pkg-config po-debconf tcl-dev \
diff --git a/docsrc/assets/cyrus-build-reqpkg.rst b/docsrc/assets/cyrus-build-reqpkg.rst
index a3a530cc39..1c8bb45951 100644
--- a/docsrc/assets/cyrus-build-reqpkg.rst
+++ b/docsrc/assets/cyrus-build-reqpkg.rst
@@ -2,6 +2,6 @@
sudo apt-get install git build-essential autoconf automake libtool \
pkg-config bison flex libssl-dev libjansson-dev libxml2-dev \
- libsqlite3-dev libical-dev libsasl2-dev libpcre3-dev uuid-dev \
+ libsqlite3-dev libical-dev libsasl2-dev libpcre2-dev uuid-dev \
libicu-dev
sudo apt-get -t jessie-backports install libxapian-dev
diff --git a/docsrc/imap/developer/compiling.rst b/docsrc/imap/developer/compiling.rst
index e05f3e43b1..2a351df5b1 100644
--- a/docsrc/imap/developer/compiling.rst
+++ b/docsrc/imap/developer/compiling.rst
@@ -194,7 +194,7 @@ Other
to enable **ptloader** to interface with LDAP directly, for canonification
of login usernames to mailbox names, and verification of login usernames,
ACL subjects and group membership. Configure option: ``--with-ldap``."
- `pcre`_, libpcre3-dev, pcre-devel, "yes", "PCRE 1 (8.x) - for utf-8/unicode
+ `pcre2`_, libpcre2-dev, pcre2-devel, "yes", "PCRE 2 (10.x) - for utf-8/unicode
regular expression matching. Could be replaced by something else in the
future. See `issues/1731`_ for more information."
`perl(Term::ReadLine)`_,,, "no", "Perl library needed by **cyradm**."
@@ -219,6 +219,7 @@ Other
.. _nghttp2: https://nghttp2.org/
.. _openldap: http://www.openldap.org/
.. _pcre: http://www.pcre.org/
+.. _pcre2: http://www.pcre.org/
.. _perl(Term::ReadLine): https://metacpan.org/pod/Term::ReadLine
.. _perl(ExtUtils::MakeMaker): http://search.cpan.org/dist/ExtUtils-MakeMaker/
.. _perl(Pod::POM::View::Restructured): https://metacpan.org/pod/Pod::POM::View::Restructured
diff --git a/docsrc/imap/download/upgrade.rst b/docsrc/imap/download/upgrade.rst
index 353a0114b8..09db9232b7 100644
--- a/docsrc/imap/download/upgrade.rst
+++ b/docsrc/imap/download/upgrade.rst
@@ -223,7 +223,7 @@ packages) for Debian is::
libcunit1-dev libdatetime-perl libdigest-sha-perl libencode-imaputf7-perl \
libfile-chdir-perl libglib2.0-dev libical-dev libio-socket-inet6-perl \
libio-stringy-perl libjansson-dev libldap2-dev libmysqlclient-dev \
- libnet-server-perl libnews-nntpclient-perl libpam0g-dev libpcre3-dev \
+ libnet-server-perl libnews-nntpclient-perl libpam0g-dev libpcre2-dev \
libsasl2-dev libsqlite3-dev libssl-dev libtest-unit-perl libtool \
libunix-syslog-perl liburi-perl libxapian-dev libxml-generator-perl \
libxml-xpath-perl libxml2-dev libwrap0-dev libzephyr-dev lsb-base \
diff --git a/imap/cyr_buildinfo.c b/imap/cyr_buildinfo.c
index 3d596c726a..a011101993 100644
--- a/imap/cyr_buildinfo.c
+++ b/imap/cyr_buildinfo.c
@@ -202,6 +202,11 @@ static json_t *buildinfo()
#else
json_object_set_new(dependency, "pcre", json_false());
#endif
+#if defined(ENABLE_REGEX) && defined(HAVE_PCRE2POSIX_H)
+ json_object_set_new(dependency, "pcre2", json_true());
+#else
+ json_object_set_new(dependency, "pcre2", json_false());
+#endif
#ifdef HAVE_CLAMAV
json_object_set_new(dependency, "clamav", json_true());
#else
diff --git a/lib/util.h b/lib/util.h
index 7f7ab9f655..6cdd95a271 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -71,17 +71,20 @@
extern const char CYRUS_VERSION[];
#ifdef ENABLE_REGEX
-# ifdef HAVE_PCREPOSIX_H
+# if defined HAVE_PCREPOSIX_H
# include <pcre.h>
# include <pcreposix.h>
-# else /* !HAVE_PCREPOSIX_H */
-# ifdef HAVE_RXPOSIX_H
-# include <rxposix.h>
-# else /* !HAVE_RXPOSIX_H */
-# include <regex.h>
-# endif /* HAVE_RXPOSIX_H */
-# endif /* HAVE_PCREPOSIX_H */
-#endif /* ENABLE_REGEX */
+# elif defined HAVE_PCRE2POSIX_H
+# ifndef PCRE2POSIX_H_INCLUDED
+# include <pcre2posix.h>
+# define PCRE2POSIX_H_INCLUDED
+# endif
+# elif defined HAVE_RXPOSIX_H
+# include <rxposix.h>
+# else
+# include <regex.h>
+# endif
+#endif
#ifdef HAVE_LIBUUID
#include <uuid/uuid.h>
diff --git a/sieve/bc_eval.c b/sieve/bc_eval.c
index 17241e166f..67d39355fa 100644
--- a/sieve/bc_eval.c
+++ b/sieve/bc_eval.c
@@ -321,9 +321,11 @@ static int regcomp_flags(int comparator, int requires)
{
int cflags = REG_EXTENDED;
-#ifdef HAVE_PCREPOSIX_H
/* support UTF8 comparisons */
+#if defined HAVE_PCREPOSIX_H
cflags |= REG_UTF8;
+#elif defined HAVE_PCRE2POSIX_H
+ cflags |= REG_UTF;
#endif
if (comparator == B_ASCIICASEMAP) {
diff --git a/sieve/comparator.h b/sieve/comparator.h
index b043bc296b..8c58bd1e73 100644
--- a/sieve/comparator.h
+++ b/sieve/comparator.h
@@ -47,17 +47,20 @@
#include <sys/types.h>
#ifdef ENABLE_REGEX
-# ifdef HAVE_PCREPOSIX_H
+# if defined HAVE_PCREPOSIX_H
# include <pcre.h>
# include <pcreposix.h>
-# else /* !HAVE_PCREPOSIX_H */
-# ifdef HAVE_RXPOSIX_H
-# include <rxposix.h>
-# else /* !HAVE_RXPOSIX_H */
-# include <regex.h>
-# endif /* HAVE_RXPOSIX_H */
-# endif /* HAVE_PCREPOSIX_H */
-#endif /* ENABLE_REGEX */
+# elif defined HAVE_PCRE2POSIX_H
+# ifndef PCRE2POSIX_H_INCLUDED
+# include <pcre2posix.h>
+# define PCRE2POSIX_H_INCLUDED
+# endif
+# elif defined HAVE_RXPOSIX_H
+# include <rxposix.h>
+# else
+# include <regex.h>
+# endif
+#endif
#include "sieve_interface.h"
#include "strarray.h"
diff --git a/sieve/sieve.y b/sieve/sieve.y
index 71aa503bd3..17adb65112 100644
--- a/sieve/sieve.y
+++ b/sieve/sieve.y
@@ -2143,9 +2143,11 @@ static int verify_regexlist(sieve_script_t *sscript,
regex_t reg;
int cflags = REG_EXTENDED | REG_NOSUB;
-#ifdef HAVE_PCREPOSIX_H
/* support UTF8 comparisons */
+#if defined HAVE_PCREPOSIX_H
cflags |= REG_UTF8;
+#elif defined HAVE_PCRE2POSIX_H
+ cflags |= REG_UTF;
#endif
if (collation == B_ASCIICASEMAP) {
From 7c7e1957d9a8074aa3dd7fe113cf551eadcb494f Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Mon, 13 Nov 2023 11:10:28 +1100
Subject: [PATCH 2/5] configure.ac: tidy up sieve/pcre checks
---
configure.ac | 101 ++++++++++++++++++++++++++-------------------------
1 file changed, 51 insertions(+), 50 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6b9f6a7a7c..975925bebe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -675,82 +675,83 @@ AM_CONDITIONAL([SQUATTER],
[test "${enable_squat}" != "no" -o "${enable_xapian}" != "no" ])
AC_ARG_ENABLE(sieve,
- [AS_HELP_STRING([--disable-sieve], [disable Sieve support])],,[enable_sieve="yes";])
-AC_ARG_ENABLE(pcre,
- [AS_HELP_STRING([--disable-pcre], [disable PCRE library])],[cyrus_cv_pcre_utf8="$enableval"])
-AC_ARG_ENABLE(pcre2,
- [AS_HELP_STRING([--disable-pcre2], [disable PCRE2 library])],[cyrus_cv_pcre2_utf8="$enableval"])
+ [AS_HELP_STRING([--disable-sieve], [disable Sieve support])],,[enable_sieve="yes";])
if test "$enable_sieve" != "no"; then
- AC_DEFINE(USE_SIEVE,[],[Build in Sieve support?])
+ AC_DEFINE(USE_SIEVE,[],[Build in Sieve support?])
- if test "x$HAVE_SQLITE" != x1; then
- AC_MSG_ERROR([Need sqlite3 for sieve])
- else
- use_sqlite="yes"
- fi
+ if test "x$HAVE_SQLITE" != x1; then
+ AC_MSG_ERROR([Need sqlite3 for sieve])
+ else
+ use_sqlite="yes"
+ fi
- dnl Sieve configure stuff
- AC_PROG_YACC
- AM_PROG_LEX
+ dnl Sieve configure stuff
+ AC_PROG_YACC
+ AM_PROG_LEX
- if test -z "$ac_cv_prog_YACC"; then
- AC_MSG_ERROR([Sieve requires bison/byacc/yacc, but none is installed])
- fi
+ if test -z "$ac_cv_prog_YACC"; then
+ AC_MSG_ERROR([Sieve requires bison/byacc/yacc, but none is installed])
+ fi
- if test -z "$ac_cv_prog_LEX"; then
- AC_MSG_ERROR([Sieve requires flex/lex, but none is installed])
- fi
+ if test -z "$ac_cv_prog_LEX"; then
+ AC_MSG_ERROR([Sieve requires flex/lex, but none is installed])
+ fi
fi
AM_CONDITIONAL([SIEVE], [test "${enable_sieve}" != "no"])
+AC_ARG_ENABLE(pcre,
+ [AS_HELP_STRING([--disable-pcre], [disable PCRE library])],[cyrus_cv_pcre_utf8="$enableval"])
+AC_ARG_ENABLE(pcre2,
+ [AS_HELP_STRING([--disable-pcre2], [disable PCRE2 library])],[cyrus_cv_pcre2_utf8="$enableval"])
+
if test "$enable_pcre" != "no"; then
- AC_CHECK_HEADER(pcreposix.h)
- if test "$ac_cv_header_pcreposix_h" = "yes"; then
- AC_MSG_CHECKING(for utf8 enabled pcre)
- AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
+ AC_CHECK_HEADER(pcreposix.h)
+ if test "$ac_cv_header_pcreposix_h" = "yes"; then
+ AC_MSG_CHECKING(for utf8 enabled pcre)
+ AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
#ifndef REG_UTF8
#include </nonexistent>
#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no))
- AC_MSG_RESULT($cyrus_cv_pcre_utf8)
- else
- cyrus_cv_pcre_utf8="no"
- fi
+ AC_MSG_RESULT($cyrus_cv_pcre_utf8)
+ else
+ cyrus_cv_pcre_utf8="no"
+ fi
fi
if test "$enable_pcre2" != "no"; then
- AC_CHECK_HEADER(pcre2posix.h)
- if test "$ac_cv_header_pcre2posix_h" = "yes"; then
- AC_MSG_CHECKING(for utf8 enabled pcre2)
- AC_CACHE_VAL(cyrus_cv_pcre2_utf8, AC_TRY_CPP([#include <pcre2posix.h>
+ AC_CHECK_HEADER(pcre2posix.h)
+ if test "$ac_cv_header_pcre2posix_h" = "yes"; then
+ AC_MSG_CHECKING(for utf8 enabled pcre2)
+ AC_CACHE_VAL(cyrus_cv_pcre2_utf8, AC_TRY_CPP([#include <pcre2posix.h>
#ifndef REG_UTF
#include </nonexistent>
#endif],cyrus_cv_pcre2_utf8=yes,cyrus_cv_pcre2_utf8=no))
- AC_MSG_RESULT($cyrus_cv_pcre2_utf8)
- else
- cyrus_cv_pcre2_utf8="no"
- fi
+ AC_MSG_RESULT($cyrus_cv_pcre2_utf8)
+ else
+ cyrus_cv_pcre2_utf8="no"
+ fi
fi
LIB_REGEX=
if test "$cyrus_cv_pcre_utf8" = "yes"; then
- LIB_REGEX="-lpcre -lpcreposix";
- AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
- AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
+ LIB_REGEX="-lpcre -lpcreposix";
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+ AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
elif test "$cyrus_cv_pcre2_utf8" = "yes"; then
- LIB_REGEX="-lpcre2-posix -lpcre2-8";
- AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
- AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?])
+ LIB_REGEX="-lpcre2-posix -lpcre2-8";
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+ AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?])
else
- AC_CHECK_HEADERS(rxposix.h)
- if test "$ac_cv_header_rxposix_h" = "yes"; then
- LIB_REGEX="-lrx"
- AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
- else
- AC_SEARCH_LIBS(regcomp, regex,
- AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?]), [])
- fi
+ AC_CHECK_HEADERS(rxposix.h)
+ if test "$ac_cv_header_rxposix_h" = "yes"; then
+ LIB_REGEX="-lrx"
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+ else
+ AC_SEARCH_LIBS(regcomp, regex,
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?]), [])
+ fi
fi
AC_SUBST(LIB_REGEX)
LIBS="$LIBS $LIB_REGEX"
From b9002dba94eaa8a688df4f3c280db31a4eb77f69 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Mon, 13 Nov 2023 11:32:13 +1100
Subject: [PATCH 3/5] configure.ac: use pkg-config to find pcre/pcre2
Fixes #4711
---
configure.ac | 73 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 24 deletions(-)
diff --git a/configure.ac b/configure.ac
index 975925bebe..7fed07e129 100644
--- a/configure.ac
+++ b/configure.ac
@@ -707,42 +707,65 @@ AC_ARG_ENABLE(pcre2,
[AS_HELP_STRING([--disable-pcre2], [disable PCRE2 library])],[cyrus_cv_pcre2_utf8="$enableval"])
if test "$enable_pcre" != "no"; then
- AC_CHECK_HEADER(pcreposix.h)
- if test "$ac_cv_header_pcreposix_h" = "yes"; then
- AC_MSG_CHECKING(for utf8 enabled pcre)
- AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include <pcreposix.h>
-#ifndef REG_UTF8
-#include </nonexistent>
-#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no))
- AC_MSG_RESULT($cyrus_cv_pcre_utf8)
- else
- cyrus_cv_pcre_utf8="no"
- fi
+ PKG_CHECK_MODULES([PCRE],
+ [libpcreposix libpcre],
+ [ AC_MSG_CHECKING(for utf8 enabled pcre)
+ saved_CFLAGS="$CFLAGS"
+ saved_LIBS="$LIBS"
+ CFLAGS="$CFLAGS PCRE_CFLAGS"
+ LIBS="$LIBS PCRE_LIBS"
+ AC_CACHE_VAL(cyrus_cv_pcre_utf8,
+ AC_TRY_CPP([ #include <pcreposix.h>
+ #ifndef REG_UTF8
+ #include </nonexistent>
+ #endif
+ ],
+ [cyrus_cv_pcre_utf8=yes],
+ [cyrus_cv_pcre_utf8=no]))
+ AC_MSG_RESULT($cyrus_cv_pcre_utf8)
+ CFLAGS="$saved_CFLAGS"
+ LIBS="$saved_LIBS"
+ ],
+ [cyrus_cv_pcre_utf8="no"])
fi
if test "$enable_pcre2" != "no"; then
- AC_CHECK_HEADER(pcre2posix.h)
- if test "$ac_cv_header_pcre2posix_h" = "yes"; then
- AC_MSG_CHECKING(for utf8 enabled pcre2)
- AC_CACHE_VAL(cyrus_cv_pcre2_utf8, AC_TRY_CPP([#include <pcre2posix.h>
-#ifndef REG_UTF
-#include </nonexistent>
-#endif],cyrus_cv_pcre2_utf8=yes,cyrus_cv_pcre2_utf8=no))
- AC_MSG_RESULT($cyrus_cv_pcre2_utf8)
- else
- cyrus_cv_pcre2_utf8="no"
- fi
+ PKG_CHECK_MODULES([PCRE2],
+ [libpcre2-posix libpcre2-8],
+ [ AC_MSG_CHECKING(for utf8 enabled pcre2)
+ saved_CFLAGS="$CFLAGS"
+ saved_LIBS="$LIBS"
+ CFLAGS="$CFLAGS PCRE2_CFLAGS"
+ LIBS="$LIBS PCRE2_LIBS"
+ AC_CACHE_VAL(cyrus_cv_pcre2_utf8,
+ AC_TRY_CPP([ #include <pcre2posix.h>
+ #ifndef REG_UTF
+ #include </nonexistent>
+ #endif
+ ],
+ [cyrus_cv_pcre2_utf8=yes],
+ [cyrus_cv_pcre2_utf8=no]))
+ AC_MSG_RESULT($cyrus_cv_pcre2_utf8)
+ CFLAGS="$saved_CFLAGS"
+ LIBS="$saved_LIBS"
+ ],
+ [cyrus_cv_pcre2_utf8="no"])
fi
LIB_REGEX=
+CFLAGS_REGEX=
if test "$cyrus_cv_pcre_utf8" = "yes"; then
- LIB_REGEX="-lpcre -lpcreposix";
+ CFLAGS_REGEX="$PCRE_CFLAGS"
+ LIB_REGEX="$PCRE_LIBS";
AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
+ cyrus_cv_pcre2_utf8="no"
elif test "$cyrus_cv_pcre2_utf8" = "yes"; then
- LIB_REGEX="-lpcre2-posix -lpcre2-8";
+ CFLAGS_REGEX="$PCRE2_CFLAGS"
+ LIB_REGEX="$PCRE2_LIBS"
AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?])
+ cyrus_cv_pcre_utf8="no"
else
AC_CHECK_HEADERS(rxposix.h)
if test "$ac_cv_header_rxposix_h" = "yes"; then
@@ -754,7 +777,9 @@ else
fi
fi
AC_SUBST(LIB_REGEX)
+AC_SUBST(CFLAGS_REGEX)
LIBS="$LIBS $LIB_REGEX"
+CFLAGS="$CFLAGS $CFLAGS_REGEX"
dnl
dnl see if we're compiling with SRS
From 3ff27055f73097123b7c1c8e3d83adc1f1c1f026 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Mon, 13 Nov 2023 13:38:25 +1100
Subject: [PATCH 4/5] configure.ac: prefer pcre2 if both available
---
configure.ac | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7fed07e129..186b0f1872 100644
--- a/configure.ac
+++ b/configure.ac
@@ -754,18 +754,18 @@ fi
LIB_REGEX=
CFLAGS_REGEX=
-if test "$cyrus_cv_pcre_utf8" = "yes"; then
- CFLAGS_REGEX="$PCRE_CFLAGS"
- LIB_REGEX="$PCRE_LIBS";
- AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
- AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
- cyrus_cv_pcre2_utf8="no"
-elif test "$cyrus_cv_pcre2_utf8" = "yes"; then
+if test "$cyrus_cv_pcre2_utf8" = "yes"; then
CFLAGS_REGEX="$PCRE2_CFLAGS"
LIB_REGEX="$PCRE2_LIBS"
AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?])
cyrus_cv_pcre_utf8="no"
+elif test "$cyrus_cv_pcre_utf8" = "yes"; then
+ CFLAGS_REGEX="$PCRE_CFLAGS"
+ LIB_REGEX="$PCRE_LIBS";
+ AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?])
+ AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?])
+ cyrus_cv_pcre2_utf8="no"
else
AC_CHECK_HEADERS(rxposix.h)
if test "$ac_cv_header_rxposix_h" = "yes"; then
From 1dc08fef4805f74a0b4f51dd090337d8c75f9e10 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Mon, 13 Nov 2023 14:15:33 +1100
Subject: [PATCH 5/5] add changes file
---
changes/next/pcre2-support | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 changes/next/pcre2-support
diff --git a/changes/next/pcre2-support b/changes/next/pcre2-support
new file mode 100644
index 0000000000..87ac924f94
--- /dev/null
+++ b/changes/next/pcre2-support
@@ -0,0 +1,30 @@
+Description:
+
+Adds pcre2 support. Prefers pcre2 over pcre if both are available.
+
+
+Config changes:
+
+None
+
+
+Upgrade instructions:
+
+Cyrus will prefer pcre2 over pcre if both are installed. If you have both
+installed and wish to use pcre rather than pcre2, run configure with
+--disable-pcre2.
+
+If you haven't specifically installed libpcre2-dev (or whatever your system's
+equivalent is), you might still have parts of pcre2 installed due to other
+packages on your system depending on it. This can confuse configure into
+thinking you have a usable pcre2 when you don't. Either properly install
+libpcre2-dev so Cyrus can use it, or configure Cyrus with --disable-pcre2
+so that it ignores the partial installation.
+
+Please note that on Debian-based systems, pcre (the old one, no longer
+maintained) is called "pcre3". Yes, this is confusing.
+
+
+GitHub issue:
+
+#3861 #4711
From 19f286ad8f2eda1cccb688edb7369050d92bb6c6 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Wed, 22 Nov 2023 16:28:14 +1100
Subject: [PATCH 1/4] Sieve: add bad regex case to badscript tests
---
cassandane/Cassandane/Cyrus/Sieve.pm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/cassandane/Cassandane/Cyrus/Sieve.pm b/cassandane/Cassandane/Cyrus/Sieve.pm
index 2cd463f37f..0f0a3e66a6 100644
--- a/cassandane/Cassandane/Cyrus/Sieve.pm
+++ b/cassandane/Cassandane/Cyrus/Sieve.pm
@@ -488,6 +488,16 @@ sub badscript_common
"require [\"fileinto\",\"copy\"];\nfileinto :copy \"foo\";\n");
$self->assert_str_equals('success', $res);
+ my $badregex1 = << 'EOF';
+require ["regex"];
+if header :regex "Subject" "Message (x)?(.*" {
+ stop;
+}
+EOF
+ ($res, $errs) = $self->compile_sieve_script('badregex1', $badregex1);
+ $self->assert_str_equals('failure', $res);
+ $self->assert_matches(qr/unbalanced/, $errs);
+
# TODO: test UTF-8 verification of the string parameter
}
From 0395da350fdca0b8af57f01decc26d9ccc5375eb Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Wed, 22 Nov 2023 16:29:12 +1100
Subject: [PATCH 2/4] sieve/sieve.y: fix pcre2 crash when regex_t uninitialised
Fixes crash when trying to regfree() after regcomp() failure
Seems like this usage was fine with the old pcreposix, but is a
problem with pcre2posix.
---
sieve/sieve.y | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sieve/sieve.y b/sieve/sieve.y
index 17adb65112..908f2a4ed0 100644
--- a/sieve/sieve.y
+++ b/sieve/sieve.y
@@ -2140,7 +2140,6 @@ static int verify_regexlist(sieve_script_t *sscript,
const strarray_t *sa, int collation)
{
int i, ret = 0;
- regex_t reg;
int cflags = REG_EXTENDED | REG_NOSUB;
/* support UTF8 comparisons */
@@ -2156,6 +2155,7 @@ static int verify_regexlist(sieve_script_t *sscript,
for (i = 0 ; !ret && i < strarray_size(sa) ; i++) {
const char *s = strarray_nth(sa, i);
+ regex_t reg = {0};
/* Don't try to validate a regex that includes variables */
if (supported(SIEVE_CAPA_VARIABLES) && strstr(s, "${")) continue;
From eae2966b2198b4446a5f311cb6b25070dffa4335 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Wed, 22 Nov 2023 16:50:52 +1100
Subject: [PATCH 3/4] buf.testc: regcomp failure is fatal
---
cunit/buf.testc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cunit/buf.testc b/cunit/buf.testc
index 19f52e8cb2..c88a54e8b0 100644
--- a/cunit/buf.testc
+++ b/cunit/buf.testc
@@ -646,7 +646,7 @@ static void test_replace_all(void)
CU_ASSERT_STRING_EQUAL(b.s, _in); \
\
r = regcomp(&re, _reg, REG_EXTENDED); \
- CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL_FATAL(r, 0);
#define TESTCASE_MIDDLE \
n = buf_replace_one_re(&b, &re, _rep);
#define TESTCASE_END \
From ba43ab2462adca1a6f2dbfc54d967f02bd1dcb33 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Wed, 22 Nov 2023 16:51:37 +1100
Subject: [PATCH 4/4] glob: assert that regcomp succeeded
instead of assuming it succeeded
---
lib/glob.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/glob.c b/lib/glob.c
index 06d5cb282b..89c45f0eae 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -46,6 +46,7 @@
#include <config.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
#include "util.h"
#include "glob.h"
#include "xmalloc.h"
@@ -58,6 +59,7 @@
EXPORTED glob *glob_init(const char *str, char sep)
{
struct buf buf = BUF_INITIALIZER;
+ int r;
buf_appendcstr(&buf, "(^");
while (*str) {
@@ -109,7 +111,9 @@ EXPORTED glob *glob_init(const char *str, char sep)
buf_appendcstr(&buf, "]|$)");
glob *g = xmalloc(sizeof(glob));
- regcomp(&g->regex, buf_cstring(&buf), REG_EXTENDED);
+ r = regcomp(&g->regex, buf_cstring(&buf), REG_EXTENDED);
+ /* XXX handle regex compilation failure properly! */
+ assert(r == 0);
buf_free(&buf);
return g;

View File

@ -1,20 +0,0 @@
diff --git a/imap/squatter.c b/imap/squatter.c
index 6a7accf1b..0c2de4d7a 100644
--- a/imap/squatter.c
+++ b/imap/squatter.c
@@ -427,8 +427,13 @@ static void expand_mboxnames(strarray_t *sa, int nmboxnames,
else {
/* Translate any separators in mailboxname */
char *intname = mboxname_from_external(mboxnames[i], &squat_namespace, NULL);
- int flags = recursive_flag ? 0 : MBOXTREE_SKIP_CHILDREN;
- mboxlist_mboxtree(intname, addmbox, sa, flags);
+ if (!intname || *intname == '\0') {
+ fprintf(stderr, "Mailbox %s: %s\n",
+ mboxnames[i], error_message(IMAP_MAILBOX_BADNAME));
+ } else {
+ int flags = recursive_flag ? 0 : MBOXTREE_SKIP_CHILDREN;
+ mboxlist_mboxtree(intname, addmbox, sa, flags);
+ }
free(intname);
}

View File

@ -1,3 +1,2 @@
SHA512 (cyrus-imapd-3.8.1.tar.gz) = 95473c7fbe0ccfae2b4f4dddd0448b33079c50848334054d9ce0489e74c70bc99c53f12ec3e46c9d8055480b31cc412896fc26a60ae2844cb8d7f61f9867caed
SHA512 (cyrus-imapd-3.8.1.tar.gz.sig) = 82ffa7791e643dc8ae38c763538a0d819708dc4cc18e0597f2de3c1e243adf6d27d4f41a7b96b5ffa4757ad5e206b4a494262d1936eca58d074355dd606db6f0
SHA512 (cassandane-testdata-ca669d4b.tar.gz) = c153ab0a57d04d9deeabc5ef724eaecc05030c23b170abaa44eaea2e7df409efcdeb24871f7896759e85d64193fb9f289a470b0af9a593a740ffcc45c80033ff
SHA512 (cyrus-imapd-3.8.2.tar.gz) = 16319110ad4ad10700a4e08273a7411534b4b8fa5700eca09704d2079ef95a702520083b87ac47c71a9cb223372956465d14804fbdfc78b999bf519261827501
SHA512 (cyrus-imapd-3.8.2.tar.gz.sig) = ef7cd4e85929e4b920aa322a1a28f1fd898635a0cb188dfbf5d7f7bcef13adc138877c48b1e86dbe8dd69e604732a749082e10e41b6d54283350892b063a2b3b