aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/sysenv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/sysenv.rb')
-rw-r--r--lib/sisu/v6/sysenv.rb53
1 files changed, 40 insertions, 13 deletions
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb
index ece3ca79..bc3f1a74 100644
--- a/lib/sisu/v6/sysenv.rb
+++ b/lib/sisu/v6/sysenv.rb
@@ -214,7 +214,7 @@ module SiSU_Env
MULTILINGUAL => false,
BUNDLE => false,
CONCORD_MAX => 260000,
- DIGEST => 'sha256',
+ DIGEST => :sha256,
WEBSERV_HOST_CGI => 'http://localhost',
WEBSERV_PORT_CGI => 8081, #8111,8123,8081
POSTGRESQL_USER => @@user, #'ralph', # change user !!!
@@ -806,6 +806,19 @@ module SiSU_Env
false
end
end
+ def sha512(filename) #sha dgst
+ program='openssl'
+ program_ref="\n\t\tsha digest requested"
+ if program_found?(program)
+ pwd=Dir.pwd
+ Dir.chdir(File.dirname(filename))
+ dgst=%x{openssl dgst -sha512 #{File.basename(filename)}}.strip #use file name without file path
+ Dir.chdir(pwd)
+ dgst.scan(/\S+/)
+ else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{program} is not installed #{program_ref}")
+ false
+ end
+ end
def psql #psql
program='psql'
program_ref="\n\t\tpsql requested"
@@ -2715,27 +2728,41 @@ WOK
end
self
end
- def digest
+ def digest_conf?
+ if defined? @rc['default']['digest'] \
+ and @rc['default']['digest'] != nil
+ case @rc['default']['digest']
+ when /^sha(?:5|512)?$/ then :sha512
+ when /^sha(?:2|256)?$/ then :sha256
+ when /^md5$/ then :md5
+ else :sha256
+ end
+ else :sha256
+ end
+ end
+ def digest(opt=nil)
+ @opt=opt
def type
- if defined? @rc['default']['digest'] \
- and @rc['default']['digest'] != nil
- case @rc['default']['digest']
- when /^sha(?:2|256)?$/ then 'sha256'
- when /^md5$/ then 'md5'
- else 'sha256'
+ if @opt
+ case @opt.act[:hash_digest_algo]
+ when :sha512 then :sha512
+ when :sha256 then :sha256
+ when :md5 then :md5
+ else digest_conf?
end
- else 'sha256'
+ else digest_conf?
end
end
def length
- case digest.type
- when /sha256/ then 64
- when /md5/ then 32
+ case digest(@opt).type
+ when :sha512 then 128
+ when :sha256 then 64
+ when :md5 then 32
else 64
end
end
def pattern
- "[0-9a-f]{#{digest.length}}" #/[0-9a-f]{#{digest.length}}/
+ "[0-9a-f]{#{digest(@opt).length}}" #/[0-9a-f]{#{digest.length}}/
end
self
end