core: fix symlink resolution in get_core_dynamic_linker #1170

Merged
merged 1 commit into from Mar 7, 2017

Conversation

Projects
None yet
3 participants
Contributor

mwhudson commented Mar 2, 2017

The existing code did not handle relative symlinks correctly, they were
expanded relative to /snap/core/current, not the directory they resided in.
This is why classic snap builds only worked on amd64 and ppc64el on Launchpad.

LP: #1665165

No test because I don't see how to add one (afaict, get_core_dynamic_linker is currently untested).

Contributor

mwhudson commented Mar 2, 2017

(I have tested this in an i386 lxd and it worked there)

Member

kyrofa commented Mar 3, 2017

I'm going to go ahead and hit the "update" button here which will hopefully fix that red X from Travis.

This looks good to me, although I'd prefer to use a snapcraft-specific exception.

snapcraft/_options.py
+ seen_paths = set()
+ while True:
+ if dynamic_linker_path in seen_paths:
+ raise EnvironmentError(
@kyrofa

kyrofa Mar 3, 2017

Member

This won't do anything about the errno in EnvironmentError. Can we please use snapcraft.internal.errors.SnapcraftEnvironmentError instead?

@mwhudson

mwhudson Mar 5, 2017

Contributor

Sure.

snapcraft/_options.py
+ if not os.path.islink(dynamic_linker_path):
+ return dynamic_linker_path
+ link_contents = os.readlink(dynamic_linker_path)
+ if link_contents.startswith('/'):
@kyrofa

kyrofa Mar 3, 2017

Member

Would os.path.isabs() be better?

@mwhudson

mwhudson Mar 5, 2017

Contributor

/me tosses a coin, let's say yes.

core: fix symlink resolution in get_core_dynamic_linker
The existing code did not handle relative symlinks correctly, they were
expanded relative to /snap/core/current, not the directory they resided in.
This is why classic snap builds only worked on amd64 and ppc64el on Launchpad.

LP: #1665165
Collaborator

sergiusens commented Mar 5, 2017

Thanks for this @mwhudson! You are correct that there is no unit test for this, we do however have integration tests and other architectures are run through adt, unfortunately we are not allowed to run subsets of tests of things we know work on other architectures and are restricted to always fail until everything works (it is the ubuntu-dev way) which hides the test results from us. We can however setup some test fixtures on the side to at least run these subsets during development and detach ourselves from the adt results from what would be a deb's tests. Do you mind looking into that @elopio?

Contributor

mwhudson commented Mar 5, 2017

Given that your autopkgtests currently succeed on armhf, which has this problem, I suspect they are not sufficient either (none of the tests of classic snaps actually install and run the built snap, afaics?)

Collaborator

sergiusens commented Mar 7, 2017

the git demo is also a classic snap and has the potential to run (it it isn't setup already).

kyrofa approved these changes Mar 7, 2017

I'm good with this, thanks @mwhudson 😃 .

Member

kyrofa commented Mar 7, 2017

@sergiusens does @elopio need to look into that before this lands?

Collaborator

sergiusens commented Mar 7, 2017

ok this does solve the problem too https://code.launchpad.net/~sergiusens/+snap/test-snap (at least for i386)

@sergiusens sergiusens merged commit b19e9cf into snapcore:master Mar 7, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details

elopio added a commit that referenced this pull request Mar 27, 2017

core: fix symlink resolution in get_core_dynamic_linker. (#1170)
The existing code did not handle relative symlinks correctly, they were
expanded relative to /snap/core/current, not the directory they resided in.
This is why classic snap builds only worked on amd64 and ppc64el on Launchpad.

LP: #1665165

kalikiana pushed a commit to kalikiana/snapcraft that referenced this pull request Apr 6, 2017

core: fix symlink resolution in get_core_dynamic_linker. (#1170)
The existing code did not handle relative symlinks correctly, they were
expanded relative to /snap/core/current, not the directory they resided in.
This is why classic snap builds only worked on amd64 and ppc64el on Launchpad.

LP: #1665165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment