Class: Yast::SignatureCheckCallbacksClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../src/modules/SignatureCheckCallbacks.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) AcceptFileWithoutChecksum(filename)

Name of the callback handler function. Required callback prototype is boolean(string filename) The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.

zypp: askUserToAcceptNoDigest

(+DontShowAgain functionality) – for one run in memory

function for CallbackAcceptFileWithoutChecksum()



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File '../../src/modules/SignatureCheckCallbacks.rb', line 98

def AcceptFileWithoutChecksum(filename)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  dont_show_dialog_ident = "-AcceptFileWithoutChecksum-"

  # Show the popup?
  if SignatureCheckDialogs.GetShowThisPopup(
      dont_show_dialog_ident,
      filename
    )
    return SignatureCheckDialogs.UseItemWithNoChecksum(
      :file,
      filename,
      dont_show_dialog_ident
    ) 
    # Return the default value entered by user
  else
    return SignatureCheckDialogs.GetDefaultDialogReturn(
      dont_show_dialog_ident,
      filename
    )
  end
end

- (Object) AcceptUnknownDigest(filename, digest)

zypp: askUserToAccepUnknownDigest



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File '../../src/modules/SignatureCheckCallbacks.rb', line 161

def AcceptUnknownDigest(filename, digest)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  dont_show_dialog_ident = "-AcceptUnknownDigest-"

  # Show the popup?
  if SignatureCheckDialogs.GetShowThisPopup(
      dont_show_dialog_ident,
      filename
    )
    return SignatureCheckDialogs.UseFileWithUnknownDigest(
      filename,
      digest,
      dont_show_dialog_ident
    )
  else
    # Return the default value entered by user
    return SignatureCheckDialogs.GetDefaultDialogReturn(
      dont_show_dialog_ident,
      filename
    )
  end
end

- (Object) AcceptUnknownGpgKey(filename, keyid, repoid)

Name of the callback handler function. Required callback prototype is boolean(string filename, string keyid, string keyname). The callback function should ask user whether the unknown key can be accepted, returned true value means to accept the file.

zypp: askUserToAcceptUnknownKey

(+DontShowAgain functionality) – for one run in memory

function for CallbackAcceptUnknownGpgKey()



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File '../../src/modules/SignatureCheckCallbacks.rb', line 199

def AcceptUnknownGpgKey(filename, keyid, repoid)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  dont_show_dialog_ident = "-AcceptUnknownGpgKey-"

  # Show the popup?
  if SignatureCheckDialogs.GetShowThisPopup(
      dont_show_dialog_ident,
      filename
    )
    # Unknown keyname == "Unknown Key"
    return SignatureCheckDialogs.ItemSignedWithUnknownSignature(
      :file,
      filename,
      keyid,
      dont_show_dialog_ident,
      repoid
    ) 
    # Return the default value entered by user
  else
    return SignatureCheckDialogs.GetDefaultDialogReturn(
      dont_show_dialog_ident,
      filename
    )
  end
end

- (Object) AcceptUnsignedFile(filename, repo_id)

Name of the callback handler function. Required callback prototype is boolean(string filename). The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.

zypp: askUserToAcceptUnsignedFile

(+DontShowAgain functionality) – for one run in memory

function for CallbackAcceptUnsignedFile()



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

def AcceptUnsignedFile(filename, repo_id)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  dont_show_dialog_ident = "-AcceptUnsignedFile-"

  # Show the popup?
  if SignatureCheckDialogs.GetShowThisPopup(
      dont_show_dialog_ident,
      filename
    )
    return SignatureCheckDialogs.UseUnsignedItem(
      :file,
      filename,
      dont_show_dialog_ident,
      repo_id
    ) 
    # Return the default value entered by user
  else
    return SignatureCheckDialogs.GetDefaultDialogReturn(
      dont_show_dialog_ident,
      filename
    )
  end
end

- (Object) AcceptVerificationFailed(filename, key, repo_id)

Name of the callback handler function. Required callback prototype is boolean(string filename, map<string,any> key). The callback function should ask user whether the unsigned file can be accepted, returned true value means to accept the file.

zypp: askUserToAcceptVerificationFailed

function for CallbackAcceptVerificationFailed()



270
271
272
273
274
275
276
277
278
# File '../../src/modules/SignatureCheckCallbacks.rb', line 270

