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
100cb760
Commit
100cb760
authored
Aug 21, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'l1k-devel' into devel
parents
f9183fcb
24c42774
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
lib/ansible/module_utils/basic.py
+7
-3
test/integration/roles/test_copy/tasks/main.yml
+25
-0
No files found.
lib/ansible/module_utils/basic.py
View file @
100cb760
...
...
@@ -1148,9 +1148,13 @@ class AnsibleModule(object):
if
self
.
selinux_enabled
():
self
.
set_context_if_different
(
tmp_dest
.
name
,
context
,
False
)
tmp_stat
=
os
.
stat
(
tmp_dest
.
name
)
if
dest_stat
and
(
tmp_stat
.
st_uid
!=
dest_stat
.
st_uid
or
tmp_stat
.
st_gid
!=
dest_stat
.
st_gid
):
os
.
chown
(
tmp_dest
.
name
,
dest_stat
.
st_uid
,
dest_stat
.
st_gid
)
try
:
tmp_stat
=
os
.
stat
(
tmp_dest
.
name
)
if
dest_stat
and
(
tmp_stat
.
st_uid
!=
dest_stat
.
st_uid
or
tmp_stat
.
st_gid
!=
dest_stat
.
st_gid
):
os
.
chown
(
tmp_dest
.
name
,
dest_stat
.
st_uid
,
dest_stat
.
st_gid
)
except
OSError
,
e
:
if
e
.
errno
!=
errno
.
EPERM
:
raise
os
.
rename
(
tmp_dest
.
name
,
dest
)
except
(
shutil
.
Error
,
OSError
,
IOError
),
e
:
self
.
cleanup
(
tmp_dest
.
name
)
...
...
test/integration/roles/test_copy/tasks/main.yml
View file @
100cb760
...
...
@@ -182,3 +182,28 @@
-
"
copy_result6.dest
==
'{{output_dir|expanduser}}/multiline.txt'"
-
"
copy_result6.md5sum
==
'1627d51e7e607c92cf1a502bf0c6cce3'"
# test overwriting a file as an unprivileged user (pull request #8624)
# this can't be relative to {{output_dir}} as ~root usually has mode 700
-
name
:
create world writable directory
file
:
dest=/tmp/worldwritable state=directory mode=0777
-
name
:
create world writable file
copy
:
dest=/tmp/worldwritable/file.txt content="bar" mode=0666
-
name
:
overwrite the file as user nobody
copy
:
dest=/tmp/worldwritable/file.txt content="baz"
sudo
:
yes
sudo_user
:
nobody
register
:
copy_result7
-
name
:
assert the file was overwritten
assert
:
that
:
-
"
copy_result7.changed"
-
"
copy_result7.dest
==
'/tmp/worldwritable/file.txt'"
-
"
copy_result7.md5sum
==
'73feffa4b7f6bb68e44cf984c85f6e88'"
-
name
:
clean up
file
:
dest=/tmp/worldwritable state=absent
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