Added new function to search a file within the PATH environment variable paths:

it will be used when sqlmap will be packaged as DEB and RPM
This commit is contained in:
Bernardo Damele 2009-05-12 20:24:47 +00:00
parent b463205544
commit 45dff4a00a

View File

@ -43,6 +43,7 @@ from lib.core.data import paths
from lib.core.data import queries from lib.core.data import queries
from lib.core.data import temp from lib.core.data import temp
from lib.core.exception import sqlmapFilePathException from lib.core.exception import sqlmapFilePathException
from lib.core.settings import PLATFORM
from lib.core.settings import SQL_STATEMENTS from lib.core.settings import SQL_STATEMENTS
from lib.core.settings import VERSION_STRING from lib.core.settings import VERSION_STRING
@ -825,3 +826,22 @@ def getCharset(charsetType=None):
asciiTbl.extend(range(96, 123)) asciiTbl.extend(range(96, 123))
return asciiTbl return asciiTbl
def searchEnvPath(fileName):
envPaths = os.environ["PATH"]
result = None
if "darwin" not in PLATFORM and "win" in PLATFORM:
envPaths = envPaths.split(";")
else:
envPaths = envPaths.split(":")
for envPath in envPaths:
envPath = envPath.replace(";", "")
result = os.path.exists(os.path.normpath("%s/%s" % (envPath, fileName)))
if result == True:
break
return result