Class List Method List File List

# Class: Yast::PamClass

Inherits:
  Module
  - Object
  - Module
  - Yast::PamClass
  show all
Defined in:
  ../../src/modules/Pam.rb

## Instance Method Summary (collapse)

- - (Object) Add(mod)

  Add options or new PAM module.

- - (Object) Enabled(mod)

  Ask if given PAM module is enabled.

- - (Object) main
- - (Hash{String => Array}) Query(mod)

  Query PAM configuration for status of given module are lists of options.

- - (Object) Remove(mod)

  Remove options or PAM module.

- - (Object) Set(mod, set)

  Add/Remove option or PAM module.

## Instance Method Details

### - (`Object`) Add(mod)

Add options or new PAM module

Parameters:

- string —

  PAM module or option

Returns:

- success

    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    # File '../../src/modules/Pam.rb', line 79

    def Add(mod)
      out = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Ops.add("/usr/sbin/pam-config -a --", mod)
        )
      )
      if Ops.get_integer(out, "exit", 0) != 0
        Builtins.y2warning("pam-config for %1 returned %2", mod, out)
        return false
      end
      true
    end

### - (`Object`) Enabled(mod)

Ask if given PAM module is enabled

    72
    73
    74
    # File '../../src/modules/Pam.rb', line 72

    def Enabled(mod)
      Ops.greater_than(Builtins.size(Query(mod)), 0)
    end

### - (`Object`) main

    34
    35
    36
    # File '../../src/modules/Pam.rb', line 34

    def main

    end

### - (`Hash{String => Array}`) Query(mod)

Query PAM configuration for status of given module are lists of options

Parameters:

- string —

  PAM module (e.g. ldap, cracklib)

Returns:

- (`Hash{String => Array}`) —

  keys are 'management groups' (e.g. auth), values

    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    # File '../../src/modules/Pam.rb', line 42

    def Query(mod)
      ret = {}
      out = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Ops.add("/usr/sbin/pam-config -q --", mod)
        )
      )
      if Ops.get_integer(out, "exit", 0) != 0
        Builtins.y2warning("pam-config for %1 returned %2", mod, out)
        return deep_copy(ret)
      end
      Builtins.foreach(
        Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
      ) do |line|
        l = Builtins.splitstring(line, ":")
        next if line == "" || Ops.less_than(Builtins.size(l), 2)
        key = Ops.get_string(l, 0, "")
        Ops.set(
          ret,
          key,
          Builtins.filter(Builtins.splitstring(Ops.get_string(l, 1, ""), " \t")) do |o|
            o != ""
          end
        )
      end
      deep_copy(ret)
    end

### - (`Object`) Remove(mod)

Remove options or PAM module

Parameters:

- string —

  PAM module or option

Returns:

- success

    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    # File '../../src/modules/Pam.rb', line 96

    def Remove(mod)
      out = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Ops.add("/usr/sbin/pam-config -d --", mod)
        )
      )
      if Ops.get_integer(out, "exit", 0) != 0
        Builtins.y2warning("pam-config for %1 returned %2", mod, out)
        return false
      end
      true
    end

### - (`Object`) Set(mod, set)

Add/Remove option or PAM module

Parameters:

- string —

  PAM module or option

- boolean —

  true for adding, false for removing

Returns:

- success

    114
    115
    116
    # File '../../src/modules/Pam.rb', line 114

    def Set(mod, set)
      set ? Add(mod) : Remove(mod)
    end