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

Handle long and denormal symlinks #165

Merged
merged 2 commits into from Dec 15, 2021
Merged

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Nov 18, 2021

Use new append_link() API to handle long symlinks

I hit this when exporting Fedora Silverblue, there are some
long symlinks in there.

Depends: alexcrichton/tar-rs#273
Closes: #162


tar/export: Write symlink targets literally

Requires: alexcrichton/tar-rs#274

And I'll just copy/paste the commit message from there, lightly edited:

In https://github.com/ostreedev/ostree we generate a cryptographic
checksum over files and symlinks, and directories.

ostree does not currently perform any canonicalization on symlinks;
we'll respect and honor whatever bytes we're provided as input,
and replicate that on the target.

We're using the Rust tar crate to do tar serialization,
which has so far worked fine...except, I hit this corner case:

[root@cosa-devsh ~]# rpm -qf /usr/lib/systemd/systemd-sysv-install
chkconfig-1.13-2.el8.x86_64
[root@cosa-devsh ~]# ll /usr/lib/systemd/systemd-sysv-install
lrwxrwxrwx. 2 root root 24 Nov 29 18:08 /usr/lib/systemd/systemd-sysv-install -> ../../..//sbin/chkconfig
[root@cosa-devsh ~]#

But, using set_link_name to write the tarball, we end up with
the canonicalized path ../../../sbin/chkconfig - i.e. without the
double //. This breaks the checksum.

Now, I am a bit tempted to change ostree to do canonicalization. But
even if we did, I'd need to exactly match what tar-rs is doing.

(I may of course also try to change the rhel8 systemd package, but
that's going to take a while to propagate and this corner case isn't
the only one I'm sure)


@cgwalters cgwalters changed the title Tar long Use new append_link() API to handle long symlinks Nov 18, 2021
@cgwalters cgwalters mentioned this pull request Nov 18, 2021
I hit this when exporting Fedora Silverblue, there are some
long symlinks in there.

Depends: alexcrichton/tar-rs#273
Closes: ostreedev#162
Requires: alexcrichton/tar-rs#274

And I'll just copy/paste the commit message from there, lightly edited:

In https://github.com/ostreedev/ostree we generate a cryptographic
checksum over files and symlinks, and directories.

ostree does not currently perform any canonicalization on symlinks;
we'll respect and honor whatever bytes we're provided as input,
and replicate that on the target.

We're using the Rust tar crate to do tar serialization,
which has so far worked fine...except, I hit this corner case:

```
[root@cosa-devsh ~]# rpm -qf /usr/lib/systemd/systemd-sysv-install
chkconfig-1.13-2.el8.x86_64
[root@cosa-devsh ~]# ll /usr/lib/systemd/systemd-sysv-install
lrwxrwxrwx. 2 root root 24 Nov 29 18:08 /usr/lib/systemd/systemd-sysv-install -> ../../..//sbin/chkconfig
[root@cosa-devsh ~]#
```

But, using `set_link_name` to write the tarball, we end up with
the canonicalized path `../../../sbin/chkconfig` - i.e. without the
double `//`.  This breaks the checksum.

Now, I am a bit tempted to change ostree to do canonicalization.  But
even if we did, I'd need to *exactly* match what tar-rs is doing.

(I may of course also try to change the rhel8 systemd package, but
 that's going to take a while to propagate and this corner case isn't
 the only one I'm sure)
@cgwalters
Copy link
Member Author

OK there's a new tar 0.4.38 with my PRs! Because it conflicted, I'm rolling
#182
into this one.

(And now that I look at this...honestly I regret not also adding append_link_literal. Oops.)

@cgwalters cgwalters changed the title Use new append_link() API to handle long symlinks Handle long and denormal symlinks Dec 14, 2021
@cgwalters cgwalters marked this pull request as ready for review December 14, 2021 20:51
Copy link
Member

@jmarrero jmarrero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jmarrero jmarrero merged commit 44d7173 into ostreedev:main Dec 15, 2021
@JayDoubleu
Copy link

I'm getting the same error with below:

rpm-ostree ex-container encapsulate --repo=repo fedora/35/x86_64/silverblue docker://ghcr.io/JayDoubleu/fedora-silverblue:35
error: Building oci: Writing ostree root to blob: Exporting commit: provided value is too long when setting link name for 
[jaydoubleu@thinkxps-sb workstation-ostree-config]$ rpm-ostree --version
rpm-ostree:
 Version: '2021.14'
 Git: 5cb5980ad94eaaee0585b8dde1a733cb12670b19
 Features:
  - compose
  - rust
  - fedora-integration

Does it mean I should wait for newer rpm-ostree ?

@cgwalters
Copy link
Member Author

Hi, yes - this fix should land in the next rpm-ostree release. There are automated builds from git main at https://copr.fedorainfracloud.org/coprs/g/CoreOS/continuous/

You can also build from source of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fails on long symlinks
3 participants