Class: Yast::PamClass

Inherits:
Module
  • Object
show all
Defined in:
src/modules/Pam.rb

Instance Method Summary collapse

Instance Method Details

#Add(mod) ⇒ Object

Add options or new PAM module


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

#Enabled(mod) ⇒ Object

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

#mainObject


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

def main

end

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

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


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

#Remove(mod) ⇒ Object

Remove options or PAM module


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

#Set(mod, set) ⇒ Object

Add/Remove option or PAM module


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

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