Package syspolicy :: Package cli :: Module prompt
[hide private]
[frames] | no frames]

Module prompt

source code

Functions for prompting the user for choices and passwords

Classes [hide private]
  AbortedException
This exception is raised when user aborts a yes/no confirmation dialog.
Functions [hide private]
 
confirm(text, default=True)
Get a confirmation from the user using the provided prompting text.
source code
 
getstr(text, default='')
Function for prompting a string value from the user on the command line.
source code
 
genpass(size=10)
Generate a random password from lower- and uppercase letters and digits of exactly size characters in length.
source code
 
checkpass(password, policy={})
Check if the given password meets a certain security policy.
source code
 
setpwd(policy={})
This function performs a password prompting routine with the user.
source code
Variables [hide private]
  SALT_TYPE = 6
1: MD5, 2a: Blowfish, 5: SHA-256, 6: SHA-512
  SALT_SIZE = 16
maximum value: 16 characters
  PASSWORD_SIZE = 10
default password size if no policy is given
  __package__ = 'syspolicy.cli'
Function Details [hide private]

confirm(text, default=True)

source code 

Get a confirmation from the user using the provided prompting text. Additionally, a default value can be specified which is returned when the user simply presses Return. The default value is also highlighted in the prompt.

When the user wishes to quit instead, an AbortedException is raised.

getstr(text, default='')

source code 

Function for prompting a string value from the user on the command line.

Additionally, a default value can be specified in case the user simply presses Return on the prompt. The default value will be shown in brackets.

checkpass(password, policy={})

source code 

Check if the given password meets a certain security policy. There are initial checks made on the length of the password and the amount of different character classes it contains.

Additionally, the password is checked using the cracklib library.

setpwd(policy={})

source code 

This function performs a password prompting routine with the user.

It accepts a password strenght policy as an argument, and based on this a default password will be proposed with the chance of setting a custom one.

The custom password will be subjected to strenght checks using the built-in strenght checker and also the cracklib library.