I need to create users and groups from rust. Rather than implementing this in a separate crate I'd like to extend this crate. However I just learned rust and I probably need some conceptual guidance.
As users can be created already I guess a save_user method could work. So the workflow to create a user would be:
let mut user = User::new(1001, "peter", 1001);
user.save_to_passwd().expect("could not save the user");
The save method could also try to validate that the user does not exist yet.
There could also be the possibility to modify the entries of a user with set_param functions followed by a save_to_passwd. In this case I think it would be good to check that the user has not been changed while it was cached. If it was changed it should fail with an appropriate error.
I need to create users and groups from rust. Rather than implementing this in a separate crate I'd like to extend this crate. However I just learned rust and I probably need some conceptual guidance.
As users can be created already I guess a save_user method could work. So the workflow to create a user would be:
The save method could also try to validate that the user does not exist yet.
There could also be the possibility to modify the entries of a user with
set_param
functions followed by asave_to_passwd
. In this case I think it would be good to check that the user has not been changed while it was cached. If it was changed it should fail with an appropriate error.Let me know what you think.