SCAutolib.models.authselect

This module provides methods allowing to configure the system for smart-card authentication using the authselect tool.

It is implemented as a context manager (Authselect class), which ensures that system configurations are properly set up upon entry and restored to their original state upon exit. The module interacts with authselect(8) to apply the sssd profile with specified features (for more information see manual page for authselect(8)).

Classes

class Authselect(required=False, lock_on_removal=False, mk_homedir=False, sudo=False)[source]

Manages the authselect configuration of the system for smart card authentication. This class is designed to be used as a context manager, ensuring that any changes made to authselect profiles are automatically backed up and restored to their previous state upon exiting the context. It configures the sssd profile with specific features like with-smartcard.

Initializes the Authselect object with desired authselect profile features. By default, it sets the with-smartcard feature for the sssd profile and uses the --force option to apply changes.

Parameters:
  • required (bool) – If True, the with-smartcard-required option will be added to the authselect profile.

  • lock_on_removal (bool) – If True, the with-smartcard-lock-on-removal option will be added to the authselect profile.

  • mk_homedir (bool) – If True, the with-mkhomedir option will be added to the authselect profile, ensuring home directories are created on login.

  • sudo (bool) – If True, the with-sudo option will be added to the authselect profile, enabling sudo integration.

Returns:

None

Return type:

None

_restore()[source]

Restores the Authselect configuration to the state it was in before the Authselect class context manager applied its changes. It attempts to restore from the backup file created during _set().

Returns:

None

Return type:

None

Raises:

FileNotFoundError – If the backup file expected for restoration does not exist.

_set()[source]

Applies the SSSD profile with the selected Authselect profile features using the authselect command. It also backs up the previous Authselect configuration to a default location.

Returns:

None

Return type:

None