def AcceptVerificationFailed(filename, key, repo_id)
  key = deep_copy(key)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  SignatureCheckDialogs.UseCorruptedItem(:file, filename, key, repo_id)
end

- (Boolean) AcceptWrongDigest(filename, requested_digest, found_digest)

Callback handler function. Required callback prototype is boolean(string filename, string requested_digest, string found_digest). The callback function should ask user whether the wrong digest can be accepted, returned true value means to accept the file. zypp: askUserToAcceptWrongDigest

Returns:

  • (Boolean)


129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File '../../src/modules/SignatureCheckCallbacks.rb', line 129

def AcceptWrongDigest(filename, requested_digest, found_digest)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  dont_show_dialog_ident = "-AcceptWrongDigest-"

  # Show the popup?
  if SignatureCheckDialogs.GetShowThisPopup(
      dont_show_dialog_ident,
      filename
    )
    return SignatureCheckDialogs.UseFileWithWrongDigest(
      filename,
      requested_digest,
      found_digest,
      dont_show_dialog_ident
    )
  else
    # Return the default value entered by user
    return SignatureCheckDialogs.GetDefaultDialogReturn(
      dont_show_dialog_ident,
      filename
    )
  end
end

- (Object) import_gpg_key_or_disable(key, repo_id)

Alternative implementation of #ImportGpgKey, used during installation, that disables the repository if the key is not trusted and enables it otherwise (a single call to Pkg.ServiceRefresh asks the user several times for the same repository, last decision must prevail).

zypp: askUserToImportKey

function for CallbackImportGpgKey()



255
256
257
258
259
260
# File '../../src/modules/SignatureCheckCallbacks.rb', line 255

def import_gpg_key_or_disable(key, repo_id)
  trusted = ImportGpgKey(key, repo_id)
  log.info "Setting enabled to #{trusted} for repo #{repo_id}, due to user reply to ImportGpgKey"
  Pkg.SourceSetEnabled(repo_id, trusted)
  trusted
end

- (Object) ImportGpgKey(key, repo_id)

Name of the callback handler function. Required callback prototype is boolean(map<string,any> key). The callback function should ask user whether the key is trusted, returned true value means the key is trusted.

zypp: askUserToImportKey

function for CallbackImportGpgKey()



237
238
239
240
241
242
243
244
245
# File '../../src/modules/SignatureCheckCallbacks.rb', line 237

def ImportGpgKey(key, repo_id)
  key = deep_copy(key)
  # Check signatures at all?
  if SignatureCheckDialogs.CheckSignaturesInYaST == false
    return @default_return_unchecked
  end

  SignatureCheckDialogs.ImportGPGKeyIntoTrustedDialog(key, repo_id)
end

- (Object) main



36
37
38
39
40
41
42
43
44
45
46
# File '../../src/modules/SignatureCheckCallbacks.rb', line 36

def main
  textdomain "base"

  Yast.import "SignatureCheckDialogs"
  Yast.import "Pkg"


  # Default return when signatures shouldn't be checked
  # @see #SignatureCheckDialogs::CheckSignaturesInYaST()
  @default_return_unchecked = true
end

- (Object) TrustedKeyAdded(key)

Name of the callback handler function. Required callback prototype is void (string keyid, string keyname). The callback function should inform user that a trusted key has been added.

function for CallbackTrustedKeyAdded()



287
288
289
290
291
292
293
294
295
296
# File '../../src/modules/SignatureCheckCallbacks.rb', line 287

def TrustedKeyAdded(key)
  key = deep_copy(key)
  Builtins.y2milestone(
    "Trusted key has been added: %1 / %2 (%3)",
    Ops.get_string(key, "id", ""),
    Ops.get_string(key, "fingerprint", ""),
    Ops.get_string(key, "name", "")
  )
  nil
end

- (Object) TrustedKeyRemoved(key)

Name of the callback handler function. Required callback prototype is void (string keyid, string keyname). The callback function should inform user that a trusted key has been removed.

function for CallbackTrustedKeyRemoved()



303
304
305
306
307
308
309
310
311
312
# File '../../src/modules/SignatureCheckCallbacks.rb', line 303

def TrustedKeyRemoved(key)
  key = deep_copy(key)
  Builtins.y2milestone(
    "Trusted key has been removed: %1 / %2 (%3)",
    Ops.get_string(key, "id", ""),
    Ops.get_string(key, "fingerprint", ""),
    Ops.get_string(key, "name", "")
  )
  nil
end