From owner-p4-projects@FreeBSD.ORG Thu Aug 14 18:29:00 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 37F451065752; Thu, 14 Aug 2008 18:29:00 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6B74106569F for ; Thu, 14 Aug 2008 18:28:59 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 43BBE8FC26 for ; Thu, 14 Aug 2008 18:28:59 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7EISxWs023917 for ; Thu, 14 Aug 2008 18:28:59 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7EISxvn023915 for perforce@freebsd.org; Thu, 14 Aug 2008 18:28:59 GMT (envelope-from trasz@freebsd.org) Date: Thu, 14 Aug 2008 18:28:59 GMT Message-Id: <200808141828.m7EISxvn023915@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Cc: Subject: PERFORCE change 147402 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Aug 2008 18:29:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=147402 Change 147402 by trasz@trasz_traszkan on 2008/08/14 18:28:04 Make inheritance in UFS work just as in ZFS. There is some non-standard behaviour, but 1. it is the same thing ZFS does and 2. it does not elevate privileges or loosen restrictions in any way; actually it does the reverse. Affected files ... .. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_nfs4.c#25 edit Differences ... ==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_nfs4.c#25 (text+ko) ==== @@ -804,7 +804,7 @@ const struct acl *parent_aclp, mode_t mode, int file_owner_id, int is_directory) { - int i, error; + int i, error, flags; const struct acl_entry *parent_entry; struct acl_entry *entry, *copy; @@ -822,14 +822,30 @@ */ for (i = 0; i < parent_aclp->acl_cnt; i++) { parent_entry = &(parent_aclp->acl_entry[i]); + flags = parent_entry->ae_flags; + + /* + * Entry is not inheritable at all. + */ + if ((flags & (ACL_ENTRY_DIRECTORY_INHERIT | + ACL_ENTRY_FILE_INHERIT)) == 0) + continue; - if (((parent_entry->ae_flags & - ACL_ENTRY_FILE_INHERIT) == 0) && !is_directory) + /* + * We're creating a file, but entry is not inheritable + * by files. + */ + if (!is_directory && (flags & ACL_ENTRY_FILE_INHERIT) == 0) continue; - if ((parent_entry->ae_flags & - (ACL_ENTRY_DIRECTORY_INHERIT | - ACL_ENTRY_FILE_INHERIT)) == 0) + /* + * Entry is inheritable only by files, but has NO_PROPAGATE + * flag set, and we're creating a directory, so it wouldn't + * propagate to any file in that directory anyway. + */ + if (is_directory && + (flags & ACL_ENTRY_DIRECTORY_INHERIT) == 0 && + (flags & ACL_ENTRY_LIMIT_INHERIT)) continue; KASSERT(child_aclp->acl_cnt + 1 <= ACL_MAX_ENTRIES, @@ -846,6 +862,16 @@ entry = &(child_aclp->acl_entry[i]); /* + * This is not in the specification, but SunOS + * apparently does that. + */ + if (((entry->ae_flags & ACL_ENTRY_LIMIT_INHERIT) || + (entry->ae_flags & ACL_ENTRY_DIRECTORY_INHERIT) == 0 || + !is_directory) && + entry->ae_extended == ACL_EXTENDED_ALLOW) + entry->ae_perm &= ~(ACL_WRITE_ACL | ACL_WRITE_OWNER); + + /* * 2.A. If the ACL_ENTRY_LIMIT_INHERIT is set, or if the object * being created is not a directory, then clear the * following flags: ACL_ENTRY_LIMIT_INHERIT, @@ -859,14 +885,6 @@ ACL_ENTRY_ONLY_INHERIT); /* - * This is not in the specification, but SunOS - * apparently does that. - */ - if (entry->ae_extended == ACL_EXTENDED_ALLOW) - entry->ae_perm &= ~(ACL_WRITE_ACL | - ACL_WRITE_OWNER); - - /* * Continue on to the next ACE. */ continue;