Salome HOME
change input and results files permissions to user only
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Apr 2023 12:43:52 +0000 (14:43 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Apr 2023 12:43:52 +0000 (14:43 +0200)
src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx

index 2a2995680d49c5a118c82f3518341f301353f711..6e0012c8dbe38b43e797aec8be792eb8f9617e9e 100644 (file)
 #include <algorithm>
 #include <errno.h>
 
+#include <boost/filesystem.hpp>
+
+namespace boofs = boost::filesystem;
+
 #ifdef _DEBUG_
 //#define _MY_DEBUG_
 #endif
@@ -112,6 +116,12 @@ static std::string flagsToErrorStr( int anInvalidEnforcedFlags )
   return str;
 }
 
+// change results files permissions to user only (using boost to be used without C++17)
+static void chmodUserOnly(const char* filename)
+{
+  boofs::permissions(filename, boofs::remove_perms | boofs::group_all | boofs::others_all );
+}
+
 typedef const list<const SMDS_MeshFace*> TTriaList;
 
 static const char theDomainGroupNamePrefix[] = "Domain_";
@@ -1571,11 +1581,19 @@ static bool writeGMFFile(MG_Tetra_API*                                   MGInput
       MGInput->GmfSetLin( idx, GmfRequiredTriangles, int( anElemSet.size()+enfID ));
   }
 
+  // close input files and change results files permissions to user only
   MGInput->GmfCloseMesh(idx);
+  chmodUserOnly(theMeshFileName);
   if (idxRequired)
-    MGInput->GmfCloseMesh(idxRequired);
+    {
+      MGInput->GmfCloseMesh(idxRequired);
+      chmodUserOnly(theRequiredFileName);
+    }
   if (idxSol)
-    MGInput->GmfCloseMesh(idxSol);
+    {
+      MGInput->GmfCloseMesh(idxSol);
+      chmodUserOnly(theRequiredFileName);
+    }
 
   return true;
 }
@@ -1736,6 +1754,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     }
   }
   aIdsFile.close();
+  chmodUserOnly(aSmdsToGhs3dIdMapFileName.ToCString());
   if ( ! Ok ) {
     if ( !_keepFiles ) {
       removeFile( aGMFFileName );
@@ -1786,6 +1805,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     BRIEF_INFOS("")
   }
 
+  // change results files permissions to user only
+  chmodUserOnly(aLogFileName.ToCString());
+  if (Ok)
+    {
+      chmodUserOnly(aResultFileName.ToCString());
+      chmodUserOnly(aResSolFileName.ToCString());
+    }
+
   // --------------
   // read a result
   // --------------