pub async fn load_all_users_and_groups(context: &Context<'_>) -> Result<()>Expand description
Loads all users and groups from the filesystem into memory.
This function scans the /system/accounts/groups and
/system/accounts/users directories, reads all group and user files, and
adds them to the Users manager with their recorded homes. It only reads:
version 0 user records get their /users/<identifier> home in memory.
It should be called during system initialization.
§Returns
Returns Ok(()) if all users and groups were loaded successfully,
or an Error if any operation failed.
§Errors
This function can return errors in the following cases:
- Failed to read users or groups directory
- Failed to add users or groups to the Users manager
Records that cannot be read or parsed are skipped with a warning instead of failing the whole load.
§Examples
use authentication::load_all_users_and_groups;
async fn example(context: &authentication::Context<'_>) -> Result<(), authentication::Error> {
load_all_users_and_groups(context).await?;
Ok(())
}