[autotest] Handle invalid restricted group name.
On the servers where the restricted groups is set
to something like "USE SHADOW CONFIG", is_restricted_user
will fail with a key error because "USE SHADOW CONFIG"
is not a valid group.
This CL handle the error properly.
TEST=None
BUG=None
Change-Id: I61a310c976488c47a51ff99855a0aea6bffc7b92
Reviewed-on: https://chromium-review.googlesource.com/327062
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Paul Hobbs <phobbs@google.com>
Commit-Queue: Fang Deng <fdeng@chromium.org>
diff --git a/server/site_utils.py b/server/site_utils.py
index 623c92e..f0d0838 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -500,8 +500,11 @@
restricted_groups = global_config.global_config.get_config_value(
'AUTOTEST_WEB', 'restricted_groups', default='').split(',')
for group in restricted_groups:
- if group and username in grp.getgrnam(group).gr_mem:
- return True
+ try:
+ if group and username in grp.getgrnam(group).gr_mem:
+ return True
+ except KeyError as e:
+ logging.debug("%s is not a valid group.", group)
return False