diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 0b25005186..2f7c0bbed8 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -57,6 +57,6 @@ jobs: - name: Run comparisons of version specs with available Fedora packages # yamllint disable rule:line-length run: | - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f39 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f38 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f40 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f39 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions diff --git a/.packit.yaml b/.packit.yaml index cf30df4a2f..eb5942eeb9 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -12,14 +12,15 @@ actions: post-upstream-clone: - "git clone https://github.com/stratis-storage/ci --depth=1 ../distro" - "mv ../distro/mockbuild_test/stratisd.spec ../distro/stratisd.spec" - - "cargo install cargo-version-util" + - "sed -i '/stratis-decode-dm/d' ../distro/stratisd.spec" + - "cargo install cargo-get" - "cargo install cargo-vendor-filterer" create-archive: - "sh -c 'python3 ../distro/release_management/create_artifacts.py ../distro/ --pre-release --specfile-path=../distro/stratisd.spec stratisd --vendor-method=filtered'" fix-spec-file: - "echo 'skipping automatic fix-spec-file actions'" get-current-version: - - "cargo version-util get-version" + - "cargo get package.version" srpm_build_deps: - git diff --git a/CHANGES.txt b/CHANGES.txt index 7d16584851..1183f3a1b9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,42 @@ +stratisd 3.6.6 +============== +Recommended Rust toolchain version: 1.76.0 +Recommended development platform for Python development: Fedora 39 + +* New commits: + * Increase lower bounds of Stratis-project dependencies + * Increase mio transitive dependency to 0.8.11 + * Hack .packit.yaml to remove stratis-decode-dm from spec file + +* Cherry-picked commits: + * Increase retry dependency lower bound to 2.0.0 + * Increase bindgen dependency lower bound to 0.69.0 + * Update a comment justifying the minimum thin dev size + * Use a constant for the maximum name size + * Do not construct a String from metadata when saving + * Cargo.toml: Set up workspace table + * github actions: update FEDORA_RELEASE to F40, F39 + * Add serializer for Strings + * validate_name: Change error strings + * validate_name: Clarify some error messages + * Reject UserInfo values that do not satisfy validate_name + * Fix clippy::useless-vec lint + * Fix let-underscore-lock lint + * Use explicit OpenOptions::truncate() + * get_dm_init: Allow static_mut_refs + * DeviceInfo: allow clippy lint large_enum_variant + * stratisd: Allow clippy lint suspicious_open_options + * stratisd-min: Allow clippy lint suspicious_open_options + * generators: Use explicit OpenOptions::truncate() + * Allow unknown lint for static_mut_refs + * validate_filesystem_size: divisble -> divisible + * validate_filesystem_size: return more specific error + * Increase env_logger dependency lower bound to 0.11.0 + * Fix PID file bug in stratisd and stratisd-min + * Initialize devicemapper context without mutability + * Increase nix dependency lower bound to 0.28.0 + + stratisd 3.6.5 ============== Recommended Rust toolchain version: 1.76.0 diff --git a/Cargo.lock b/Cargo.lock index 8caddeca09..061912dce1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,17 +35,31 @@ dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon", + "anstyle-wincon 1.0.1", "colorchoice", "is-terminal", "utf8parse", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon 3.0.2", + "colorchoice", + "utf8parse", +] + [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -62,7 +76,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -72,7 +86,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", ] [[package]] @@ -115,16 +139,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bindgen" -version = "0.68.1" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ "bitflags 2.4.0", "cexpr", "clang-sys", + "itertools 0.12.0", "lazy_static", "lazycell", - "peeking_take_while", "proc-macro2", "quote", "regex", @@ -220,6 +244,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" version = "0.4.26" @@ -258,7 +288,7 @@ version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" dependencies = [ - "anstream", + "anstream 0.3.2", "anstyle", "bitflags 1.3.2", "clap_lex", @@ -345,16 +375,16 @@ dependencies = [ [[package]] name = "devicemapper" -version = "0.34.0" +version = "0.34.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff98688149bf6128f259f0009f98eb8ad82584aa0aae143081fdfde513d3d13" +checksum = "68d15851812d2feb80b0b51ab7d440927e4a900c16d33b154e64a2828e0d7041" dependencies = [ "bitflags 2.4.0", "devicemapper-sys", "env_logger", "lazy_static", "log", - "nix 0.26.2", + "nix 0.28.0", "rand", "retry", "semver", @@ -363,9 +393,9 @@ dependencies = [ [[package]] name = "devicemapper-sys" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734fba4d2e6b551396439ea7dd4f56980b11bb096bbf505d4a259943b228367b" +checksum = "3d6681f5413e2094480381a97b8299f548c0579f07095ee20fe58e0a28cb34b5" dependencies = [ "bindgen", ] @@ -398,17 +428,27 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" dependencies = [ + "anstream 0.6.13", + "anstyle", + "env_filter", "humantime", - "is-terminal", "log", - "regex", - "termcolor", ] [[package]] @@ -419,7 +459,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -633,7 +673,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.2", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -651,7 +691,7 @@ dependencies = [ "hermit-abi 0.3.2", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -701,9 +741,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libblkid-rs" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b43fd7c0de11a5209aff91fb625c118fc15173ae3dd0ac11e8f61a1b4d1a863" +checksum = "c4b9f67fa2e7a372994bd5be702ea51add4fbee90bfcbf1224a88806240cb8f2" dependencies = [ "either", "libblkid-rs-sys", @@ -713,9 +753,9 @@ dependencies = [ [[package]] name = "libblkid-rs-sys" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "163068067b2faf263fb2fc3daff137b45608ee185044ca849dc41438aa38e23a" +checksum = "d8e2a4facc1d764d39c5126817def019f29fca51e965db1bb826f1730c0068d8" dependencies = [ "bindgen", "cc", @@ -723,15 +763,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.149" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libcryptsetup-rs" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d2aa26d63e5289d6fac1e7e0be2e248ded9b5dfb3e2c345820d060c537d4b6" +checksum = "99a61d3782d841dca88244f582cfd95d96da9d175fb06616d50a480058647e39" dependencies = [ "bitflags 2.4.0", "either", @@ -747,9 +787,9 @@ dependencies = [ [[package]] name = "libcryptsetup-rs-sys" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20fc299fd05078d353a895d940fc463d1008d94258fc8096c095467549324707" +checksum = "c78b397341cb9aa5ddc8d11118754ed0eab4aeb9cee96ee7cbe83a7d2867b8d2" dependencies = [ "bindgen", "cc", @@ -827,9 +867,9 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "loopdev-3" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "378e7ca4e85e592564e6a96c362303972b5c7860367014383aadc10a8704fc38" +checksum = "90a97d7a5124296ee9124a815acdc3dc4a91f577b72812b3f1f99bb959b46e8d" dependencies = [ "bindgen", "errno", @@ -842,15 +882,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -868,13 +899,13 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -892,28 +923,15 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", - "memoffset 0.7.1", - "pin-utils", - "static_assertions", -] - -[[package]] -name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.0", "cfg-if 1.0.0", + "cfg_aliases", "libc", - "memoffset 0.9.0", + "memoffset", ] [[package]] @@ -954,15 +972,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pin-project-lite" @@ -1148,9 +1160,9 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "retry" -version = "1.3.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" +checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4" [[package]] name = "rustc-hash" @@ -1169,7 +1181,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1272,15 +1284,9 @@ dependencies = [ "winapi", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "stratisd" -version = "3.6.5" +version = "3.6.6" dependencies = [ "assert_cmd", "assert_matches", @@ -1308,7 +1314,8 @@ dependencies = [ "libudev", "log", "loopdev-3", - "nix 0.27.1", + "nix 0.28.0", + "once_cell", "pkg-config", "predicates", "pretty-hex", @@ -1376,16 +1383,7 @@ dependencies = [ "fastrand", "redox_syscall", "rustix", - "windows-sys", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", + "windows-sys 0.48.0", ] [[package]] @@ -1417,7 +1415,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1562,15 +1560,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1583,7 +1572,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", ] [[package]] @@ -1592,7 +1581,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", ] [[package]] @@ -1601,13 +1599,28 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -1616,38 +1629,80 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/Cargo.toml b/Cargo.toml index 5d1d623497..3a6a3e7fa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "stratisd" -version = "3.6.5" -authors = ["Stratis Developers "] -edition = "2021" -rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN +version = "3.6.6" +authors.workspace = true +edition.workspace = true +rust-version.workspace = true build = "build.rs" description = "Stratis daemon" license = "MPL-2.0" @@ -31,6 +31,14 @@ exclude = [ "/udev" ] +[workspace] +members = [".", "stratisd_proc_macros"] + +[workspace.package] +authors = ["Stratis Developers "] +edition = "2021" +rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN + [[bin]] name = "stratisd" required-features = ["engine"] @@ -90,7 +98,7 @@ version = "2.3.0" optional = true [dependencies.devicemapper] -version = "0.34.0" +version = "0.34.2" optional = true [dependencies.dbus] @@ -106,7 +114,7 @@ version = "1.6.1" optional = true [dependencies.env_logger] -version ="0.10.0" +version ="0.11.0" optional = true [dependencies.futures] @@ -126,7 +134,7 @@ version = "1.4.0" optional = true [dependencies.libblkid-rs] -version = "0.3.1" +version = "0.3.2" optional = true [dependencies.libc] @@ -134,12 +142,12 @@ version = "0.2.147" optional = true [dependencies.libcryptsetup-rs] -version = "0.9.1" +version = "0.9.3" features = ["mutex"] optional = true [dependencies.libcryptsetup-rs-sys] -version = "0.3.0" +version = "0.4.0" optional = true [dependencies.libmount] @@ -155,10 +163,14 @@ version = "0.4.19" optional = true [dependencies.nix] -version = "0.27.1" +version = "0.28.0" optional = true features = ["fs", "ioctl", "mount", "poll", "process", "sched", "signal", "socket"] +[dependencies.once_cell] +version = "1.19.0" +optional = true + [dependencies.pretty-hex] version = "0.4.1" optional = true @@ -172,7 +184,7 @@ version = "1.5.4" optional = true [dependencies.retry] -version = "1.3.1" +version = "2.0.0" default-features = false optional = true @@ -225,13 +237,13 @@ pkg-config = "0.3.18" [build-dependencies.bindgen] default_features = false features = ["runtime"] -version = "0.68.1" +version = "0.69.0" optional = true [dev-dependencies] assert_cmd = "2.0.8" assert_matches = "1.5.0" -loopdev-3 = "0.5.0" +loopdev-3 = "0.5.1" predicates = "3.0.0" proptest = "1.0.0" @@ -258,6 +270,7 @@ engine = [ "libudev", "log", "nix", + "once_cell", "rand", "regex", "retry", diff --git a/src/bin/stratis-min/stratisd-min.rs b/src/bin/stratis-min/stratisd-min.rs index c44fac79cf..35cbea64d1 100644 --- a/src/bin/stratis-min/stratisd-min.rs +++ b/src/bin/stratis-min/stratisd-min.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#![allow(deprecated)] + use std::{ env, error::Error, @@ -44,6 +46,8 @@ fn parse_args() -> Command { /// To ensure only one instance of stratisd runs at a time, acquire an /// exclusive lock. Return an error if lock attempt fails. fn trylock_pid_file() -> StratisResult { + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) @@ -59,6 +63,7 @@ fn trylock_pid_file() -> StratisResult { })?; let stratisd_min_file = match flock(f.as_raw_fd(), FlockArg::LockExclusiveNonblock) { Ok(_) => { + f.set_len(0)?; f.write_all(getpid().to_string().as_bytes())?; f } @@ -75,6 +80,8 @@ fn trylock_pid_file() -> StratisResult { } }; + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) diff --git a/src/bin/stratisd.rs b/src/bin/stratisd.rs index ca68555a50..dfbec47304 100644 --- a/src/bin/stratisd.rs +++ b/src/bin/stratisd.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#![allow(deprecated)] + use std::{ env, fs::{File, OpenOptions}, @@ -52,6 +54,8 @@ fn initialize_log(log_level: Option<&str>) { /// To ensure only one instance of stratisd runs at a time, acquire an /// exclusive lock. Return an error if lock attempt fails. fn trylock_pid_file() -> StratisResult { + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) @@ -65,6 +69,7 @@ fn trylock_pid_file() -> StratisResult { })?; let stratisd_file = match flock(f.as_raw_fd(), FlockArg::LockExclusiveNonblock) { Ok(_) => { + f.set_len(0)?; f.write_all(getpid().to_string().as_bytes())?; Ok(f) } @@ -81,6 +86,8 @@ fn trylock_pid_file() -> StratisResult { } }; + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) diff --git a/src/bin/utils/generators/lib.rs b/src/bin/utils/generators/lib.rs index a68357627a..e5768e6036 100644 --- a/src/bin/utils/generators/lib.rs +++ b/src/bin/utils/generators/lib.rs @@ -70,7 +70,11 @@ pub fn get_kernel_cmdline() -> Result>>, io:: } pub fn write_unit_file(dest: &Path, file_contents: String) -> Result<(), io::Error> { - let mut file = OpenOptions::new().write(true).create(true).open(dest)?; + let mut file = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(dest)?; file.write_all(file_contents.as_bytes())?; Ok(()) } diff --git a/src/engine/shared.rs b/src/engine/shared.rs index c52686393c..537b4c73c6 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -6,7 +6,10 @@ use std::{ collections::{hash_map::RandomState, HashMap, HashSet}, fs::File, io::Read, - os::unix::io::{FromRawFd, RawFd}, + os::{ + fd::AsFd, + unix::io::{FromRawFd, RawFd}, + }, path::{Path, PathBuf}, }; @@ -32,10 +35,17 @@ const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB #[cfg(test)] pub const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB -// xfs is planning to reject making "small" filesystems: -// https://www.spinics.net/lists/linux-xfs/msg59453.html +// Current versions of xfs now reject "small" filesystems: +// The data section of the filesystem must be at least 300 MiB. +// A Stratis imposed minimum of 512 MiB allows sufficient space for XFS +// metadata. const MIN_THIN_DEV_SIZE: Sectors = Sectors(IEC::Mi); // 512 MiB +// Linux has a maximum filename length of 255 bytes. We use this length +// as a cap on the size of the pool name also. This ensures that the name +// serialized in the pool-level metadata has a bounded length. +const MAXIMUM_NAME_SIZE: usize = 255; + /// Called when the name of a requested pool coincides with the name of an /// existing pool. Returns an error if the specifications of the requested /// pool differ from the specifications of the existing pool, otherwise @@ -118,8 +128,8 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult let bytes_read = key_file.read(memory)?; if bytes_read == MAX_STRATIS_PASS_SIZE { - let mut pollers = [PollFd::new(&key_file, PollFlags::POLLIN)]; - let num_events = poll(&mut pollers, 0)?; + let mut pollers = [PollFd::new(key_file.as_fd(), PollFlags::POLLIN)]; + let num_events = poll(&mut pollers, 0u8)?; if num_events > 0 { return Err(StratisError::Msg(format!( "Provided key exceeded maximum allow length of {}", @@ -133,28 +143,33 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult /// Validate a str for use as a Pool or Filesystem name. pub fn validate_name(name: &str) -> StratisResult<()> { + if name.is_empty() { + return Err(StratisError::Msg(format!( + "Provided string is empty: {name}" + ))); + } + if name.contains('\u{0}') { return Err(StratisError::Msg(format!( - "Name contains NULL characters: {name}" + "Provided string contains NULL characters: {name}" ))); } if name == "." || name == ".." { return Err(StratisError::Msg(format!("Name is . or .. : {name}"))); } - // Linux has a maximum filename length of 255 bytes - if name.len() > 255 { + if name.len() > MAXIMUM_NAME_SIZE { return Err(StratisError::Msg(format!( - "Name has more than 255 bytes: {name}" + "Provided string has more than {MAXIMUM_NAME_SIZE} bytes: {name}" ))); } if name.len() != name.trim().len() { return Err(StratisError::Msg(format!( - "Name contains leading or trailing space: {name}" + "Provided string contains leading or trailing space: {name}" ))); } if name.chars().any(|c| c.is_control()) { return Err(StratisError::Msg(format!( - "Name contains control characters: {name}" + "Provided string contains control characters: {name}" ))); } lazy_static! { @@ -163,19 +178,14 @@ pub fn validate_name(name: &str) -> StratisResult<()> { } if NAME_UDEVREGEX.is_match(name) { return Err(StratisError::Msg(format!( - "Name contains characters not allowed in udev symlinks: {name}" + "Provided string contains characters not allowed in udev symlinks: {name}" ))); } let name_path = Path::new(name); - if name_path.components().count() != 1 { + if name_path.components().count() > 1 || name_path.is_absolute() { return Err(StratisError::Msg(format!( - "Name is a path with 0 or more than 1 components: {name}" - ))); - } - if name_path.is_absolute() { - return Err(StratisError::Msg(format!( - "Name is an absolute path: {name}" + "Provided string is a directory path: {name}" ))); } Ok(()) @@ -208,10 +218,17 @@ pub fn validate_filesystem_size( ) -> StratisResult> { size_opt .map(|size| { + let max_size = Sectors(u64::MAX).bytes(); + if size > max_size { + return Err(StratisError::Msg(format!( + "Requested size or size limit of filesystem {name} exceeds maximum specifiable filesystem size {max_size}" + ))); + } + let size_sectors = size.sectors(); if size_sectors.bytes() != size { Err(StratisError::Msg(format!( - "Requested size or size limit of filesystem {name} must be divisble by {SECTOR_SIZE}" + "Requested size or size limit of filesystem {name} must be divisible by {SECTOR_SIZE}" ))) } else if size_sectors < MIN_THIN_DEV_SIZE { Err(StratisError::Msg(format!( diff --git a/src/engine/sim_engine/pool.rs b/src/engine/sim_engine/pool.rs index d6b7dda5c9..d16a6f4847 100644 --- a/src/engine/sim_engine/pool.rs +++ b/src/engine/sim_engine/pool.rs @@ -628,6 +628,7 @@ impl Pool for SimPool { uuid: DevUuid, user_info: Option<&str>, ) -> StratisResult> { + user_info.map(validate_name).transpose()?; Ok(self.get_mut_blockdev_internal(uuid).map_or_else( || RenameAction::NoSource, |(_, b)| { diff --git a/src/engine/strat_engine/dm.rs b/src/engine/strat_engine/dm.rs index 960e978f56..f52aeac67d 100644 --- a/src/engine/strat_engine/dm.rs +++ b/src/engine/strat_engine/dm.rs @@ -4,9 +4,11 @@ // Get ability to instantiate a devicemapper context. -use std::{path::Path, sync::Once}; +use std::path::Path; -use devicemapper::{DevId, DmNameBuf, DmOptions, DmResult, DM}; +use once_cell::sync::Lazy; + +use devicemapper::{DevId, DmError, DmNameBuf, DmOptions, DM}; use crate::{ engine::{ @@ -19,23 +21,18 @@ use crate::{ stratis::{StratisError, StratisResult}, }; -static INIT: Once = Once::new(); -static mut DM_CONTEXT: Option> = None; - /// Path to logical devices for encrypted devices pub const DEVICEMAPPER_PATH: &str = "/dev/mapper"; +pub static DM_CONTEXT: Lazy> = Lazy::new(DM::new); + pub fn get_dm_init() -> StratisResult<&'static DM> { - unsafe { - INIT.call_once(|| DM_CONTEXT = Some(DM::new())); - match &DM_CONTEXT { - Some(Ok(ref context)) => Ok(context), - Some(Err(e)) => Err(StratisError::Chained( - "Failed to initialize DM context".to_string(), - Box::new(e.clone().into()), - )), - _ => panic!("DM_CONTEXT.is_some()"), - } + match *DM_CONTEXT { + Ok(ref context) => Ok(context), + Err(ref e) => Err(StratisError::Chained( + "Failed to initialize DM context".to_string(), + Box::new(e.clone().into()), + )), } } diff --git a/src/engine/strat_engine/liminal/identify.rs b/src/engine/strat_engine/liminal/identify.rs index ca6acb08d9..b03e96122c 100644 --- a/src/engine/strat_engine/liminal/identify.rs +++ b/src/engine/strat_engine/liminal/identify.rs @@ -150,6 +150,7 @@ impl fmt::Display for StratisInfo { /// An enum type to distinguish between LUKS devices belong to Stratis and /// Stratis devices. #[derive(Debug, Eq, Hash, PartialEq)] +#[allow(clippy::large_enum_variant)] pub enum DeviceInfo { Luks(LuksInfo), Stratis(StratisInfo), diff --git a/src/engine/strat_engine/liminal/setup.rs b/src/engine/strat_engine/liminal/setup.rs index c648f38bb1..90f6e056ec 100644 --- a/src/engine/strat_engine/liminal/setup.rs +++ b/src/engine/strat_engine/liminal/setup.rs @@ -84,7 +84,7 @@ pub fn get_name(infos: HashMap) -> StratisResult>(); match get_metadata(infos)? { Some((_, pool)) => { - let v = vec![]; + let v = []; let meta_uuids = pool .backstore .data_tier diff --git a/src/engine/strat_engine/pool.rs b/src/engine/strat_engine/pool.rs index 4a8d1ee930..754a1899f0 100644 --- a/src/engine/strat_engine/pool.rs +++ b/src/engine/strat_engine/pool.rs @@ -324,8 +324,8 @@ impl StratPool { /// Write current metadata to pool members. #[pool_mutating_action("NoPoolChanges")] pub fn write_metadata(&mut self, name: &str) -> StratisResult<()> { - let data = serde_json::to_string(&self.record(name))?; - self.backstore.save_state(data.as_bytes()) + let data = serde_json::to_vec(&self.record(name))?; + self.backstore.save_state(&data) } /// Teardown a pool. @@ -433,10 +433,8 @@ impl StratPool { self.thin_pool.teardown(pool_uuid)?; let mut data = self.record(pool_name); data.started = Some(false); - let json = serde_json::to_string(&data).map_err(|e| (StratisError::from(e), false))?; - self.backstore - .save_state(json.as_bytes()) - .map_err(|e| (e, false))?; + let json = serde_json::to_vec(&data).map_err(|e| (StratisError::from(e), false))?; + self.backstore.save_state(&json).map_err(|e| (e, false))?; self.backstore.teardown(pool_uuid).map_err(|e| (e, false))?; let bds = self.backstore.drain_bds(); Ok(DeviceSet::from(bds)) @@ -1135,6 +1133,7 @@ impl Pool for StratPool { uuid: DevUuid, user_info: Option<&str>, ) -> StratisResult> { + user_info.map(validate_name).transpose()?; let result = self.backstore.set_blockdev_user_info(uuid, user_info); match result { Ok(Some(uuid)) => { @@ -1378,6 +1377,7 @@ mod tests { .unwrap(); OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(&new_file) .unwrap() @@ -1686,6 +1686,7 @@ mod tests { let mut f = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); @@ -1761,6 +1762,7 @@ mod tests { let mut f = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); diff --git a/src/engine/strat_engine/serde_structs.rs b/src/engine/strat_engine/serde_structs.rs index f77693509a..2e41b970f0 100644 --- a/src/engine/strat_engine/serde_structs.rs +++ b/src/engine/strat_engine/serde_structs.rs @@ -12,12 +12,58 @@ // can convert to or from them when saving our current state, or // restoring state from saved metadata. -use serde::Serialize; +use serde::{Serialize, Serializer}; use devicemapper::{Sectors, ThinDevId}; use crate::engine::types::{DevUuid, FilesystemUuid}; +const MAXIMUM_STRING_SIZE: usize = 255; + +// Find the largest index which occurs on a char boundary of value which is no +// greater than len. +// TODO: Replace this method with String::floor_char_boundary when +// possible. +fn our_floor_char_boundary(value: &str, len: usize) -> usize { + let len = std::cmp::min(len, value.len()); + + let mut new_index = len; + while !value.is_char_boundary(new_index) && new_index != 0 { + new_index -= 1; + } + + new_index +} + +// Return a new String, split at the highest index which lies on a char +// boundary of value which is no greater than len. +fn safe_split_at(value: &str, len: usize) -> &str { + value.split_at(our_floor_char_boundary(value, len)).0 +} + +// Serialize a string. Only the first MAXIMUM_STRING_SIZE bytes of the string +// are serialized. +fn serialize_string(value: &str, serializer: S) -> Result +where + S: Serializer, +{ + str::serialize(safe_split_at(value, MAXIMUM_STRING_SIZE), serializer) +} + +// Serialize an optional string. Only the first MAXIMUM_STRING_SIZE bytes of +// the string are serialized. +fn serialize_option_string(value: &Option, serializer: S) -> Result +where + S: Serializer, +{ + Option::serialize( + &value + .as_ref() + .map(|v| safe_split_at(v, MAXIMUM_STRING_SIZE)), + serializer, + ) +} + /// Implements saving struct data to a serializable form. The form should be /// sufficient, in conjunction with the environment, to reconstruct the /// saved struct in all its essentials. @@ -31,6 +77,7 @@ pub trait Recordable { // some duplicate type definitions which are obviously not defined twice. #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct PoolSave { + #[serde(serialize_with = "serialize_string")] pub name: String, pub backstore: BackstoreSave, pub flex_devs: FlexDevsSave, @@ -70,8 +117,10 @@ pub struct BaseDevSave { pub struct BaseBlockDevSave { pub uuid: DevUuid, #[serde(skip_serializing_if = "Option::is_none")] + #[serde(serialize_with = "serialize_option_string")] pub user_info: Option, #[serde(skip_serializing_if = "Option::is_none")] + #[serde(serialize_with = "serialize_option_string")] pub hardware_info: Option, } @@ -112,6 +161,7 @@ pub struct ThinPoolDevSave { // by stratisd. #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct FilesystemSave { + #[serde(serialize_with = "serialize_string")] pub name: String, pub uuid: FilesystemUuid, pub thin_id: ThinDevId, @@ -120,3 +170,23 @@ pub struct FilesystemSave { #[serde(skip_serializing_if = "Option::is_none")] pub fs_size_limit: Option, } + +#[cfg(test)] +mod tests { + use super::safe_split_at; + proptest! { + #[test] + /// Check safe splitting on random strings. + fn test_split(s in "\\PC*", index in 0..10usize) { + let result = safe_split_at(&s, s.len().saturating_sub(index)); + prop_assert_eq!(s.find(result), Some(0)); + // A UTF8 String character requires at most 4 bytes. + prop_assert!(s.len() - result.len() <= index + 3); + + prop_assert!((index == 0 || s.is_empty()) || result.len() < s.len()); + prop_assert!(result.len() != s.len() || (index == 0 || s.is_empty())); + prop_assert!(result.is_char_boundary(result.len())); + + } + } +} diff --git a/src/engine/strat_engine/tests/loopbacked.rs b/src/engine/strat_engine/tests/loopbacked.rs index ae6229874e..2fbcc96c50 100644 --- a/src/engine/strat_engine/tests/loopbacked.rs +++ b/src/engine/strat_engine/tests/loopbacked.rs @@ -54,6 +54,7 @@ impl LoopTestDev { .read(true) .write(true) .create(true) + .truncate(true) .open(path) .unwrap(); diff --git a/src/engine/strat_engine/thinpool/mdv.rs b/src/engine/strat_engine/thinpool/mdv.rs index 56687f950a..70da2b8825 100644 --- a/src/engine/strat_engine/thinpool/mdv.rs +++ b/src/engine/strat_engine/thinpool/mdv.rs @@ -110,7 +110,7 @@ impl MetadataVol { uuid: FilesystemUuid, fs: &StratFilesystem, ) -> StratisResult<()> { - let data = serde_json::to_string(&fs.record(name, uuid))?; + let data = serde_json::to_vec(&fs.record(name, uuid))?; let path = self .mount_pt .join(FILESYSTEM_DIR) @@ -123,9 +123,10 @@ impl MetadataVol { let mut mdv_record_file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(&temp_path)?; - mdv_record_file.write_all(data.as_bytes())?; + mdv_record_file.write_all(&data)?; // This ultimately results in an fsync() on the file. mdv_record_file.sync_all()?; } @@ -191,17 +192,16 @@ impl MetadataVol { /// Tear down a Metadata Volume. pub fn teardown(&mut self, pool_uuid: PoolUuid) -> StratisResult<()> { - if let Err(e) = retry_with_index(Fixed::from_millis(100).take(2), |i| { - trace!("MDV unmount attempt {}", i); - umount(&self.mount_pt) - }) { - return Err(match e { - retry::Error::Internal(msg) => StratisError::Msg(msg), - retry::Error::Operation { error, .. } => StratisError::Chained( - "Failed to unmount MDV".to_string(), - Box::new(StratisError::from(error)), - ), - }); + if let Err(retry::Error { error, .. }) = + retry_with_index(Fixed::from_millis(100).take(2), |i| { + trace!("MDV unmount attempt {}", i); + umount(&self.mount_pt) + }) + { + return Err(StratisError::Chained( + "Failed to unmount MDV".to_string(), + Box::new(StratisError::from(error)), + )); } if let Err(err) = remove_dir(&self.mount_pt) { @@ -266,17 +266,16 @@ impl Drop for MetadataVol { }; if mtpt_stat.st_dev != parent_stat.st_dev { - if let Err(e) = retry_with_index(Fixed::from_millis(100).take(2), |i| { - trace!("MDV unmount attempt {}", i); - umount(mount_pt) - }) { - Err(match e { - retry::Error::Internal(msg) => StratisError::Msg(msg), - retry::Error::Operation { error, .. } => StratisError::Chained( - "Failed to unmount MDV".to_string(), - Box::new(StratisError::from(error)), - ), + if let Err(retry::Error { error, .. }) = + retry_with_index(Fixed::from_millis(100).take(2), |i| { + trace!("MDV unmount attempt {}", i); + umount(mount_pt) }) + { + Err(StratisError::Chained( + "Failed to unmount MDV".to_string(), + Box::new(StratisError::from(error)), + )) } else { Ok(()) } diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index df7f446cb7..d3b58f8889 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1947,6 +1947,7 @@ mod tests { convert_test!(IEC::Mi, u64, usize), OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(file_path) .unwrap(), @@ -2095,6 +2096,7 @@ mod tests { convert_test!(IEC::Mi, u64, usize), OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(file_path) .unwrap(), @@ -2268,6 +2270,7 @@ mod tests { writeln!( &OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(), @@ -2478,6 +2481,7 @@ mod tests { .unwrap(); OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(&new_file) .unwrap() @@ -2602,6 +2606,7 @@ mod tests { .unwrap(); let mut file = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); diff --git a/src/engine/structures/lock.rs b/src/engine/structures/lock.rs index a849a28b9b..201dc1120b 100644 --- a/src/engine/structures/lock.rs +++ b/src/engine/structures/lock.rs @@ -516,7 +516,7 @@ where /// This counter performs wrapping addition so the maximum number of futures supported by /// this lock is u64::MAX. fn next_idx(&self) -> u64 { - let (mut lock_record, _) = self.acquire_mutex(); + let (mut lock_record, _unused) = self.acquire_mutex(); let idx = lock_record.next_idx; lock_record.next_idx = lock_record.next_idx.wrapping_add(1); idx diff --git a/src/jsonrpc/client/key.rs b/src/jsonrpc/client/key.rs index 03497fde11..77372b72c9 100644 --- a/src/jsonrpc/client/key.rs +++ b/src/jsonrpc/client/key.rs @@ -25,7 +25,7 @@ pub fn key_set(key_desc: KeyDescription, keyfile_path: Option<&str>) -> StratisR let (read_end, write_end) = pipe()?; write(write_end, password.as_bytes())?; - do_request!(KeySet, key_desc; read_end) + do_request!(KeySet, key_desc; read_end.as_raw_fd()) } }; if rc != 0 { diff --git a/src/jsonrpc/client/pool.rs b/src/jsonrpc/client/pool.rs index 76766889b4..d85a56096c 100644 --- a/src/jsonrpc/client/pool.rs +++ b/src/jsonrpc/client/pool.rs @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use std::path::PathBuf; +use std::{os::fd::AsRawFd, path::PathBuf}; use nix::unistd::{pipe, write}; @@ -37,7 +37,7 @@ pub fn pool_start( do_request_standard!(PoolStart, id, unlock_method; { let (read_end, write_end) = pipe()?; write(write_end, password.as_bytes())?; - read_end + read_end.as_raw_fd() }) } else { do_request_standard!(PoolStart, id, unlock_method) diff --git a/src/jsonrpc/server/server.rs b/src/jsonrpc/server/server.rs index c13ff90f90..3386ca6d80 100644 --- a/src/jsonrpc/server/server.rs +++ b/src/jsonrpc/server/server.rs @@ -22,8 +22,8 @@ use futures::{ use nix::{ fcntl::{fcntl, FcntlArg, OFlag}, sys::socket::{ - accept, bind, listen, recvmsg, sendmsg, socket, AddressFamily, ControlMessageOwned, - MsgFlags, SockFlag, SockType, UnixAddr, + accept, bind, listen, recvmsg, sendmsg, socket, AddressFamily, Backlog, + ControlMessageOwned, MsgFlags, SockFlag, SockType, UnixAddr, }, unistd::close, }; @@ -444,7 +444,7 @@ impl StratisUnixListener { })?; fcntl(fd.as_raw_fd(), FcntlArg::F_SETFL(flags | OFlag::O_NONBLOCK))?; bind(fd.as_raw_fd(), &UnixAddr::new(path.as_ref())?)?; - listen(&fd, 0)?; + listen(&fd, Backlog::new(0).expect("0 is always valid"))?; Ok(StratisUnixListener { fd: AsyncFd::new(fd)?, }) diff --git a/src/stratis/udev_monitor.rs b/src/stratis/udev_monitor.rs index a840e9631e..99d1b17226 100644 --- a/src/stratis/udev_monitor.rs +++ b/src/stratis/udev_monitor.rs @@ -33,8 +33,8 @@ pub async fn udev_thread( loop { - let mut pollers = [PollFd::new(&udev, PollFlags::POLLIN)]; - match poll(&mut pollers, 100)? { + let mut pollers = [PollFd::new(udev.as_fd(), PollFlags::POLLIN)]; + match poll(&mut pollers, 100u8)? { 0 => { match should_exit.try_recv() { Ok(()) => { diff --git a/stratisd_proc_macros/Cargo.toml b/stratisd_proc_macros/Cargo.toml index e8327a185b..64987b7611 100644 --- a/stratisd_proc_macros/Cargo.toml +++ b/stratisd_proc_macros/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "stratisd_proc_macros" version = "0.2.1" -authors = ["Stratis Developers "] -edition = "2021" -rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN +authors.workspace = true +edition.workspace = true +rust-version.workspace = true description = "Stratis daemon procedural macros" license = "MPL-2.0" repository = "https://github.com/stratis-storage/stratisd/"