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
cbfeb0a2
Commit
cbfeb0a2
authored
Dec 05, 2013
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #5169 Evaluate check_mode in the user module SunOS class
parent
71a5de6e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
45 deletions
+51
-45
library/system/user
+51
-45
No files found.
library/system/user
View file @
cbfeb0a2
...
@@ -1137,27 +1137,30 @@ class SunOS(User):
...
@@ -1137,27 +1137,30 @@ class SunOS(User):
cmd
.
append
(
self
.
name
)
cmd
.
append
(
self
.
name
)
(
rc
,
out
,
err
)
=
self
.
execute_command
(
cmd
)
if
self
.
module
.
check_mode
:
if
rc
is
not
None
and
rc
!=
0
:
return
(
0
,
''
,
''
)
self
.
module
.
fail_json
(
name
=
self
.
name
,
msg
=
err
,
rc
=
rc
)
else
:
(
rc
,
out
,
err
)
=
self
.
execute_command
(
cmd
)
# we have to set the password by editing the /etc/shadow file
if
rc
is
not
None
and
rc
!=
0
:
if
self
.
password
is
not
None
:
self
.
module
.
fail_json
(
name
=
self
.
name
,
msg
=
err
,
rc
=
rc
)
try
:
lines
=
[]
for
line
in
open
(
self
.
SHADOWFILE
,
'rb'
)
.
readlines
():
fields
=
line
.
strip
()
.
split
(
':'
)
if
not
fields
[
0
]
==
self
.
name
:
lines
.
append
(
line
)
continue
fields
[
1
]
=
self
.
password
line
=
':'
.
join
(
fields
)
lines
.
append
(
'
%
s
\n
'
%
line
)
open
(
self
.
SHADOWFILE
,
'w+'
)
.
writelines
(
lines
)
except
Exception
,
err
:
self
.
module
.
fail_json
(
msg
=
"failed to update users password:
%
s"
%
str
(
err
))
return
(
rc
,
out
,
err
)
# we have to set the password by editing the /etc/shadow file
if
self
.
password
is
not
None
:
try
:
lines
=
[]
for
line
in
open
(
self
.
SHADOWFILE
,
'rb'
)
.
readlines
():
fields
=
line
.
strip
()
.
split
(
':'
)
if
not
fields
[
0
]
==
self
.
name
:
lines
.
append
(
line
)
continue
fields
[
1
]
=
self
.
password
line
=
':'
.
join
(
fields
)
lines
.
append
(
'
%
s
\n
'
%
line
)
open
(
self
.
SHADOWFILE
,
'w+'
)
.
writelines
(
lines
)
except
Exception
,
err
:
self
.
module
.
fail_json
(
msg
=
"failed to update users password:
%
s"
%
str
(
err
))
return
(
rc
,
out
,
err
)
def
modify_user_usermod
(
self
):
def
modify_user_usermod
(
self
):
cmd
=
[
self
.
module
.
get_bin_path
(
'usermod'
,
True
)]
cmd
=
[
self
.
module
.
get_bin_path
(
'usermod'
,
True
)]
...
@@ -1214,33 +1217,36 @@ class SunOS(User):
...
@@ -1214,33 +1217,36 @@ class SunOS(User):
cmd
.
append
(
'-s'
)
cmd
.
append
(
'-s'
)
cmd
.
append
(
self
.
shell
)
cmd
.
append
(
self
.
shell
)
# modify the user if cmd will do anything
if
self
.
module
.
check_mode
:
if
cmd_len
!=
len
(
cmd
):
return
(
0
,
''
,
''
)
cmd
.
append
(
self
.
name
)
(
rc
,
out
,
err
)
=
self
.
execute_command
(
cmd
)
if
rc
is
not
None
and
rc
!=
0
:
self
.
module
.
fail_json
(
name
=
self
.
name
,
msg
=
err
,
rc
=
rc
)
else
:
else
:
(
rc
,
out
,
err
)
=
(
None
,
''
,
''
)
# modify the user if cmd will do anything
if
cmd_len
!=
len
(
cmd
):
# we have to set the password by editing the /etc/shadow file
cmd
.
append
(
self
.
name
)
if
self
.
update_password
==
'always'
and
self
.
password
is
not
None
and
info
[
1
]
!=
self
.
password
:
(
rc
,
out
,
err
)
=
self
.
execute_command
(
cmd
)
try
:
if
rc
is
not
None
and
rc
!=
0
:
lines
=
[]
self
.
module
.
fail_json
(
name
=
self
.
name
,
msg
=
err
,
rc
=
rc
)
for
line
in
open
(
self
.
SHADOWFILE
,
'rb'
)
.
readlines
():
else
:
fields
=
line
.
strip
()
.
split
(
':'
)
(
rc
,
out
,
err
)
=
(
None
,
''
,
''
)
if
not
fields
[
0
]
==
self
.
name
:
lines
.
append
(
line
)
continue
fields
[
1
]
=
self
.
password
line
=
':'
.
join
(
fields
)
lines
.
append
(
'
%
s
\n
'
%
line
)
open
(
self
.
SHADOWFILE
,
'w+'
)
.
writelines
(
lines
)
rc
=
0
except
Exception
,
err
:
self
.
module
.
fail_json
(
msg
=
"failed to update users password:
%
s"
%
str
(
err
))
return
(
rc
,
out
,
err
)
# we have to set the password by editing the /etc/shadow file
if
self
.
update_password
==
'always'
and
self
.
password
is
not
None
and
info
[
1
]
!=
self
.
password
:
try
:
lines
=
[]
for
line
in
open
(
self
.
SHADOWFILE
,
'rb'
)
.
readlines
():
fields
=
line
.
strip
()
.
split
(
':'
)
if
not
fields
[
0
]
==
self
.
name
:
lines
.
append
(
line
)
continue
fields
[
1
]
=
self
.
password
line
=
':'
.
join
(
fields
)
lines
.
append
(
'
%
s
\n
'
%
line
)
open
(
self
.
SHADOWFILE
,
'w+'
)
.
writelines
(
lines
)
rc
=
0
except
Exception
,
err
:
self
.
module
.
fail_json
(
msg
=
"failed to update users password:
%
s"
%
str
(
err
))
return
(
rc
,
out
,
err
)
# ===========================================
# ===========================================
...
...
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