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
936e1de1
Commit
936e1de1
authored
Jun 03, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when using os.getlogin() without a tty
parent
c4b6c0ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletions
+12
-1
lib/ansible/module_utils/basic.py
+12
-1
No files found.
lib/ansible/module_utils/basic.py
View file @
936e1de1
...
...
@@ -1020,7 +1020,18 @@ class AnsibleModule(object):
context
=
self
.
selinux_default_context
(
dest
)
creating
=
not
os
.
path
.
exists
(
dest
)
switched_user
=
os
.
getlogin
()
!=
pwd
.
getpwuid
(
os
.
getuid
())[
0
]
try
:
login_name
=
os
.
getlogin
()
except
OSError
:
# not having a tty can cause the above to fail, so
# just get the LOGNAME environment variable instead
login_name
=
os
.
environ
.
get
(
'LOGNAME'
,
None
)
# if the original login_name doesn't match the currently
# logged-in user, or if the SUDO_USER environment variable
# is set, then this user has switched their credentials
switched_user
=
login_name
and
login_name
!=
pwd
.
getpwuid
(
os
.
getuid
())[
0
]
or
os
.
environ
.
get
(
'SUDO_USER'
)
try
:
# Optimistically try a rename, solves some corner cases and can avoid useless work, throws exception if not atomic.
...
...
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