@@ -622,17 +622,40 @@ def getDocRoot():
622622 warnMsg = "unable to retrieve the web server document root"
623623 logger .warn (warnMsg )
624624
625- message = "please provide the web server document root "
626- message += "[%s]: " % "," .join (root for root in defaultDocRoot )
627- inputDocRoot = readInput (message , default = defaultDocRoot )
625+ docRoot = []
628626
629- if inputDocRoot :
630- if isinstance (inputDocRoot , basestring ):
631- docRoot = inputDocRoot .split (',' )
627+ message = "do you want to provide a text file with a list of "
628+ message += "directories to try? [y/N] "
629+ answer = readInput (message , default = "N" )
630+
631+ if answer and answer .lower () == "y" :
632+ message = "please provide the directories list file to try: "
633+ dirFilePath = readInput (message )
634+
635+ if dirFilePath :
636+ if os .path .isfile (dirFilePath ):
637+ fd = codecs .open (dirFilePath , "rb" , UNICODE_ENCODING )
638+
639+ for filepath in fd .readlines ():
640+ docRoot .append (normalizePath (filepath ))
641+
642+ else :
643+ errMsg = "provided directory list file %s " % dirFilePath
644+ errMsg += "is not a valid file"
645+ logger .error (errMsg )
646+
647+ if len (docRoot ) == 0 :
648+ message = "please provide the web server document root "
649+ message += "[%s]: " % ", " .join (root for root in defaultDocRoot )
650+ inputDocRoot = readInput (message , default = defaultDocRoot )
651+
652+ if inputDocRoot :
653+ if isinstance (inputDocRoot , basestring ):
654+ docRoot = inputDocRoot .split (',' )
655+ else :
656+ docRoot = inputDocRoot
632657 else :
633- docRoot = inputDocRoot
634- else :
635- docRoot = defaultDocRoot
658+ docRoot = defaultDocRoot
636659
637660 return docRoot
638661
@@ -657,8 +680,9 @@ def getDirs():
657680 if webDir :
658681 directories .add (webDir )
659682
660- message = "please provide any additional web server full path to try "
661- message += "to upload the agent [Enter for None]: "
683+ message = "please provide additional comma separated file paths to "
684+ message += "try to upload the agent inside the possible document "
685+ message += "root%s [Enter for None]: " % "s" if len (kb .docRoot ) > 1 else ""
662686 inputDirs = readInput (message )
663687
664688 if inputDirs :
@@ -1325,8 +1349,9 @@ def normalizePath(filepath):
13251349
13261350 retVal = filepath
13271351
1328- if filepath :
1329- retVal = ntpath .normpath (filepath ) if isWindowsDriveLetterPath (filepath ) else posixpath .normpath (filepath )
1352+ if retVal :
1353+ retVal = retVal .strip ("\r " ).strip ("\n " )
1354+ retVal = ntpath .normpath (retVal ) if isWindowsDriveLetterPath (retVal ) else posixpath .normpath (retVal )
13301355
13311356 return retVal
13321357
0 commit comments