From patchwork Mon Jan 29 00:30:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin T X-Patchwork-Id: 223 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director1.mail.ord1d.rsapps.net ([172.27.255.58]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id 93FdADEGb1o4YAAAgoeIoA for ; Mon, 29 Jan 2018 06:32:01 -0500 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.58]) by director1.mail.ord1d.rsapps.net (Dovecot) with LMTP id yULpDjEGb1qRFAAANGzteQ ; Mon, 29 Jan 2018 06:32:01 -0500 Received: from smtp35.gate.iad3a ([172.27.255.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net (Dovecot) with LMTP id UoHrLjEGb1rkQwAABcWvHw ; Mon, 29 Jan 2018 06:32:01 -0500 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.34.181.88] Authentication-Results: smtp35.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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-Classification-ID: 05ab7d96-04e8-11e8-a20d-bc305bf5a7c0-1-1 Received: from [216.34.181.88] ([216.34.181.88:7104] helo=lists.sourceforge.net) by smtp35.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 70/07-00490-1360F6A5; Mon, 29 Jan 2018 06:32:01 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1eg7eb-0006ym-3g; Mon, 29 Jan 2018 11:31:13 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eg7eZ-0006yM-JP for openvpn-devel@lists.sourceforge.net; Mon, 29 Jan 2018 11:31:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From: MIME-Version:Sender:Reply-To:Cc: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=f7Ne+zfk00y87ByOtkRT8NAcP+Kk/dB3bCykqn99qgg=; b=QspCil3H01edsyxP7QsqaL6307 SHa/Bvxhn0EoLiRqDjdAS09WrHA9iKnxr+ATNQFDCgmjziPkE2Rs5wNWFFrEFI+C0Bl/WDKwKQoc2 /V/zeN/OQ+KMLKRGLLh407SkKiHcIPNPw7g3Yc2P50sT7G9f1ptXeqqOoJDa2f8gxeL0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:To:Subject:Message-ID:Date:From:MIME-Version:Sender:Reply-To :Cc: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=f7Ne+zfk00y87ByOtkRT8NAcP+Kk/dB3bCykqn99qgg=; b=m jdVNWMv4mQTopsKLn4JPS3njLI5Ta8kLxuLGaghA6IhG1+1OQ9kt5cJj+4JvKltrxhDtZuCT+jZ2F hg6qeplOSOHL2+tGdfi9jzAlmdEVZhuOj+Pr3cxQzyRS8vwLWbRgl7UL7cbiPyEteybCwA9aK+5Y7 jqyBJrOxpO/VEh1I=; Received: from mail-yb0-f178.google.com ([209.85.213.178]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) id 1eg7eT-000471-JV for openvpn-devel@lists.sourceforge.net; Mon, 29 Jan 2018 11:31:11 +0000 Received: by mail-yb0-f178.google.com with SMTP id l3so2630536ybk.5 for ; Mon, 29 Jan 2018 03:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=f7Ne+zfk00y87ByOtkRT8NAcP+Kk/dB3bCykqn99qgg=; b=CkvybnxgjcW6O0kYGTs0rhrGpO0bIrVDh7p9/g4E/lX8OnZqPw5fFJffFQuJaiaU6O 3EUAxwp5KaWCSde7b+se0kT98gd9ZU5yEqRip8Z/j/o3COqVIMXbWKfDaf0Re3eGuKEI C54gEr2V9xVkWXxboGNvKm/gN5kZn6HKSIs+rHPHAmvs1yVidQd6cOSPVhbcqqTVXE1P FRgGNm9M6MXxzUd5vCIbU6rwxmSzlcoyRe3GKDt9h5Pqqr1DZgezDUOQkK1HQXBhQzmR fqjOyRHC7Nz0e+44MF6dgbki4Hsz8ZNKP2QXhfUuF8i6vC7qhOYUod5BPhE5dO7lTqW2 omKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=f7Ne+zfk00y87ByOtkRT8NAcP+Kk/dB3bCykqn99qgg=; b=ihGS0XHxQslKj3QwNiTSFNMXZa+kvCwqbV3ZLeXxuudJ5HxTJZIASsn/uUqUy9QLGR RRzMpYNvsNde5GfK2AqmF4B4VMBNinNEvTxDFyukeTyReRtJk/1eTzMGe4EXKQzMgcxz YyzXfNmXZjKNEZbWII2Jb0lMGU7T3tdXfBZnjmLCNcxPY1OrAnzxFVcgUWpz1+on2dp6 fSjNg9N5hGwblpZvvT+r9Ol6Sd6C+9hwnQhUqMdfq4EwGL0ZShtMs90YuHP+HijPVwJk lBgfpmYldycPNeS6h9DwUbFtKMkaxpQ3AZ6LY+LPFrV1Rd4WMqrZ+tAs1e654a10Zq96 HV4w== X-Gm-Message-State: AKwxytdb+NiFYcHMSFfcJwaLPX5AU7gddSK6UbYk63CnKztNojX/qTuk 2N4aRwRYKu9GeWdTzE/74e5ObdqbkMBLfzHpSQ19tg== X-Google-Smtp-Source: AH8x225Ff6O3oBiqdTZ3Rpp9x2mfLVDMbX7cN81lU+GYO4d5UJPoQOnnDCM+kKwG1OtJUQJQmn2Pd2I/a8JAyQItrEw= X-Received: by 10.37.164.103 with SMTP id f94mr16569970ybi.129.1517225459914; Mon, 29 Jan 2018 03:30:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.48.9 with HTTP; Mon, 29 Jan 2018 03:30:59 -0800 (PST) From: Martin T Date: Mon, 29 Jan 2018 13:30:59 +0200 Message-ID: To: openvpn-devel@lists.sourceforge.net X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.6 HK_RANDOM_ENVFROM Envelope sender username looks random 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (m4rtntns[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.213.178 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1eg7eT-000471-JV Subject: [Openvpn-devel] patch for openvpn-auth-pam plugin to pass PAM_RHOST variable 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 Hi! Currently openvpn-auth-pam plugin does not set PAM_RHOST(requesting host) variable. This is needed when for example pam_access.so plugin is used and based on OpenVPN client network, different authentication methods are desired. Proof of concept patch for PAM_RHOST is following: get_env("common_name", envp) : ""; if (username && strlen(username) > 0 && password) @@ -458,6 +462,8 @@ 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, untrusted_ip) == -1 + || send_string(context->foreground_fd, untrusted_ip6) == -1 || send_string(context->foreground_fd, common_name) == -1) { fprintf(stderr, "AUTH-PAM: Error sending auth info to background process\n"); @@ -681,6 +687,16 @@ status = pam_start(service, name_value_list_provided ? NULL : up->username, &conv, &pamh); if (status == PAM_SUCCESS) { + + if (strlen(up->untrusted_ip) > 0) + { + pam_set_item(pamh, PAM_RHOST, up->untrusted_ip); + } + else + { + pam_set_item(pamh, PAM_RHOST, up->untrusted_ip6); + } + /* Call PAM to verify username/password */ status = pam_authenticate(pamh, 0); if (status == PAM_SUCCESS) @@ -770,6 +786,8 @@ 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.untrusted_ip, sizeof(up.untrusted_ip)) == -1 + || recv_string(fd, up.untrusted_ip6, sizeof(up.untrusted_ip6)) == -1 || recv_string(fd, up.common_name, sizeof(up.common_name)) == -1) { fprintf(stderr, "AUTH-PAM: BACKGROUND: read error on command channel: code=%d, exiting\n", WBR, Martin ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot --- /var/tmp/auth-pam.c.orig 2018-01-24 21:26:06.262178266 +0200 +++ auth-pam.c 2018-01-25 01:23:14.669019911 +0200 @@ -110,6 +110,8 @@ char username[128]; char password[128]; + char untrusted_ip[128]; + char untrusted_ip6[128]; char common_name[128]; const struct name_value_list *name_value_list; @@ -451,6 +453,8 @@ /* get username/password from envp string array */ const char *username = get_env("username", envp); const char *password = get_env("password", envp); + const char *untrusted_ip = get_env ("untrusted_ip", envp) ? get_env("untrusted_ip", envp) : ""; + const char *untrusted_ip6 = get_env ("untrusted_ip6", envp) ? get_env("untrusted_ip6", envp) : ""; const char *common_name = get_env("common_name", envp) ?