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
97db1676
Commit
97db1676
authored
Feb 26, 2014
by
nate@bx.psu.edu
Committed by
Michael DeHaan
Mar 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix for xattrless files and the capabilities module.
parent
f26ebff4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
library/system/capabilities
+18
-18
No files found.
library/system/capabilities
View file @
97db1676
...
@@ -84,8 +84,6 @@ class CapabilitiesModule(object):
...
@@ -84,8 +84,6 @@ class CapabilitiesModule(object):
self
.
setcap_cmd
=
module
.
get_bin_path
(
'setcap'
,
required
=
True
)
self
.
setcap_cmd
=
module
.
get_bin_path
(
'setcap'
,
required
=
True
)
self
.
capability_tup
=
self
.
_parse_cap
(
self
.
capability
,
op_required
=
self
.
state
==
'present'
)
self
.
capability_tup
=
self
.
_parse_cap
(
self
.
capability
,
op_required
=
self
.
state
==
'present'
)
self
.
changed
=
False
self
.
run
()
self
.
run
()
def
run
(
self
):
def
run
(
self
):
...
@@ -102,15 +100,16 @@ class CapabilitiesModule(object):
...
@@ -102,15 +100,16 @@ class CapabilitiesModule(object):
current
=
filter
(
lambda
x
:
x
[
0
]
!=
self
.
capability_tup
[
0
],
current
)
current
=
filter
(
lambda
x
:
x
[
0
]
!=
self
.
capability_tup
[
0
],
current
)
# add new cap with correct op/flags
# add new cap with correct op/flags
current
.
append
(
self
.
capability_tup
)
current
.
append
(
self
.
capability_tup
)
self
.
module
.
exit_json
(
changed
=
True
,
msg
=
'capabilities changed'
,
stdout
=
self
.
setcap
(
self
.
path
,
current
))
self
.
module
.
exit_json
(
changed
=
True
,
state
=
self
.
state
,
msg
=
'capabilities changed'
,
stdout
=
self
.
setcap
(
self
.
path
,
current
))
if
self
.
state
==
'absent'
and
self
.
capability_tup
[
0
]
in
caps
:
el
if
self
.
state
==
'absent'
and
self
.
capability_tup
[
0
]
in
caps
:
# need to remove capability
# need to remove capability
if
self
.
module
.
check_mode
:
if
self
.
module
.
check_mode
:
self
.
module
.
exit_json
(
changed
=
True
,
msg
=
'capabilities changed'
)
self
.
module
.
exit_json
(
changed
=
True
,
msg
=
'capabilities changed'
)
else
:
else
:
# remove from current cap list and then set current list
# remove from current cap list and then set current list
current
=
filter
(
lambda
x
:
x
[
0
]
!=
self
.
capability_tup
[
0
],
current
)
current
=
filter
(
lambda
x
:
x
[
0
]
!=
self
.
capability_tup
[
0
],
current
)
self
.
module
.
exit_json
(
changed
=
True
,
msg
=
'capabilities changed'
,
stdout
=
self
.
setcap
(
self
.
path
,
current
))
self
.
module
.
exit_json
(
changed
=
True
,
state
=
self
.
state
,
msg
=
'capabilities changed'
,
stdout
=
self
.
setcap
(
self
.
path
,
current
))
self
.
module
.
exit_json
(
changed
=
False
,
state
=
self
.
state
)
def
getcap
(
self
,
path
):
def
getcap
(
self
,
path
):
rval
=
[]
rval
=
[]
...
@@ -123,19 +122,20 @@ class CapabilitiesModule(object):
...
@@ -123,19 +122,20 @@ class CapabilitiesModule(object):
# If the file does not eixst the output will be (with rc == 0...):
# If the file does not eixst the output will be (with rc == 0...):
# '/foo (No such file or directory)'
# '/foo (No such file or directory)'
if
rc
!=
0
or
(
stdout
.
strip
()
!=
path
and
stdout
.
count
(
' ='
)
!=
1
):
if
rc
!=
0
or
(
stdout
.
strip
()
!=
path
and
stdout
.
count
(
' ='
)
!=
1
):
self
.
module
.
fail_json
(
msg
=
"Unable to get capabilities of
%
s"
%
path
,
stdout
=
stdout
,
stderr
=
stderr
)
self
.
module
.
fail_json
(
msg
=
"Unable to get capabilities of
%
s"
%
path
,
stdout
=
stdout
.
strip
(),
stderr
=
stderr
)
caps
=
stdout
.
split
(
' ='
)[
1
]
.
strip
()
.
split
()
if
stdout
.
strip
()
!=
path
:
for
cap
in
caps
:
caps
=
stdout
.
split
(
' ='
)[
1
]
.
strip
()
.
split
()
cap
=
cap
.
lower
()
for
cap
in
caps
:
# getcap condenses capabilities with the same op/flags into a
cap
=
cap
.
lower
()
# comma-separated list, so we have to parse that
# getcap condenses capabilities with the same op/flags into a
if
','
in
cap
:
# comma-separated list, so we have to parse that
cap_group
=
cap
.
split
(
','
)
if
','
in
cap
:
cap_group
[
-
1
],
op
,
flags
=
self
.
_parse_cap
(
cap_group
[
-
1
])
cap_group
=
cap
.
split
(
','
)
for
subcap
in
cap_group
:
cap_group
[
-
1
],
op
,
flags
=
self
.
_parse_cap
(
cap_group
[
-
1
])
rval
.
append
(
(
subcap
,
op
,
flags
)
)
for
subcap
in
cap_group
:
else
:
rval
.
append
(
(
subcap
,
op
,
flags
)
)
rval
.
append
(
self
.
_parse_cap
(
cap
))
else
:
rval
.
append
(
self
.
_parse_cap
(
cap
))
return
rval
return
rval
def
setcap
(
self
,
path
,
caps
):
def
setcap
(
self
,
path
,
caps
):
...
...
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