From 0c3329a557bc45d5b2f9e68639f25f5686cdfb40 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 13 May 2013 03:40:14 -0700 Subject: [PATCH] Be more flexible about where sha1_hex lives --- Girocco/User.pm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Girocco/User.pm b/Girocco/User.pm index ca0f1da..19c0842 100644 --- a/Girocco/User.pm +++ b/Girocco/User.pm @@ -4,11 +4,27 @@ use strict; use warnings; use Girocco::Config; +use Girocco::CGI; +use Girocco::Util; BEGIN { - use Girocco::CGI; - use Girocco::Util; - use Digest::SHA1 qw(sha1_hex); + eval { + require Digest::SHA; + Digest::SHA->import( + qw(sha1_hex) + );1} || + eval { + require Digest::SHA1; + Digest::SHA1->import( + qw(sha1_hex) + );1} || + eval { + require Digest::SHA::PurePerl; + Digest::SHA::PurePerl->import( + qw(sha1_hex) + );1} || + die "One of Digest::SHA or Digest::SHA1 or Digest::SHA::PurePerl " + . "must be available\n"; } sub _passwd_add { @@ -163,7 +179,7 @@ sub keys_save { sub gen_auth { my $self = shift; - $self->{auth} = Digest::SHA1::sha1_hex(time . $$ . rand() . $self->{keys}); + $self->{auth} = sha1_hex(time . $$ . rand() . $self->{keys}); $self->_sshkey_save; $self->{auth}; } -- 2.11.4.GIT