Exemplo n.º 1
0
        /// <exception cref="System.IO.IOException"/>
        internal static HdfsFileStatus RemoveDefaultAcl(FSDirectory fsd, string srcArg)
        {
            string src = srcArg;

            CheckAclsConfigFlag(fsd);
            FSPermissionChecker pc = fsd.GetPermissionChecker();

            byte[][] pathComponents = FSDirectory.GetPathComponentsForReservedPath(src);
            src = fsd.ResolvePath(pc, src, pathComponents);
            INodesInPath iip;

            fsd.WriteLock();
            try
            {
                iip = fsd.GetINodesInPath4Write(FSDirectory.NormalizePath(src), true);
                fsd.CheckOwner(pc, iip);
                INode            inode       = FSDirectory.ResolveLastINode(iip);
                int              snapshotId  = iip.GetLatestSnapshotId();
                IList <AclEntry> existingAcl = AclStorage.ReadINodeLogicalAcl(inode);
                IList <AclEntry> newAcl      = AclTransformation.FilterDefaultAclEntries(existingAcl);
                AclStorage.UpdateINodeAcl(inode, newAcl, snapshotId);
                fsd.GetEditLog().LogSetAcl(src, newAcl);
            }
            finally
            {
                fsd.WriteUnlock();
            }
            return(fsd.GetAuditFileInfo(iip));
        }
Exemplo n.º 2
0
        /// <exception cref="System.IO.IOException"/>
        internal static IList <AclEntry> UnprotectedSetAcl(FSDirectory fsd, string src, IList
                                                           <AclEntry> aclSpec, bool fromEdits)
        {
            System.Diagnostics.Debug.Assert(fsd.HasWriteLock());
            INodesInPath iip = fsd.GetINodesInPath4Write(FSDirectory.NormalizePath(src), true
                                                         );

            // ACL removal is logged to edits as OP_SET_ACL with an empty list.
            if (aclSpec.IsEmpty())
            {
                UnprotectedRemoveAcl(fsd, iip);
                return(AclFeature.EmptyEntryList);
            }
            INode            inode      = FSDirectory.ResolveLastINode(iip);
            int              snapshotId = iip.GetLatestSnapshotId();
            IList <AclEntry> newAcl     = aclSpec;

            if (!fromEdits)
            {
                IList <AclEntry> existingAcl = AclStorage.ReadINodeLogicalAcl(inode);
                newAcl = AclTransformation.ReplaceAclEntries(existingAcl, aclSpec);
            }
            AclStorage.UpdateINodeAcl(inode, newAcl, snapshotId);
            return(newAcl);
        }