From f2b72e62c0f8c83857bd8fd7396395295a08cb9b Mon Sep 17 00:00:00 2001 From: nitzmahone Date: Tue, 8 Dec 2015 16:16:23 -0500 Subject: [PATCH] fixed disappearing groups on OSX user module Ensure that we don't try to modify the groups collection if groups are not specified --- system/user.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/system/user.py b/system/user.py index e43173dac4f..397abfbc253 100755 --- a/system/user.py +++ b/system/user.py @@ -1674,9 +1674,10 @@ class DarwinUser(User): self._update_system_user() # here we don't care about change status since it is a creation, # thus changed is always true. - (rc, _out, _err, changed) = self._modify_group() - out += _out - err += _err + if self.groups: + (rc, _out, _err, changed) = self._modify_group() + out += _out + err += _err return (rc, err, out) def modify_user(self): @@ -1708,12 +1709,13 @@ class DarwinUser(User): err += _err changed = rc - (rc, _out, _err, _changed) = self._modify_group() - out += _out - err += _err + if self.groups: + (rc, _out, _err, _changed) = self._modify_group() + out += _out + err += _err - if _changed is True: - changed = rc + if _changed is True: + changed = rc rc = self._update_system_user() if rc == 0: