Module: PuppetX::EnterpriseModules::Oracle::Password

Includes:
Information
Defined in:
lib/puppet_x/enterprisemodules/oracle/password.rb

Overview

docs

Instance Method Summary collapse

Methods included from Information

#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_passwordObject



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

#get_current_password_informationObject



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
  #
  # A hashed password has the format S:61B19096E12ADE8417B04A50D801B1102E72E0C484C759ED057F601357A1;rest
  # we need the part after the double colon but before the semi colon
  #
  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_hashObject



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_updateObject



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_stringObject



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_hashObject



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