| Message ID | 20200330125719.766763-1-wardragon78@gmail.com |
|---|---|
| State | Changes Requested |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> 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 <patchwork@openvpn.net>; 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 <openvpn-devel-bounces@lists.sourceforge.net>) (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 <openvpn-devel-bounces@lists.sourceforge.net>) 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 <wardragon78@gmail.com>) 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 <openvpn-devel@lists.sourceforge.net>; 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 <wardragon78@gmail.com> 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: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel,v5] Insert client connection data into PAM environment
|
|
Commit Message
Paolo Cerrito
March 30, 2020, 1:57 a.m. UTC
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(-)
Comments
Hi, On Mon, Mar 30, 2020 at 8:59 AM Paolo Cerrito <wardragon78@gmail.com> wrote: > 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 <signal.h> > #include <syslog.h> > #include "utils.h" > - > +#include <arpa/inet.h> #include <openvpn-plugin.h> > > #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 > INET6_ADDRSTRLEN = 46 already includes space for nul termination More importantly, you have to provide a single updated patch preferably with version indicated in the subject and sent out with --in-reply-to <msgid> referring to the previous version. Submitting incremental pieces of fixup commits doesn't help. And please wait for review before making changes unless correcting a critical error. Thanks, Selva <div dir="ltr"><div>Hi,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 30, 2020 at 8:59 AM Paolo Cerrito <<a href="mailto:wardragon78@gmail.com">wardragon78@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">1) so remote was set to the maxlenght of ipv6 address defined into<br> arpa/inet.h + 1 for string terminator<br> <br> 2) I refactored the call to get_env to take first ipv6 address, then<br> only if it is NULL, i make a call for ipv4<br> ---<br> src/plugins/auth-pam/auth-pam.c | 8 +++++---<br> 1 file changed, 5 insertions(+), 3 deletions(-)<br> <br> diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c<br> index ae0d495a..cd91a33c 100644<br> --- a/src/plugins/auth-pam/auth-pam.c<br> +++ b/src/plugins/auth-pam/auth-pam.c<br> @@ -48,7 +48,7 @@<br> #include <signal.h><br> #include <syslog.h><br> #include "utils.h"<br> -<br> +#include <arpa/inet.h> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> #include <openvpn-plugin.h><br> <br> #define DEBUG(verb) ((verb) >= 4)<br> @@ -115,7 +115,7 @@ struct user_pass {<br> char password[128];<br> char common_name[128];<br> char response[128];<br> - char remote[46]; //46 as ipv6 form n:n:n:n:n:n:d.d.d.d and + terminator \0<br> + char remote[INET6_ADDRSTRLEN+1]; //INET6_ADDRSTRLEN is the lenght of ipv6 + terminator \0<br></blockquote><div><br></div><div>INET6_ADDRSTRLEN = 46 already includes space for nul termination </div><div><br></div><div>More importantly, you have to provide a single updated patch </div><div>preferably with version indicated in the subject and sent out with</div><div>--in-reply-to <msgid> referring to the previous version.</div><div><br></div><div>Submitting incremental pieces of fixup commits doesn't help. And please</div><div>wait for review before making changes unless correcting a critical error.</div><div><br></div><div>Thanks,</div><div><br></div><div>Selva</div></div></div>
So,
as you asked, now a make the complete patch from diff from master and my
branch, making the change to remote lenght.
--- a/src/plugins/auth-pam/auth-pam.c
+++ b/src/plugins/auth-pam/auth-pam.c
@@ -48,7 +48,7 @@
#include <signal.h>
#include <syslog.h>
#include "utils.h"
-
+#include <arpa/inet.h>
#include <openvpn-plugin.h>
#define DEBUG(verb) ((verb) >= 4)
@@ -115,6 +115,7 @@ struct user_pass {
char password[128];
char common_name[128];
char response[128];
+ char remote[INET6_ADDRSTRLEN];
const struct name_value_list *name_value_list;
};
@@ -517,13 +518,19 @@ 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); //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
|| send_string(context->foreground_fd, username) == -1
|| send_string(context->foreground_fd, password) == -1
- || send_string(context->foreground_fd, common_name) == -1)
+ || send_string(context->foreground_fd, common_name) == -1
+ || send_string(context->foreground_fd, remote) == -1)
{
fprintf(stderr, "AUTH-PAM: Error sending auth info to
background process\n");
}
@@ -750,8 +757,16 @@ pam_auth(const char *service, const struct
user_pass *up)
status = pam_start(service, name_value_list_provided ? NULL :
up->username, &conv, &pamh);
if (status == PAM_SUCCESS)
{
+ /* Set PAM_RHOST environment variable */
+ if (*(up->remote))
+ {
+ status = pam_set_item(pamh, PAM_RHOST, up->remote);
+ }
/* Call PAM to verify username/password */
- status = pam_authenticate(pamh, 0);
+ if (status == PAM_SUCCESS)
+ {
+ status = pam_authenticate(pamh, 0);
+ }
if (status == PAM_SUCCESS)
{
status = pam_acct_mgmt(pamh, 0);
@@ -839,7 +854,8 @@ pam_server(int fd, const char *service, int verb,
const struct name_value_list *
case COMMAND_VERIFY:
if (recv_string(fd, up.username, sizeof(up.username)) == -1
|| recv_string(fd, up.password,
sizeof(up.password)) == -1
- || recv_string(fd, up.common_name,
sizeof(up.common_name)) == -1)
+ || recv_string(fd, up.common_name,
sizeof(up.common_name)) == -1
+ || recv_string(fd, up.remote, sizeof(up.remote)) == -1)
{
fprintf(stderr, "AUTH-PAM: BACKGROUND: read error
on command channel: code=%d, exiting\n",
command);
@@ -853,6 +869,7 @@ pam_server(int fd, const char *service, int verb,
const struct name_value_list *
up.username, up.password);
#else
fprintf(stderr, "AUTH-PAM: BACKGROUND: USER: %s\n",
up.username);
+ fprintf(stderr, "AUTH-PAM: BACKGROUND: REMOTE:
%s\n", up.remote);
#endif
}
Il 30/03/20 22:58, Selva Nair ha scritto:
> Hi,
>
> On Mon, Mar 30, 2020 at 8:59 AM Paolo Cerrito <wardragon78@gmail.com
> <mailto:wardragon78@gmail.com>> wrote:
>
> 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 <signal.h>
> #include <syslog.h>
> #include "utils.h"
> -
> +#include <arpa/inet.h>
>
> #include <openvpn-plugin.h>
>
> #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
>
>
> INET6_ADDRSTRLEN = 46 already includes space for nul termination
>
> More importantly, you have to provide a single updated patch
> preferably with version indicated in the subject and sent out with
> --in-reply-to <msgid> referring to the previous version.
>
> Submitting incremental pieces of fixup commits doesn't help. And please
> wait for review before making changes unless correcting a critical error.
>
> Thanks,
>
> Selva
Am 31.03.20 um 09:34 schrieb Paolo: > So, > as you asked, now a make the complete patch from diff from master and my > branch, making the change to remote lenght. > Your patch got mangled very badly for me: > -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â || send_string(context->foreground_fd, > common_name) == -1)<br> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â || send_string(context->foreground_fd, > common_name) == -1<br> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â || send_string(context->foreground_fd, remote) Can you try to resend it with git send email or even as an attachment that does not get reformatted would help. Arne
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 <signal.h> #include <syslog.h> #include "utils.h" - +#include <arpa/inet.h> #include <openvpn-plugin.h> #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