Skip to content

Commit af414b2

Browse files
committed
More build system cleanup
* Remove old, broken OpenSSL fallback detection * Remove Jansson fallback detection * Only check for Jansson when building the milter * Require explicit disabling of Jansson if it's not desired * Remove more stale code * Indicate correct dependencies in pkg-config file * libopenarc does not use pthreads
1 parent f298e7b commit af414b2

File tree

8 files changed

+48
-221
lines changed

8 files changed

+48
-221
lines changed

.github/workflows/build-dist.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Build dist tarball
2323
run: |
2424
autoreconf -fiv
25-
./configure
25+
./configure --without-libjansson
2626
make release
2727
working-directory: ${{ github.workspace }}/openarc
2828

.github/workflows/build.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: sudo apt update
2727

2828
- name: Install dependencies
29-
run: sudo apt install libbsd-dev libmilter-dev libssl-dev
29+
run: sudo apt install libbsd-dev libjansson-dev libmilter-dev libssl-dev
3030

3131
- name: Install Python dependencies
3232
run: sudo pip install pytest miltertest
@@ -47,6 +47,12 @@ jobs:
4747
CC=clang ./configure
4848
make -j4 CFLAGS='-Wall -Werror'
4949
50+
- name: Build OpenARC without Jansson
51+
run: |
52+
make distclean
53+
CC=clang ./configure --without-jansson
54+
make -j4
55+
5056
- name: Build OpenARC without milter
5157
run: |
5258
make distclean

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ All notable changes to this project will be documented in this file.
99
- milter - `RequireSafeKeys` configuration option.
1010

1111
### Changed
12+
- Custom OpenSSL locations must be configured using `OPENSSL_CFLAGS`
13+
and `OPENSSL_LIBS` environment variables instead of passing
14+
`--with-openssl=/path` to `configure`.
15+
- Custom Jansson locations must be configured using `LIBJANSSON_CFLAGS`
16+
and `LIBJANSSON_LIBS` environment variables instead of passing
17+
`--with-libjansson=/path` to `configure`.
18+
- Building the milter defaults to requiring Jansson. You can explicitly
19+
disable it by passing `--without-libjansson` to `configure`.
1220
- libopenarc - `ARC-Message-Signature` and `ARC-Authentication-Results` headers
1321
are excluded from the AMS, as required by RFC 8617.
1422
- libopenarc - ARC headers are returned with a space before the header value.
@@ -20,6 +28,7 @@ All notable changes to this project will be documented in this file.
2028
- libopenarc - signing with simple header canonicalization works.
2129
- libopenarc - ARC headers with a misplaced instance tag are rejected.
2230
- libopenarc - unlikely memory leak after memory allocation failures.
31+
- libopenarc - The installed pkg-config file is more correct.
2332
- openarc - use after free.
2433
- openarc - unlikely division by zero.
2534
- openarc - small memory leak during config loading.

Makefile.am

