• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-yast2 / 13440235285

20 Feb 2025 04:40PM UTC coverage: 41.869% (-0.02%) from 41.889%
13440235285

push

github

web-flow
Merge pull request #1316 from yast/agama_kernel_conf

Respect Agama kernel parameters

2 of 4 new or added lines in 1 file covered. (50.0%)

265 existing lines in 40 files now uncovered.

12605 of 30106 relevant lines covered (41.87%)

10.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.78
/library/packages/src/modules/SignatureCheckCallbacks.rb
1
# ***************************************************************************
2
#
3
# Copyright (c) 2002 - 2012 Novell, Inc.
4
# All Rights Reserved.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of version 2 of the GNU General Public License as
8
# published by the Free Software Foundation.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail,
19
# you may find current contact information at www.novell.com
20
#
21
# ***************************************************************************
22
# Module:    SignatureCheckCallbacks.ycp
23
# Authors:    Lukas Ocilka <locilka@suse.cz>
24
#
25
# Callbacks for handling signatures.
26
#
27
# $Id: SignatureCheckCallbacks.ycp 28363 2006-02-24 12:27:15Z locilka $
28
require "yast"
1✔
29

30
module Yast
1✔
31
  class SignatureCheckCallbacksClass < Module
1✔
32
    include Yast::Logger
1✔
33

34
    def main
1✔
35
      textdomain "base"
1✔
36

37
      Yast.import "SignatureCheckDialogs"
1✔
38
      Yast.import "Pkg"
1✔
39

40
      # Default return when signatures shouldn't be checked
41
      # @see #SignatureCheckDialogs::CheckSignaturesInYaST()
42
      @default_return_unchecked = true
1✔
43
    end
44

45
    # ============================ < Callbacks for Repositories > ============================
46

47
    # Name of the callback handler function. Required callback prototype is
48
    # boolean(string filename). The callback function should ask user whether the
49
    # unsigned file can be accepted, returned true value means to accept the
50
    # file.
51
    #
52
    # zypp: askUserToAcceptUnsignedFile
53
    #
54
    # (+DontShowAgain functionality) -- for one run in memory
55
    #
56
    # function for CallbackAcceptUnsignedFile()
57
    def AcceptUnsignedFile(filename, repo_id)
1✔
58
      # Check signatures at all?
59
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
60

61
      dont_show_dialog_ident = "-AcceptUnsignedFile-"
×
62

63
      # Show the popup?
64
      if SignatureCheckDialogs.GetShowThisPopup(
×
65
        dont_show_dialog_ident,
66
        filename
67
      )
68
        SignatureCheckDialogs.UseUnsignedItem(
×
69
          :file,
70
          filename,
71
          dont_show_dialog_ident,
72
          repo_id
73
        )
74
        # Return the default value entered by user
75
      else
76
        SignatureCheckDialogs.GetDefaultDialogReturn(
×
77
          dont_show_dialog_ident,
78
          filename
79
        )
80
      end
81
    end
82

83
    # Name of the callback handler function. Required callback prototype is
84
    # boolean(string filename) The callback function should ask user whether
85
    # the unsigned file can be accepted, returned true value means to accept the file.
86
    #
87
    # zypp: askUserToAcceptNoDigest
88
    #
89
    # (+DontShowAgain functionality) -- for one run in memory
90
    #
91
    # function for CallbackAcceptFileWithoutChecksum()
92
    def AcceptFileWithoutChecksum(filename)
1✔
93
      # Check signatures at all?
94
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
95

96
      dont_show_dialog_ident = "-AcceptFileWithoutChecksum-"
×
97

98
      # Show the popup?
99
      if SignatureCheckDialogs.GetShowThisPopup(
×
100
        dont_show_dialog_ident,
101
        filename
102
      )
103
        SignatureCheckDialogs.UseItemWithNoChecksum(
×
104
          :file,
105
          filename,
106
          dont_show_dialog_ident
107
        )
108
        # Return the default value entered by user
109
      else
110
        SignatureCheckDialogs.GetDefaultDialogReturn(
×
111
          dont_show_dialog_ident,
112
          filename
113
        )
