Class: Yast::ShadowConfigClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
library/general/src/modules/ShadowConfig.rb

Overview

This class allows to access the API to handle login.defs attributes from Perl

Defined Under Namespace

Classes: UnknownAttributeError

Instance Method Summary collapse

Instance Method Details

#fetch(attr) ⇒ String?

Returns an attribute from login.defs configuration

Examples:

Getting the encryption method

Yast::ShadowConfig.fetch(:encrypt_method) #=> "SHA512"

Getting the encryption method using the variable name

Yast::ShadowConfig.fetch(ENCRYPT_METHOD) #=> "SHA512"

Parameters:

  • attr (String, Symbol)

    Attribute name

Returns:

  • (String, nil)

    Attribute value


57
58
59
60
61
# File 'library/general/src/modules/ShadowConfig.rb', line 57

def fetch(attr)
  normalized_attr = attr.to_s.downcase
  check_attribute(normalized_attr)
  config.public_send(normalized_attr)
end

#mainObject

Module initialization


35
36
37
# File 'library/general/src/modules/ShadowConfig.rb', line 35

def main
  textdomain "base"
end

#resetObject

Resets the configuration

It forces to read the configuration again discarding the changes.


43
44
45
# File 'library/general/src/modules/ShadowConfig.rb', line 43

def reset
  @config = nil
end

#set(attr, value) ⇒ Object

Sets an attribute to login.defs

Examples:

Setting the encryption method

Yast::ShadowConfig.set(:encrypt_method, "SHA512")

Parameters:

  • attr (String, Symbol)

    Attribute name

  • value (String, nil)

    Attribute value


70
71
72
73
74
# File 'library/general/src/modules/ShadowConfig.rb', line 70

def set(attr, value)
  normalized_attr = attr.to_s.downcase
  check_attribute(normalized_attr)
  config.public_send("#{normalized_attr}=", value)
end

#writeObject

Writes the login.defs configuration


77
78
79
# File 'library/general/src/modules/ShadowConfig.rb', line 77

def write
  config.save
end