From patchwork Wed Mar 25 21:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Cerrito X-Patchwork-Id: 1051 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 ECD4BO1wfF77FgAAIUCqbw for ; Thu, 26 Mar 2020 05:07:57 -0400 Received: from proxy11.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id KKFcAu1wfF4dTgAAvGGmqA ; Thu, 26 Mar 2020 05:07:57 -0400 Received: from smtp5.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy11.mail.iad3b.rsapps.net with LMTP id qPu6N+xwfF6UDwAARNREpw ; Thu, 26 Mar 2020 05:07:56 -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: smtp5.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; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 47aac9ca-6f41-11ea-8b75-525400155d63-1-1 Received: from [216.105.38.7] ([216.105.38.7:55466] helo=lists.sourceforge.net) by smtp5.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 2B/9B-10965-CE07C7E5; Thu, 26 Mar 2020 05:07: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 1jHOTt-0002K2-2v; Thu, 26 Mar 2020 09:07:17 +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 1jHOTq-0002Jp-S4 for openvpn-devel@lists.sourceforge.net; Thu, 26 Mar 2020 09:07:14 +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:Cc:To:From:Sender:Reply-To: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=VnzYQo88Rt8iHYtUz6wakqIaxUFNARrBXJ03Bf5v9Ww=; b=lGemuNEE4va7NCaftJ+PqIflTK ICXDLTqiEYjueqPdyOjJkqgjY2M+XYRrQS0WTVp9F3gKLVmeJ1HT0zbqBxSQCG4PuSqU9k4rbET+O ZVZ4kAuVUbk2R2Ff9i1trBOfITRbNdR7w9KgOmOuzq0O0C0/ngZ4PQFDZkiaz8ujvbvM=; 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:Cc:To:From :Sender:Reply-To: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=VnzYQo88Rt8iHYtUz6wakqIaxUFNARrBXJ03Bf5v9Ww=; b=A t3uX7ms8EwPRZwvb5j0HBxY2fa4RXCpSNKDoVKbmaEky9kRNQagD/gfNTGF+unK96vwEF/Esp1CoD 5K6dPfqty6MJEdoR3gxB4pwr+E2U3MFnQK46YFctnLm1gTM58JWiiWtia0NnsE5TyCLwhHkq/qxgD VLFZ+elPXZ/cP8X0=; Received: from smtp.uniroma2.it ([160.80.6.16]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jHOTn-007zUq-UB for openvpn-devel@lists.sourceforge.net; Thu, 26 Mar 2020 09:07:14 +0000 Received: from wardragon.ccd.uniroma2.it (wardragon-176.ccd.uniroma2.it [160.80.8.176] (may be forged)) by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 02Q8lKot016078; Thu, 26 Mar 2020 09:47:25 +0100 From: Paolo Cerrito To: openvpn-devel@lists.sourceforge.net Date: Thu, 26 Mar 2020 09:47:04 +0100 Message-Id: <20200326084704.45458-1-wardragon78@gmail.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Virus-Status: Clean 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 (wardragon78[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (wardragon78[at]gmail.com) 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [160.80.6.16 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list 0.0 MAY_BE_FORGED Relay IP's reverse DNS does not resolve to IP 0.0 SPOOFED_FREEMAIL No description available. X-Headers-End: 1jHOTn-007zUq-UB Subject: [Openvpn-devel] [PATCH] [PATCH V3] - changed remote lenght and refactored get_env 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 1) I put remote lenght to 51, as it have to hold ipv6/ipv4 ip address plus string terminator. 2) As asked, i refactor the call to get_env, so now first of all there is a one call to get_env to get the ipv6 address, if is not set, and only in this case, we recall get_env for ipv4. --- .gitignore | 1 + src/plugins/auth-pam/auth-pam.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0d68ec4b..3977882f 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ nbproject test-driver compile stamp-h2 +outgoing/* diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c index 9d8dfb95..b55a2ecd 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -115,7 +115,7 @@ struct user_pass { char password[128]; char common_name[128]; char response[128]; - char remote[128]; + char remote[51]; //51 as ipv6 form n:n:n:n:n:n:d.d.d.d/mask and terminator+1 const struct name_value_list *name_value_list; }; @@ -518,7 +518,11 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const cha const char *username = get_env("username", envp); const char *password = get_env("password", envp); const char *common_name = get_env("common_name", envp) ? get_env("common_name", envp) : ""; - const char *remote = get_env("untrusted_ip", envp) ? get_env("untrusted_ip", envp) : get_env("untrusted_ip6", envp); + const char *remote = get_env("untrusted_ip6", envp); + + if (remote == NULL){ + remote = get_env("untrusted_ip", envp); //try to take ipv4 if not set ipv6 + } if (username && strlen(username) > 0 && password) {