Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e3849f1b
Commit
e3849f1b
authored
Oct 11, 2013
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4312 for older versions of usermod which do not have --append
parent
119b6d73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
library/system/user
+28
-3
No files found.
library/system/user
View file @
e3849f1b
...
...
@@ -313,9 +313,28 @@ class User(object):
return
self
.
execute_command
(
cmd
)
def
_check_usermod_append
(
self
):
# check if this version of usermod can append groups
cmd
=
[
self
.
module
.
get_bin_path
(
'usermod'
,
True
)]
cmd
.
append
(
'--help'
)
rc
,
data1
,
data2
=
self
.
execute_command
(
cmd
)
helpout
=
data1
+
data2
# check if --append exists
lines
=
helpout
.
split
(
'
\n
'
)
for
line
in
lines
:
if
line
.
strip
()
.
startswith
(
'-a, --append'
):
return
True
return
False
def
modify_user_usermod
(
self
):
cmd
=
[
self
.
module
.
get_bin_path
(
'usermod'
,
True
)]
info
=
self
.
user_info
()
has_append
=
self
.
_check_usermod_append
()
if
self
.
uid
is
not
None
and
info
[
2
]
!=
int
(
self
.
uid
):
cmd
.
append
(
'-u'
)
...
...
@@ -348,15 +367,21 @@ class User(object):
if
self
.
append
:
for
g
in
groups
:
if
g
in
group_diff
:
cmd
.
append
(
'-a'
)
if
has_append
:
cmd
.
append
(
'-a'
)
groups_need_mod
=
True
break
else
:
groups_need_mod
=
True
if
groups_need_mod
:
cmd
.
append
(
'-G'
)
cmd
.
append
(
','
.
join
(
groups
))
if
self
.
append
and
not
has_append
:
cmd
.
append
(
'-A'
)
cmd
.
append
(
','
.
join
(
group_diff
))
else
:
cmd
.
append
(
'-G'
)
cmd
.
append
(
','
.
join
(
groups
))
if
self
.
comment
is
not
None
and
info
[
4
]
!=
self
.
comment
:
cmd
.
append
(
'-c'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment