From patchwork Mon Mar 30 01:57:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Cerrito X-Patchwork-Id: 1059 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id AOr6OEztgV7hFwAAIUCqbw for ; Mon, 30 Mar 2020 08:59:56 -0400 Received: from proxy1.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id cIdKNkztgV5FQQAAfY0hYg ; Mon, 30 Mar 2020 08:59:56 -0400 Received: from smtp11.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.iad3b.rsapps.net with LMTP id UOxlMEztgV77WgAALM5PBw ; Mon, 30 Mar 2020 08:59: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: smtp11.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: 5a15031c-7286-11ea-a839-52540070b5bb-1-1 Received: from [216.105.38.7] ([216.105.38.7:33288] helo=lists.sourceforge.net) by smtp11.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 30/4A-18878-B4DE18E5; Mon, 30 Mar 2020 08:59:55 -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 1jIu0O-0004G0-32; Mon, 30 Mar 2020 12:59:04 +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 1jIu0N-0004Fp-5s for openvpn-devel@lists.sourceforge.net; Mon, 30 Mar 2020 12:59:03 +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=uLhNBKDAUEube2+TsVL3kbe+FdLpMJqCl/3nbH7hehg=; b=idqHN5CmwhMVfoFKozNaI/jk0A AmJtUfP9rtAPPuowi9ICAYfZleHIiv1FtQ5BAjczmpcISmIIQwqNmnCbYihQMeJx7c/SACGSBDdvi V6OcYV2foJIm4UeXLWZ8/3qrfkl5MqlH6kh35pKdSmrGpPEWxglBjcDDiiISYlKkYA3c=; 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=uLhNBKDAUEube2+TsVL3kbe+FdLpMJqCl/3nbH7hehg=; b=S wRTIblibI5+KVyxgpa/EaayHj3NDCOOwY+g2Fg7l0sBYwavubSmNPlIhu+TeIGT5kn8gesM0bZux1 CbWxXXvvOF5d4QIOUW6uicHNIkB5bw6Wy7rBd5nw2fCcwEeIdF1c6O12QS+BP6u/YUCdM6HkWqYFn +u6QpsKsvJRfFdok=; Received: from mail-wr1-f66.google.com ([209.85.221.66]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jIu0L-00CPSo-Rz for openvpn-devel@lists.sourceforge.net; Mon, 30 Mar 2020 12:59:03 +0000 Received: by mail-wr1-f66.google.com with SMTP id h9so21469558wrc.8 for ; Mon, 30 Mar 2020 05:59:01 -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:mime-version :content-transfer-encoding; bh=uLhNBKDAUEube2+TsVL3kbe+FdLpMJqCl/3nbH7hehg=; b=VbXn/71qzr7FUy0qgPaLiKraS+N9R8vhkbH5ejXsUZXIIbmou3+tUKByfpoeSYnfJj XIuhn9mvjCL7ZktXynopdp9NNlglfugF3UAv9RTWuu5SN7rr17uxtuxNHGSRmdRvhhK9 8FYtSpJJOgE1/85pijfn9rQRn1y3AMrkol+VT7WdlmJMqI2jdMVbk+5g9Zm6U/IOTmTI N9zCHl/HVH0oS8Q7O8goc2GI4bIN/701CTbv6C1YbQPtbiAv0Hw65bZG5BCxPYrhm6jR BISaz9i91BWv/O///2bXNWthwQMg2HPevtGx1upNO4TXm3Ip/nMHm2/FXdkNXlwYSC1N wS6Q== 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:mime-version :content-transfer-encoding; bh=uLhNBKDAUEube2+TsVL3kbe+FdLpMJqCl/3nbH7hehg=; b=CjpTgjcOee1uRFGM0Xg2APxf7ENYBL6SMnljbslzKtZGsr2yWMs0lXMCFzTa3n+LR3 M7ay7tQY4VUy+k7LcXy3ptnlTmkdzsBLLBMagHF827EIXWrfDXTSzPzVnhM3T1xErMBD 7jlWGuSkvP5PQu3vVZG6oSSeesewYoZIIiYI5mb5AYWnkCGoEfhXCxLI8rDdpvmV3i23 Vd6gMPgd0Sn5ywRbLIfTuxqV2A3FGfPFf+/oTSEInZxJkJtiwKxh3yvs6/DNNU5SGjx6 xBJGXaqTSTz+dDUHF1zmYa+yvOSh6OiZP/GAxARTLWpb/19dS/vkabDr3rJPMgUhuUhG m9Ig== X-Gm-Message-State: ANhLgQ0TDz8KM8/banEAjhWG3xyei/tJ5ZikJIYRdHWfR/4E2uqhAB+n kMmZwb/D28HJLQZaaIhikvethziCU40= X-Google-Smtp-Source: ADFU+vsbZ5LIIHp1y41zBrfupLjE10szGdg/YPM84/ihnsnX1qbDg7uI6FhUHgNPTyLRdUviRyI5ew== X-Received: by 2002:adf:e492:: with SMTP id i18mr14601208wrm.316.1585573135006; Mon, 30 Mar 2020 05:58:55 -0700 (PDT) Received: from wardragon.ccd.uniroma2.it (wardragon-m.ccd.uniroma2.it. [160.80.8.176]) by smtp.gmail.com with ESMTPSA id f187sm16561754wme.9.2020.03.30.05.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 05:58:54 -0700 (PDT) From: Paolo Cerrito To: openvpn-devel@lists.sourceforge.net Date: Mon, 30 Mar 2020 14:57:20 +0200 Message-Id: <20200330125719.766763-1-wardragon78@gmail.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -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 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (wardragon78[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.66 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 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.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.8 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1jIu0L-00CPSo-Rz Subject: [Openvpn-devel] [PATCH] [PATCH v5] Insert client connection data into PAM environment 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) so remote was set to the maxlenght of ipv6 address defined into arpa/inet.h + 1 for string terminator 2) I refactored the call to get_env to take first ipv6 address, then only if it is NULL, i make a call for ipv4 --- src/plugins/auth-pam/auth-pam.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c index ae0d495a..cd91a33c 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -48,7 +48,7 @@ #include #include #include "utils.h" - +#include #include #define DEBUG(verb) ((verb) >= 4) @@ -115,7 +115,7 @@ struct user_pass { char password[128]; char common_name[128]; char response[128]; - char remote[46]; //46 as ipv6 form n:n:n:n:n:n:d.d.d.d and + terminator \0 + char remote[INET6_ADDRSTRLEN+1]; //INET6_ADDRSTRLEN is the lenght of ipv6 + terminator \0 const struct name_value_list *name_value_list; }; @@ -518,12 +518,14 @@ 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_ip6", envp); if (remote == NULL){ - remote = get_env("untrusted_ip", envp); //try to take ipv4 if not set ipv6 + remote = get_env("untrusted_ip", envp); //if Null, try to take ipv4 if not set ipv6 } + if (username && strlen(username) > 0 && password) { if (send_control(context->foreground_fd, COMMAND_VERIFY) == -1