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

Can't pull and unpack image containing symlink when use an absolute path for the output directory. #740

Closed
1 task
GrahamDumpleton opened this issue Jan 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@GrahamDumpleton
Copy link

What happened in your environment?

Create a directory with a symlink contained in it:

% mkdir ora-test
% cd ora-test
% mkdir src
% touch src/FILE1.md
% ln -s FILE1.md src/FILE2.md
% ls -las src
total 0
0 drwxr-xr-x  4 graham  wheel  128 10 Jan 17:50 .
0 drwxr-xr-x  3 graham  wheel   96 10 Jan 17:50 ..
0 -rw-r--r--  1 graham  wheel    0 10 Jan 17:50 FILE1.md
0 lrwxr-xr-x  1 graham  wheel    8 10 Jan 17:50 FILE2.md -> FILE1.md

Push this to an image registry.

% (cd src; oras push localhost:5001/oras-test:latest .)
Uploading cd6f0d9b1610 .
Uploaded  cd6f0d9b1610 .
Pushed localhost:5001/oras-test:latest
Digest: sha256:db78ceca3debd8a61bdcbfb3d8b979f5cacbe199ef21a9b6043777fb123053bd

Create a directory unpack it and pull back image.

% mkdir dst
% (cd dst; oras pull localhost:5001/oras-test:latest)
Downloading cd6f0d9b1610 .
Downloaded  cd6f0d9b1610 .
Pulled localhost:5001/oras-test:latest
Digest: sha256:e31c3c6b2f3c52da5a1bc46e71400cd0d645139cd602fa00b3ae450bb1264fd4
% ls -las dst
total 0
0 drwxr-xr-x  4 graham  wheel  128 10 Jan 17:52 .
0 drwxr-xr-x  4 graham  wheel  128 10 Jan 17:51 ..
0 -rw-r--r--  1 graham  wheel    0 10 Jan 17:50 FILE1.md
0 lrwxr-xr-x  1 graham  wheel    8 10 Jan 17:52 FILE2.md -> FILE1.md

This handles the symlink in the image fine when unpacking it.

Pull image again, but this time supply output directory with is a relative path.

% rm -rf dst
% oras pull localhost:5001/oras-test:latest -o dst
Downloading cd6f0d9b1610 .
Downloaded  cd6f0d9b1610 .
Pulled localhost:5001/oras-test:latest
Digest: sha256:e31c3c6b2f3c52da5a1bc46e71400cd0d645139cd602fa00b3ae450bb1264fd4
% ls -las dst
total 0
0 drwxr-xr-x  4 graham  wheel  128 10 Jan 17:53 .
0 drwxr-xr-x  4 graham  wheel  128 10 Jan 17:53 ..
0 -rw-r--r--  1 graham  wheel    0 10 Jan 17:50 FILE1.md
0 lrwxr-xr-x  1 graham  wheel    8 10 Jan 17:53 FILE2.md -> FILE1.md

This also works fine.

Now pull image one more time, but this time use an absolute directory.

% rm -rf dst
% oras pull localhost:5001/oras-test:latest -o `pwd`/dst
Downloading cd6f0d9b1610 .
Error: failed to extract tar to /tmp/ora-test/dst: Rel: can't make /tmp/ora-test/dst/FILE1.md relative to .

This fails.

What did you expect to happen?

Would expect unpacking of the image with symlink would still work even though absolute path was supplied for output directory.

How can we reproduce it?

See steps above.

What is the version of your ORAS CLI?

% oras version
Version:    0.16.0+Homebrew
Go version: go1.19.3

What is your OS environment?

Darwin xxx 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64

Are you willing to submit PRs to fix it?

  • Yes, I am willing to fix it.
@GrahamDumpleton GrahamDumpleton added the bug Something isn't working label Jan 10, 2023
@shizhMSFT
Copy link
Contributor

@Wwwsylvia Could you take a look? It seems a bug in the oras-go.

@Wwwsylvia
Copy link
Member

The error is thrown at here in oras-go.
I've opened an issue in the oras-go repo to track: oras-project/oras-go#402

@shizhMSFT shizhMSFT modified the milestones: v1.0.0, v1.0.0-rc.1 Jan 17, 2023
@shizhMSFT
Copy link
Contributor

@GrahamDumpleton Thank you for reporting this bug. It has been fixed by the new release v1.0.0-rc.1 and the fix has been verified.

Please try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants