From owner-svn-src-head@FreeBSD.ORG Sun Sep 14 07:13:48 2014 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ED8D71E7; Sun, 14 Sep 2014 07:13:48 +0000 (UTC) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id AA760F8D; Sun, 14 Sep 2014 07:13:47 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA22898; Sun, 14 Sep 2014 10:13:46 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1XT40H-000ExY-VK; Sun, 14 Sep 2014 10:13:45 +0300 Message-ID: <54153FF2.7050105@FreeBSD.org> Date: Sun, 14 Sep 2014 10:12:50 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r271256 - head/lib/libpam/modules/pam_login_access References: <201409080919.s889J1QL050814@svn.freebsd.org> In-Reply-To: <201409080919.s889J1QL050814@svn.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2014 07:13:49 -0000 On 08/09/2014 12:19, Dag-Erling Smørgrav wrote: > Author: des > Date: Mon Sep 8 09:19:01 2014 > New Revision: 271256 > URL: http://svnweb.freebsd.org/changeset/base/271256 > > Log: > Fail rather than segfault if neither PAM_TTY nor PAM_RHOST is set. > > PR: 83099 > MFC after: 3 days Thanks! But please see a line comment below. > Modified: > head/lib/libpam/modules/pam_login_access/pam_login_access.c > > Modified: head/lib/libpam/modules/pam_login_access/pam_login_access.c > ============================================================================== > --- head/lib/libpam/modules/pam_login_access/pam_login_access.c Mon Sep 8 09:16:07 2014 (r271255) > +++ head/lib/libpam/modules/pam_login_access/pam_login_access.c Mon Sep 8 09:19:01 2014 (r271256) > @@ -79,7 +79,14 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int > > gethostname(hostname, sizeof hostname); > > - if (rhost == NULL || *(const char *)rhost == '\0') { > + if (rhost != NULL && *(const char *)rhost != '\0') { > + PAM_LOG("Checking login.access for user %s from host %s", > + (const char *)user, (const char *)rhost); > + if (login_access(user, rhost) != 0) > + return (PAM_SUCCESS); > + PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", > + user, rhost); > + } else if (tty != NULL || *(const char *)tty != '\0') { I think that the operator should be && here as well. > PAM_LOG("Checking login.access for user %s on tty %s", > (const char *)user, (const char *)tty); > if (login_access(user, tty) != 0) > @@ -87,12 +94,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int > PAM_VERBOSE_ERROR("%s is not allowed to log in on %s", > user, tty); > } else { > - PAM_LOG("Checking login.access for user %s from host %s", > - (const char *)user, (const char *)rhost); > - if (login_access(user, rhost) != 0) > - return (PAM_SUCCESS); > - PAM_VERBOSE_ERROR("%s is not allowed to log in from %s", > - user, rhost); > + PAM_VERBOSE_ERROR("PAM_RHOST or PAM_TTY required"); > + return (PAM_AUTHINFO_UNAVAIL); > } > > return (PAM_AUTH_ERR); > -- Andriy Gapon