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

See Also:

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



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

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

#mainObject

Module initialization



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

def main
  textdomain "base"
end

#resetObject

Resets the configuration

It forces to read the configuration again discarding the changes.



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

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



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

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



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

def write
  config.save
end