cli: Only block root user on moblab
CL:316448 blocked the root user from running the 'atest' cli suite. This
was required only for moblab, but was implemented uniformly. CL:*635332
started depending on the atest suite of tools in the staging lab,
running them as root.
Restrict the user check to moblab only.
BUG=chromium:850118
TEST=Run atest suite locally as root / non root user.
Change-Id: Ic81de55b049255a0ca8c65796e742953695a8c71
Reviewed-on: https://chromium-review.googlesource.com/1089113
Reviewed-by: Allen Li <ayatane@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/cli/atest.py b/cli/atest.py
index 8dea71b..4a88424 100644
--- a/cli/atest.py
+++ b/cli/atest.py
@@ -20,6 +20,7 @@
import common
from autotest_lib.cli import topic_common
+from autotest_lib.client.common_lib import lsbrelease_utils
from autotest_lib.server import utils
@@ -30,7 +31,7 @@
atest-<topic> <action> <options>
atest --help
"""
- utils.verify_not_root_user()
+ _disallow_root_user_on_moblab()
cli = os.path.basename(sys.argv[0])
syntax_obj = topic_common.atest()
@@ -99,3 +100,9 @@
traceback.print_exc()
finally:
return action_obj.show_all_failures()
+
+
+def _disallow_root_user_on_moblab():
+ """Running these tools as root interferes with moblab services"""
+ if lsbrelease_utils.is_moblab():
+ utils.verify_not_root_user()