Class: Yast::SignatureCheckCallbacksClass

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

Instance Method Summary collapse

Instance Method Details

#AcceptFileWithoutChecksum(filename) ⇒ Object

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()



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

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

#AcceptUnknownDigest(filename, digest) ⇒ Object

zypp: askUserToAccepUnknownDigest



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

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

#AcceptUnknownGpgKey(filename, keyid, repoid) ⇒ Object

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()



195
196
197
198
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
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 195

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

#AcceptUnsignedFile(filename, repo_id) ⇒ Object

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()



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
84
85
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 59

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

#AcceptVerificationFailed(filename, key, repo_id) ⇒ Object

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()



266
267
268
269
270
271
272
273
274
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 266

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

#AcceptWrongDigest(filename, requested_digest, found_digest) ⇒ Boolean

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)


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

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

#import_gpg_key_or_disable(key, repo_id) ⇒ Object

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()



251
252
253
254
255
256
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 251

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

#ImportGpgKey(key, repo_id) ⇒ Object

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()



233
234
235
236
237
238
239
240
241
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 233

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

#mainObject



36
37
38
39
40
41
42
43
44
45
# File 'library/packages/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

#TrustedKeyAdded(key) ⇒ Object

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()



283
284
285
286
287
288
289
290
291
292
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 283

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

#TrustedKeyRemoved(key) ⇒ Object

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()



299
300
301
302
303
304
305
306
307
308
# File 'library/packages/src/modules/SignatureCheckCallbacks.rb', line 299

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