Browse Source

HPCC-19414 Prevent protected status being copied into super.

When the 1st subfile was added or removed, the common attributes
from it were cloned. This also unintentionally cloned "Protect",
which prevented any sub files from being removed from the
superfile.
Ensure 'Protect' is not cloned.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 7 years ago
parent
commit
2f304e60e1
1 changed files with 16 additions and 6 deletions
  1. 16 6
      dali/base/dadfs.cpp

+ 16 - 6
dali/base/dadfs.cpp

@@ -5139,7 +5139,8 @@ protected:
         // first renumber all above
         StringBuffer path;
         IPropertyTree *sub;
-        for (unsigned i=subfiles.ordinality();i>pos;i--) {
+        for (unsigned i=subfiles.ordinality();i>pos;i--)
+        {
             sub = root->queryPropTree(getSubPath(path.clear(),i-1).str());
             if (!sub)
                 throw MakeStringException(-1,"C(2): Corrupt subfile file part %d cannot be found",i);
@@ -5148,8 +5149,11 @@ protected:
         sub = createPTree();
         sub->setPropInt("@num",pos+1);
         sub->setProp("@name",file->queryLogicalName());
-        if (pos==0) {
-            resetFileAttr(createPTreeFromIPT(&file->queryAttributes()));
+        if (pos==0)
+        {
+            Owned<IPropertyTree> superAttrs = createPTreeFromIPT(&file->queryAttributes());
+            superAttrs->removeProp("Protect"); // do not automatically inherit protected status
+            resetFileAttr(superAttrs.getClear());
         }
         root->addPropTree("SubFile",sub);
         subfiles.add(*file.getClear(),pos);
@@ -5165,16 +5169,22 @@ protected:
             throw MakeStringException(-1,"CDistributedSuperFile(3): Corrupt subfile file part %d cannot be found",pos+1);
         root->removeTree(sub);
         // now renumber all above
-        for (unsigned i=pos+1; i<subfiles.ordinality(); i++) {
+        for (unsigned i=pos+1; i<subfiles.ordinality(); i++)
+        {
             sub = root->queryPropTree(getSubPath(path.clear(),i).str());
             if (!sub)
                 throw MakeStringException(-1,"CDistributedSuperFile(2): Corrupt subfile file part %d cannot be found",i+1);
             sub->setPropInt("@num",i);
         }
         subfiles.remove(pos);
-        if (pos==0) {
+        if (pos==0)
+        {
             if (subfiles.ordinality())
-                resetFileAttr(createPTreeFromIPT(&subfiles.item(0).queryAttributes()));
+            {
+                Owned<IPropertyTree> superAttrs = createPTreeFromIPT(&subfiles.item(0).queryAttributes());
+                superAttrs->removeProp("Protect"); // do not automatically inherit protected status
+                resetFileAttr(superAttrs.getClear());
+            }
             else
                 resetFileAttr(getEmptyAttr());
         }