Repository navigation
Delegate resource reading to embedder - #20533
Conversation
|
Heads up! This PR modifies the following files:
|
1cc07ad to
48f2222
Compare
|
Note to self:
|
|
eb91969 fixes the sandboxing issues. |
|
Tested on Android and Mac. Sandboxing has been tested too. |
|
@mbrubeck r? |
|
(fixed the Windows failure) |
| buffer | ||
| } | ||
| fn sandbox_access_files_rec(&self) -> Vec<PathBuf> { | ||
| vec![resources_dir_path().expect("Can't find resources directory")] |
There was a problem hiding this comment.
If this just returns paths to top-level directories (rather than recursively iterating over the files inside those directories), maybe it should be renamed to sandox_access_files_dirs.
| shared_lock: &SharedRwLock, | ||
| filename: &'static str, | ||
| filename: &str, | ||
| content: String, |
There was a problem hiding this comment.
This could take Vec<u8> or &[u8] instead, and then the callers could use read_bytes instead of read_string to avoid needless UTF-8 validation.
mbrubeck
left a comment
There was a problem hiding this comment.
Looks good overall. Some minor suggestions/concerns below.
| path.push(file); | ||
| let mut buffer = vec![]; | ||
| File::open(path).expect(&format!("Can't find file: {}", file)) | ||
| .read_to_end(&mut buffer).expect("Can't read file"); |
There was a problem hiding this comment.
This could use the new std::fs::read which pre-allocates a buffer.
| let mut txt = String::new(); | ||
| let mut file = File::open(PathBuf::from(path)) | ||
| .expect("Couldn't not find certificate file"); | ||
| file.read_to_string(&mut txt).expect("Cant read certificate"); |
| ssl_connector_builder.set_ca_file(ca_file).expect("could not set CA file"); | ||
| loop { | ||
| if let Some(index) = certs.rfind("-----BEGIN CERTIFICATE-----") { | ||
| let cert = certs.split_off(index); |
There was a problem hiding this comment.
We could avoid allocating and copying here, by keeping cert as &str instead of String, and doing:
let (cert, rest) = certs.split_at(i);
certs = rest;| } | ||
| }).expect("could not set CA file"); | ||
| } else { | ||
| break; |
There was a problem hiding this comment.
It looks like this might skip the last certificate in the file, because it's not followed by a BEGIN CERTIFICATE line.
There was a problem hiding this comment.
I use END CERTIFICATE now.
| // but if any of them were already added, openssl would fail to insert all | ||
| // of them. | ||
| let mut ssl_connector_builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); | ||
| ssl_connector_builder.set_ca_file(ca_file).expect("could not set CA file"); |
There was a problem hiding this comment.
Maybe we should add a function to the openssl crate that takes the certificate file contents as a string. Then we could continue to let OpenSSL do the parsing here.
There was a problem hiding this comment.
It already has a method to parse the whole certs file, but it's a "all or non" operation (not like the previous method we were passing a file instead of a buffer). If it fails to load one of the certificate, they are all rejected. And in our case, it might fail because some certificates were already registered (so it's fine to ignore the error). So if we were to improve the Rust OpenSSL API, we should allow OpenSSL to ignore the duplicate error.
I can file a bug for that. Sounds to me that it's a OpenSSL issue, not a Rust OpenSSL problem though.
|
(comments addressed) |
|
@bors-servo r+ |
|
📌 Commit eced418 has been approved by |
Delegate resource reading to embedder Now the embedder provides the content of the files itself. Now, on Android, we can use regular assets instead of unzipping all the resources on the scared at startup. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15635 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20533) <!-- Reviewable:end -->
|
💔 Test failed - linux-dev |
Delegate resource reading to embedder Now the embedder provides the content of the files itself. Now, on Android, we can use regular assets instead of unzipping all the resources on the scared at startup. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15635 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20533) <!-- Reviewable:end -->
|
💔 Test failed - mac-rel-css1 |
|
@bors-servo retry
|
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-wpt, mac-dev-unit, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt3, windows-msvc-dev are reusable. Rebuilding only linux-rel-css, mac-rel-css1, mac-rel-wpt2, mac-rel-wpt4... |
|
@bors-servo retry force |
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt3, windows-msvc-dev are reusable. Rebuilding only mac-rel-wpt2, mac-rel-wpt4... |
|
⛄ The build was interrupted to prioritize another pull request. |
|
Sorry again @paulrouget, Homu was sitting on its hands doing nothing. @bors-servo p=1 |
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt3, windows-msvc-dev are reusable. Rebuilding only mac-rel-wpt2, mac-rel-wpt4... |
|
💔 Test failed - mac-rel-wpt2 |
|
@paulrouget CI is still a bit foobar'd. Please don't retry this, I'll do it myself once I know it can build without constant attention. |
|
@bors-servo r=mbrubeck |
|
💡 This pull request was already approved, no need to approve it again.
|
|
📌 Commit 9fb5795 has been approved by |
Delegate resource reading to embedder Now the embedder provides the content of the files itself. Now, on Android, we can use regular assets instead of unzipping all the resources on the scared at startup. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [ ] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15635 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20533) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Now the embedder provides the content of the files itself. Now, on Android, we can use regular assets instead of unzipping all the resources on the scared at startup.
./mach build -ddoes not report any errors./mach build-geckolibdoes not report any errors./mach test-tidydoes not report any errorsThis change is