From patchwork Wed Oct 19 13:36:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2824 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director14.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id SLEHBKD9T2N3IAAAIUCqbw (envelope-from ) for ; Wed, 19 Oct 2022 09:37:36 -0400 Received: from proxy7.mail.ord1d.rsapps.net ([172.30.191.6]) by director14.mail.ord1d.rsapps.net with LMTP id MC/KA6D9T2NxQgAAeJ7fFg (envelope-from ) for ; Wed, 19 Oct 2022 09:37:36 -0400 Received: from smtp1.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.ord1d.rsapps.net with LMTPS id aJSHA6D9T2N2ZQAAMe1Fpw (envelope-from ) for ; Wed, 19 Oct 2022 09:37:36 -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: smtp1.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=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 30617174-4fb3-11ed-b55e-5254002d775b-1-1 Received: from [216.105.38.7] ([216.105.38.7:40556] helo=lists.sourceforge.net) by smtp1.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 2F/85-15836-F9DFF436; Wed, 19 Oct 2022 09:37:35 -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.95) (envelope-from ) id 1ol9FS-0002EZ-TY; Wed, 19 Oct 2022 13:36:42 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ol9FP-0002EL-L5 for openvpn-devel@lists.sourceforge.net; Wed, 19 Oct 2022 13:36:39 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mynm+VQWWnb81ec8FRb9FU1NnK/XFdoYOQeo8tuAGU8=; b=GmxzNYnw6pQo5QgXEz1Bz0PTvm 99EAPTB9mROGNrToSBXSwQ5CjYIaKVVFdNSIVTPY9t9yiSDx0SoAgVENNEMXE5rpvPzMG/3/f/5PU YbDPG8W65Th7ZRyAim9+yF9S0k++4FoqmPh75a8phqJY08GfGy1EdiIH1EY38bCDwf2Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=mynm+VQWWnb81ec8FRb9FU1NnK/XFdoYOQeo8tuAGU8=; b=J IWFQPCPe8+iHoDWIq1YUW/uXtriRBGUo0byWuCAS+oBgxM2M1L/sAq3LUc0HuywhqCaz+OTt84H9I 3+aZjc4BpM4johv+RhExHufdikbCOrpAlpE3LGRs1uVZ9T3fWaVcBZHMwwUa7rq3IpZRShvl8RH2o inpTtkrtkr1OiJdo=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ol9FK-0002FX-PI for openvpn-devel@lists.sourceforge.net; Wed, 19 Oct 2022 13:36:39 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1ol9FD-000HDK-Cr for openvpn-devel@lists.sourceforge.net; Wed, 19 Oct 2022 15:36:27 +0200 Received: (nullmailer pid 2918156 invoked by uid 10006); Wed, 19 Oct 2022 13:36:27 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Wed, 19 Oct 2022 15:36:27 +0200 Message-Id: <20221019133627.2918110-1-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Commit facb6fffb changed a call in the style of if(a() | b()) to if(a() || b()). While this looks identical, it is not. The first statement always executes b() while the second only executes b() if a( [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1ol9FK-0002FX-PI Subject: [Openvpn-devel] [PATCH] Fix regression of ignoring --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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Commit facb6fffb changed a call in the style of if(a() | b()) to if(a() || b()). While this looks identical, it is not. The first statement always executes b() while the second only executes b() if a() returns false. This lead to to the platform_state_user never to set as side effect and thus --user being ignored. Rewrite the code to make this more explicit. Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 07d43d49d..7de65a3ec 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -3597,10 +3597,14 @@ do_init_first_time(struct context *c) ALLOC_OBJ_CLEAR_GC(c->c0, struct context_0, &c->gc); c0 = c->c0; - /* get user and/or group that we want to setuid/setgid to */ - c0->uid_gid_specified = - platform_group_get(c->options.groupname, &c0->platform_state_group) - || platform_user_get(c->options.username, &c0->platform_state_user); + /* get user and/or group that we want to setuid/setgid to, + * sets also platform_x_state */ + bool group_defined = platform_group_get(c->options.groupname, + &c0->platform_state_group); + bool user_defined = platform_user_get(c->options.username, + &c0->platform_state_user); + + c0->uid_gid_specified = user_defined || group_defined; /* perform postponed chdir if --daemon */ if (c->did_we_daemonize && c->options.cd_dir == NULL)