Commit 0a906243 authored by Christophe Maudoux's avatar Christophe Maudoux

Improve code

parent 879a7693
Pipeline #3863 passed with stages
in 12 minutes and 2 seconds
...@@ -5,12 +5,12 @@ use File::Temp 'tempdir'; ...@@ -5,12 +5,12 @@ use File::Temp 'tempdir';
use IPC::Run; use IPC::Run;
use Mouse; use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw( use Lemonldap::NG::Portal::Main::Constants qw(
PE_BADCREDENTIALS PE_BADCREDENTIALS
PE_ERROR PE_ERROR
PE_FIRSTACCESS PE_FIRSTACCESS
PE_FORMEMPTY PE_FORMEMPTY
PE_NOTOKEN PE_NOTOKEN
PE_OK PE_OK
); );
our $VERSION = '2.0.1'; our $VERSION = '2.0.1';
...@@ -68,16 +68,16 @@ sub extractFormInfo { ...@@ -68,16 +68,16 @@ sub extractFormInfo {
} }
my ( $out, $err ); my ( $out, $err );
$self->logger->debug( $self->logger->debug(
"Launching:\ngpgv --homedir /dev/null --keyring $self->{db} <<EOF\n$signed\nEOF" "Launching:\ngpgv --homedir /dev/null --keyring $self->{db} <<EOF\n$signed\nEOF"
); );
my $lang = $ENV{LANG}; my ( $lang, $language ) = ( $ENV{LANG}, $ENV{LANGUAGE} );
my $language = $ENV{LANGUAGE}; $ENV{LANG} = $ENV{LANGUAGE} = 'C';
$ENV{LANG} = 'C'; IPC::Run::run(
$ENV{LANGUAGE} = 'C'; [ 'gpgv', '--homedir', '/dev/null', '--keyring', $self->db ],
IPC::Run::run( [ 'gpgv', '--homedir', '/dev/null', '--keyring', $self->db ],
\$signed, \$out, \$err, IPC::Run::timeout(10) ); \$signed, \$out, \$err, IPC::Run::timeout(10) );
if ( $? >> 8 != 0 ) { if ( $? >> 8 != 0 ) {
$self->userLogger->error("GPG verification fails:\n$out\n# # #\n$err"); $self->userLogger->error(
"GPG verification fails:\n$out\n# # #\n$err");
$self->setSecurity($req); $self->setSecurity($req);
return PE_BADCREDENTIALS; return PE_BADCREDENTIALS;
} }
...@@ -93,8 +93,7 @@ sub extractFormInfo { ...@@ -93,8 +93,7 @@ sub extractFormInfo {
$self->logger->debug("GPG full sign key: $key"); $self->logger->debug("GPG full sign key: $key");
my $in; my $in;
IPC::Run::run( IPC::Run::run(
[ [ 'gpg', '--homedir', $self->tmp, '--keyring',
'gpg', '--homedir', $self->tmp, '--keyring',
$self->db, '--list-key', $key $self->db, '--list-key', $key
], ],
\$in, \$in,
...@@ -102,8 +101,7 @@ sub extractFormInfo { ...@@ -102,8 +101,7 @@ sub extractFormInfo {
\$err, \$err,
IPC::Run::timeout(10) IPC::Run::timeout(10)
); );
$ENV{LANG} = $lang; ( $ENV{LANG}, $ENV{LANGUAGE} ) = ( $lang, $language );
$ENV{LANGUAGE} = $language;
if ( $? >> 8 != 0 ) { if ( $? >> 8 != 0 ) {
$self->logger->error("gpg --list-key return an error:\n$err"); $self->logger->error("gpg --list-key return an error:\n$err");
return PE_ERROR; return PE_ERROR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment