Bladeren bron

HPCC-18706 Sometimes file access calls to Dali don't provide creds

In several places Roxie is not sending credentials in calls to Dali. This
PR fixes all known instances of this omission

Signed-off-by: Russ Whitehead <william.whitehead@lexisnexis.com>
Russ Whitehead 7 jaren geleden
bovenliggende
commit
6b14361bd1
6 gewijzigde bestanden met toevoegingen van 58 en 9 verwijderingen
  1. 19 3
      roxie/ccd/ccdcontext.cpp
  2. 5 0
      roxie/ccd/ccddali.cpp
  3. 1 0
      roxie/ccd/ccddali.hpp
  4. 11 1
      roxie/ccd/ccdfile.cpp
  5. 14 4
      roxie/ccd/ccdserver.cpp
  6. 8 1
      roxie/ccd/ccdstate.cpp

+ 19 - 3
roxie/ccd/ccdcontext.cpp

@@ -429,7 +429,7 @@ private:
 
     inline bool fileExists(const char *lfn)
     {
-        Owned<IDistributedFile> f = queryDistributedFileDirectory().lookup(lfn, NULL);  // MORE - need a userdescriptor from workunit
+        Owned<IDistributedFile> f = queryDistributedFileDirectory().lookup(lfn, queryUserDescriptor());
         if (f)
             return true;
         return false;
@@ -437,7 +437,15 @@ private:
 
     inline IUserDescriptor *queryUserDescriptor()
     {
-        return workunit->queryUserDescriptor();
+        if (workunit)
+            return workunit->queryUserDescriptor();//ad-hoc mode
+        else
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     bool checkPersistUptoDate(IRuntimeWorkflowItem & item, const char * logicalName, unsigned eclCRC, unsigned __int64 allCRC, bool isFile, StringBuffer &errText)
@@ -3666,7 +3674,15 @@ public:
     }
     IUserDescriptor *queryUserDescriptor()
     {
-        return NULL; // TBD - Richard, where do user credentials for a roxie query come from
+        if (workUnit)
+            return workUnit->queryUserDescriptor();//ad-hoc mode
+        else
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     virtual bool isResult(const char * name, unsigned sequence)

+ 5 - 0
roxie/ccd/ccddali.cpp

@@ -431,6 +431,11 @@ public:
             initMyNode(1); // Hack
     }
 
+    virtual IUserDescriptor *queryUserDescriptor()
+    {
+        return userdesc;
+    }
+
     static const char *getQuerySetPath(StringBuffer &buf, const char *id)
     {
         buf.appendf("QuerySets/QuerySet[@id='%s']", id);

+ 1 - 0
roxie/ccd/ccddali.hpp

@@ -56,6 +56,7 @@ interface IRoxieDaliHelper : extends IInterface
     virtual void noteQueuesRunning(const char *queueNames) = 0;
     virtual void noteWorkunitRunning(const char *wu, bool running) = 0;
     virtual StringBuffer &getDaliIp(StringBuffer &ip) const = 0;
+    virtual IUserDescriptor *queryUserDescriptor() = 0;
 };
 
 

+ 11 - 1
roxie/ccd/ccdfile.cpp

@@ -2646,7 +2646,17 @@ private:
 
             Owned<IDistributedFile> publishFile = queryDistributedFileDirectory().createNew(desc); // MORE - we'll create this earlier if we change the locking paradigm
             publishFile->setAccessedTime(modifiedTime);
-            publishFile->attach(dFile->queryLogicalName(), activity ? activity->queryUserDescriptor() : UNKNOWN_USER);
+            IUserDescriptor * userdesc = NULL;
+            if (activity)
+                userdesc = activity->queryUserDescriptor();
+            else
+            {
+                Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+                if (daliHelper)
+                    userdesc = daliHelper->queryUserDescriptor();//predeployed query mode
+            }
+
+            publishFile->attach(dFile->queryLogicalName(), userdesc);
             // MORE should probably write to the roxielocalstate too in case Dali is down next time I look...
         }
     }

+ 14 - 4
roxie/ccd/ccdserver.cpp

@@ -11625,9 +11625,14 @@ public:
     {
         IConstWorkUnit *workUnit = ctx->queryWorkUnit();
         if (workUnit)
-            return workUnit->queryUserDescriptor();
+            return workUnit->queryUserDescriptor();//ad-hoc mode
         else
-            return NULL;
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 
     virtual bool isOutputTransformed() const { return false; }
@@ -12168,9 +12173,14 @@ public:
     {
         IConstWorkUnit *workUnit = ctx->queryWorkUnit();
         if (workUnit)
-            return workUnit->queryUserDescriptor();
+            return workUnit->queryUserDescriptor();//ad-hoc mode
         else
-            return NULL;
+        {
+            Owned<IRoxieDaliHelper> daliHelper = connectToDali(false);
+            if (daliHelper)
+                return daliHelper->queryUserDescriptor();//predeployed query mode
+        }
+        return NULL;
     }
 };
 

+ 8 - 1
roxie/ccd/ccdstate.cpp

@@ -724,7 +724,14 @@ public:
         Owned<IRoxieDaliHelper> daliHelper = connectToDali();
         bool onlyLocal = fileNameServiceDali.isEmpty();
         bool onlyDFS = !resolveLocally() && !onlyLocal;
-        Owned<ILocalOrDistributedFile> ldFile = createLocalOrDistributedFile(fileName, NULL, onlyLocal, onlyDFS, true);
+
+        IUserDescriptor *user = NULL;
+        if (wu)
+            user = wu->queryUserDescriptor();//ad-hoc mode
+        else if (daliHelper)
+            user = daliHelper->queryUserDescriptor();//predeployed query mode
+
+        Owned<ILocalOrDistributedFile> ldFile = createLocalOrDistributedFile(fileName, user, onlyLocal, onlyDFS, true);
         if (!ldFile)
             throw MakeStringException(ROXIE_FILE_ERROR, "Cannot write %s", fileName.str());
         return createRoxieWriteHandler(daliHelper, ldFile.getClear(), clusters);