Class: Simp::Cli::Config::Item::LdapRootHash

Inherits:
PasswordItem show all
Defined in:
lib/simp/cli/config/item/ldap_root_hash.rb

Instance Attribute Summary

Attributes inherited from PasswordItem

#can_generate, #generate_by_default

Attributes inherited from Simp::Cli::Config::Item

#allow_user_apply, #config_items, #description, #die_on_apply_fail, #fact, #fail_on_missing_answer, #key, #next_items_tree, #silent, #skip_apply, #skip_query, #skip_yaml, #value

Instance Method Summary collapse

Methods inherited from PasswordItem

#query_ask, #query_extras, #query_generate_password

Methods inherited from Simp::Cli::Config::Item

#apply, #default_value, #highline_question_type, #next_items, #not_valid_message, #print_banner, #print_summary, #puppet_value, #query, #query_ask, #query_extras, #query_status, #recommended_value, #safe_apply, #say_blue, #say_green, #say_red, #say_yellow, #to_yaml_s

Constructor Details

#initializeLdapRootHash

Returns a new instance of LdapRootHash.



9
10
11
12
13
14
15
16
17
# File 'lib/simp/cli/config/item/ldap_root_hash.rb', line 9

def initialize
  super
  @key                 = 'ldap::root_hash'
  @description         = %Q{The LDAP root password hash.

    If you set this with simp config, type the password and the hash will be
    generated for you.' }.gsub( /^\s{8}/, '' )
  @generate_by_default = false
end

Instance Method Details

#encrypt(string, salt = nil) ⇒ Object



26
27
28
# File 'lib/simp/cli/config/item/ldap_root_hash.rb', line 26

def encrypt( string, salt=nil )
  Simp::Cli::Config::Utils.encrypt_openldap_hash( string, salt )
end

#os_valueObject



19
20
21
22
23
24
# File 'lib/simp/cli/config/item/ldap_root_hash.rb', line 19

def os_value
  if File.readable?('/etc/openldap/slapd.conf')
    `grep rootpw /etc/openldap/slapd.conf` =~ /\Arootpw\s+(.*)\s*/
    $1
  end
end

#validate(x) ⇒ Object



30
31
32
33
# File 'lib/simp/cli/config/item/ldap_root_hash.rb', line 30

def validate( x )
  Simp::Cli::Config::Utils.validate_openldap_hash( x ) ||
    ( !x.to_s.strip.empty? && super )
end