From patchwork Mon Sep 14 02:27:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sommerseth X-Patchwork-Id: 1449 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id uIjVGxJiX18rCwAAIUCqbw (envelope-from ) for ; Mon, 14 Sep 2020 08:29:06 -0400 Received: from proxy5.mail.ord1c.rsapps.net ([172.28.255.1]) by director9.mail.ord1d.rsapps.net with LMTP id 2JC3GxJiX1/xDwAAalYnBA (envelope-from ) for ; Mon, 14 Sep 2020 08:29:06 -0400 Received: from smtp3.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.ord1c.rsapps.net with LMTPS id kGRtGxJiX1/RUwAAPBRIyg (envelope-from ) for ; Mon, 14 Sep 2020 08:29:06 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp3.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=openvpn.net X-Suspicious-Flag: YES X-Classification-ID: e1154092-f685-11ea-bbef-842b2b47481a-1-1 Received: from [216.105.38.7] ([216.105.38.7:44624] helo=lists.sourceforge.net) by smtp3.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 7C/09-02642-1126F5F5; Mon, 14 Sep 2020 08:29:06 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kHnal-0007bD-NB; Mon, 14 Sep 2020 12:28:19 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHnak-0007b6-9M for openvpn-devel@lists.sourceforge.net; Mon, 14 Sep 2020 12:28:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/e8HU3UBbHiphmThRQTYztFNL6ulcY+jzn1UKrTn2RI=; b=C8IK3etIXSQ3M4yQopqJrEtCuA 53yNAHGiYo/B/jSpLmRDae/282R/yykwXznKHnv99cfPZPViOozk+R3WMs+q4gVI9R/ejZsJvQRPT E1jQmtJcUDKl8Ura5X55wbEX6pOdskOmY1ZH9qzPEmPmF5iuycW5JxvapoQaMMt1ja7o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/e8HU3UBbHiphmThRQTYztFNL6ulcY+jzn1UKrTn2RI=; b=NfAQwllQcDCb1qo2sMexC1HhG7 jmipi1PXIWvTYm25a4oKwHDPZyymmHNQjQtDtoa3Y5GOgn112tB1busi4OHSPJYUqC3HvEsfajvop IlI6ACHm2+h620zFL0/JR3xU7JvJN7lYzxt+M6a0XTdFRHabGqfNIIEzOhzhN/oXEO+s=; Received: from mx1.basenordic.cloud ([217.170.205.104]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kHnac-008NQR-Sv for openvpn-devel@lists.sourceforge.net; Mon, 14 Sep 2020 12:28:18 +0000 Received: from localhost (unknown [127.0.0.1]) by mx1.basenordic.cloud (Postfix) with ESMTP id D2958E731 for ; Mon, 14 Sep 2020 12:27:57 +0000 (UTC) Received: from mx1.basenordic.cloud ([127.0.0.1]) by localhost (mx1.basenordic.cloud [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9PJ0QfNov0ss for ; Mon, 14 Sep 2020 14:27:56 +0200 (CEST) Received: from zimbra.sommerseth.email (e-post.sommerseth.email [172.16.33.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.basenordic.cloud (Postfix) with ESMTPS id D2C71E712 for ; Mon, 14 Sep 2020 14:27:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.sommerseth.email (Postfix) with ESMTP id 6D1AA401D33B for ; Mon, 14 Sep 2020 14:27:56 +0200 (CEST) Received: from zimbra.sommerseth.email ([127.0.0.1]) by localhost (zimbra.sommerseth.email [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2PwmtPuepk_3 for ; Mon, 14 Sep 2020 14:27:56 +0200 (CEST) Received: from optimus.homebase.sommerseths.net (unknown [10.35.7.3]) by zimbra.sommerseth.email (Postfix) with ESMTPS id 2703B401D332 for ; Mon, 14 Sep 2020 14:27:56 +0200 (CEST) From: David Sommerseth To: openvpn-devel@lists.sourceforge.net Date: Mon, 14 Sep 2020 14:27:21 +0200 Message-Id: <20200914122721.14173-1-davids@openvpn.net> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200914115706.11066-1-davids@openvpn.net> References: <20200914115706.11066-1-davids@openvpn.net> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: configure.ac] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1kHnac-008NQR-Sv Subject: [Openvpn-devel] [PATCH v2] sample-plugins: Partially autotoolize the sample-plugins build X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The sample-plugins have their own set of build/winbuild scripts in each of these plugin directories. This does not give a good way to reuse various macros the autoconf/automake/configure process enables; which can contain important macros to make some code build without errors or warnings. Normally we would embrace the full autoconf/automake approach. But this is sample code which we only want to build per request and the built code should not be installed anywhere via 'make install'. But since we do use libtool other plug-ins being installed and automake gets kind of cranky when it comes to define certain build targets not following the expected use cases, we try to only embrace just enough of automake to get our main goals achieved. This changeset kicks out the build scripts and replaces them with a single Makefile.plugins file, which defines the plugins we want to build by default when running 'make from the sample-plugins directory. Neither of these plugins are otherwise built by default. No sample-plugins are being installed. But we have enough strings attached to automake to grab the CFLAGS and LDFLAGS used by the rest of the code. This also makes it easy to use #include "config.h" in sample code, to also get various macros defined by the ./configure run. This patch does not touch the winbuild scripts, as it seems building these sample-plugins on Windows requires a bit different compile and linking steps than *nix systems in general. Signed-off-by: David Sommerseth --- v2 - Process README files with correct instructions and details --- configure.ac | 1 + sample/sample-plugins/Makefile.am | 28 ++++++++++++++ sample/sample-plugins/Makefile.plugins | 31 ++++++++++++++++ sample/sample-plugins/README | 37 +++++++++++++++++++ sample/sample-plugins/defer/README | 16 -------- sample/sample-plugins/defer/build | 15 -------- .../keying-material-exporter-demo/build | 15 -------- sample/sample-plugins/log/build | 15 -------- sample/sample-plugins/simple/README | 16 -------- sample/sample-plugins/simple/build | 15 -------- 10 files changed, 97 insertions(+), 92 deletions(-) create mode 100644 sample/sample-plugins/Makefile.am create mode 100644 sample/sample-plugins/Makefile.plugins create mode 100644 sample/sample-plugins/README delete mode 100644 sample/sample-plugins/defer/README delete mode 100755 sample/sample-plugins/defer/build delete mode 100755 sample/sample-plugins/keying-material-exporter-demo/build delete mode 100755 sample/sample-plugins/log/build delete mode 100644 sample/sample-plugins/simple/README delete mode 100755 sample/sample-plugins/simple/build diff --git a/configure.ac b/configure.ac index f8279924..ebb32204 100644 --- a/configure.ac +++ b/configure.ac @@ -1433,6 +1433,7 @@ AC_CONFIG_FILES([ doc/doxygen/Makefile doc/doxygen/openvpn.doxyfile include/Makefile + sample/sample-plugins/Makefile src/Makefile src/compat/Makefile src/openvpn/Makefile diff --git a/sample/sample-plugins/Makefile.am b/sample/sample-plugins/Makefile.am new file mode 100644 index 00000000..d02abe48 --- /dev/null +++ b/sample/sample-plugins/Makefile.am @@ -0,0 +1,28 @@ +# +# OpenVPN -- An application to securely tunnel IP networks +# over a single UDP port, with support for SSL/TLS-based +# session authentication and key exchange, +# packet encryption, packet authentication, and +# packet compression. +# +# Copyright (C) 2002-2020 OpenVPN Inc +# + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +# We don't want automake to pull in libtool for building these +# sample-plugins. Even though this breaks the conceptual ideas +# around autoconf/automake/libtools ... these sample plug-ins +# are just sample code, not to be installed or distributed outside +# of the source tarball. Not even built by default, by design. +# +# We only add this as a simple and convenient way to build all +# these plug-ins with the same build parameters as the rest +# of the OpenVPN code. +# +# All the plugins which will be built are processed in this +# separate Makefile, which disconnects everything just enough +# to achieve our goal. +include Makefile.plugins + diff --git a/sample/sample-plugins/Makefile.plugins b/sample/sample-plugins/Makefile.plugins new file mode 100644 index 00000000..76768dbe --- /dev/null +++ b/sample/sample-plugins/Makefile.plugins @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2020 OpenVPN Inc +# + +# +# Plug-ins to build - listed entries should not carry any extensions +# +PLUGINS = \ + defer/simple \ + keying-material-exporter-demo/keyingmaterialexporter \ + log/log log/log_v3 \ + simple/base64 \ + simple/simple + +# All the plugins to build - rewritten with .so extension +all : $(foreach var, $(PLUGINS), $(var).so) + +# Compile step +.c.o : + test -d `dirname $@` || $(MKDIR_P) `dirname $@`; \ + $(CC) -c -o $@ $(CFLAGS) -I$(top_srcdir) -fPIC $< + +# Link step +%.so : %.o + $(CC) $(LDFLAGS) -shared -fPIC -o $@ $< + +# Clean up all build object and shared object files +clean : + rm -f $(foreach var, $(PLUGINS), $(var).o) \ + $(foreach var, $(PLUGINS), $(var).so) diff --git a/sample/sample-plugins/README b/sample/sample-plugins/README new file mode 100644 index 00000000..167d8d32 --- /dev/null +++ b/sample/sample-plugins/README @@ -0,0 +1,37 @@ +OpenVPN plug-in examples. + +Examples provided: + +* authentication and logging +simple/simple.c -- using the --auth-user-pass-verify callback, verify + that the username/password is "foo"/"bar". +defer/simple.c -- using the --auth-user-pass-verify callback, + test deferred authentication. +log/log.c -- Extended variant of simple/simple.c which adds more + logging of what is happening inside the plug-in +log/log_v3.c -- A variant of log/log.c, which makes use of the + OpenVPN plug-in v3 API. This will also log even more + information related to certificates in use. + +* cryptography related +simple/base64.c -- Example using the OpenVPN exported base64 encode/decode + functions +keying-material-exporter-demo/keyingmaterialexporter.c + -- Example based on TLS Keying Material Exporters over HTTP [RFC-5705] + (openvpn/doc/keying-material-exporter.txt). For more details, see + keying-material-exporter-demo/README + + +To build on *BSD/Linux platforms: + + make (builds a default set of plug-ins) + make simple/simple.so + +To build on Windows platform (MinGW): + + cd simple; ./winbuild simple.so + +To use in OpenVPN, add to config file: + + plugin simple.so (Linux/BSD/etc.) + plugin simple.dll diff --git a/sample/sample-plugins/defer/README b/sample/sample-plugins/defer/README deleted file mode 100644 index d8990f8b..00000000 --- a/sample/sample-plugins/defer/README +++ /dev/null @@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, - test deferred authentication. - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows) diff --git a/sample/sample-plugins/defer/build b/sample/sample-plugins/defer/build deleted file mode 100755 index ba41a39f..00000000 --- a/sample/sample-plugins/defer/build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared ${LDFLAGS} -Wl,-soname,$1.so -o $1.so $1.o -lc diff --git a/sample/sample-plugins/keying-material-exporter-demo/build b/sample/sample-plugins/keying-material-exporter-demo/build deleted file mode 100755 index bbb05f7c..00000000 --- a/sample/sample-plugins/keying-material-exporter-demo/build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc diff --git a/sample/sample-plugins/log/build b/sample/sample-plugins/log/build deleted file mode 100755 index c07ec408..00000000 --- a/sample/sample-plugins/log/build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../../include}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc diff --git a/sample/sample-plugins/simple/README b/sample/sample-plugins/simple/README deleted file mode 100644 index 4400cd30..00000000 --- a/sample/sample-plugins/simple/README +++ /dev/null @@ -1,16 +0,0 @@ -OpenVPN plugin examples. - -Examples provided: - -simple.c -- using the --auth-user-pass-verify callback, verify - that the username/password is "foo"/"bar". - -To build: - - ./build simple (Linux/BSD/etc.) - ./winbuild simple (MinGW on Windows) - -To use in OpenVPN, add to config file: - - plugin simple.so (Linux/BSD/etc.) - plugin simple.dll (MinGW on Windows) diff --git a/sample/sample-plugins/simple/build b/sample/sample-plugins/simple/build deleted file mode 100755 index bbb05f7c..00000000 --- a/sample/sample-plugins/simple/build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# -# Build an OpenVPN plugin module on *nix. The argument should -# be the base name of the C source file (without the .c). -# - -# This directory is where we will look for openvpn-plugin.h -CPPFLAGS="${CPPFLAGS:--I../../..}" - -CC="${CC:-gcc}" -CFLAGS="${CFLAGS:--O2 -Wall -g}" - -$CC $CPPFLAGS $CFLAGS -fPIC -c $1.c && \ -$CC $CFLAGS -fPIC -shared $LDFLAGS -Wl,-soname,$1.so -o $1.so $1.o -lc