Skip to content

Commit

Permalink
Check access rights for OUTPUT_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrasandulescu committed Jul 17, 2015
1 parent b3b3875 commit 2346b14
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions framework/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,11 @@ def FrameworkConfigGetLogsDir(self):
config file
"""
logs_dir = self.FrameworkConfigGet("LOGS_DIR")
if (os.path.isabs(logs_dir)):
if (os.path.isabs(logs_dir) and os.access(logs_dir, os.W_OK)):
return logs_dir
else:
return os.path.join(
self.FrameworkConfigGet("OUTPUT_PATH"),
self.GetOutputDir(),
logs_dir
)

Expand Down Expand Up @@ -582,7 +582,15 @@ def Show(self):
cprint(str(k) + " => " + str(v))

def GetOutputDir(self):
return os.path.expanduser(self.FrameworkConfigGet("OUTPUT_PATH"))
output_dir = os.path.expanduser(self.FrameworkConfigGet("OUTPUT_PATH"))
if (not os.path.isabs(output_dir)):
if (os.access(os.getcwd(), os.W_OK)):
return output_dir
else:
#the output_dir may not be created yet, so check its parent
if (os.access(os.path.dirname(output_dir), os.W_OK)):
return output_dir
return os.path.expanduser(os.path.join("~/.owtf", output_dir))

def GetOutputDirForTargets(self):
return os.path.join(
Expand Down

0 comments on commit 2346b14

Please sign in to comment.