unarchive - respect symlinks in archives

this patch fixes the extraction if symlinks are present in an archive
but the symlinks don't exist in the target filesystem.

tar reports this with:
```
/bin/tar: $filename: Warning: Cannot readlink: No such file or directory
```

previously, this was not matched against, hence the re-extraction was not triggered, although needed.

additionally, setting permissions on that file later fails, leading to errors like:
Unexpected error when accessing exploded file: `[Errno 2] No such file or directory: b'/path/to/$filename'`

```
  File "payload.zip/ansible/modules/unarchive.py", line 901, in main
  File "payload.zip/ansible/module_utils/basic.py", line 1417, in set_fs_attributes_if_different
    file_args['path'], file_args['owner'], changed, diff, expand
  File "payload.zip/ansible/module_utils/basic.py", line 1058, in set_owner_if_different
    orig_uid, orig_gid = self.user_and_group(b_path, expand)
  File "payload.zip/ansible/module_utils/basic.py", line 952, in user_and_group
    st = os.lstat(b_path)
```
pull/80136/head
Jonas Jelten 1 year ago
parent 8fec2d2a82
commit 152cc34a1a

@ -275,6 +275,7 @@ MOD_TIME_DIFF_RE = re.compile(r': Mod time differs$')
# NEWER_DIFF_RE = re.compile(r' is newer or same age.$')
EMPTY_FILE_RE = re.compile(r': : Warning: Cannot stat: No such file or directory$')
MISSING_FILE_RE = re.compile(r': Warning: Cannot stat: No such file or directory$')
MISSING_LINK_RE = re.compile(r': Warning: Cannot readlink: No such file or directory$')
ZIP_FILE_MODE_RE = re.compile(r'([r-][w-][SsTtx-]){3}')
INVALID_OWNER_RE = re.compile(r': Invalid owner')
INVALID_GROUP_RE = re.compile(r': Invalid group')
@ -871,6 +872,8 @@ class TgzArchive(object):
out += line + '\n'
if MISSING_FILE_RE.search(line):
out += line + '\n'
if MISSING_LINK_RE.search(line):
out += line + '\n'
if INVALID_OWNER_RE.search(line):
out += line + '\n'
if INVALID_GROUP_RE.search(line):

Loading…
Cancel
Save