Struct ::passwd::Passwd
A representation of the user and group databases
This can be used to handle /etc/passwd
and related files. Typically, you would:
- Create an instance early in the main phase
- Add things to it as needed (next to the associated packages)
- Apply it at the end of the main phase
A rough example:
// Mappings for the IDs that systemd auto-assigns inconsistently from computer to computer
const USER_MAPPING =
const GROUP_MAPPING =
pub async
Methods
Create a new Passwd instance
Arguments
user_ids
- A list of tuples of (username, uid) to use if sysusers files does not specify a UIDgroup_ids
- A list of tuples of (groupname, gid) to use if sysusers files does not specify a GID
Add a user to the passwd database (and add a matching group with the same ID)
Add an already added user to one or more already added groups
Add an already added user to one or more already added groups
fn add_from_sysusers(self, package_manager: PackageManager, package: String, config_file: String) -> Result
Add users and groups declared in a systemd sysusers file
You need to provide a map of preferred IDs for any IDs not explicitly set in the sysusers file.
Arguments
package_manager
- The package manager to use for reading the sysusers fileconfig_file
- The path to the sysusers file
Set user passwords to what they are set to on the system for the given users
Read the passwd and group files from the system and update IDs to match the system (based on name)