diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2015-07-07 11:53:45 +0200 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2015-07-07 13:14:07 +0200 |
commit | b5728db95f23643dc19eea652b323c6c98b7c5a7 (patch) | |
tree | 6277e867093409e9815ad9c1b0bac64144e7117b | |
parent | 840de73d294e7dccbf2ddb61816479e1b8ccf44a (diff) |
Add check for ownership in ~/.cache/pip
There are problems when Rally installs Tempest and the owner of
that directory is root instead of the current user
More info: https://bugs.launchpad.net/rally/+bug/1461493
JIRA: FUNCTEST-14
Change-Id: I90d0edf206ff4dcc10d95cc8a4e806021017b429
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rw-r--r-- | testcases/config_functest.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py index cab2a945..3c608344 100644 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -8,9 +8,11 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import re, json, os, urllib2, argparse, logging, shutil, subprocess, yaml, sys +import re, json, os, urllib2, argparse, logging, shutil, subprocess, yaml, sys, getpass import functest_utils from git import Repo +from os import stat +from pwd import getpwuid actions = ['start', 'check', 'clean'] parser = argparse.ArgumentParser() @@ -71,6 +73,10 @@ def action_start(): """ Start the functest environment installation """ + if not check_permissions(): + logger.error("Bad Python cache directory ownership.") + exit(-1) + if not functest_utils.check_internet_connectivity(): logger.error("There is no Internet connectivity. Please check the network configuration.") exit(-1) @@ -219,6 +225,18 @@ def action_clean(): +def check_permissions(): + current_user = getpass.getuser() + cache_dir = HOME+".cache/pip" + logger.info("Checking permissions of '%s'..." %cache_dir) + logger.debug("Current user is '%s'" %current_user) + cache_user = getpwuid(stat(cache_dir).st_uid).pw_name + logger.debug("Cache directory owner is '%s'" %cache_user) + if cache_user != current_user: + logger.info("The owner of '%s' is '%s'. Please run 'sudo chown -R %s %s'." %(cache_dir, cache_user, current_user, cache_dir)) + return False + + return True def install_rally(): |