114
      end
115
    end
116

117
    # Callback handler function. Required callback prototype is <code>boolean(string filename, string requested_digest, string found_digest)</code>. The callback function should ask user whether the wrong digest can be accepted, returned true value means to accept the file.
118
    # @return [Boolean]
119
    # zypp: askUserToAcceptWrongDigest
120
    def AcceptWrongDigest(filename, requested_digest, found_digest)
1✔
121
      # Check signatures at all?
122
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
123

124
      dont_show_dialog_ident = "-AcceptWrongDigest-"
×
125

126
      # Show the popup?
127
      if SignatureCheckDialogs.GetShowThisPopup(
×
128
        dont_show_dialog_ident,
129
        filename
130
      )
131
        SignatureCheckDialogs.UseFileWithWrongDigest(
×
132
          filename,
133
          requested_digest,
134
          found_digest,
135
          dont_show_dialog_ident
136
        )
137
      else
138
        # Return the default value entered by user
139
        SignatureCheckDialogs.GetDefaultDialogReturn(
×
140
          dont_show_dialog_ident,
141
          filename
142
        )
143
      end
144
    end
145

146
    # Callback handler function. Required callback prototype is <code>boolean(string filename, string name)</code>. The callback function should ask user whether the uknown digest can be accepted, returned true value means to accept the digest.
147
    # @return [Boolean]
148

149
    # zypp: askUserToAccepUnknownDigest
150
    def AcceptUnknownDigest(filename, digest)
1✔
151
      # Check signatures at all?
152
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
153

154
      dont_show_dialog_ident = "-AcceptUnknownDigest-"
×
155

156
      # Show the popup?
157
      if SignatureCheckDialogs.GetShowThisPopup(
×
158
        dont_show_dialog_ident,
159
        filename
160
      )
161
        SignatureCheckDialogs.UseFileWithUnknownDigest(
×
162
          filename,
163
          digest,
164
          dont_show_dialog_ident
165
        )
166
      else
167
        # Return the default value entered by user
168
        SignatureCheckDialogs.GetDefaultDialogReturn(
×
169
          dont_show_dialog_ident,
170
          filename
171
        )
172
      end
173
    end
174

175
    # Name of the callback handler function. Required callback prototype is
176
    # boolean(string filename, string keyid, string keyname). The callback
177
    # function should ask user whether the unknown key can be accepted, returned
178
    # true value means to accept the file.
179
    #
180
    # zypp: askUserToAcceptUnknownKey
181
    #
182
    # (+DontShowAgain functionality) -- for one run in memory
183
    #
184
    # function for CallbackAcceptUnknownGpgKey()
185
    def AcceptUnknownGpgKey(filename, keyid, repoid)
1✔
186
      # Check signatures at all?
187
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
188

189
      dont_show_dialog_ident = "-AcceptUnknownGpgKey-"
×
190

191
      # Show the popup?
192
      if SignatureCheckDialogs.GetShowThisPopup(
×
193
        dont_show_dialog_ident,
194
        filename
195
      )
196
        # Unknown keyname == "Unknown Key"
197
        SignatureCheckDialogs.ItemSignedWithUnknownSignature(
×
198
          :file,
199
          filename,
200
          keyid,
201
          dont_show_dialog_ident,
202
          repoid
203
        )
204
        # Return the default value entered by user
205
      else
206
        SignatureCheckDialogs.GetDefaultDialogReturn(
×
207
          dont_show_dialog_ident,
208
          filename
209
        )
210
      end
211
    end
212

213
    # Name of the callback handler function. Required callback prototype is
214
    # boolean(map<string,any> key). The callback
215
    # function should ask user whether the key is trusted, returned true value
216
    # means the key is trusted.
217
    #
218
    # zypp: askUserToImportKey
219
    #
220
    # function for CallbackImportGpgKey()
221
    def ImportGpgKey(key, repo_id)
1✔
222
      key = deep_copy(key)
2✔
223
      # Check signatures at all?
224
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
2✔
225

226
      SignatureCheckDialogs.ImportGPGKeyIntoTrustedDialog(key, repo_id)
