Fix lusermod using a group name and not id (#61965) (#77914)

* Fix lusermod using a group name and not id (#61965)
pull/77942/head
Julien Lecomte 3 years ago committed by GitHub
parent 9f7956ba30
commit 33beeace10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- prevent lusermod from using group name instead of group id (https://github.com/ansible/ansible/pull/77914)

@ -821,7 +821,7 @@ class User(object):
ginfo = self.group_info(self.group) ginfo = self.group_info(self.group)
if info[3] != ginfo[2]: if info[3] != ginfo[2]:
cmd.append('-g') cmd.append('-g')
cmd.append(self.group) cmd.append(ginfo[2])
if self.groups is not None: if self.groups is not None:
# get a list of all groups for the user, including the primary # get a list of all groups for the user, including the primary

@ -85,6 +85,7 @@
- testgroup2 - testgroup2
- testgroup3 - testgroup3
- testgroup4 - testgroup4
- testgroup5
tags: tags:
- user_test_local_mode - user_test_local_mode
@ -121,6 +122,28 @@
tags: tags:
- user_test_local_mode - user_test_local_mode
- name: Assign named group for local_ansibulluser
user:
name: local_ansibulluser
state: present
local: yes
group: testgroup5
register: local_user_test_6
tags:
- user_test_local_mode
# If we don't re-assign, then "Set user expiration" will
# fail.
- name: Re-assign named group for local_ansibulluser
user:
name: local_ansibulluser
state: present
local: yes
group: local_ansibulluser
ignore_errors: yes
tags:
- user_test_local_mode
- name: Remove local_ansibulluser again - name: Remove local_ansibulluser again
user: user:
name: local_ansibulluser name: local_ansibulluser
@ -139,6 +162,7 @@
- testgroup2 - testgroup2
- testgroup3 - testgroup3
- testgroup4 - testgroup4
- testgroup5
tags: tags:
- user_test_local_mode - user_test_local_mode
@ -149,6 +173,7 @@
- local_user_test_2 is not changed - local_user_test_2 is not changed
- local_user_test_3 is changed - local_user_test_3 is changed
- local_user_test_4 is changed - local_user_test_4 is changed
- local_user_test_6 is changed
- local_user_test_remove_1 is changed - local_user_test_remove_1 is changed
- local_user_test_remove_2 is not changed - local_user_test_remove_2 is not changed
tags: tags:

Loading…
Cancel
Save