Class: Yast::KeyManagerClient

Inherits:
Client
  • Object
show all
Defined in:
src/clients/key_manager.rb

Overview

Manages GPG keys in the package manager

Instance Method Summary collapse

Instance Method Details

#mainObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'src/clients/key_manager.rb', line 5

def main
  Yast.import "Pkg"
  Yast.import "UI"
  textdomain "packager"

  Yast.import "PackageCallbacks"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Report"
  Yast.import "CommandLine"
  Yast.import "Popup"
  Yast.import "PackageLock"
  Yast.import "KeyManager"
  Yast.import "Installation"
  Yast.import "Sequencer"

  Yast.include self, "packager/key_manager_dialogs.rb"

  @cmdline_description = {
    "id"         => "key_mgmgt",
    "guihandler" => fun_ref(method(:Main), "symbol ()")
  }

  CommandLine.Run(@cmdline_description)
end

#MainObject

main function - start the workflow


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'src/clients/key_manager.rb', line 59

def Main
  Wizard.CreateDialog
  Wizard.SetDesktopIcon("security")
  # dialog caption
  Wizard.SetContents(_("Initializing..."), Empty(), "", false, true)

  aliases = {
    "read"  => -> { Read() },
    "edit"  => -> { RunGPGKeyMgmt(true) },
    "write" => -> { Write() }
  }

  sequence = {
    "ws_start" => "read",
    "read"     => { next: "edit" },
    "edit"     => { abort: :abort, next: "write" },
    "write"    => { next: :next, abort: :abort }
  }

  Builtins.y2milestone("Starting the key management sequence")
  ret = Sequencer.Run(aliases, sequence)

  Wizard.CloseDialog
  ret
end

#ReadObject


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'src/clients/key_manager.rb', line 31

def Read
  if !Ops.get_boolean(PackageLock.Connect(false), "connected", false)
    # SW management is already in use, access denied
    # the yast module cannot be started
    Wizard.CloseDialog
    return :abort
  end

  # init the target - read the keys
  if !Pkg.TargetInitialize(Installation.destdir)
    Builtins.y2error("The target cannot be initialized, aborting...")
    return :abort
  end

  # read the current keys
  if !KeyManager.Read
    Builtins.y2error("The key configuration cannot be read, aborting...")
    return :abort
  end

  :next
end

#WriteObject


54
55
56
# File 'src/clients/key_manager.rb', line 54

def Write
  KeyManager.Write ? :next : :abort
end