From owner-svn-src-stable@FreeBSD.ORG Thu May 20 18:45:08 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36D5E106572A; Thu, 20 May 2010 18:45:08 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BB8A8FC23; Thu, 20 May 2010 18:45:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4KIj7Ze077995; Thu, 20 May 2010 18:45:07 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4KIj7kx077993; Thu, 20 May 2010 18:45:07 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201005201845.o4KIj7kx077993@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 20 May 2010 18:45:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208358 - stable/8/lib/libc/posix1e X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2010 18:45:08 -0000 Author: trasz Date: Thu May 20 18:45:07 2010 New Revision: 208358 URL: http://svn.freebsd.org/changeset/base/208358 Log: MFC r208033: Make it possible to actually use NFSv4 permission bits with acl_set_perm(3) and acl_delete_perm(3). It went undetected, because neither setfacl(1) nor Samba use this routines. D'oh. Modified: stable/8/lib/libc/posix1e/acl_perm.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/posix1e/acl_perm.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_perm.c Thu May 20 18:39:33 2010 (r208357) +++ stable/8/lib/libc/posix1e/acl_perm.c Thu May 20 18:45:07 2010 (r208358) @@ -35,6 +35,20 @@ __FBSDID("$FreeBSD$"); #include #include +static int +_perm_is_invalid(acl_perm_t perm) +{ + + /* Check if more than a single bit is set. */ + if ((perm & -perm) == perm && + (perm & (ACL_POSIX1E_BITS | ACL_NFS4_PERM_BITS)) == perm) + return (0); + + errno = EINVAL; + + return (1); +} + /* * acl_add_perm() (23.4.1): add the permission contained in perm to the * permission set permset_d @@ -43,18 +57,17 @@ int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm) { - if (permset_d) { - switch(perm) { - case ACL_READ: - case ACL_WRITE: - case ACL_EXECUTE: - *permset_d |= perm; - return (0); - } + if (permset_d == NULL) { + errno = EINVAL; + return (-1); } - errno = EINVAL; - return (-1); + if (_perm_is_invalid(perm)) + return (-1); + + *permset_d |= perm; + + return (0); } /* @@ -83,16 +96,15 @@ int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm) { - if (permset_d) { - switch(perm) { - case ACL_READ: - case ACL_WRITE: - case ACL_EXECUTE: - *permset_d &= ~(perm & ACL_PERM_BITS); - return (0); - } + if (permset_d == NULL) { + errno = EINVAL; + return (-1); } - errno = EINVAL; - return (-1); + if (_perm_is_invalid(perm)) + return (-1); + + *permset_d &= ~perm; + + return (0); }