+7-8
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ libopenarc_libopenarc_la_SOURCES = \
4343
libopenarc/arc-util.h \
4444
util/arc-dstring.c \
4545
util/arc-dstring.h
46-
libopenarc_libopenarc_la_CPPFLAGS = -I$(srcdir)/util $(LIBCRYPTO_CPPFLAGS)
47-
libopenarc_libopenarc_la_CFLAGS = $(LIBCRYPTO_INCDIRS) $(LIBOPENARC_INC)
48-
libopenarc_libopenarc_la_LDFLAGS = -no-undefined $(LIBCRYPTO_LIBDIRS) -version-info $(LIBOPENARC_VERSION_INFO)
49-
libopenarc_libopenarc_la_LIBADD = $(LIBOPENARC_LIBS) $(LIBCRYPTO_LDADD)
46+
libopenarc_libopenarc_la_CPPFLAGS = -I$(srcdir)/util $(OPENSSL_CFLAGS)
47+
libopenarc_libopenarc_la_LDFLAGS = -no-undefined -version-info $(LIBOPENARC_VERSION_INFO)
48+
libopenarc_libopenarc_la_LIBADD = $(OPENSSL_LIBS)
5049
if !ALL_SYMBOLS
5150
libopenarc_libopenarc_la_DEPENDENCIES = libopenarc/symbols.map
5251
libopenarc_libopenarc_la_LDFLAGS += -export-symbols libopenarc/symbols.map
@@ -88,10 +87,10 @@ openarc_openarc_SOURCES = \
8887
util/arc-dstring.c \
8988
util/arc-dstring.h
9089
openarc_openarc_CC = $(PTHREAD_CC)
91-
openarc_openarc_CFLAGS = $(PTHREAD_CFLAGS) $(LIBCRYPTO_CFLAGS)
92-
openarc_openarc_CPPFLAGS = -I$(srcdir)/libopenarc -I$(srcdir)/util $(LIBCRYPTO_CPPFLAGS) $(LIBMILTER_INCDIRS) $(LIBJANSSON_CPPFLAGS)
93-
openarc_openarc_LDFLAGS = $(LIBCRYPTO_LIBDIRS) $(LIBMILTER_LIBDIRS) $(PTHREAD_CFLAGS) $(LIBJANSSON_LDFLAGS)
94-
openarc_openarc_LDADD = libopenarc/libopenarc.la $(LIBMILTER_LIBS) $(LIBCRYPTO_LIBS) $(PTHREAD_LIBS) $(LIBJANSSON_LIBS) $(LIBRESOLV)
90+
openarc_openarc_CFLAGS = $(PTHREAD_CFLAGS)
91+
openarc_openarc_CPPFLAGS = -I$(srcdir)/libopenarc -I$(srcdir)/util $(OPENSSL_CFLAGS) $(LIBMILTER_INCDIRS) $(LIBJANSSON_CFLAGS)
92+
openarc_openarc_LDFLAGS = $(LIBMILTER_LIBDIRS) $(PTHREAD_CFLAGS)
93+
openarc_openarc_LDADD = libopenarc/libopenarc.la $(LIBMILTER_LIBS) $(OPENSSL_LIBS) $(PTHREAD_LIBS) $(LIBJANSSON_LIBS) $(LIBRESOLV)
9594
endif
9695

9796
$(DIST_ARCHIVES).sha1: $(DIST_ARCHIVES)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ If you are building the filter, you will also need:
4444

