diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1591c9..0684428 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,12 +10,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@v19 + - uses: actions/checkout@v5 + - uses: DeterminateSystems/nix-installer-action@v20 with: diagnostic-endpoint: "" source-url: "https://install.lix.systems/lix/lix-installer-x86_64-linux" - - uses: DeterminateSystems/magic-nix-cache-action@v4 + - uses: DeterminateSystems/magic-nix-cache-action@v13 with: diagnostic-endpoint: "" - run: nix flake check --log-format raw-with-logs -L diff --git a/flake.lock b/flake.lock index 6cb0c51..9213f9d 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { @@ -23,11 +23,11 @@ ] }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "4524271976b625a4a605beefd893f270620fd751", "type": "github" }, "original": { @@ -59,11 +59,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725432240, - "narHash": "sha256-+yj+xgsfZaErbfYM3T+QvEE2hU7UuE+Jf0fJCJ8uPS0=", + "lastModified": 1757745802, + "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ad416d066ca1222956472ab7d0555a6946746a80", + "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", "type": "github" }, "original": { @@ -73,22 +73,6 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1720386169, - "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -97,15 +81,14 @@ "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" + ] }, "locked": { - "lastModified": 1725513492, - "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", + "lastModified": 1757588530, + "narHash": "sha256-tJ7A8mID3ct69n9WCvZ3PzIIl3rXTdptn/lZmqSS95U=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", + "rev": "b084b2c2b6bc23e83bbfe583b03664eb0b18c411", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e628a64..40d8cf7 100644 --- a/flake.nix +++ b/flake.nix @@ -76,7 +76,7 @@ userborn-mutable-users userborn-mutable-etc userborn-immutable-users - userborn-immutable-etc + # userborn-immutable-etc # currently broken on master ; }; diff --git a/rust/userborn/Cargo.lock b/rust/userborn/Cargo.lock index c6307ee..192bfe2 100644 --- a/rust/userborn/Cargo.lock +++ b/rust/userborn/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" [[package]] name = "cexpr" @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "clang-sys" @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f8e79d1fbf76bdfbde321e902714bf6c49df88a7dda6fc682fc2979226962d" +checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921" [[package]] name = "either" @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "indoc" @@ -139,15 +139,15 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", "windows-targets", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "memchr" @@ -183,15 +183,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "prettyplease" -version = "0.2.31" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", "syn", @@ -199,9 +199,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -217,9 +217,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" dependencies = [ "aho-corasick", "memchr", @@ -229,9 +229,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" dependencies = [ "aho-corasick", "memchr", @@ -240,9 +240,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" [[package]] name = "rustc-hash" @@ -258,18 +258,28 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.223" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a505d71960adde88e293da5cb5eda57093379f64e61cf77bf0e6a63af07a7bac" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.223" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "20f57cbd357666aa7b3ac84a90b4ea328f1d4ddb6772b430caa5d9e1309bb9e9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.223" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "3d428d07faf17e306e699ec1e91996e5a165ba5d6bce5b5155173e91a8a01a56" dependencies = [ "proc-macro2", "quote", @@ -278,14 +288,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -296,9 +307,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -307,9 +318,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" [[package]] name = "userborn" @@ -325,12 +336,19 @@ dependencies = [ "xcrypt", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-targets" -version = "0.52.6" +version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ + "windows-link", "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", @@ -343,51 +361,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" [[package]] name = "windows_i686_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" [[package]] name = "windows_i686_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "xcrypt" diff --git a/rust/userborn/Cargo.toml b/rust/userborn/Cargo.toml index 6f60fff..541279e 100644 --- a/rust/userborn/Cargo.toml +++ b/rust/userborn/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" [dependencies] anyhow = "1.0.99" -log = "0.4.27" -serde = { version = "1.0.219", features = [ "derive" ] } -serde_json = "1.0.142" +log = "0.4.28" +serde = { version = "1.0.223", features = [ "derive" ] } +serde_json = "1.0.145" env_logger = { version = "0.11.8", default-features = false } xcrypt = "0.3.1" diff --git a/rust/userborn/src/fs.rs b/rust/userborn/src/fs.rs index cbd2907..d82b666 100644 --- a/rust/userborn/src/fs.rs +++ b/rust/userborn/src/fs.rs @@ -2,10 +2,10 @@ use std::{fs, io::Write, os::unix::fs::OpenOptionsExt, path::Path}; use anyhow::{Context, Result}; -/// Atomicaly write a buffer into a file. +/// Atomically write a buffer into a file. /// /// This will first write the buffer to the path with a `.tmp` suffix and then move the file to -/// it's actual path. +/// its actual path. /// /// This increases the atomicity of the write. pub fn atomic_write(path: impl AsRef, buffer: impl AsRef<[u8]>, mode: u32) -> Result<()> { @@ -25,7 +25,10 @@ pub fn atomic_write(path: impl AsRef, buffer: impl AsRef<[u8]>, mode: u32) Ok(file) => break (file, tmp_path), Err(err) => { if err.kind() != std::io::ErrorKind::AlreadyExists { - return Err(err).context(format!("Failed to open temporary file {tmp_path:?}")); + return Err(err).context(format!( + "Failed to open temporary file {}", + tmp_path.display() + )); } } } @@ -33,12 +36,17 @@ pub fn atomic_write(path: impl AsRef, buffer: impl AsRef<[u8]>, mode: u32) }; file.write_all(buffer.as_ref()) - .with_context(|| format!("Failed to write to {tmp_path:?}"))?; + .with_context(|| format!("Failed to write to {}", tmp_path.display()))?; file.sync_all() - .with_context(|| format!("Failed to sync the temporary file {tmp_path:?}"))?; + .with_context(|| format!("Failed to sync the temporary file {}", tmp_path.display()))?; - fs::rename(&tmp_path, &path) - .with_context(|| format!("Failed to rename {tmp_path:?} to {:?}", path.as_ref()))?; + fs::rename(&tmp_path, &path).with_context(|| { + format!( + "Failed to rename {} to {}", + tmp_path.display(), + path.as_ref().display() + ) + })?; Ok(()) } diff --git a/rust/userborn/src/group.rs b/rust/userborn/src/group.rs index d9eb364..ca1dc2a 100644 --- a/rust/userborn/src/group.rs +++ b/rust/userborn/src/group.rs @@ -103,7 +103,7 @@ pub struct Group { impl Group { pub fn from_file(path: impl AsRef) -> Result { let file = fs::read_to_string(path.as_ref()) - .with_context(|| format!("Failed to read {:?}.", path.as_ref()))?; + .with_context(|| format!("Failed to read {}.", path.as_ref().display()))?; Ok(Self::from_buffer(&file)) } diff --git a/rust/userborn/src/id.rs b/rust/userborn/src/id.rs index 3e67e61..8228409 100644 --- a/rust/userborn/src/id.rs +++ b/rust/userborn/src/id.rs @@ -22,8 +22,8 @@ pub fn allocate(already_allocated_ids: &BTreeSet, is_normal: bool) -> Resul return Ok(candidate); } } - }; - bail!("Failed to allocated new UID") + } + bail!("Failed to allocated new UID/GID") } #[cfg(test)] diff --git a/rust/userborn/src/main.rs b/rust/userborn/src/main.rs index b5eb8ab..c03a5d3 100644 --- a/rust/userborn/src/main.rs +++ b/rust/userborn/src/main.rs @@ -22,7 +22,7 @@ use shadow::Shadow; /// This is used when `USERBORN_NO_LOGIN_PATH` is not set during runtime and /// `USERBORN_NO_LOGIN_DEFAULT_PATH` hasn't been set during compilation. const NO_LOGIN_FALLBACK: &str = "/run/current-system/sw/bin/nologin"; -/// Default path to the nolign binary. +/// Default path to the nologin binary. /// /// This can be configured via a compile-time environment variable. const NO_LOGIN_DEFAULT: Option<&'static str> = option_env!("USERBORN_NO_LOGIN_DEFAULT_PATH"); @@ -79,7 +79,7 @@ fn run() -> Result<()> { log::debug!("Persisting files to disk..."); // We should skip this if the files haven't actually changed - // We should create backup files with an `-` appended to the file name. + // We should create backup files with an `-` appended to the filename. group_db.to_file(group_path)?; passwd_db.to_file(passwd_path)?; shadow_db.to_file_sorted(&passwd_db, shadow_path)?; @@ -105,7 +105,7 @@ fn update_users_and_groups( existing_entry.update(group_config.members.clone()); } else if let Err(e) = create_group(group_config, group_db) { log::error!("Failed to create group {}: {e:#}", group_config.name); - }; + } } let mut users_in_config: BTreeSet<&str> = BTreeSet::new(); @@ -120,10 +120,10 @@ fn update_users_and_groups( if let Some(existing_entry) = passwd_db.get_mut(&user_config.name) { if let Err(e) = update_user(existing_entry, user_config, group_db, shadow_db) { log::error!("Failed to update user {}: {e:#}", user_config.name); - }; + } } else if let Err(e) = create_user(user_config, group_db, passwd_db, shadow_db) { log::error!("Failed to create user {}: {e:#}", user_config.name); - }; + } } // Find groups in the DB that are not in the config and empty them. @@ -133,7 +133,7 @@ fn update_users_and_groups( entry.update(BTreeSet::from([entry.name().to_owned()])); } else { entry.update(BTreeSet::new()); - }; + } } } @@ -320,7 +320,7 @@ fn ensure_shadow(user_config: &config::User, shadow_db: &mut Shadow) -> Result<( user_config.name ) })?; - }; + } Ok(()) } diff --git a/rust/userborn/src/passwd.rs b/rust/userborn/src/passwd.rs index 423a558..7d8c204 100644 --- a/rust/userborn/src/passwd.rs +++ b/rust/userborn/src/passwd.rs @@ -62,7 +62,7 @@ impl Entry { self.gid, ); self.gid = gid; - }; + } } if let Some(gecos) = gecos { if self.gecos != gecos { @@ -72,7 +72,7 @@ impl Entry { self.gecos, ); self.gecos = gecos; - }; + } } if let Some(directory) = directory { if self.directory != directory { @@ -92,7 +92,7 @@ impl Entry { self.shell, ); self.shell = shell; - }; + } } } @@ -149,7 +149,7 @@ pub struct Passwd { impl Passwd { pub fn from_file(path: impl AsRef) -> Result { let file = fs::read_to_string(path.as_ref()) - .with_context(|| format!("Failed to read {:?}.", path.as_ref()))?; + .with_context(|| format!("Failed to read {}.", path.as_ref().display()))?; Ok(Self::from_buffer(&file)) } diff --git a/rust/userborn/src/password.rs b/rust/userborn/src/password.rs index 8d070c8..232d7ea 100644 --- a/rust/userborn/src/password.rs +++ b/rust/userborn/src/password.rs @@ -79,7 +79,7 @@ impl HashedPassword { /// actual password hasn't changed. /// /// This function doesn't need to be particularly secure since the original password cannot be -/// treated as secure as it's passed via a plaintxt config. This is, e.g. why it doesn't zeroize +/// treated as secure as it's passed via a plaintext config. This is, e.g. why it doesn't zeroize /// the buffer. /// /// It only serves to convert a non-secret raw password into a format that is understood by @@ -125,7 +125,7 @@ mod tests { assert!(s.starts_with("$y$")); } else { bail!("Wrong HashedPassword variant") - }; + } Ok(()) } diff --git a/rust/userborn/src/shadow.rs b/rust/userborn/src/shadow.rs index 536aa98..85ca490 100644 --- a/rust/userborn/src/shadow.rs +++ b/rust/userborn/src/shadow.rs @@ -45,8 +45,8 @@ impl Entry { if self.password != password { log::info!("Updating password of user {}...", self.name,); self.password = password; - }; - }; + } + } } /// Lock the account by resetting its password. @@ -111,7 +111,7 @@ pub struct Shadow(BTreeMap); impl Shadow { pub fn from_file(path: impl AsRef) -> Result { let file = fs::read_to_string(path.as_ref()) - .with_context(|| format!("Failed to read {:?}.", path.as_ref()))?; + .with_context(|| format!("Failed to read {}.", path.as_ref().display()))?; Ok(Self::from_buffer(&file)) } @@ -150,7 +150,7 @@ impl Shadow { } else { // This should only happen if the DB was somehow manually tampered with. log::warn!("Passwd DB contains entry for {name} that is not in Shadow DB"); - }; + } } s }