-
Notifications
You must be signed in to change notification settings - Fork 281
build and test on FreeBSD #705
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| name: FreeBSD | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "master" ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build and Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - name: Build and test in a FreeBSD VM | ||
| uses: vmactions/freebsd-vm@v1 | ||
| timeout-minutes: 90 | ||
| with: | ||
| release: '15' | ||
| usesh: true | ||
| copyback: false | ||
| cache-after-prepare: true | ||
|
|
||
| prepare: | | ||
| pkg install -y git pkgconf rust protobuf llvm fusefs-libs3 | ||
|
|
||
| run: | | ||
| set -e | ||
|
|
||
| # protobuf provides protoc, which build.rs falls back to because | ||
| # protoc-bin-vendored ships no FreeBSD binary. llvm provides the | ||
| # libclang bindgen needs, and fusefs-libs3 the fuse3.pc that | ||
| # libfuse-sys probes for. | ||
| rustc --version | ||
| pkg-config --modversion fuse3 | ||
|
|
||
| # fusefs is a loadable module, not compiled into GENERIC, so | ||
| # /dev/fuse only exists once it is loaded. | ||
| kldstat -q -n fusefs.ko || kldload fusefs | ||
|
|
||
| cargo clippy --all-targets --all-features -- -D warnings | ||
|
|
||
| cargo build --release | ||
|
|
||
| cargo test --release | ||
|
|
||
| ENCFS_LIVE_TESTS=1 cargo test --release --test live_mount -- --ignored --test-threads=1 | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| //! On-disk naming for encfs's encrypted extended attributes. | ||
| //! | ||
| //! Each attribute is stored under [`PREFIX`] followed by the base64 of its | ||
| //! encrypted name. [`PREFIX`] carries the `user.` namespace; that is part of | ||
| //! the stored name on Linux and macOS, but on FreeBSD the `extattr_*` | ||
| //! syscalls pass it out-of-band and the backing file records only | ||
| //! `encfs.<b64>`. The standard base64 alphabet includes `/`, which FreeBSD | ||
| //! will not accept in an extended-attribute name: `setextattr(8)` fails with | ||
| //! `EINVAL` on a name containing one, while the same name spelled with `+` | ||
| //! or `=` is stored without complaint. Two of the six distinct names the | ||
| //! xattr tests here produce contain a `/`, so a third of attributes could | ||
| //! not be stored on FreeBSD at all. | ||
| //! | ||
| //! New names therefore use the URL-safe alphabet, which spells the two | ||
| //! disputed characters `-` and `_`. Reading accepts either. The alphabets | ||
| //! differ only in those four characters, so a string that decodes under both | ||
| //! contains none of them and yields the same bytes either way: trying one and | ||
| //! then the other cannot return the wrong plaintext. [`encode_legacy`] | ||
| //! reproduces the older spelling so a lookup can fall back to it. | ||
| //! | ||
| //! Only this port is affected. The C++ encfs passed attribute names through | ||
| //! to the backing file unchanged; encrypting and encoding them arrived with | ||
| //! the Rust port. Filenames are unrelated -- they use the cipher's own | ||
| //! alphabet, not this one. | ||
|
|
||
| use base64::Engine; | ||
| use base64::engine::general_purpose::{STANDARD_NO_PAD, URL_SAFE_NO_PAD}; | ||
|
|
||
| /// Prefix encfs uses for a stored (encrypted) attribute name. | ||
| pub const PREFIX: &str = "user.encfs."; | ||
|
|
||
| /// The on-disk name for an encrypted attribute name. | ||
| pub fn encode(encrypted_name: &[u8]) -> String { | ||
| format!("{}{}", PREFIX, URL_SAFE_NO_PAD.encode(encrypted_name)) | ||
| } | ||
|
|
||
| /// The on-disk name a build from before the alphabet change would have | ||
| /// written. Identical to [`encode`] whenever the encoding happens to use none | ||
| /// of the characters the two alphabets disagree on. | ||
| pub fn encode_legacy(encrypted_name: &[u8]) -> String { | ||
| format!("{}{}", PREFIX, STANDARD_NO_PAD.encode(encrypted_name)) | ||
| } | ||
|
|
||
| /// Decode the base64 part of a stored name, accepting either alphabet. | ||
| pub fn decode(encoded: &str) -> Option<Vec<u8>> { | ||
| URL_SAFE_NO_PAD | ||
| .decode(encoded) | ||
| .or_else(|_| STANDARD_NO_PAD.decode(encoded)) | ||
| .ok() | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| /// Encodes to `///8` under the standard alphabet and `___8` under the | ||
| /// URL-safe one, so it exercises exactly the disagreement. | ||
| const DISPUTED: &[u8] = &[0xFF, 0xFF, 0xFC]; | ||
|
|
||
| #[test] | ||
| fn new_names_avoid_the_character_freebsd_rejects() { | ||
| let name = encode(DISPUTED); | ||
| assert!(!name.contains('/'), "{}", name); | ||
| // and the old spelling really did contain it, or this proves nothing | ||
| assert!(encode_legacy(DISPUTED).contains('/')); | ||
| } | ||
|
|
||
| #[test] | ||
| fn both_spellings_decode_to_the_same_bytes() { | ||
| for name in [encode(DISPUTED), encode_legacy(DISPUTED)] { | ||
| let encoded = name.strip_prefix(PREFIX).expect("prefix"); | ||
| assert_eq!(decode(encoded).expect("decodes"), DISPUTED, "{}", name); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn the_spellings_coincide_when_nothing_is_disputed() { | ||
| assert_eq!(encode(b"encfs"), encode_legacy(b"encfs")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_what_is_not_base64() { | ||
| assert!(decode("not base64!").is_none()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.