4545
* [sendmail](https://sendmail.org) >= 8.13.0, or
4646
[Postfix](https://www.postfix.org/) >= 2.3 and libmilter.
47-
* (optional) [jansson](https://github.com/akheron/jansson) for full
47+
* (optional) [Jansson](https://github.com/akheron/jansson) >= 2.2.1 for full
4848
`SealHeaderChecks` support.
4949

5050
If you are building from a git checkout instead of a release tarball,

configure.ac

+19-203
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ then
229229
AC_MSG_ERROR(no strlcpy/strlcat found)
230230
fi
231231

232+
AC_SUBST(STRL_LIBS)
233+
232234
AC_CHECK_HEADERS([strl.h], [strl_h_found="yes"])
233235
if test x"$strl_h_found" != x"yes"
234236
then
@@ -259,13 +261,13 @@ fi
259261
if test x"$strl_h_found" = x"yes" -a x"$bsdstrl_h_found" = x"no"
260262
then
261263
AC_DEFINE([USE_STRL_H], 1,
262-
[Define to 1 if you need to include <strl.h> to get the `strlcat()' and `strlcpy()' functions.])
264+
[Define to 1 if you need to include <strl.h> to get the strlcat() and strlcpy() functions.])
263265
fi
264266

265267
if test x"$bsdstrl_h_found" = x"yes"
266268
then
267269
AC_DEFINE([USE_BSD_H], 1,
268-
[Define to 1 if you need to include <bsd/string.h> to get the `strlcat()' and `strlcpy()' functions.])
270+
[Define to 1 if you need to include <bsd/string.h> to get the strlcat() and strlcpy() functions.])
269271
fi
270272

271273
#
@@ -531,125 +533,9 @@ AM_CONDITIONAL([DEBUG], [test x"$enable_debug" = x"yes"])
531533
# OpenSSL
532534
#
533535

534-
AC_ARG_WITH([openssl],
535-
AS_HELP_STRING([--with-openssl],
536-
[location of OpenSSL includes and library]),
537-
[sslpath="$withval"], [sslpath="auto"])
538-
539-
openssl_found="no"
540-
541-
if test \( "$sslpath" = "auto" -o x"$sslpath" = x"yes" \) -a x"$PKG_CONFIG" != x""
542-
then
543-
PKG_CHECK_MODULES([LIBCRYPTO], [openssl >= 1.0.0],
544-
[openssl_found="yes"],
545-
[openssl_found="no"
546-
AC_MSG_WARN([pkg-config for openssl not found, trying manual search...])
547-
])
548-
elif test "$sslpath" != "auto" -a x"$sslpath" != x"yes"
549-
then
550-
AC_MSG_CHECKING([for OpenSSL includes])
551-
if test -f $sslpath/include/openssl/opensslv.h
552-
then
553-
LIBCRYPTO_CPPFLAGS="-I$sslpath/include"
554-
LIBCRYPTO_CFLAGS=""
555-
LIBCRYPTO_LIBDIRS="-L$sslpath/lib"
556-
LIBCRYPTO_LIBS="-lssl -lcrypto"
557-
openssl_found=yes
558-
AC_MSG_RESULT([$sslpath])
559-
else
560-
AC_MSG_RESULT([no])
561-
fi
562-
fi
563-
564-
if test x"$openssl_found" = x"no"
565-
then
566-
AC_MSG_CHECKING([for OpenSSL library and includes])
567-
ssldirs="/usr/local/ssl /usr/local /usr/sfw /opt/local /usr"
568-
if test "$sslpath" = "auto" -o "$sslpath" = "yes"
569-
then
570-
for d in $ssldirs
571-
do
572-
if test -f $d/include/openssl/opensslv.h
573-
then
574-
sslpath=$d
575-
openssl_found=yes
576-
break
577-
fi
578-
done
579-
fi
580-
case "$sslpath" in
581-
no)
582-
AC_MSG_ERROR([OpenSSL is required])
583-
;;
584-
auto)
585-
AC_MSG_ERROR([OpenSSL not found])
586-
;;
587-
*/*)
588-
AC_MSG_RESULT([$sslpath])
589-
;;
590-
*)
591-
AC_MSG_ERROR([OpenSSL not found])
592-
;;
593-
esac
594-
LIBCRYPTO_CPPFLAGS="-I$sslpath/include"
595-
LIBCRYPTO_CFLAGS=""
596-
LIBCRYPTO_LIBDIRS="-L$sslpath/lib"
597-
LIBCRYPTO_LIBS="-lssl -lcrypto"
598-
fi
599-
600-
if test x"$openssl_found" = x"yes"
601-
then
602-
saved_CFLAGS="$CFLAGS"
603-
saved_CPPFLAGS="$CPPFLAGS"
604-
saved_LDFLAGS="$LDFLAGS"
605-
saved_LIBS="$LIBS"
606-
607-
LIBS="$outer_LIBS $LIBCRYPTO_LIBS $saved_LIBS"
608-
CPPFLAGS="$LIBCRYPTO_CPPFLAGS $saved_CPPFLAGS"
609-
CFLAGS="$LIBCRYPTO_CFLAGS $saved_CFLAGS"
610-
LDFLAGS="$outer_LDFLAGS $LIBCRYPTO_LIBDIRS $saved_LDFLAGS"
611-
612-
AC_CHECK_HEADERS([openssl/bio.h openssl/conf.h openssl/crypto.h openssl/err.h openssl/evp.h openssl/md5.h openssl/opensslv.h openssl/pem.h openssl/rsa.h openssl/sha.h openssl/ssl.h], ,
613-
AC_MSG_ERROR([required OpenSSL header not found]))
614-
615-
# -ldl is needed to assist with compilation of static openssl libraries.
616-
# It appears to need dl for opening engine plugins. It fails at load
617-
# time It also fails to build on FreeBSD if enabled by default.
618-
AC_SEARCH_LIBS([ERR_peek_error], [crypto], ,
619-
AC_MSG_ERROR([libcrypto not found]))
620-
621-
AC_SEARCH_LIBS([SSL_new], [ssl], ,
622-
[
623-
if test x"$enable_shared" = x"yes"
624-
then
625-
AC_MSG_ERROR([Cannot build shared openarc
626-
against static openssl libraries.
627-
Configure with --disable-shared
628-
to get this working or obtain a
629-
shared libssl library for
630-
openarc to use.])
631-
fi
632-
633-
# avoid caching issue - last result of SSL_new
634-
# shouldn't be cached for this next check
635-
unset ac_cv_search_SSL_new
636-
LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
637-
AC_SEARCH_LIBS([SSL_new], [ssl], ,
638-
AC_MSG_ERROR([libssl not found]), [-ldl])
639-
]
640-
)
641-
642-
CFLAGS="$saved_CFLAGS"
643-
CPPFLAGS="$saved_CPPFLAGS"
644-
LDFLAGS="$saved_LDFLAGS"
645-
LIBS="$saved_LIBS"
646-
647-
fi
648-
649-
AC_SUBST(LIBCRYPTO_CFLAGS)
650-
AC_SUBST(LIBCRYPTO_CPPFLAGS)
651-
AC_SUBST(LIBCRYPTO_LIBDIRS)
652-
AC_SUBST(LIBCRYPTO_LIBS)
536+
PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.0])
537+
AC_SUBST(OPENSSL_CFLAGS)
538+
AC_SUBST(OPENSSL_LIBS)
653539

654540
#
655541
# libmilter
@@ -777,92 +663,22 @@ AC_SUBST(LIBMILTER_LIBS)
777663
# header filtering requires libjansson
778664
#
779665

780-
AC_ARG_WITH([libjansson],
781-
AS_HELP_STRING([--with-libjansson],
782-
[location of jansson includes and library]),
783-
[janssonpath="$withval"], [janssonpath="auto"])
666+
AC_ARG_WITH([libjansson], AS_HELP_STRING([--with-libjansson], [use Jansson for header field checks]))
784667

785-
LIBJANSSON_CPPFLAGS=""
786-
LIBJANSSON_LDFLAGS=""
787-
LIBJANSSON_LIBS=""
788-
789-
jansson_found="no"
790-
if test \( x"$janssonpath" = x"auto" -o x"$janssonpath" = x"yes" \) -a \
791-
x"$PKG_CONFIG" != x""
792-
then
793-
PKG_CHECK_MODULES([LIBJANSSON], [jansson >= 2.2.1],
794-
[
795-
jansson_found="yes"
796-
LIBJANSSON_CPPFLAGS="$LIBJANSSON_CFLAGS"
797-
LIBJANSSON_LIBS="$LIBJANSSON_LIBS"
798-
],
799-
[
800-
jansson_found="no"
801-
AC_MSG_WARN([pkg-config for libjansson not found, trying manual
802-
search...])
803-
])
804-
fi
668+
AS_IF(
669+
[test "x$enable_filter" != xno -a "x$with_libjansson" != xno],
670+
[
671+
PKG_CHECK_MODULES(
672+
[LIBJANSSON],
673+
[jansson >= 2.2.1],
674+
[AC_DEFINE([USE_JANSSON], [1], [use Jansson for header field checks])]
675+
)
676+
]
677+
)
805678

806-
if test x"$janssonpath" != x"no" -a x"$jansson_found" = x"no"
807-
then
808-
AC_MSG_CHECKING([for libjansson])
809-
if test x"$janssonpath" != x"auto" -a x"$janssonpath" != x"yes"
810-
then
811-
if test -f $janssonpath/include/jansson.h
812-
then
813-
AC_MSG_RESULT($janssonpath)
814-
jansson_found="yes"
815-
LIBJANSSON_CPPFLAGS="-I$janssonpath/include"
816-
LIBJANSSON_LDFLAGS="-L$janssonpath/lib"
817-
LIBJANSSON_LIBS="-ljansson"
818-
else
819-
AC_MSG_ERROR(not found at $janssonpath)
820-
fi
821-
else
822-
janssondirs="/usr /usr/local"
823-
for d in $janssondirs
824-
do
825-
if test -f $d/include/jansson.h
826-
then
827-
janssonpath=$d
828-
AC_MSG_RESULT($d)
829-
jansson_found="yes"
830-
LIBJANSSON_CPPFLAGS="-I$janssonpath/include"
831-
LIBJANSSON_LDFLAGS="-L$janssonpath/lib"
832-
LIBJANSSON_LIBS="-ljansson"
833-
break
834-
fi
835-
done
836-
fi
837-
if test x"$jansson_found" != x"yes"
838-
then
839-
AC_MSG_RESULT([no])
840-
fi
841-
fi
842-
AC_SUBST(LIBJANSSON_CPPFLAGS)
843-
AC_SUBST(LIBJANSSON_LDFLAGS)
679+
AC_SUBST(LIBJANSSON_CFLAGS)
844680
AC_SUBST(LIBJANSSON_LIBS)
845-
AM_CONDITIONAL(JANSSON, test x"$LIBJANSSON_LIBS" != x"")
846-
847-
if test x"$jansson_found" == x"yes"
848-
then
849-
AC_DEFINE(USE_JANSSON, 1, [use libjansson to provide header field checks])
850-
fi
851-
852-
# This (below) is just for the pkg-config file openarc.pc.in
853-
LIBOPENARC_LIBS_PKG="$LIBOPENARC_LIBS"
854-
LIBOPENARC_INC="$LIBCRYPTO_CPPFLAGS $LIBCRYPTO_CFLAGS $LIBTRE_CPPFLAGS"
855-
856-
if test x"$USE_DB_LIBOPENARC_TRUE" = x""
857-
then
858-
LIBOPENARC_INC="$LIBOPENARC_INC $LIBDB_INCDIRS"
859-
LIBOPENARC_LIBS_PKG="$LIBOPENARC_LIBS_PKG $LIBDB_LIBS"
860-
LIBOPENARC_LIBS="$LIBOPENARC_LIBS $LIBDB_LIBS"
861-
fi
862681

863-
AC_SUBST(LIBOPENARC_LIBS)
864-
AC_SUBST(LIBOPENARC_LIBS_PKG)
865-
AC_SUBST(LIBOPENARC_INC)
866682

867683
AC_DEFINE_UNQUOTED([LIBOPENARC_FEATURE_STRING], "$LIBOPENARC_FEATURE_STRING",
868684
[Feature string for printing])

libopenarc/arc.c

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <string.h>
2525
#include <limits.h>
2626
#include <unistd.h>
27-
#include <pthread.h>
2827
#include <resolv.h>
2928

3029
#ifdef __STDC__

libopenarc/openarc.pc.in

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Process this file with autoconf to produce a pkg-config metadata file.
2-
31
prefix=@prefix@
42
exec_prefix=@exec_prefix@
53
libdir=@libdir@
@@ -9,7 +7,7 @@ Name: OpenARC Library
97
Description: Library for performing ARC signing and verification
108
URL: https://github.com/flowerysong/OpenARC
119
Version: @VERSION@
12-
Libs: -L${libdir} @PTHREAD_CFLAGS@ -lopenarc
13-
Libs.private: @LIBOPENARC_LIBS_PKG@ @PTHREAD_LIBS@
14-
Cflags: -I${includedir} @PTHREAD_CFLAGS@
15-
10+
Libs: -L${libdir} -lopenarc
11+
Libs.private: @STRL_LIBS@
12+
Requires.private: openssl >= 1.0.0
13+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)