Navigation Menu

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

[SR-12094] Swift Package Manager in 5.2 forbids previously allowed symlink directories #4617

Closed
Lukasa opened this issue Jan 28, 2020 · 11 comments
Labels

Comments

@Lukasa
Copy link
Contributor

Lukasa commented Jan 28, 2020

Previous ID SR-12094
Radar rdar://problem/58963219
Original Reporter @Lukasa
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 5.2-dev (Swift 7c021027d3)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

Watchers: @shahmishal

md5: 78b3b9df4e3154cc1b669c0a447ae83e

Issue Description:

In Swift versions prior to 5.2 it was acceptable to have symlinks in source directories, or even for source directories to be symlinks. These symlinks would be followed and treated as part of the directory hierarchy.

As part of the package resources work this block of code was added by @aciidb0mb3r (in this commit) that actively forbids the use of symlinks, without any justification of why they are forbidden.

This breakage caused issues in the SwiftNIO integration test suite. It's not clear that there is a good reason for forbidding the use of symlinks. If there is, we should add the missing diagnostic so others who are affected do not need to dive into the source code to find out why. If there isn't (which seems more likely to me) we should re-add the support for symlinks.

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 28, 2020

@swift-ci create

@ankitspd
Copy link
Member

IIRC I did that to retain compatibility with existing behavior but maybe I misunderstood the existing behavior 🙂 I'll take a look soon.

@ankitspd
Copy link
Member

master: #2539
5.2: #2540

@Lukasa
Copy link
Contributor Author

Lukasa commented Jan 28, 2020

Thanks Ankit!

@weissi
Copy link
Member

weissi commented Jan 29, 2020

latest snapshots still show the issue, probably need to wait one more day. Tested with

$ jw-docker-swift-5.2 swift -version
docker.io/swiftlang/swift:nightly-5.2-bionic
Swift version 5.2-dev (Swift 7c021027d3)
Target: x86_64-unknown-linux-gnu
$ jw-docker-swift-master swift -version
docker.io/swiftlang/swift:nightly-master-bionic
Swift version 5.2-dev
Target: x86_64-unknown-linux-gnu

@aciidb0mb3r btw, a repro in the NIO repo is

IntegrationTests/run-tests.sh -f tests_02

that should only run the failing tests

@ankitspd
Copy link
Member

Yeah, it's in trunk snapshot but not in 5.2 yet.

@weissi
Copy link
Member

weissi commented Jan 29, 2020

@aciidb0mb3r hmm, are you sure? I tried with

swiftlang/swift                       nightly-master-bionic   58ccabdebba5        31 hours ago        1.65GB

$ docker pull swiftlang/swift:nightly-master-bionic
nightly-master-bionic: Pulling from swiftlang/swift
Digest: sha256:c54309df5a1b98276b0d745dfb2ba5d14beae494c3901979d1b7306fd0e35552
Status: Image is up to date for swiftlang/swift:nightly-master-bionic
docker.io/swiftlang/swift:nightly-master-bionic
johannes:~/devel/swift-nio (jw-clang-mods)
$ docker run -it --rm -v "$PWD:$PWD" -w "$PWD" swiftlang/swift:nightly-master-bionic IntegrationTests/run-tests.sh -f tests_02

and it still fails.

root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# swift run
warning: Source files for target CNIOLinux should be located under /tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/CNIOLinux
warning: Source files for target CNIODarwin should be located under /tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/CNIODarwin
/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/syscallwrapper/System.swift:27:8: error: no such module 'CNIOLinux'
import CNIOLinux
       ^
/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/syscallwrapper/System.swift:27:8: error: no such module 'CNIOLinux'
import CNIOLinux
       ^
/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/syscallwrapper/System.swift:27:8: error: no such module 'CNIOLinux'
import CNIOLinux
       ^
/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper/Sources/syscallwrapper/System.swift:27:8: error: no such module 'CNIOLinux'
import CNIOLinux
       ^

root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# ls Sources/
CNIODarwin/     CNIOLinux/      syscallwrapper/ 
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# ls Sources/CNIO
CNIODarwin/ CNIOLinux/  
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# ls -la Sources/CNIO
ls: cannot access 'Sources/CNIO': No such file or directory
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# ls -la Sources/
total 20
drwxr-xr-x 3 root root 4096 Jan 29 16:50 .
drwxr-xr-x 5 root root 4096 Jan 29 16:50 ..
lrwxrwxrwx 1 root root   99 Jan 29 16:50 CNIODarwin -> /Users/johannes/devel/swift-nio/IntegrationTests/tests_02_syscall_wrappers/../../Sources/CNIODarwin
lrwxrwxrwx 1 root root   98 Jan 29 16:50 CNIOLinux -> /Users/johannes/devel/swift-nio/IntegrationTests/tests_02_syscall_wrappers/../../Sources/CNIOLinux
drwxr-xr-x 2 root root 4096 Jan 29 16:50 syscallwrapper
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# ls -lad /Users/johannes/devel/swift-nio/IntegrationTests/tests_02_syscall_wrappers/../../Sources/CNIOLinux
drwxr-xr-x 6 root root 192 Oct  7 13:55 /Users/johannes/devel/swift-nio/IntegrationTests/tests_02_syscall_wrappers/../../Sources/CNIOLinux
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# cat Package.swift 
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "syscallwrapper",
    dependencies: [],
    targets: [
        .target(
            name: "syscallwrapper",
            dependencies: ["CNIOLinux", "CNIODarwin"]),
        .target(
            name: "CNIOLinux",
            dependencies: []),
        .target(
            name: "CNIODarwin",
            dependencies: []),
    ]
)
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# swift -version
Swift version 5.2-dev
Target: x86_64-unknown-linux-gnu
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# clang -version
clang-7: error: unknown argument '-version'; did you mean '--version'?
clang-7: error: no input files
root@b180dcd8b6ed:/tmp/.swift-nio-syscall-wrappers-sh-test_SRX9MW/syscallwrapper# clang --version
clang version 7.0.0 (git@github.com:apple/llvm-project.git ed54a32a9759092e353bf87d76ba5d81228dd990)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@ankitspd
Copy link
Member

