From owner-svn-src-all@freebsd.org Tue Sep 4 10:51:42 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2A2AFEB3E9; Tue, 4 Sep 2018 10:51:42 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 77D0A92783; Tue, 4 Sep 2018 10:51:42 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 72C0616133; Tue, 4 Sep 2018 10:51:42 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w84ApgIw012478; Tue, 4 Sep 2018 10:51:42 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w84ApgC8012476; Tue, 4 Sep 2018 10:51:42 GMT (envelope-from des@FreeBSD.org) Message-Id: <201809041051.w84ApgC8012476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Tue, 4 Sep 2018 10:51:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338453 - head/lib/libpam/modules/pam_exec X-SVN-Group: head X-SVN-Commit-Author: des X-SVN-Commit-Paths: head/lib/libpam/modules/pam_exec X-SVN-Commit-Revision: 338453 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 10:51:42 -0000 Author: des Date: Tue Sep 4 10:51:41 2018 New Revision: 338453 URL: https://svnweb.freebsd.org/changeset/base/338453 Log: For full Linux-PAM compatibility, add a trailing NUL character when passing the authentication token to the external program. Approved by: re (kib) Submitted by: Thomas Munro MFC after: 1 week Differential Revision: D16950 Modified: head/lib/libpam/modules/pam_exec/pam_exec.8 head/lib/libpam/modules/pam_exec/pam_exec.c Modified: head/lib/libpam/modules/pam_exec/pam_exec.8 ============================================================================== --- head/lib/libpam/modules/pam_exec/pam_exec.8 Tue Sep 4 09:58:13 2018 (r338452) +++ head/lib/libpam/modules/pam_exec/pam_exec.8 Tue Sep 4 10:51:41 2018 (r338453) @@ -74,7 +74,8 @@ Ignored for compatibility reasons. Use the program exit status as the return code of the pam_sm_* function. It must be a valid return value for this function. .It Cm expose_authtok -Write the authentication token to the program's standard input stream. +Write the authentication token to the program's standard input stream, +followed by a NUL character. .It Cm -- Stop options parsing; program and its arguments follow. Modified: head/lib/libpam/modules/pam_exec/pam_exec.c ============================================================================== --- head/lib/libpam/modules/pam_exec/pam_exec.c Tue Sep 4 09:58:13 2018 (r338452) +++ head/lib/libpam/modules/pam_exec/pam_exec.c Tue Sep 4 10:51:41 2018 (r338453) @@ -254,7 +254,8 @@ _pam_exec(pam_handle_t *pamh, } rc = pam_get_authtok(pamh, PAM_AUTHTOK, &authtok, NULL); if (rc == PAM_SUCCESS) { - authtok_size = strlen(authtok); + /* We include the trailing NUL-terminator. */ + authtok_size = strlen(authtok) + 1; } else { openpam_log(PAM_LOG_ERROR, "%s: pam_get_authtok(): %s", func, pam_strerror(pamh, rc));