Function create_user

Source
pub async fn create_user<'a>(
    virtual_file_system: &'a VirtualFileSystem<'a>,
    user_name: &str,
    password: &str,
    primary_group: GroupIdentifier,
    user_identifier: Option<UserIdentifier>,
) -> Result<UserIdentifier>
Expand description

Creates a new user account with the specified parameters.

This function creates a new user in the system by:

  1. Generating a new user identifier (if not provided)
  2. Adding the user to the Users manager
  3. Generating a random salt and hashing the password
  4. Creating the user file with all user data

§Arguments

  • Virtual_file_system - Reference to the virtual file system
  • User_name - Username for the new account
  • Password - Plain text password for the new account
  • Primary_group - Primary group identifier for the user
  • User_identifier - Optional specific user identifier (auto-generated if None)

§Returns

Returns Ok(User_identifier_type) with the new user’s identifier, or an appropriate error if creation fails.

§Errors

This function can fail for various reasons including:

  • User identifier generation or assignment failures
  • File system operations (directory creation, file writing)
  • Users manager operations (adding user)
  • Random salt generation failures