Seems like the latest nightly on docker is not updated yet. Latest snapshot on swift.org is swift-DEVELOPMENT-SNAPSHOT-2020-01-28-a where as docker nightly currently has swift-DEVELOPMENT-SNAPSHOT-2020-01-27-a.

cc @shahmishal

@shahmishal
Copy link
Member

The Docker image failed to update due to GPG server, I have updated the nightly dockerfiles to import the key from swift.org to avoid unexpected outage.

apple/swift-docker#155

@weissi
Copy link
Member

weissi commented Jan 30, 2020

Awesome![]( Thanks so much Mishal)!

@weissi
Copy link
Member

weissi commented Jan 30, 2020

I think this can be closed, now works with both the latest 5.2 and master snapshots from docker.

$ jw-docker-swift-master IntegrationTests/run-tests.sh -f tests_02
docker.io/swiftlang/swift:nightly-master-bionic
Running test suite 'tests_01_http'
Skipping test 'test_01_get_file.sh'
Skipping test 'test_02_get_random_bytes.sh'
Skipping test 'test_03_post_random_bytes.sh'
Skipping test 'test_04_keep_alive_works.sh'
Skipping test 'test_05_repeated_reqs_work.sh'
Skipping test 'test_06_http_1.0.sh'
Skipping test 'test_07_headers_work.sh'
Skipping test 'test_08_survive_signals.sh'
Skipping test 'test_09_curl_happy_with_trailers.sh'
Skipping test 'test_10_connection_drop_in_body_ok.sh'
Skipping test 'test_11_res_body_streaming.sh'
Skipping test 'test_12_headers_too_large.sh'
Skipping test 'test_13_http_pipelining.sh'
Skipping test 'test_14_strict_mode_assertion.sh'
Skipping test 'test_15_post_in_chunked_encoding.sh'
Skipping test 'test_16_tcp_client_ip.sh'
Skipping test 'test_17_serve_massive_sparse_file.sh'
Skipping test 'test_18_close_with_no_keepalive.sh'
Skipping test 'test_19_connection_drop_while_waiting_for_response_uds.sh'
Skipping test 'test_20_connection_drop_while_waiting_for_response_tcp.sh'
Skipping test 'test_21_connection_reset_tcp.sh'
Skipping test 'test_22_http_1.0_keep_alive.sh'
Skipping test 'test_23_repeated_reqs_with_half_closure.sh'
Skipping test 'test_24_http_over_stdio.sh'
Running test suite 'tests_02_syscall_wrappers'
Running test 'test_01_syscall_wrapper_fast.sh'... OK (14s)
Running test 'test_02_blacklisted_errnos.sh'... OK (7s)
Running test suite 'tests_03_linker_things'
Skipping test 'test_01_check_we_do_not_link_Foundation.sh'
Running test suite 'tests_04_performance'
Skipping test 'test_01_allocation_counts.sh'
Running test suite 'tests_05_assertions'
Skipping test 'test_01_syscall_wrapper_fast.sh'
OK (ran 2 tests successfully)
johannes:~/devel/swift-nio (master)
$ jw-docker-swift-5.2 IntegrationTests/run-tests.sh -f tests_02
docker.io/swiftlang/swift:nightly-5.2-bionic
Running test suite 'tests_01_http'
Skipping test 'test_01_get_file.sh'
Skipping test 'test_02_get_random_bytes.sh'
Skipping test 'test_03_post_random_bytes.sh'
Skipping test 'test_04_keep_alive_works.sh'
Skipping test 'test_05_repeated_reqs_work.sh'
Skipping test 'test_06_http_1.0.sh'
Skipping test 'test_07_headers_work.sh'
Skipping test 'test_08_survive_signals.sh'
Skipping test 'test_09_curl_happy_with_trailers.sh'
Skipping test 'test_10_connection_drop_in_body_ok.sh'
Skipping test 'test_11_res_body_streaming.sh'
Skipping test 'test_12_headers_too_large.sh'
Skipping test 'test_13_http_pipelining.sh'
Skipping test 'test_14_strict_mode_assertion.sh'
Skipping test 'test_15_post_in_chunked_encoding.sh'
Skipping test 'test_16_tcp_client_ip.sh'
Skipping test 'test_17_serve_massive_sparse_file.sh'
Skipping test 'test_18_close_with_no_keepalive.sh'
Skipping test 'test_19_connection_drop_while_waiting_for_response_uds.sh'
Skipping test 'test_20_connection_drop_while_waiting_for_response_tcp.sh'
Skipping test 'test_21_connection_reset_tcp.sh'
Skipping test 'test_22_http_1.0_keep_alive.sh'
Skipping test 'test_23_repeated_reqs_with_half_closure.sh'
Skipping test 'test_24_http_over_stdio.sh'
Running test suite 'tests_02_syscall_wrappers'
Running test 'test_01_syscall_wrapper_fast.sh'... OK (15s)
Running test 'test_02_blacklisted_errnos.sh'... OK (8s)
Running test suite 'tests_03_linker_things'
Skipping test 'test_01_check_we_do_not_link_Foundation.sh'
Running test suite 'tests_04_performance'
Skipping test 'test_01_allocation_counts.sh'
Running test suite 'tests_05_assertions'
Skipping test 'test_01_syscall_wrapper_fast.sh'
OK (ran 2 tests successfully)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants