lucab / libsystemd-rs

A pure-Rust client library to work with systemd
https://crates.io/crates/libsystemd
Other
105 stars 19 forks source link

Add credential loader helper #98

Closed vilgotf closed 2 years ago

vilgotf commented 2 years ago

Not a part of the C libsystemd library but I don't know if being strictly 1-1 is a goal.

Although the code is simple I do feel that it'd be a waste for every application to reimplement it.

lucab commented 2 years ago

Strict 1:1 is indeed not a goal, if an helper makes sense to have I'll gladly take it :) Thanks for the PR, I'll see the patch is small so I'll try to review it next week. But it is the first time I encounter this systemd feature, so I first need to get myself familiar with that (which may take a bit longer).

swsnr commented 2 years ago

Essentially, this is std::fs::read(std::env::var_os("CREDENTIALS_DIRECTORY")?.into().join(id))? isn't it? I'm not sure whether this is worth abstracting over to be honest…

vilgotf commented 2 years ago

Currently it only abstracts away CREDENTIALS_DIRECTORY and provides an iterator.

It could be extended by get() returning Option<Vec<u8>> since the only possible IO error should be NotFound (panicking or discarding other errors).

lucab commented 2 years ago

@vilgotf are you still pursuing this? If you have other things to handle at the moment, I'd be happy to push some changes on top of your branch and land it.

lucab commented 2 years ago

(I'm not sure how this PR got closed, but even if it got stale by now I'll be happy to throw some changes on top and eventually merge it)

lucab commented 2 years ago

Ah, the repository behind this PR does not exist anymore so I can't push there to update the PR. I'll close this one and recreate it as a new one.