Module: Yast::AuditLafCmdlineInclude

Defined in:
../../src/include/audit-laf/cmdline.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) GetDiskspaceSettings



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File '../../src/include/audit-laf/cmdline.rb', line 76

def GetDiskspaceSettings
  settings = ""

  Builtins.foreach(@diskspace_settings) do |key|
    settings = Ops.add(
      Ops.add(
        Ops.add(Ops.add(settings, key), ": "),
        AuditLaf.GetAuditdOption(key)
      ),
      "\n"
    )
  end

  settings
end

- (Object) GetDispatcherSettings



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File '../../src/include/audit-laf/cmdline.rb', line 92

def GetDispatcherSettings
  settings = ""

  Builtins.foreach(@dispatcher_settings) do |key|
    settings = Ops.add(
      Ops.add(
        Ops.add(Ops.add(settings, key), ": "),
        AuditLaf.GetAuditdOption(key)
      ),
      "\n"
    )
  end

  settings
end

- (Object) GetLogfileSettings



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File '../../src/include/audit-laf/cmdline.rb', line 61

def GetLogfileSettings
  settings = ""

  Builtins.foreach(@logfile_settings) do |key|
    settings = Ops.add(
      Ops.add(
        Ops.add(Ops.add(settings, key), ": "),
        AuditLaf.GetAuditdOption(key)
      ),
      "\n"
    )
  end
  settings
end

- (Object) initialize_audit_laf_cmdline(include_target)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File '../../src/include/audit-laf/cmdline.rb', line 31

def initialize_audit_laf_cmdline(include_target)
  textdomain "audit-laf"

  Yast.import "CommandLine"
  Yast.import "AuditLaf"
  Yast.import "Report"

  @logfile_settings = [
    "log_file",
    "log_format",
    "flush",
    "freq",
    "max_log_file",
    "max_log_file_action",
    "num_logs",
    "name_format",
    "name"
  ]
  @diskspace_settings = [
    "space_left",
    "space_left_action",
    "admin_space_left",
    "admin_space_left_action",
    "action_mail_acct",
    "disk_full_action",
    "disk_error_action"
  ]
  @dispatcher_settings = ["disp_qos", "dispatcher"]
end

- (Object) SettingsHandler(options)



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File '../../src/include/audit-laf/cmdline.rb', line 107

def SettingsHandler(options)
  options = deep_copy(options)
  Builtins.y2milestone("Command line options: %1", options)

  Builtins.foreach(options) do |key, val|
    value = ""
    if Ops.is_integer?(val)
      value = Builtins.tostring(val)
    else
      value = Convert.to_string(val)
    end
    if Builtins.contains(@logfile_settings, key) ||
        Builtins.contains(@diskspace_settings, key) ||
        Builtins.contains(@dispatcher_settings, key)
      # option (key/value pair) can be written 'as is', e.g. log_format = RAW
      AuditLaf.SetAuditdOption(key, value)
    elsif Builtins.substring(key, Ops.subtract(Builtins.size(key), 6)) == "script"
      AuditLaf.SetAuditdOption(
        Ops.add(
          Builtins.substring(key, 0, Ops.subtract(Builtins.size(key), 6)),
          "action"
        ),
        Ops.add("EXEC ", value) # replace "script" by "action"
      ) # EXEC <script>
    end
  end

  true # call Write
end

- (Boolean) ShowHandler(options)

Show information about settings

Returns:

  • (Boolean)

    false



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File '../../src/include/audit-laf/cmdline.rb', line 139

def ShowHandler(options)
  options = deep_copy(options)
  Builtins.y2milestone("Options:%1", options)
  sets = []

  Builtins.foreach(options) do |key, val|
    if Builtins.contains(["logfile", "diskspace", "disp"], key)
      sets = Builtins.add(sets, key)
    end
  end
  if sets == []
    CommandLine.Print(
      "Please specify information ('logfile', 'diskpace' or 'disp')"
    )
  end

  Builtins.foreach(sets) do |option|
    if option == "logfile"
      CommandLine.Print(GetLogfileSettings())
    elsif option == "diskspace"
      CommandLine.Print(GetDiskspaceSettings())
    elsif option == "disp"
      CommandLine.Print(GetDispatcherSettings())
    else
      CommandLine.Print("Unknown option")
    end
  end

  false # do not call Write...
end