summaryrefslogtreecommitdiff
path: root/crates/fs-mistrust/src/user.rs
Commit message (Collapse)AuthorAgeFilesLines
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* fs-mistrust: Removed dependency on `once_cell`hashcatHitman2025-06-141-3/+3
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* educe: Use std's default for enums where default variant is unitIan Jackson2024-02-121-6/+4
| | | | | | | | | | | | | Since Rust 1.66, std's default works properly for enums, provided that the default variant is a unit. Review all uses of `#[educe(default)]` on enums and replace them with std where possible, which is most of them. In 1.66 and later, std's `#[derive(Default)]` doesn't infer any generic bounds on the derived impl, where it's an enum - since the unit variant can always be constructed. So this change doesn't add any generic bounds and is not API-visible.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run cargo +nightly fmt to format many let ... else ...Ian Jackson2023-07-241-4/+9
| | | | | | | | | | | rustfmt has grown opinions about how let ... else ... ought to be formatted. They don't always agree with our previous manual decisions. I think our policy is to always insist on rustfmt. When that version of rustfmt hits stable, our CI will start to fail for everyone. (Right now this discrepancy just causes trouble for contributors who are using nightly by default.)
* fs-mistrust: Run rustfmt to apply deferred formatting churnIan Jackson2023-07-141-10/+10
|
* fs-mistrust: In a test, simplify env var handlingIan Jackson2023-07-141-17/+10
|
* fs-mistrust: users: Use OsStr and OsString a lot lessIan Jackson2023-07-141-13/+23
| | | | | | | | We don't use OsString now except where it appears in our public API, or where we get it from std::env. Moving the `use` statements into the use sites enabled me to see that I had found all the places I wanted to change.
* fs-mistrust: Remove a now-unneeded suppressionIan Jackson2023-07-141-1/+0
| | | | This function is actually (properly) fallible now.
* fs-mistruct: Abolish some now-unneeded mutsIan Jackson2023-07-141-26/+25
| | | | | MockPwdGrpProvider has internal mutability and is Sync, so its add functions take &self.
* fs-mistrust: Use pwd-grp's getgroups functionIan Jackson2023-07-141-24/+1
| | | | | This gets rid of some unsafe code here, with doubtful error handling, in favour of the unit-tested version in pwd-grp.
* fs-mistruct: switch from users to pwd-grpIan Jackson2023-07-141-41/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | users is unmaintained. pwd-grp is the crate I have just written to replace it. In this commit: Change the cargo dependency and imports. Replace the cacheing arrangements. users has a built-in cache; pwd-grp doesn't. Now, instead of cashing individual lookups, we cache the trusted user and trusted gid calculation results. This saves on some syscalls, and is also more convenient to write. (Mocking is still done via the dependency.) Many systematic consequential changes of details: * The entrypoint names to the library are different: pwd-grp uses the names of the corresponding Unix functions. * pwd-grp's returned structs are transparent, so we don't call accessors for .uid(), .name(), etc. * pwd-grp's methods are much more often fallible (returning io::Result<Option<...>) * We're using the non-UTF-8 pwd-grp API, which means we must use turbofish syntax in some places. * The mocking API is a bit different.
* fs-mistrust: Introduce tempoary PwdGrpProvider aliasIan Jackson2023-07-141-4/+8
| | | | | This allows us to change a number of trait bounds in advance, reducing noise in the next commit.
* fs-mistrust: impl Hash for TrustedUser and TrustedGroup (config)Ian Jackson2023-07-141-2/+2
|
* fs-mistrust: users: tests: Introduce mock_users etc.Ian Jackson2023-07-141-25/+36
| | | | | | | | | | Add some wrapper functions for convenience. The pwd-grp crate has a richer and more faithful, but not so convenient, way of creating dummy user/group entries. Also the type names are all going to change. Doing this now reduces churn.
* fs-mistrust: users: Make several functions fallibleIan Jackson2023-07-141-25/+34
| | | | | | | | | The actual underlying operations here *are* fallible. The `users` crate hides those errors in several cases. (Failures are very rare (at least unless NIS is involved), so this is not of much practical import, but it's going to be necessary when we use the more careful pwd-grp crate.
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Merge branch 'bug487' into 'main'Ian Jackson2022-05-301-0/+6
|\ | | | | | | | | | | | | fs-mistrust: add getegid() to getgrouplist() output. Closes #487 See merge request tpo/core/arti!548
| * fs-mistrust: add getegid() to getgrouplist() output.Nick Mathewson2022-05-271-0/+6
| | | | | | | | | | | | | | | | | | | | This fixes a unit test failure in weird environments (like some containers) where the current effective GID is not included in the list of current groups. Closes #487. Bug reported by @sjm217.
* | fs-mistrust: Document problems with non-UTF8 OsString in tomlNick Mathewson2022-05-261-0/+5
|/ | | | | | | | | | | It turns out that the `toml` crate can't handle OsString, since `toml` doesn't support serialize_newtype_variant, and the `serde` crate tries to serialize OsString using that method. In this commit we document that limitation, and test that we can at least round-trip through json. Found by inspecting test coverage.
* Use serde attrs instead of manual implsNick Mathewson2022-05-241-0/+10
|
* Write custom serde impls for Trusted{User,Group}Nick Mathewson2022-05-241-10/+22
| | | | | | | | | | | | | | | | We support all of the following (in TOML notation): ``` user = "rose" # by name user = 413 # by ID user = false # no user user = ":current" # A 'special' user. user = { name: "rose" } user = { id: 413 } user = { special: ":none" } user = { special: ":current" } ```
* Add serde derives for MistrustBuilder.Nick Mathewson2022-05-241-0/+10
| | | | | | The Group and User (de)serialization is pretty ugly, and I can't vouch for the correcness of MistrustBuilder. I will seek feedback before I proceed.
* fs-mistrust: Add Group and User types.Nick Mathewson2022-05-241-18/+168
| | | | | This will help make the actual configuration more serializable, I hope.
* fs-mistrust: make Mistrust have a corresponding Builder type.Nick Mathewson2022-05-241-0/+8
| | | | | This is an approximately minimal revision to get Builder in place; subsequent commits will clean up the API.
* Fix typos (using the typos-cli tool).Nick Mathewson2022-05-041-1/+1
|
* Work around CI config weirdness.Nick Mathewson2022-05-031-0/+5
| | | | | Some of our builders put root into gid 0, but getgroups() doesn't actually give any result.
* fs-mistrust: Add code to make a self-named group "trusted".Nick Mathewson2022-05-031-0/+202
This required a bit of poking through the `users` crate, to mess with the user and group dbs. The original goal was to "trust the group with the same name as us", but it turned into a bit of a production, since: * We want to take our own name from $USER, assuming that matches our uid. (Otherwise we want to ask getpwuid_r().) * We only want to trust the group if we are actually a member of that group. * We want to cache this information. * We want to test this code.