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
ae29e43f
Commit
ae29e43f
authored
Apr 18, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_7009_nfs_selinux' into devel
parents
bec0e596
3715482d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
lib/ansible/module_utils/basic.py
+35
-6
No files found.
lib/ansible/module_utils/basic.py
View file @
ae29e43f
...
...
@@ -350,6 +350,31 @@ class AnsibleModule(object):
gid
=
st
.
st_gid
return
(
uid
,
gid
)
def
find_mount_point
(
self
,
path
):
path
=
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
path
)))
while
not
os
.
path
.
ismount
(
path
):
path
=
os
.
path
.
dirname
(
path
)
return
path
def
is_nfs_path
(
self
,
path
):
"""
Returns a tuple containing (True, selinux_context) if the given path
is on a NFS mount point, otherwise the return will be (False, None).
"""
try
:
f
=
open
(
'/proc/mounts'
,
'r'
)
mount_data
=
f
.
readlines
()
f
.
close
()
except
:
return
(
False
,
None
)
path_mount_point
=
self
.
find_mount_point
(
path
)
for
line
in
mount_data
:
(
device
,
mount_point
,
fstype
,
options
,
rest
)
=
line
.
split
(
' '
,
4
)
if
path_mount_point
==
mount_point
and
'nfs'
in
fstype
:
nfs_context
=
self
.
selinux_context
(
path_mount_point
)
return
(
True
,
nfs_context
)
return
(
False
,
None
)
def
set_default_selinux_context
(
self
,
path
,
changed
):
if
not
HAVE_SELINUX
or
not
self
.
selinux_enabled
():
return
changed
...
...
@@ -365,12 +390,16 @@ class AnsibleModule(object):
# Iterate over the current context instead of the
# argument context, which may have selevel.
for
i
in
range
(
len
(
cur_context
)):
if
len
(
context
)
>
i
:
if
context
[
i
]
is
not
None
and
context
[
i
]
!=
cur_context
[
i
]:
new_context
[
i
]
=
context
[
i
]
if
context
[
i
]
is
None
:
new_context
[
i
]
=
cur_context
[
i
]
(
is_nfs
,
nfs_context
)
=
self
.
is_nfs_path
(
path
)
if
is_nfs
:
new_context
=
nfs_context
else
:
for
i
in
range
(
len
(
cur_context
)):
if
len
(
context
)
>
i
:
if
context
[
i
]
is
not
None
and
context
[
i
]
!=
cur_context
[
i
]:
new_context
[
i
]
=
context
[
i
]
if
context
[
i
]
is
None
:
new_context
[
i
]
=
cur_context
[
i
]
if
cur_context
!=
new_context
:
try
:
...
...
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