Codebase list osrframework / 2a83a63 debian / patches / create-real-temporary-dir.patch
2a83a63

Tree @2a83a63 (Download .tar.gz)

create-real-temporary-dir.patch @2a83a63raw · history · blame

Description: create real temporary directory
 Don't create a ./tmp/* directory in the dir from where you run the
 command. Create a real temporay directory using tempfile in Python.
Author: Sophie Brun <[email protected]>
Last-Update: 2017-09-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/osrframework/transforms/lib/configure_maltego.py
+++ b/osrframework/transforms/lib/configure_maltego.py
@@ -24,6 +24,7 @@ import os
 import zipfile
 import argparse
 import shutil, errno
+import tempfile
 
 import osrframework
 import osrframework.utils.configuration as configuration
@@ -104,10 +105,12 @@ def zip(pathFolder=None):
     zf.close()
 
     # After everything, deleting the previously created folder
-    try:
-        shutil.rmtree(pathFolder)
-    except:
-        pass
+    # folder is created in configureMaltego function / it's removed in
+    # configureMaltego function too 
+    #try:
+    #    shutil.rmtree(pathFolder)
+    #except:
+    #    pass
 
     return filePath
 
@@ -118,7 +121,7 @@ def configureMaltego(transformsConfigFol
     settingsFile = "osrframework-maltego-settings"  + "_" + VERSION
 
     # Defining the full path to the folder in which the configuration files will be created
-    dst=os.path.join("./", "tmp", settingsFile)
+    dst=os.path.join(tempfile.mkdtemp(), settingsFile)
 
     # copying anything in the config folder
     copyAnything(src=base, dst=dst)
@@ -145,8 +148,8 @@ def configureMaltego(transformsConfigFol
         print "Moving the .mtz file to the backup folder:    " + os.path.join(backupPath, fileName)
         shutil.copy2(filePath, backupPath)
 
-    # Remove tmp files.
-    shutil.rmtree(os.path.join("./", "tmp"))
+    # Remove tmp files and directories
+    shutil.rmtree(dst)
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description='configure_maltego.py - A function to automatically generate Maltego configuration files.', prog='configure_maltego.py', epilog="", add_help=False)