2✔
227
    end
228

229
    # Alternative implementation of #ImportGpgKey, used during installation,
230
    # that disables the repository if the key is not trusted and enables it
231
    # otherwise (a single call to Pkg.ServiceRefresh asks the user several
232
    # times for the same repository, last decision must prevail).
233
    #
234
    # zypp: askUserToImportKey
235
    #
236
    # function for CallbackImportGpgKey()
237
    def import_gpg_key_or_disable(key, repo_id)
1✔
238
      trusted = ImportGpgKey(key, repo_id)
2✔
239
      log.info "Setting enabled to #{trusted} for repo #{repo_id}, due to user reply to ImportGpgKey"
2✔
240
      Pkg.SourceSetEnabled(repo_id, trusted)
2✔
241
      trusted
2✔
242
    end
243

244
    # Name of the callback handler function. Required callback prototype is
245
    # boolean(string filename, map<string,any> key). The callback
246
    # function should ask user whether the unsigned file can be accepted,
247
    # returned true value means to accept the file.
248
    #
249
    # zypp: askUserToAcceptVerificationFailed
250
    #
251
    # function for CallbackAcceptVerificationFailed()
252
    def AcceptVerificationFailed(filename, key, repo_id)
1✔
253
      key = deep_copy(key)
×
254
      # Check signatures at all?
255
      return @default_return_unchecked if SignatureCheckDialogs.CheckSignaturesInYaST == false
×
256

257
      SignatureCheckDialogs.UseCorruptedItem(:file, filename, key, repo_id)
×
258
    end
259

260
    # ============================ < Callbacks for Repositories > ============================
261

262
    # Name of the callback handler function. Required callback prototype is void
263
    # (string keyid, string keyname). The callback function should inform user
264
    # that a trusted key has been added.
265
    #
266
    # function for CallbackTrustedKeyAdded()
267
    def TrustedKeyAdded(key)
1✔
268
      key = deep_copy(key)
×
269
      Builtins.y2milestone(
×
270
        "Trusted key has been added: %1 / %2 (%3)",
271
        Ops.get_string(key, "id", ""),
272
        Ops.get_string(key, "fingerprint", ""),
273
        Ops.get_string(key, "name", "")
274
      )
UNCOV
275
      nil
×
276
    end
277

278
    # Name of the callback handler function. Required callback prototype is void
279
    # (string keyid, string keyname). The callback function should inform user
280
    # that a trusted key has been removed.
281
    #
282
    # function for CallbackTrustedKeyRemoved()
283
    def TrustedKeyRemoved(key)
1✔
284
      key = deep_copy(key)
×
285
      Builtins.y2milestone(
×
286
        "Trusted key has been removed: %1 / %2 (%3)",
287
        Ops.get_string(key, "id", ""),
288
        Ops.get_string(key, "fingerprint", ""),
289
        Ops.get_string(key, "name", "")
290
      )
UNCOV
291
      nil
×
292
    end
293

294
    publish function: :AcceptUnsignedFile, type: "boolean (string, integer)"
1✔
295
    publish function: :AcceptFileWithoutChecksum, type: "boolean (string)"
1✔
296
    publish function: :AcceptWrongDigest, type: "boolean (string, string, string)"
1✔
297
    publish function: :AcceptUnknownDigest, type: "boolean (string, string)"
1✔
298
    publish function: :AcceptUnknownGpgKey, type: "boolean (string, string, integer)"
1✔
299
    publish function: :ImportGpgKey, type: "boolean (map <string, any>, integer)"
1✔
300
    publish function: :import_gpg_key_or_disable, type: "boolean (map <string, any>, integer)"
1✔
301
    publish function: :AcceptVerificationFailed, type: "boolean (string, map <string, any>, integer)"
1✔
302
    publish function: :TrustedKeyAdded, type: "void (map <string, any>)"
1✔
303
    publish function: :TrustedKeyRemoved, type: "void (map <string, any>)"
1✔
304
  end
305

306
  SignatureCheckCallbacks = SignatureCheckCallbacksClass.new
1✔
307
  SignatureCheckCallbacks.main
1✔
308
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc