mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-22 16:33:48 +01:00
LSattr_html :: password : Add possibility to generate password using pwgen command
This commit is contained in:
parent
8313191f54
commit
27b56ef505
2 changed files with 43 additions and 2 deletions
|
@ -19,6 +19,9 @@
|
|||
// d'apparitions égal à 1
|
||||
...
|
||||
),
|
||||
'use_pwgen' => [booléen], // Utiliser pwgen pour la génération du mot de passe
|
||||
'pwgen_path' => "/path/to/pwgen",
|
||||
'pwgen_opts' => "[options à passer à pwgen]",
|
||||
'verify' => [booléen], // Activation de l'outil de vérification du mot de passe
|
||||
'viewHash' => [booléen], // Activation de l'outil de visualisation du mot de passe haché
|
||||
'mail' => array( // Configuration de l'envoi du mot de passe par mail
|
||||
|
@ -84,6 +87,29 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>use_pwgen</term>
|
||||
<listitem>
|
||||
<para>Booléen définissant si la commande <literal>pwgen</literal> doit être
|
||||
utilisé pour générer le mot de passe.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>pwgen_path</term>
|
||||
<listitem>
|
||||
<para>Chemin d'accès au binaire <literal>pwgen</literal>.
|
||||
(Par défaut : <literal>pwgen</literal>).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>pwgen_opts</term>
|
||||
<listitem>
|
||||
<para>Options à passer à la commande <literal>pwgen</literal>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>verify</term>
|
||||
<listitem>
|
||||
|
|
|
@ -165,6 +165,20 @@ class LSformElement_password extends LSformElement {
|
|||
}
|
||||
|
||||
function generatePassword($params=NULL) {
|
||||
if ($params['html_options']['use_pwgen']) {
|
||||
$args=(isset($params['html_options']['pwgen_opts'])?$params['html_options']['pwgen_opts']:'');
|
||||
$len=(isset($params['html_options']['lenght'])?$params['html_options']['lenght']:8);
|
||||
$bin=(isset($params['html_options']['pwgen_path'])?$params['html_options']['pwgen_path']:'pwgen');
|
||||
$cmd="$bin ".escapeshellcmd($args)." $len 1";
|
||||
exec($cmd,$ret,$retcode);
|
||||
LSdebug("Generate password using pwgen. Cmd : '$cmd' / Return code : $retcode / Return : ".print_r($ret,1));
|
||||
if ($retcode==0 && count($ret)>0) {
|
||||
return $ret[0];
|
||||
}
|
||||
else {
|
||||
LSerror :: addErrorCode('LSformElement_password_03');
|
||||
}
|
||||
}
|
||||
return generatePassword($params['html_options']['chars'],$params['html_options']['lenght']);
|
||||
}
|
||||
|
||||
|
@ -329,5 +343,6 @@ _("LSformElement_password : No contact mail available to send password.")
|
|||
LSerror :: defineError('LSformElement_password_02',
|
||||
_("LSformElement_password : Contact mail invalid (%{mail}). Can't send password.")
|
||||
);
|
||||
|
||||
?>
|
||||
LSerror :: defineError('LSformElement_password_03',
|
||||
_("LSformElement_password : Fail to exec pwgen. Check it's correctly installed.")
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue