Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy module: Error handling for missing permissions on the copy destination. #504

Merged
merged 2 commits into from
Jun 25, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions library/copy
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ if dest:
if not os.path.exists(src):
exit_kv(rc=1, failed=1, msg="Source %s failed to transfer" % (src))

if os.path.exists(dest):
# raise an error if copy has no permission on dest
if not os.access(dest, os.W_OK):
exit_kv(rc=1, failed=1, msg="Destination %s not writable" % (dest))
elif not os.access(dest, os.R_OK):
exit_kv(rc=1, failed=1, msg="Destination %s not readable" % (dest))
else:
if not os.access(os.path.dirname(dest), os.W_OK):
exit_kv(rc=1, failed=1, msg="Destination %s not writable" % (dest))

md5sum = None
changed = False
if os.path.exists(dest):
Expand Down