[SSL] fix validate_writeable_directory

We have to exmand user if ~ was used in path and we have to use
normpath in order not to traverse nonexisting directory and remove
trailing /.

Change-Id: Ic44917b6a1e01c9565cef1df60ed57d3da39cf33
This commit is contained in:
Lukas Bezdicka
2015-05-28 11:29:30 +02:00
parent 185b932c42
commit fb99b80db5
6 changed files with 15 additions and 6 deletions

View File

@@ -207,8 +207,10 @@ def validate_writeable_directory(param, options=None):
return
options = options or []
if not ((os.path.isdir(param) and os.access(param, os.W_OK)) or
os.access(os.path.join(param, os.pardir), os.W_OK)):
path = os.path.expanduser(param)
if not ((os.path.isdir(path) and os.access(path, os.W_OK)) or
os.access(
os.path.normpath(os.path.join(path, os.pardir)), os.W_OK)):
logging.debug('validate_writeable_directory(%s, options=%s) failed.' %
(param, options))
msg = 'Given directory does not exist or is not writeable: %s'