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
b58d7470
Commit
b58d7470
authored
Oct 12, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup logic and be more paranoid about passwords with spaces
parent
5c5806d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
lib/ansible/plugins/lookup/password.py
+22
-15
No files found.
lib/ansible/plugins/lookup/password.py
View file @
b58d7470
...
...
@@ -134,22 +134,29 @@ class LookupModule(LookupBase):
f
.
write
(
content
+
'
\n
'
)
else
:
content
=
open
(
path
)
.
read
()
.
rstrip
()
sep
=
content
.
find
(
' '
)
if
sep
>=
0
:
password
=
content
[:
sep
]
salt
=
content
[
sep
+
1
:]
.
split
(
'='
)[
1
]
else
:
password
=
content
salt
=
None
# crypt requested, add salt if missing
if
(
params
[
'encrypt'
]
is
not
None
and
not
salt
):
salt
=
self
.
random_salt
()
content
=
'
%
s salt=
%
s'
%
(
password
,
salt
)
with
open
(
path
,
'w'
)
as
f
:
os
.
chmod
(
path
,
0
o600
)
f
.
write
(
content
+
'
\n
'
)
if
params
[
'encrypt'
]
is
not
None
:
try
:
sep
=
content
.
rindex
(
' '
)
except
ValueError
:
password
=
content
salt
=
None
else
:
salt_field
=
content
[
sep
+
1
:]
if
salt_field
.
startswith
(
'salt='
):
password
=
content
[:
sep
]
salt
=
salt_field
[
len
(
'salt='
:]
else
:
password
=
content
salt
=
None
# crypt requested, add salt if missing
if
not
salt
:
salt
=
self
.
random_salt
()
content
=
'
%
s salt=
%
s'
%
(
password
,
salt
)
with
open
(
path
,
'w'
)
as
f
:
os
.
chmod
(
path
,
0
o600
)
f
.
write
(
content
+
'
\n
'
)
if
params
[
'encrypt'
]:
password
=
do_encrypt
(
password
,
params
[
'encrypt'
],
salt
=
salt
)
...
...
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