From patchwork Sun Apr 1 09:13:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Hesse X-Patchwork-Id: 283 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id e4pKEq0zwVrMSwAAIUCqbw for ; Sun, 01 Apr 2018 15:31:57 -0400 Received: from proxy19.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net (Dovecot) with LMTP id E5SRC60zwVoyUQAApN4f7A ; Sun, 01 Apr 2018 15:31:57 -0400 Received: from smtp40.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.iad3b.rsapps.net with LMTP id UNGYCa0zwVqRHwAAIG4riQ ; Sun, 01 Apr 2018 15:31:57 -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: smtp40.gate.iad3b.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; dkim=fail (signature verification failed) header.d=eworm.de; dmarc=none (p=nil; dis=none) header.from=eworm.de X-Suspicious-Flag: YES X-Classification-ID: 566e667c-35e3-11e8-a81a-5254000cc6d4-1-1 Received: from [216.105.38.7] ([216.105.38.7:50365] helo=lists.sourceforge.net) by smtp40.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3F/E0-21651-CA331CA5; Sun, 01 Apr 2018 15:31:56 -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 1f2ih4-0005OX-8E; Sun, 01 Apr 2018 19:31:10 +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 1f2ih1-0005OB-Jg for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=cQAKjbtI41aPYmrfNzS2HnDKF6BbCK9QB0n0cOY8DEA=; b=j9dQ19pvMv32+0kT/QY3GAqw+A 5jaEmksK/TUWpusOjXzynu3Rp/WJKp7QBw6YtkOHR54iZVsa/Kp/goXK13RfSED+z10j34l2zcrg/ DMkbAEhVTxhiUgXf90nO7YgyfTBhT1H0tvdYIr2y5WB8xq3/IXfpNeJ37HS1RJwIEkGE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=cQAKjbtI41aPYmrfNzS2HnDKF6BbCK9QB0n0cOY8DEA=; b=JztgA+/W+mkMaQvvwFUGsyemwa suVo8HnPJaNN9yK1GRMfmDkBQGYFd5LvyU16LopwMUv0GGod3n3+kz0MHOOouceWaRZewDjQy/Hl7 5+gqwGHOBrUwM8OOCxCBBsahF2e4flBtY/rHDCXyniY+dcrQ2Q1wmbQKFLIdxLPolMbg=; Received: from mx.mylinuxtime.de ([148.251.109.235]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1f2igx-008LJ3-UN for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:07 +0000 Received: from leda.eworm.de (unknown [10.10.4.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 3E8B7266FC; Sun, 1 Apr 2018 21:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mx.mylinuxtime.de 3E8B7266FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eworm.de; s=mail; t=1522610042; bh=avZStheqBA9xTS+QWT4Hm2Qqx5du5Ks1UtfqM+Qni0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kNm+Y5EcQK2vYoWYlTT/cn/kpt4KIKnFLzZh84ciepREJBbV5wnORwoCNd+nLhEzu lLbuyQihTaI8cO7XsChuD/NX9o39HY16vZJ4otGjZtec/wdGdaMfbM1Fq4FcyFpnIw XyahIXFt3Pxq8a8FRkOG8X3EQCnMYw+JRd4J+FtM= Received: by leda.eworm.de (Postfix, from userid 1000) id DE8EF1026DA; Sun, 1 Apr 2018 21:13:55 +0200 (CEST) From: Christian Hesse To: OpenVPN Development Date: Sun, 1 Apr 2018 21:13:07 +0200 Message-Id: <20180401191309.32211-2-list@eworm.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180401191309.32211-1-list@eworm.de> References: <20180401191309.32211-1-list@eworm.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1f2igx-008LJ3-UN Subject: [Openvpn-devel] [RFC 1/3] systemd: run openvpn with dedicated user 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: , Cc: Christian Hesse MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Christian Hesse Now that we have a native netlink interface run the process with dedicated user 'openvpn'. This is possibly by granting ambient capabilities, see systemd.exec(5). Signed-off-by: Christian Hesse --- configure.ac | 8 ++++++++ distro/systemd/Makefile.am | 4 ++++ distro/systemd/openvpn-client@.service.in | 4 +++- distro/systemd/openvpn-server@.service.in | 4 +++- distro/systemd/sysusers-openvpn.conf | 1 + distro/systemd/tmpfiles-openvpn.conf | 4 ++-- 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 distro/systemd/sysusers-openvpn.conf ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot diff --git a/configure.ac b/configure.ac index f2e4aa47..3d9d2ed5 100644 --- a/configure.ac +++ b/configure.ac @@ -365,6 +365,7 @@ AC_ARG_VAR([GIT], [path to git utility]) AC_ARG_VAR([SYSTEMD_ASK_PASSWORD], [path to systemd-ask-password utility]) AC_ARG_VAR([SYSTEMD_UNIT_DIR], [Path of systemd unit directory @<:@default=LIBDIR/systemd/system@:>@]) AC_ARG_VAR([TMPFILES_DIR], [Path of tmpfiles directory @<:@default=LIBDIR/tmpfiles.d@:>@]) +AC_ARG_VAR([SYSUSERS_DIR], [Path of sysusers directory @<:@default=LIBDIR/sysusers.d@:>@]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) @@ -1198,6 +1199,12 @@ if test "$enable_systemd" = "yes" ; then else tmpfilesdir="\${libdir}/tmpfiles.d" fi + + if test -n "${SYSUSERS_DIR}"; then + sysusersdir="${SYSUSERS_DIR}" + else + sysusersdir="\${libdir}/sysusers.d" + fi fi @@ -1381,6 +1388,7 @@ AC_SUBST([sampledir]) AC_SUBST([systemdunitdir]) AC_SUBST([tmpfilesdir]) +AC_SUBST([sysusersdir]) VENDOR_SRC_ROOT="\$(abs_top_srcdir)/vendor/" VENDOR_DIST_ROOT="\$(abs_top_builddir)/vendor/dist" diff --git a/distro/systemd/Makefile.am b/distro/systemd/Makefile.am index 69e12699..2641a63d 100644 --- a/distro/systemd/Makefile.am +++ b/distro/systemd/Makefile.am @@ -14,6 +14,7 @@ EXTRA_DIST = \ tmpfiles-openvpn.conf \ + sysusers-openvpn.conf \ openvpn-client@.service.in \ openvpn-server@.service.in @@ -23,11 +24,14 @@ systemdunit_DATA = \ openvpn-server@.service tmpfiles_DATA = \ tmpfiles-openvpn.conf +sysusers_DATA = \ + sysusers-openvpn.conf dist_doc_DATA = \ README.systemd install-data-hook: mv $(DESTDIR)$(tmpfilesdir)/tmpfiles-openvpn.conf $(DESTDIR)$(tmpfilesdir)/openvpn.conf + mv $(DESTDIR)$(sysusersdir)/sysusers-openvpn.conf $(DESTDIR)$(sysusersdir)/openvpn.conf endif MAINTAINERCLEANFILES = \ diff --git a/distro/systemd/openvpn-client@.service.in b/distro/systemd/openvpn-client@.service.in index cbcef653..a103d751 100644 --- a/distro/systemd/openvpn-client@.service.in +++ b/distro/systemd/openvpn-client@.service.in @@ -9,9 +9,11 @@ Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO [Service] Type=notify PrivateTmp=true +User=openvpn +Group=openvpn WorkingDirectory=/etc/openvpn/client ExecStart=@sbindir@/openvpn --suppress-timestamps --nobind --config %i.conf -CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE +AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE LimitNPROC=10 DeviceAllow=/dev/null rw DeviceAllow=/dev/net/tun rw diff --git a/distro/systemd/openvpn-server@.service.in b/distro/systemd/openvpn-server@.service.in index a8366a04..7275e86a 100644 --- a/distro/systemd/openvpn-server@.service.in +++ b/distro/systemd/openvpn-server@.service.in @@ -9,9 +9,11 @@ Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO [Service] Type=notify PrivateTmp=true +User=openvpn +Group=openvpn WorkingDirectory=/etc/openvpn/server ExecStart=@sbindir@/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf -CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE +AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE LimitNPROC=10 DeviceAllow=/dev/null rw DeviceAllow=/dev/net/tun rw diff --git a/distro/systemd/sysusers-openvpn.conf b/distro/systemd/sysusers-openvpn.conf new file mode 100644 index 00000000..d200852b --- /dev/null +++ b/distro/systemd/sysusers-openvpn.conf @@ -0,0 +1 @@ +u openvpn - "OpenVPN user" / diff --git a/distro/systemd/tmpfiles-openvpn.conf b/distro/systemd/tmpfiles-openvpn.conf index bb79671e..835dc1c8 100644 --- a/distro/systemd/tmpfiles-openvpn.conf +++ b/distro/systemd/tmpfiles-openvpn.conf @@ -1,2 +1,2 @@ -d /run/openvpn-client 0710 root root - -d /run/openvpn-server 0710 root root - +d /run/openvpn-client 0750 openvpn openvpn - +d /run/openvpn-server 0750 openvpn openvpn - From patchwork Sun Apr 1 09:13:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Hesse X-Patchwork-Id: 284 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id y2pPFLIzwVqWWQAAIUCqbw for ; Sun, 01 Apr 2018 15:32:02 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net (Dovecot) with LMTP id CzAFDrIzwVoyUQAApN4f7A ; Sun, 01 Apr 2018 15:32:02 -0400 Received: from smtp20.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTP id AISiC7IzwVpjFgAAEsW3lA ; Sun, 01 Apr 2018 15:32:02 -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: smtp20.gate.iad3b.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; dkim=fail (signature verification failed) header.d=eworm.de; dmarc=none (p=nil; dis=none) header.from=eworm.de X-Suspicious-Flag: YES X-Classification-ID: 596a95b2-35e3-11e8-af99-525400497f28-1-1 Received: from [216.105.38.7] ([216.105.38.7:19890] helo=lists.sourceforge.net) by smtp20.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 17/27-21306-1B331CA5; Sun, 01 Apr 2018 15:32:01 -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 1f2ih4-0005OK-2x; Sun, 01 Apr 2018 19:31:10 +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 1f2igz-0005O4-RJ for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=WOTQjlse488oI/uIi7yxFRDTsLM5bP8FxpEtLnMSy8g=; b=bYkUariK9/9Lx5td5ta1fZoQz1 5lL1MoXoqaU87t8ujLUzm4bc5Fx4Ph/VoMVWmf0qen8KWijwYNtu8gz+YQu93ayytQZNvxw3LuHUp dSS+jwxE/zMvQnciOvl/snjswXMimMJHbDzk6M20k0CqtB7ZveGzC5H0M2uXlEgaFccQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=WOTQjlse488oI/uIi7yxFRDTsLM5bP8FxpEtLnMSy8g=; b=hAW9hP6+XEvgBdt29DkHecVTFS GtdfK4EzXc3Ate/H8GYxPvVpOyV/x2gmx4I3psBBQ4Ym5K/PbrxqfOroNrYyAz48/qVik9953m6pR YyBWZ/OjEnrHFLaNd4Gs5WU5XSOnwDsWy1YrvSo3TEVdUieLvCIk7jYbz06RVahKR/6Y=; Received: from mx.mylinuxtime.de ([148.251.109.235]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1f2igx-0059X3-SY for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:05 +0000 Received: from leda.eworm.de (unknown [10.10.4.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 4A522266FE; Sun, 1 Apr 2018 21:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mx.mylinuxtime.de 4A522266FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eworm.de; s=mail; t=1522610042; bh=rceahONkzF8bG/waJ1kqHFQoK/+eyG7kul83BxtQXZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rDuiLZXyKn/pg+SehTT+ge5bviTC5uYZikDYAhC5afawOwxSZEjx7Q+fypAaCACjI T+vwvsdZ2jeiZWoqQWvm9c8xjaphDYOHk90Rs2TecbWec5mrpQU2Peok/qLNEbeB/w LqqR2ng7iBnciA9XFkEIM0YEjqVj0r5ysgUEJbdA= Received: by leda.eworm.de (Postfix, from userid 1000) id E43B9102880; Sun, 1 Apr 2018 21:13:55 +0200 (CEST) From: Christian Hesse To: OpenVPN Development Date: Sun, 1 Apr 2018 21:13:08 +0200 Message-Id: <20180401191309.32211-3-list@eworm.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180401191309.32211-1-list@eworm.de> References: <20180401191309.32211-1-list@eworm.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1f2igx-0059X3-SY Subject: [Openvpn-devel] [RFC 2/3] systemd: do not downgrade UID/GID 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: , Cc: Christian Hesse MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Christian Hesse Now that systemd starts the process with dedicated user we do no longer want to downgrade privileges. Also remove CAP_SETGID and CAP_SETUID from granted privileges. Signed-off-by: Christian Hesse --- distro/systemd/openvpn-client@.service.in | 2 +- distro/systemd/openvpn-server@.service.in | 2 +- src/openvpn/init.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot diff --git a/distro/systemd/openvpn-client@.service.in b/distro/systemd/openvpn-client@.service.in index a103d751..ee7957a6 100644 --- a/distro/systemd/openvpn-client@.service.in +++ b/distro/systemd/openvpn-client@.service.in @@ -13,7 +13,7 @@ User=openvpn Group=openvpn WorkingDirectory=/etc/openvpn/client ExecStart=@sbindir@/openvpn --suppress-timestamps --nobind --config %i.conf -AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE +AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SYS_CHROOT CAP_DAC_OVERRIDE LimitNPROC=10 DeviceAllow=/dev/null rw DeviceAllow=/dev/net/tun rw diff --git a/distro/systemd/openvpn-server@.service.in b/distro/systemd/openvpn-server@.service.in index 7275e86a..03d28a2e 100644 --- a/distro/systemd/openvpn-server@.service.in +++ b/distro/systemd/openvpn-server@.service.in @@ -13,7 +13,7 @@ User=openvpn Group=openvpn WorkingDirectory=/etc/openvpn/server ExecStart=@sbindir@/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf -AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE +AmbientCapabilities=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SYS_CHROOT CAP_DAC_OVERRIDE LimitNPROC=10 DeviceAllow=/dev/null rw DeviceAllow=/dev/net/tun rw diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 36c1a4c4..0fc60d62 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1151,6 +1151,14 @@ do_uid_gid_chroot(struct context *c, bool no_delay) /* set user and/or group if we want to setuid/setgid */ if (c0->uid_gid_specified) { +#ifdef ENABLE_SYSTEMD + if (sd_notify(0, "READY=0") > 0 && getuid() != 0) + { + msg(M_INFO, "NOTE: Running from systemd with non-root uid, skipping downgrade"); + return; + } +#endif + if (no_delay) { platform_group_set(&c0->platform_state_group); From patchwork Sun Apr 1 09:13:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Hesse X-Patchwork-Id: 285 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id gwPnK7YzwVpJDQAAIUCqbw for ; Sun, 01 Apr 2018 15:32:06 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net (Dovecot) with LMTP id q9thJLYzwVo0UQAApN4f7A ; Sun, 01 Apr 2018 15:32:06 -0400 Received: from smtp21.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTP id AMUiIrYzwVr9FgAAEsW3lA ; Sun, 01 Apr 2018 15:32: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: smtp21.gate.iad3b.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; dkim=fail (signature verification failed) header.d=eworm.de; dmarc=none (p=nil; dis=none) header.from=eworm.de X-Suspicious-Flag: YES X-Classification-ID: 5c48c236-35e3-11e8-84a2-525400cdc90a-1-1 Received: from [216.105.38.7] ([216.105.38.7:8859] helo=lists.sourceforge.net) by smtp21.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id BA/4F-04066-6B331CA5; Sun, 01 Apr 2018 15:32:06 -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 1f2ih1-0007fp-Og; Sun, 01 Apr 2018 19:31:07 +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 1f2igz-0007fh-VU for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=DWJAWcifijeYLL5FLa1e9wd5FnanUBUT8MB3NKy5DhI=; b=PVPgf18MPXr84GnuIqklF7kpaG YZtu3bGt/5+G5m8qCBLjMVYIc5+fQkY5g0/fvbl5vXVCQV0fGP/GyWw0SS07pf+ckTNUiOcvnV4A9 48waTqQScHCh0pX4x3/abqRo9dNUi8TWCSxppVQPOCVzzmDVrw6fBwHBOdB9LQYKiTR8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=DWJAWcifijeYLL5FLa1e9wd5FnanUBUT8MB3NKy5DhI=; b=WjHNf7OtkWwc4FABf2h4EauMqN X51uKdoP5/oMaVAas/o7x3q5E72+3RT0dt+PsaqLXdzd8wY6dQOYStxb2B4v3EE4byo8L326oL/wI ZeOFfRFPmIUlMaAwh0WqsOXdQUEJkgSBTaiGiCvEIYl4/T01xqPDXfHBLD4S/kDE8kPY=; Received: from mx.mylinuxtime.de ([148.251.109.235]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1f2igx-005JDc-4X for openvpn-devel@lists.sourceforge.net; Sun, 01 Apr 2018 19:31:05 +0000 Received: from leda.eworm.de (unknown [10.10.4.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 49480266FD; Sun, 1 Apr 2018 21:14:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mx.mylinuxtime.de 49480266FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eworm.de; s=mail; t=1522610042; bh=DWJAWcifijeYLL5FLa1e9wd5FnanUBUT8MB3NKy5DhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A/bnf5ooUmet9L7Eyan4lVXFCTxwec4xrcgPb9jBkvVXCjP0/LpCkXG2J5dcuRu8e SnXWvUTpTBuNfE9ytdO9/+glR3V7g4WDjJ39tJ22s5chPfZCq4qe/na05kAEEHxi8n 7cx3y+p8u6X+r887co2urEEqeY3ykWcxZn7b9ULU= Received: by leda.eworm.de (Postfix, from userid 1000) id EBB36102881; Sun, 1 Apr 2018 21:13:55 +0200 (CEST) From: Christian Hesse To: OpenVPN Development Date: Sun, 1 Apr 2018 21:13:09 +0200 Message-Id: <20180401191309.32211-4-list@eworm.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180401191309.32211-1-list@eworm.de> References: <20180401191309.32211-1-list@eworm.de> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1f2igx-005JDc-4X Subject: [Openvpn-devel] [RFC 3/3] systemd: create configuration directories from tmpfiles 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: , Cc: Christian Hesse MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Christian Hesse We have a dedicated user created by systemd-sysusers, so create configuration directories from systemd-tmpfiles for proper permissions. This mitigates a race condition at packaging/install time. Signed-off-by: Christian Hesse --- distro/systemd/tmpfiles-openvpn.conf | 2 ++ 1 file changed, 2 insertions(+) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot diff --git a/distro/systemd/tmpfiles-openvpn.conf b/distro/systemd/tmpfiles-openvpn.conf index 835dc1c8..0f96baa5 100644 --- a/distro/systemd/tmpfiles-openvpn.conf +++ b/distro/systemd/tmpfiles-openvpn.conf @@ -1,2 +1,4 @@ d /run/openvpn-client 0750 openvpn openvpn - d /run/openvpn-server 0750 openvpn openvpn - +d /etc/openvpn/client 0750 openvpn openvpn - +d /etc/openvpn/server 0750 openvpn openvpn -