Module: PuppetX::EnterpriseModules::Oracle::Password
- Includes:
- Information
- Defined in:
- lib/puppet_x/enterprisemodules/oracle/password.rb
Overview
Instance Method Summary
collapse
#cached_sid_value, #cluster?, #cluster_instances, #containerdb?, #database_properties, #database_version, #db_create_file_dest, #db_domain, #db_for, #diagnostic_dest, included, #local_sid_for_db, #open_pdbs, #oracle_major_version, #oracle_managed_files_enabled?, #pdb?, #primary?, #rootdb?, #seeddb?, #sid_for, #value_for_init_param
Instance Method Details
#current_hashed_password ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 53
def current_hashed_password
options = { :sid => sid_from_resource }
password_info = case oracle_major_version(sid_from_resource)
when 10
sql "SELECT password FROM dba_users WHERE name='#{resource[:username]}'", options
when 11, 12, 18, 19, 20, 21
sql "SELECT spare4 as password FROM sys.user$ WHERE name='#{resource[:username]}'", options
else
fail 'unsupported Oracle version'
end
password_info.first['PASSWORD']
end
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 15
def get_current_password_information
current_password = current_hashed_password
if current_password && (s_part = current_password.split(';').detect { |e| e.include?('S:') })
@rest = current_password.gsub(s_part, '')
hash = s_part.split(':').last
@password_hash = hash[0, 40]
@salt = hash[40, 20]
else
@password_hash = nil
@salt = nil
end
end
|
#is_password_hash ⇒ Object
36
37
38
39
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 36
def is_password_hash
get_current_password_information unless @password_hash
@password_hash
end
|
#password_for_update ⇒ Object
32
33
34
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 32
def password_for_update
"S:#{should_password_hash}#{@salt}#{@rest}"
end
|
#salt_string ⇒ Object
66
67
68
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 66
def salt_string
@salt.scan(/../).map { |x| x.hex.chr }.join
end
|
#should_password_hash ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/puppet_x/enterprisemodules/oracle/password.rb', line 41
def should_password_hash
if @salt
get_current_password_information
sha1 = Digest::SHA1.new
sha1.update(value)
sha1.update(salt_string)
sha1.hexdigest.upcase
else
''
end
end
|