saltstack/salt — pull request #2784 by thekuffs (2012-12-03 20:05:30+00:00)
Title: Fix path access check windows

I ran into the following error when setting up a new minion in Windows:

```
Traceback (most recent call last):
File "", line 6, in
File "__main__.py", line 726, in
File "__main__.py", line 332, in bootstrap
File "__main__.py", line 359, in chainload
File "__main__.py", line 715, in _chainload
File "__main__.py", line 128, in
File "__main__firehost-mgmt__.py", line 17, in
File "salt/scripts.py", line 28, in salt_minion
File "salt/__init__.py", line 116, in start
File "salt/minion.py", line 178, in __init__
File "salt/minion.py", line 533, in authenticate
File "salt/crypt.py", line 256, in sign_in
File "salt/crypt.py", line 172, in minion_sign_in_payload
File "salt/crypt.py", line 149, in get_keys
File "salt/utils/verify.py", line 269, in check_parent_dirs
salt.exceptions.SaltClientError: Could not access directory \etc\salt\pki\minion. Try running as user root.
```

The message is troubling given that 'root' doesn't mean anything on Windows. But it's also not clear where the path is actually rooted.

This patch adds some platform agnosticism to the approach, producing a slightly less confusing error below:

```
Traceback (most recent call last):
File "", line 6, in
File "__main__.py", line 726, in
File "__main__.py", line 332, in bootstrap
File "__main__.py", line 359, in chainload
File "__main__.py", line 715, in _chainload
File "__main__.py", line 128, in
File "__main__firehost-mgmt__.py", line 17, in
File "salt/scripts.py", line 28, in salt_minion
File "salt/__init__.py", line 116, in start
File "salt/minion.py", line 178, in __init__
File "salt/minion.py", line 533, in authenticate
File "salt/crypt.py", line 256, in sign_in
File "salt/crypt.py", line 172, in minion_sign_in_payload
File "salt/crypt.py", line 149, in get_keys
File "salt/utils/verify.py", line 288, in check_path_traversal
salt.exceptions.SaltClientError: Could not access c:\etc\salt\pki\minion. Try running as user root.
```

This means it now supports running on an alternate drive as well.

This patch comes with a function for generating a list of directories leading up to a path. And revises the calling code so that the context is a little more clear.