summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--google_compute_engine/accounts/accounts_utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/google_compute_engine/accounts/accounts_utils.py b/google_compute_engine/accounts/accounts_utils.py
index 1b18eb1..4096086 100644
--- a/google_compute_engine/accounts/accounts_utils.py
+++ b/google_compute_engine/accounts/accounts_utils.py
@@ -278,10 +278,12 @@ class AccountsUtils(object):
if not bool(USER_REGEX.match(user)):
self.logger.warning('Invalid user account name %s.', user)
return False
- if not self._GetUser(user) and not self._AddUser(user):
- return False
- if not self._UpdateUserGroups(user, self.groups):
- return False
+ if not self._GetUser(user):
+ # User does not exist. Attempt to create the user and add them to the
+ # appropriate user groups.
+ if not (self._AddUser(user) and
+ self._UpdateUserGroups(user, self.groups)):
+ return False
# Don't try to manage account SSH keys with a shell set to disable
# logins. This helps avoid problems caused by operator and root sharing