Module: Yast::Y2StartHelpers

Defined in:
src/ruby/yast/y2start_helpers.rb

Constant Summary collapse

LOG_LOCATIONS =
["/var/log/YaST2/signal", "y2signal.log"]

Class Method Summary collapse

Class Method Details

.config_envObject

Configure global environment for YaST

Currently it only sets values for $PATH.

By configuring $PATH, it ensures that correct external programs are executed when relative paths are given, so possible CVEs are avoided when running YaST.

Note that forked processes will inherit the environment configuration, for example when executing commands via SCR or Cheetah.



12
13
14
# File 'src/ruby/yast/y2start_helpers.rb', line 12

def self.config_env
  ENV["PATH"] = "/sbin:/usr/sbin:/usr/bin:/bin"
end

.helpObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'src/ruby/yast/y2start_helpers.rb', line 38

def self.help
  "Usage: y2start [GenericOpts] Client [ClientOpts] Server " \
  "[Specific ServerOpts]\n" \
  "\n" \
  "GenericOptions are:\n" \
  "    -h --help         : Sprint this help\n" \
  "\n" \
  "ClientOptions are:\n" \
  "    -a --arg          : add argument for client. Can be used multiple times.\n" \
  "\n" \
  "Specific ServerOptions are any options passed on unevaluated.\n" \
  "\n" \
  "Examples:\n" \
  "y2start installation qt\n" \
  "    Start binary y2start with intallation.ycp as client and qt as server\n" \
  "y2start installation -a initial qt\n" \
  "    Provide parameter initial for client installation\n" \
  "y2start installation qt -geometry 800x600\n" \
  "    Provide geometry information as specific server options\n"
end

.parse_arguments(args) ⇒ Object

Parses ARGV of y2start. it returns map with keys:

  • :generic_options [Hash]
  • :client_name [String]
  • :client_options [Hash] always contains params: with Array of client arguments
  • :server_name [String]
  • :server_options Array

Raises:

  • RuntimeError when unknown option appear or used wrongly



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'src/ruby/yast/y2start_helpers.rb', line 24

def self.parse_arguments(args)
  ret = {}

  ret[:generic_options] = parse_generic_options(args)
  # for --help early quit as other argument are ignored
  return ret if ret[:generic_options][:help]
  ret[:client_name] = args.shift or raise "Missing client name."
  ret[:client_options] = parse_client_options(args)
  ret[:server_name] = args.shift or raise "Missing server name."
  ret[:server_options] = args

  ret
end

.setup_signalsObject

so how works signals in ruby version? It logs what we know about signal and then continue with standard ruby handler, which raises SignalException that can be processed. If it is not catched, it show popup asking for report bug.



63
64
65
66
67
68
69
70
# File 'src/ruby/yast/y2start_helpers.rb', line 63

def self.setup_signals
  Signal.trap("PIPE", "IGNORE")

  # SEGV, ILL and FPE is reserved, so cannot be set
  ["HUP", "INT", "QUIT", "ABRT", "TERM"].each do |name|
    Signal.trap(name) { signal_handler(name) }
  end
end