浏览代码

HPCC-23190 File.ProtectLogicalFilename should not prepend "user:"

Fix inconsistency between esp and fileservices when protecting
a file.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 5 年之前
父节点
当前提交
7b656b32af
共有 1 个文件被更改,包括 14 次插入7 次删除
  1. 14 7
      plugins/fileservices/fileservices.cpp

+ 14 - 7
plugins/fileservices/fileservices.cpp

@@ -2603,17 +2603,24 @@ FILESERVICES_API char * FILESERVICES_CALL fsfGetLogicalFileAttribute(ICodeContex
     return ret.detach();
 }
 
-FILESERVICES_API void FILESERVICES_CALL fsProtectLogicalFile(ICodeContext * ctx,const char *_lfn,bool set)
+FILESERVICES_API void FILESERVICES_CALL fsProtectLogicalFile(ICodeContext * ctx, const char *_lfn, bool set)
 {
     StringBuffer lfn;
     constructLogicalName(ctx, _lfn, lfn);
     Linked<IUserDescriptor> udesc = ctx->queryUserDescriptor();
-    Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(lfn.str(),udesc, false, false, false, nullptr, defaultPrivilegedUser);
-    StringBuffer ret;
-    if (df) {
-        StringBuffer u("user:");
-        udesc->getUserName(u);
-        df->setProtect(u.str(),set);
+    Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(lfn.str(), udesc, false, false, false, nullptr, defaultPrivilegedUser);
+    if (df)
+    {
+        StringBuffer uname;
+        udesc->getUserName(uname);
+        df->setProtect(uname, set);
+        if (!set)
+        {
+            // for backward compatibility only (see HPCC-23190)
+            uname.clear().append("user:");
+            udesc->getUserName(uname);
+            df->setProtect(uname, false);
+        }
     }
     else if (set)
         throw MakeStringException(0, "ProtectLogicalFile: Could not find logical file %s", lfn.str());