Skip to content

unarchive - respect symlinks in archives#80136

Open
TheJJ wants to merge 1 commit intoansible:develfrom
TheJJ:unarchive-symlink
Open

unarchive - respect symlinks in archives#80136
TheJJ wants to merge 1 commit intoansible:develfrom
TheJJ:unarchive-symlink

Conversation

@TheJJ
Copy link
Copy Markdown

@TheJJ TheJJ commented Mar 3, 2023

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)
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

unarchive module

@ansibot ansibot added affects_2.15 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. small_patch traceback This issue/PR includes a traceback. labels Mar 3, 2023
@mkrizek mkrizek added needs_verified This issue needs to be verified/reproduced by maintainer and removed needs_triage Needs a first human triage before being processed. labels Mar 7, 2023
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 15, 2023
@TheJJ

This comment was marked as outdated.

@TheJJ

This comment was marked as off-topic.

@TheJJ

This comment was marked as abuse.

@webknjaz

This comment was marked as resolved.

@ansibot ansibot added the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. label May 2, 2024
@azure-pipelines

This comment was marked as resolved.

@webknjaz
Copy link
Copy Markdown
Member

webknjaz commented May 2, 2024

The PR needs rebasing for the CI to pick it up.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels May 2, 2024
@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label May 2, 2024
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 16, 2024
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Jun 27, 2024
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)
```
@TheJJ TheJJ force-pushed the unarchive-symlink branch from 152cc34 to 57f4527 Compare November 22, 2024 15:21
@ansibot ansibot removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Nov 22, 2024
@TheJJ
Copy link
Copy Markdown
Author

TheJJ commented Nov 28, 2024

I've rebased. Please merge? :) @webknjaz

@webknjaz
Copy link
Copy Markdown
Member

Looks like there's a needs_verified label, meaning there's no reproducer and somebody from the core needs to attempt triggering this manually. Note that many folks are on vacation until the end of the year. But I'd recommend adding an integration test demonstrating the mentioned behavior that would prove that it works and would be a regression test long-term.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Dec 2, 2024
@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects_2.15 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_verified This issue needs to be verified/reproduced by maintainer new_contributor This PR is the first contribution by a new community member. small_patch stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year. traceback This issue/PR includes a traceback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants