From patchwork Tue Aug 18 21:07:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Stipakov X-Patchwork-Id: 1395 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id ePF4BBnQPF8JTQAAIUCqbw for ; Wed, 19 Aug 2020 03:09:13 -0400 Received: from proxy16.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id GGdoBBnQPF9UBwAAvGGmqA (envelope-from ) for ; Wed, 19 Aug 2020 03:09:13 -0400 Received: from smtp13.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.iad3b.rsapps.net with LMTPS id CNLiOBjQPF+bEwAAPj+4aA (envelope-from ) for ; Wed, 19 Aug 2020 03:09:12 -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: smtp13.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=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: e2203564-e1ea-11ea-ad0f-5254001dfc40-1-1 Received: from [216.105.38.7] ([216.105.38.7:59270] helo=lists.sourceforge.net) by smtp13.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id BF/78-17202-810DC3F5; Wed, 19 Aug 2020 03:09:12 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1k8ICo-0007za-Ha; Wed, 19 Aug 2020 07:08:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8ICn-0007zQ-Np for openvpn-devel@lists.sourceforge.net; Wed, 19 Aug 2020 07:08:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wx0079oexxge96ApqiBl9x1aDsyIiQFPAxLyyqGagxs=; b=J3DQlw/ep6sjBDEmUHPhQYQsEx DjDDu4pwZmJWUFj0bytZadhJEwOhMEyuCQ9Rn6xOynbv1WWYxJDQET4M93O3zYQlZj4nFb+XVsZHd okH3fYbBhhPrbvqp6XrLz85ZrwlW1Vdjnd7Rwog6LAEjjvN0rGLlpcvKeOocSctMTLXc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wx0079oexxge96ApqiBl9x1aDsyIiQFPAxLyyqGagxs=; b=G9EK1CuUhM4V70vUloWfdLClQz U5/dB2dP53Az3PhFqlyWkh0oL0T/GAIL1hfqe2OWxbO4jyhVvmuXpee1CGILsga2p8E7phT2gkqFG 9jQt+s6qdmSRL/lwqLsCo6MkHEcKtFpE2ReFOR2uGxoO1Jy2R+RgY3liP8OLqE23etO4=; Received: from mail-wr1-f66.google.com ([209.85.221.66]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1k8ICj-00165f-TC for openvpn-devel@lists.sourceforge.net; Wed, 19 Aug 2020 07:08:17 +0000 Received: by mail-wr1-f66.google.com with SMTP id p20so20434425wrf.0 for ; Wed, 19 Aug 2020 00:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wx0079oexxge96ApqiBl9x1aDsyIiQFPAxLyyqGagxs=; b=PQwNmnQSceNEod/7MzfVCzkEaZ5iAg5MhHpddSx0yHrXV2aB5KefT0thV1xjH6wBBx yoMkFPkqDs0gnyklWAcu/FlatguzCJ40KG7rq7BMo1XNII3oONdg69sxQEUqvLO9ArG8 BU9VDcf7Z7jELC76sfEOH/DD94+yYPbdCGHQH4eGL6YfIRR3YIi94IDKnR2SYu+/7rPh p4+HJRIePIFJmwsBt5UXRFhqhOGotIkrZMpYuBKYKdKMFeOw6eWfI6Eryk0zt3ieHeoV 1Mv5CXYNKc16dMwqw5yn4bxhjZei6nJfCNZcViNtpiOkKnYBqxNQ4wzE1THdPSE7nGQY ilwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wx0079oexxge96ApqiBl9x1aDsyIiQFPAxLyyqGagxs=; b=MLuQudX46FI5A643BvTDs0dV+DyoE1aaQ3lNUEcscV9sTAOtlSEbxWT/E40umaugvI fMSRRH+ZzVaegx8TWsQxBG5Io1GvonMszALcTJNnn3TcF+G1qhuSiwmnWy+Samu2q/3T 26H8ZNcPKAD+/WdE1nzf1fzh1cnAs+mQYIUh/SivgeH9n0Ttb67mzJSlANHgynLA6Cb6 rijq/8DqLqeSxUS5Mm04DSZ3tnVR5LdjcsfRG7lsUT84EnZG3FDnpIqafwasJ1kK48nl +PLYpOWujRQNUcxDvNrtxL+mvwREQ66K7lfhJ4epp+v07ucgCtmZ9tln3FS/FAv2OXnR zPrA== X-Gm-Message-State: AOAM531BI1pbfsbKfZA1OHQlIgyP2nJqswf/8fPRLRsojl2o0uUVmhHE GgteVriRSo25Uyef56EfcxMRGylOByE= X-Google-Smtp-Source: ABdhPJwd6k3h0g+KxJV4saeld4P+5mMfp3lY48gUvOklXT8wT5GEPEEHgOOXKGozWKzQ8uIuuqwF2Q== X-Received: by 2002:a5d:4fc2:: with SMTP id h2mr22469351wrw.333.1597820879966; Wed, 19 Aug 2020 00:07:59 -0700 (PDT) Received: from LAPTOP-4L3N7KFS.localdomain (nat2.panoulu.net. [185.38.2.2]) by smtp.gmail.com with ESMTPSA id a10sm41216505wrh.36.2020.08.19.00.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 00:07:59 -0700 (PDT) From: Lev Stipakov To: openvpn-devel Date: Wed, 19 Aug 2020 10:07:46 +0300 Message-Id: <20200819070746.197-1-lstipakov@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (lstipakov[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: openvpn.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.66 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.66 listed in wl.mailspike.net] X-Headers-End: 1k8ICj-00165f-TC Subject: [Openvpn-devel] [PATCH] tun.c: enable using wintun driver under SYSTEM 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: Lev Stipakov MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Lev Stipakov Commit 6d19775a468 has removed SYSTEM elevation hack, but introduced regression - inability to use wintun without interactive service. Proceed with ring buffers registration even if iservice is unavailable and display relevant error message. Trac #1318 Signed-off-by: Lev Stipakov Acked-by: selva.nair@gmail.com Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
--- src/openvpn/tun.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 30454454..62557364 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -6158,12 +6158,32 @@ wintun_register_ring_buffer(struct tuntap *tt, const char *device_guid) } else { - msg(M_FATAL, "ERROR: Wintun requires SYSTEM privileges and therefore " - "should be used with interactive service. If you want to " - "use openvpn from command line, you need to do SYSTEM " - "elevation yourself (for example with psexec)."); - } + if (!register_ring_buffers(tt->hand, + tt->wintun_send_ring, + tt->wintun_receive_ring, + tt->rw_handle.read, + tt->rw_handle.write)) + { + switch (GetLastError()) + { + case ERROR_ACCESS_DENIED: + msg(M_FATAL, "ERROR: Wintun requires SYSTEM privileges and therefore " + "should be used with interactive service. If you want to " + "use openvpn from command line, you need to do SYSTEM " + "elevation yourself (for example with psexec)."); + break; + + case ERROR_ALREADY_INITIALIZED: + msg(M_NONFATAL, "Adapter %s is already in use", device_guid); + break; + default: + msg(M_NONFATAL | M_ERRNO, "Failed to register ring buffers"); + } + ret = false; + } + + } return ret; }