From patchwork Tue Sep 15 10:52:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sommerseth X-Patchwork-Id: 1454 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id eKxdAGwqYV/VOQAAIUCqbw (envelope-from ) for ; Tue, 15 Sep 2020 16:56:12 -0400 Received: from proxy10.mail.ord1d.rsapps.net ([172.30.191.6]) by director12.mail.ord1d.rsapps.net with LMTP id 2DyCO2sqYV/TNwAAIasKDg (envelope-from ) for ; Tue, 15 Sep 2020 16:56:11 -0400 Received: from smtp27.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy10.mail.ord1d.rsapps.net with LMTPS id sLkUO2sqYV/wIwAAfSg8FQ (envelope-from ) for ; Tue, 15 Sep 2020 16:56:11 -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: smtp27.gate.ord1d.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: e273b2f0-f795-11ea-9e99-5254003773d7-1-1 Received: from [216.105.38.7] ([216.105.38.7:35870] helo=lists.sourceforge.net) by smtp27.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id DC/0F-26506-B6A216F5; Tue, 15 Sep 2020 16:56:11 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1kIHz0-0005qH-Gx; Tue, 15 Sep 2020 20:55:22 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIHyy-0005q3-RQ for openvpn-devel@lists.sourceforge.net; Tue, 15 Sep 2020 20:55:20 +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=tO02iG0gESGU2KwgH0ovdZWTaxvG8iELbsoVmk+ofys=; b=mNuLXf7io/j1XGjnpOERWvqJjq Yh5O6jptWg3EtbWntO/AqmTtRnbs8LuZlFRaURrodQq5Tujdr3mFul6wm5VBJO4/7snmal8aT6Nfs I0rne9LSQcxbp5ov//90QBTdaHeMEZQWYnsdfmPedKLJZe+AtX9jYJOCO5n/gcUQXbxI=; 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=tO02iG0gESGU2KwgH0ovdZWTaxvG8iELbsoVmk+ofys=; b=Bugorns+1ZUsoNUpM2TZRVs1S1 5pfWvKa6AKghxEpt71Cagr2rIdZGg8RpRQHaI9FjwMyzhf2iDNSYAAngVxXx0bvvJGil4k+zySzxZ xknBszSaXHJcdebKfLu85pA4BXK70iLhX6LuxM/03RDu6rWW8VdzcMtoHcn4LmEYD+KU=; 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 1kIHys-00ARx9-7A for openvpn-devel@lists.sourceforge.net; Tue, 15 Sep 2020 20:55:20 +0000 Received: from localhost (unknown [127.0.0.1]) by mx1.basenordic.cloud (Postfix) with ESMTP id B8335E731 for ; Tue, 15 Sep 2020 20:55:01 +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 4nq84K7oagku for ; Tue, 15 Sep 2020 22:54:59 +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 79292E73C for ; Tue, 15 Sep 2020 22:54:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.sommerseth.email (Postfix) with ESMTP id 58867401D334 for ; Tue, 15 Sep 2020 22:54:59 +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 G2-NSqD0N7YC for ; Tue, 15 Sep 2020 22:54:59 +0200 (CEST) Received: from optimus.homebase.sommerseths.net (unknown [10.35.7.3]) by zimbra.sommerseth.email (Postfix) with ESMTPS id 327BC401D332 for ; Tue, 15 Sep 2020 22:54:59 +0200 (CEST) From: David Sommerseth To: openvpn-devel@lists.sourceforge.net Date: Tue, 15 Sep 2020 22:52:54 +0200 Message-Id: <20200915205254.32605-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 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: 1kIHys-00ARx9-7A Subject: [Openvpn-devel] [PATCH v3] 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 v3 - Add missing -I$(top_srcdir)/include and explicitly state GNU Make requirement --- configure.ac | 1 + sample/sample-plugins/Makefile.am | 30 +++++++++++++++ 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, 99 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..657764a6 --- /dev/null +++ b/sample/sample-plugins/Makefile.am @@ -0,0 +1,30 @@ +# +# 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 + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include + +# 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..d19aa5bb --- /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) $(AM_CPPFLAGS) -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..3ed60348 --- /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 (requires GNU Make): + + gmake (builds a default set of plug-ins) + gmake 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