From ecd518e31e6341c4b7099d2ac71ac57b8b06fe18 Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 5 Aug 2013 01:35:40 -0700 Subject: [PATCH] import sha.pm on ubuntu instands of sha1.pm --- perl-xCAT/xCAT/Utils.pm | 8 ++++++- xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm | 17 +++++++++---- xCAT-server/lib/perl/xCAT/IPMI.pm | 25 ++++++++++++++------ xCAT-server/lib/xcat/plugins/ipmi.pm | 1 - 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 9d1da5e9c..24f4bbf99 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -179,7 +179,13 @@ sub genUUID return $uuid; } elsif ($args{url} and $sha1support) { #generate a UUIDv5 from URL #6ba7b810-9dad-11d1-80b4-00c04fd430c8 is the uuid for URL namespace - my $sum = Digest::SHA1::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url}); + my $sum = ''; + if ( -f "/etc/debian_version" ){ + $sum = Digest::SHA::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url}); + } + else{ + $sum = Digest::SHA1::sha1('6ba7b810-9dad-11d1-80b4-00c04fd430c8'.$args{url}); + } my @data = unpack("C*",$sum); splice @data,16; $data[6] = $data[6] & 0xf; diff --git a/xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm b/xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm index d53239032..5588f2157 100644 --- a/xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm +++ b/xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm @@ -19,10 +19,19 @@ use File::Path; use Socket; use strict; use Symbol; -my $sha1support = eval { - require Digest::SHA1; - 1; -}; +if ( -f "/etc/debian_version" ) { + $sha1support = eval { + require Digest::SHA; + 1; + }; +} +else { + + $sha1support = eval { + require Digest::SHA1; + 1; + }; +} use IPC::Open3; use IO::Select; use warnings "all"; diff --git a/xCAT-server/lib/perl/xCAT/IPMI.pm b/xCAT-server/lib/perl/xCAT/IPMI.pm index c13c01efd..92ee0ab65 100644 --- a/xCAT-server/lib/perl/xCAT/IPMI.pm +++ b/xCAT-server/lib/perl/xCAT/IPMI.pm @@ -46,13 +46,24 @@ use Digest::MD5 qw/md5/; my $pendingpackets=0; my %tabooseq; #TODO: this is a global which means one taboo in the whole set causes unrelated session objects to consider it taboo unnecessarily my $maxpending; #determined dynamically based on rcvbuf detection -my $ipmi2support = eval { - require Digest::SHA1; - Digest::SHA1->import(qw/sha1/); - require Digest::HMAC_SHA1; - Digest::HMAC_SHA1->import(qw/hmac_sha1/); - 1; -}; +if ( -f "/etc/debian_release" ){ + $ipmi2support = eval { + require Digest::SHA; + Digest::SHA->import(qw/sha1/); + require Digest::HMAC_SHA1; + Digest::HMAC_SHA1->import(qw/hmac_sha1/); + 1; + }; +} +else { + $ipmi2support = eval { + require Digest::SHA1; + Digest::SHA1->import(qw/sha1/); + require Digest::HMAC_SHA1; + Digest::HMAC_SHA1->import(qw/hmac_sha1/); + 1; + }; +} my $aessupport; if ($ipmi2support) { $aessupport = eval { diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 3bd5fb5f8..1d7abb317 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -73,7 +73,6 @@ use IO::Socket; use IO::Select; use Class::Struct; use Digest::MD5 qw(md5); -use Digest::SHA1 qw(sha1); use POSIX qw(WNOHANG mkfifo strftime); use Fcntl qw(:flock);