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

Warn (error?) about symlinks outside of package #4147

Closed
jgsogo opened this issue Dec 17, 2018 · 6 comments
Closed

Warn (error?) about symlinks outside of package #4147

jgsogo opened this issue Dec 17, 2018 · 6 comments
Assignees

Comments

@jgsogo
Copy link
Contributor

jgsogo commented Dec 17, 2018

I was packaging a gcc cross-compiler together with the sys-root of the target system. That sys-root contained a lot of symlinks, sometimes targeting files outside of the package (such as /etc/whatever). Conan packages this without complaining. However this created an error at conan install time with an access violation when trying to set some properties (timestamps?) on the target of these packages (which conan shouldn't be modifying anyway as they are outside of the package). You may want to
create another problem report for this specific issue.

Originally posted by @michiel-dewilde in #4051 (comment)

@lasote
Copy link
Contributor

lasote commented Dec 20, 2018

Probably checking always all the files to see if they belong to the package is costly. We could provide a tool maybe? how the files were packaged? by conan or by an external install? I don't know if the conan copy could check links pointing out of the package.

@danimtb
Copy link
Member

danimtb commented Dec 21, 2018

IIRC the FileCopier class already clears the broken symlinks but I am not sure if it takes the outside symlinks into account

@jgsogo
Copy link
Contributor Author

jgsogo commented Dec 21, 2018

Maybe this can be a pre/post_package hook, what do you think?

@danimtb
Copy link
Member

danimtb commented Dec 21, 2018

Did a small test and the FileCopier is copying the symlink correctly but it does not take into account that the "outside links" have to be copied too:

    def test_outside_link_copy(self):
        folder1 = temp_folder()
        sub1 = os.path.join(folder1, "subdir1")
        sub2 = os.path.join(folder1, "subdir2")
        file1_path = os.path.join(sub1, "file1.txt")
        file2_path = os.path.join(sub1, "file2.c")
        save(file1_path, "file1")
        save(file2_path, "file2")
        os.makedirs(sub2)
        os.symlink(file1_path, os.path.join(sub2, "file_subdir1_symlink.txt"))

        folder2 = temp_folder()
        copier = FileCopier(sub2, folder2)
        copier("*", links=True)
        self.assertEqual(os.listdir(folder2), ["file1.txt", "file2.c"])

However, I think this is the right behavior as we don't know if the user is doing this on purpose or not (for example in the case of a conanfile used to mimic a System package).

The most we could do is provide a tool for this, bu I think the user should be responsible for taking care of the symlinks on what they is trying to achieve

@jgsogo
Copy link
Contributor Author

jgsogo commented Dec 24, 2018

That's the reason I was suggesting a hook. Maybe we can provide an implementation that warns about links outside a package (traverse the packaged directory checking for links outside it), the user can activate/deactivate it, or even modify it to raise an error instead of a warning.

@danimtb
Copy link
Member

danimtb commented Dec 24, 2018

Agree. I have opened an issue in the hooks repo conan-io/hooks#14

I think it is enough to close this one

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

No branches or pull requests

3 participants