MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _createTemporaryDirectory

Function _createTemporaryDirectory

lib/core/option.py:1614–1668  ·  view source on GitHub ↗

Creates temporary directory for this run.

()

Source from the content-addressed store, hash-verified

1612 raise NotImplementedError
1613
1614def _createTemporaryDirectory():
1615 """
1616 Creates temporary directory for this run.
1617 """
1618
1619 if conf.tmpDir:
1620 try:
1621 if not os.path.isdir(conf.tmpDir):
1622 os.makedirs(conf.tmpDir)
1623
1624 _ = os.path.join(conf.tmpDir, randomStr())
1625
1626 open(_, "w+b").close()
1627 os.remove(_)
1628
1629 tempfile.tempdir = conf.tmpDir
1630
1631 warnMsg = "using '%s' as the temporary directory" % conf.tmpDir
1632 logger.warning(warnMsg)
1633 except (OSError, IOError) as ex:
1634 errMsg = "there has been a problem while accessing "
1635 errMsg += "temporary directory location(s) ('%s')" % getSafeExString(ex)
1636 raise SqlmapSystemException(errMsg)
1637 else:
1638 try:
1639 if not os.path.isdir(tempfile.gettempdir()):
1640 os.makedirs(tempfile.gettempdir())
1641 except Exception as ex:
1642 warnMsg = "there has been a problem while accessing "
1643 warnMsg += "system's temporary directory location(s) ('%s'). Please " % getSafeExString(ex)
1644 warnMsg += "make sure that there is enough disk space left. If problem persists, "
1645 warnMsg += "try to set environment variable 'TEMP' to a location "
1646 warnMsg += "writeable by the current user"
1647 logger.warning(warnMsg)
1648
1649 if "sqlmap" not in (tempfile.tempdir or "") or conf.tmpDir and tempfile.tempdir == conf.tmpDir:
1650 try:
1651 tempfile.tempdir = tempfile.mkdtemp(prefix="sqlmap", suffix=str(os.getpid()))
1652 except:
1653 tempfile.tempdir = os.path.join(paths.SQLMAP_HOME_PATH, "tmp", "sqlmap%s%d" % (randomStr(6), os.getpid()))
1654
1655 kb.tempDir = tempfile.tempdir
1656
1657 if not os.path.isdir(tempfile.tempdir):
1658 try:
1659 os.makedirs(tempfile.tempdir)
1660 except Exception as ex:
1661 errMsg = "there has been a problem while setting "
1662 errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
1663 raise SqlmapSystemException(errMsg)
1664
1665 conf.tempDirs.append(tempfile.tempdir)
1666
1667 if six.PY3:
1668 _pympTempLeakPatch(kb.tempDir)
1669
1670def _cleanupOptions():
1671 """

Callers 1

initFunction · 0.85

Calls 7

randomStrFunction · 0.90
getSafeExStringFunction · 0.90
_pympTempLeakPatchFunction · 0.85
removeMethod · 0.80
closeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…