Class: Yast::SignatureCheckDialogsClass

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

Instance Method Summary collapse

Instance Method Details

#CheckSignaturesObject

A semi-public helper. Convert the kernel parameter to the sysconfig string

Returns:

  • sysconfig value: yes, yast, no



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 198

def CheckSignatures
  cmdline = Linuxrc.InstallInf("Cmdline")
  Builtins.y2milestone("Cmdline: %1", cmdline)

  val = Builtins.regexpsub(
    cmdline,
    "CHECK_SIGNATURES=([[:alpha:]]+)",
    "\\1"
  )
  if val.nil?
    val = Builtins.regexpsub(cmdline, "no_sig_check=([^[:digit:]]+)", "\\1")
    if !val.nil?
      trans = { "0" => "yes", "1" => "yast", "2" => "no" }
      val = Ops.get(trans, val)
    end
  end
  val = "yes" if val.nil?
  val
end

#CheckSignaturesInYaSTObject

Should signatures be checked at all? Check a sysconfig variable (or a kernel parameter for the 1st installation stage).

Returns:

  • do checking?



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 221

def CheckSignaturesInYaST
  if @check_signatures.nil?
    chs = if Stage.initial
      CheckSignatures()
    else
      # default is "yes"
      Convert.to_string(
        SCR.Read(path(".sysconfig.security.CHECK_SIGNATURES"))
      )
    end
    Builtins.y2milestone("CHECK_SIGNATURES: %1", chs)
    @check_signatures = chs != "no"
  end
  @check_signatures
end

#GetDefaultDialogReturn(popup_type, popup_url) ⇒ true, false

Function returns the default popup return value for case when user selected "don't show again"

Parameters:

  • popup_type (String)

    dialog type

  • popup_url (String)

    dialog type

Returns:

  • (true, false)

    default dialog return



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 173

def GetDefaultDialogReturn(popup_type, popup_url)
  if popup_type.nil?
    Builtins.y2error("popup_type %1 mustn't be nil!", popup_type)
    return false
  end

  stored_return = Convert.to_boolean(
    DontShowAgain.GetDefaultReturn(
      "q_type"  => "inst-source",
      "q_ident" => popup_type,
      "q_url"   => popup_url
    )
  )

  Builtins.y2milestone(
    "User decided not to show popup for '%1' again, returning user-decision '%2'",
    popup_type,
    stored_return
  )
  stored_return
end

#GetShowThisPopup(popup_type, popup_url) ⇒ Boolean

Function returns whether user want's to show the dialog (again). true is the default if nothing is set.

Parameters:

  • popup_type (String)

    dialog type

  • popup_url (String)

    if any

Returns:

  • (Boolean)

    show the dialog



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 118

def GetShowThisPopup(popup_type, popup_url)
  if popup_type.nil?
    Builtins.y2error("popup_type %1 mustn't be nil!", popup_type)
    return true
  end

  # Read the current configuration from system configuration
  stored = DontShowAgain.GetShowQuestionAgain(
    "q_type"  => "inst-source",
    "q_ident" => popup_type,
    "q_url"   => popup_url
  )

  # Stored in the configuration?
  stored.nil? ? true : stored
end

#ImportGPGKeyIntoTrustedDialog(key, repository) ⇒ Boolean

ImportUntrustedGPGKeyIntoTrustedDialog

Parameters:

Returns:

  • (Boolean)

    whether zypp should import the key into the keyring of trusted keys



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 640

def ImportGPGKeyIntoTrustedDialog(key, repository)
  key = deep_copy(key)
  # additional Richtext (HTML) warning text (kind of help), 1/2
  warning_text = _(
    "<p>The owner of the key may distribute updates,\n" \
    "packages, and package repositories that your system will trust and offer\n" \
    "for installation and update without any further warning. In this way,\n" \
    "importing the key into your keyring of trusted keys allows the key owner\n" \
    "to have a certain amount of control over the software on your system.</p>"
  ) +
    # additional Richtext (HTML) warning text (kind of help), 2/2
    _(
      "<p>A warning dialog opens for every package that\n" \
      "is not signed by a trusted (imported) key. If you do not trust the key,\n" \
      "the packages or repositories created by the owner of the key will not be used.</p>"
    )

  repo = Pkg.SourceGeneralData(repository)

  # popup message - label, part 1, %1 stands for repository name, %2 for its URL
  dialog_text = Builtins.sformat(
    _(
      "The following GnuPG key has been found in repository\n" \
      "%1\n" \
      "(%2):"
    ),
    Ops.get_locale(repo, "name", _("Unknown")),
    (repo && repo["url"]) ? repo["url"].scan(/.{1,59}/).join("\n") : _("Unknown")
  )

  # popup message - label, part 2
  dialog_text2 = _(
    "You can choose to import it into your keyring of trusted\n" \
    "public keys, meaning that you trust the owner of the key.\n" \
    "You should be sure that you can trust the owner and that\n" \
    "the key really belongs to that owner before importing it."
  )

  expires = Ops.get_integer(key, "expires_raw", 0)
  if Ops.greater_than(expires, 0) &&
      Ops.greater_than(Builtins.time, expires)
    # warning label - the key to import is expired
    dialog_text2 = Ops.add(
      Ops.add(Builtins.sformat(_("WARNING: The key has expired!")), "\n\n"),
      dialog_text2
    )
  end

  displayinfo = UI.GetDisplayInfo
  # hide additional help text in not enough wide terminals so
  # the important GPG key properties are completely displayed
  hide_help = Ops.get_boolean(displayinfo, "TextMode", false) &&
    Ops.less_than(Ops.get_integer(displayinfo, "Width", 80), 105)

  UI.OpenDialog(
    Opt(:decorated),
    HBox(
      # left-side help
      if hide_help
        Empty()
      else
        HWeight(3, VBox(RichText(warning_text)))
      end,
      HSpacing(1.5),
      # dialog
      HWeight(
        5,
        VBox(
          # popup heading
          Heading(_("Import Untrusted GnuPG Key")),
          # dialog message
          MarginBox(
            0.4,
            0.4,
            VBox(
              Left(Label(dialog_text)),
              GPGKeyAsTerm(key),
              Left(Label(dialog_text2))
            )
          ),
          # dialog buttons
          ButtonBox(
            # push button
            PushButton(Id(:trust), Opt(:key_F10, :okButton), _("&Trust")),
            PushButton(
              Id(:cancel),
              Opt(:key_F9, :cancelButton),
              Label.CancelButton
            )
          )
        )
      )
    )
  )

  UI.SetFocus(:cancel)

  ret = Convert.to_symbol(UI.UserInput)

  UI.CloseDialog

  ret == :trust
end

#ItemSignedWithPublicSignature(item_type, item_name, key) ⇒ Symbol

Used for file or package signed by a public key. This key is still not listed in trusted keys.

Parameters:

  • item_type (Symbol)

    :file or :package

  • item_name (String)

    file name or package name

  • key (Hash<String, Object>)

Returns:

  • (Symbol)

    :key_import, :install, :skip



563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 563

def ItemSignedWithPublicSignature(item_type, item_name, key)
  key = deep_copy(key)
  description_text = Builtins.sformat(
    if item_type == :package
      # popup question, %1 stands for the package name, %2 for the key ID, %3 for the key name
      _(
        "The package %1 is digitally signed\n" \
        "with key '%2 (%3)'.\n" \
        "\n" \
        "There is no trust relationship with the owner of the key.\n" \
        "If you trust the owner, mark the key as trusted.\n" \
        "\n" \
        "Installing a package from an unknown repository puts\n" \
        "the integrity of your system at risk. It is safest\n" \
        "to skip the package.\n"
      )
    else
      item_name = strip_download_prefix(item_name)
      # popup question, %1 stands for the filename, %2 for the key ID, %3 for the key name
      _(
        "The file %1 is digitally signed\n" \
        "with key '%2 (%3)'.\n" \
        "\n" \
        "There is no trust relationship with the owner of the key.\n" \
        "If you trust the owner, mark the key as trusted.\n" \
        "\n" \
        "Installing a file from an unknown repository puts\n" \
        "the integrity of your system at risk. It is safest\n" \
        "to skip it.\n"
      )
    end,
    item_name,
    Ops.get_string(key, "id", ""),
    Ops.get_string(key, "name", "")
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      # popup heading
      Heading(_("Signed with Untrusted Public Key")),
      MarginBox(0.5, 0.5, Label(description_text)),
      ButtonBox(
        # push button
        PushButton(
          Id(:trust),
          Opt(:okButton, :key_F10),
          _("&Trust and Import the Key")
        ),
        PushButton(Id(:skip), Opt(:cancelButton, :key_F9), Label.SkipButton)
      )
    )
  )
  UI.SetFocus(:skip)

  # wait for one of listed ID's, return the default value in case of `cancel
  ret = WaitForSymbolUserInput([:trust, :skip], :skip)

  if ret == :trust
    # later, if asking whether to import the key, the key is trusted
    # so it will be also imported
    # bugzilla #282254
    @list_of_trusted_keys = Builtins.add(
      @list_of_trusted_keys,
      Ops.get_string(key, "id", "")
    )
  end

  UI.CloseDialog
  ret
end

#ItemSignedWithUnknownSignature(item_type, item_name, key_id, dont_show_dialog_ident, repoid) ⇒ Boolean

Used for file or package signed by unknown key.

Parameters:

  • item_type (Symbol)

    file orpackage

  • item_name (String)

    file name or package name

  • key_id (String)
  • dont_show_dialog_ident (String)

    for the identification in magic "don't show" functions

  • repoid (Fixnum)

    Id of the repository from the item was downloaded

Returns:

  • (Boolean)

    true if 'yes, use file'



474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 474

def ItemSignedWithUnknownSignature(item_type, item_name, key_id, dont_show_dialog_ident, repoid)
  repo_url = Ops.get_string(Pkg.SourceGeneralData(repoid), "url", "")
  description_text = Builtins.sformat(
    if item_type == :package
      # popup question, %1 stands for the package name, %2 for the complex multiline description of the GnuPG key
      _(
        "The package %1 is digitally signed\n" \
        "with the following unknown GnuPG key: %2.\n" \
        "\n" \
        "This means that a trust relationship to the creator of the package\n" \
        "cannot be established. Installing the package may put the integrity\n" \
        "of your system at risk.\n" \
        "\n" \
        "Install it anyway?"
      )
    else
      item_name = strip_download_prefix(item_name)
      # popup question, %1 stands for the filename, %2 for the complex multiline description of the GnuPG key
      _(
        "The file %1\n" \
        "is digitally signed with the following unknown GnuPG key: %2.\n" \
        "\n" \
        "This means that a trust relationship to the creator of the file\n" \
        "cannot be established. Using the file may put the integrity\n" \
        "of your system at risk.\n" \
        "\n" \
        "Use it anyway?"
      )
    end,
    # TODO: use something like "%1 from %2" and make it translatable
    if repo_url == ""
      item_name
    else
      Builtins.sformat("%1 (%2)", item_name, repo_url)
    end,
    Ops.add(
      "\n",
      # Part of the GnuPG key description in popup, %1 is a GnuPG key ID
      Builtins.sformat(_("ID: %1"), key_id)
    )
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      # popup heading
      Heading(_("Unknown GnuPG Key")),
      MarginBox(0.5, 0.5, Label(description_text)),
      Left(
        MarginBox(
          0,
          1.2,
          CheckBox(
            Id(:dont_show_again),
            Message.DoNotShowMessageAgain,
            GetShowThisPopup(dont_show_dialog_ident, item_name) ? false : true
          )
        )
      ),
      YesNoButtons(:no)
    )
  )

  # This will optionally offer to retrieve the key from gpg keyservers
  # That's why it will return 'symbol' instead of 'boolean'
  # But by now it only handles yes/no/cancel
  ret = WaitForYesNoCancelUserInput()
  # default value
  ret = false if ret.nil?

  # Store the don't show value, store the default return value
  HandleDoNotShowDialogAgain(
    ret,
    dont_show_dialog_ident,
    :dont_show_again,
    item_name
  )

  UI.CloseDialog
  ret
end

#mainObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 32

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

  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Message"
  Yast.import "DontShowAgain"
  Yast.import "Stage"
  Yast.import "Linuxrc"

  # --------------------------- Don't show this dialog again Magic ---------------------------

  # /etc/sysconfig/security:CHECK_SIGNATURES

  @check_signatures = nil # lazy

  # Standard text strings

  # GnuPG fingerprint used as "Fingerprint: AAA BBB CCC"
  @s_fingerprint = _("Fingerprint")
  # GnuPG key ID used as "Key ID: 1144AAAA444"
  @s_keyid = _("Key ID")

  # UI can show images
  @has_local_image_support = nil

  # List of trusted keys
  #
  # @see bugzilla #282254
  @list_of_trusted_keys = []
end

#SetDefaultDialogReturn(popup_type, default_return, popup_url) ⇒ Object

Function sets the default dialog return value for case when user selected "don't show again"

Parameters:

  • popup_type (String)

    dialog type

  • default_return (Boolean)


140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 140

def SetDefaultDialogReturn(popup_type, default_return, popup_url)
  if popup_type.nil? || default_return.nil?
    Builtins.y2error(
      "Neither popup_type %1 nor default_return %2 can be nil!",
      popup_type,
      default_return
    )
    return
  end
  Builtins.y2milestone(
    "User decision in default return for '%1' for '%2' is '%3'",
    popup_type,
    popup_url,
    default_return
  )
  DontShowAgain.SetDefaultReturn(
    {
      "q_type"  => "inst-source",
      "q_ident" => popup_type,
      "q_url"   => popup_url
    },
    default_return
  )

  nil
end

#SetShowThisPopup(popup_type, show_it, popup_url) ⇒ Object

Functions sets whether user want's to show the dialog again

Parameters:

  • popup_type (String)

    dialog type

  • show_it (true, false)

    show again

  • popup_url (String)


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 73

def SetShowThisPopup(popup_type, show_it, popup_url)
  if popup_type.nil? || show_it.nil?
    Builtins.y2error(
      "Neither popup_type %1 nor show_it %2 can be nil!",
      popup_type,
      show_it
    )
    return
  end

  # it's the default
  if show_it
    Builtins.y2debug(
      "User decision to show dialog '%1' again is '%2'",
      popup_type,
      show_it
    )
    # store only "don't show"
  else
    Builtins.y2milestone(
      "User decision to show dialog '%1' for '%2' again is '%3'",
      popup_type,
      popup_url,
      show_it
    )
    # Show again -> false, so, store it
    DontShowAgain.SetShowQuestionAgain(
      {
        "q_type"  => "inst-source",
        "q_ident" => popup_type,
        "q_url"   => popup_url
      },
      show_it
    )
  end

  nil
end

#UseCorruptedItem(item_type, item_name, key, repository) ⇒ Boolean

Used for corrupted file or package. Opens dialog asking whether user wants to use this corrupted item.

Parameters:

  • item_type (Symbol)

    file orpackage

  • item_name (String)

    file name or package name

  • key (Hash{String => Object})

    Used key

Returns:

  • (Boolean)

    use or don't use ('true' if 'yes')



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 409

def UseCorruptedItem(item_type, item_name, key, repository)
  key = deep_copy(key)
  repo = Pkg.SourceGeneralData(repository)

  description_text = Builtins.sformat(
    if item_type == :package
      # popup question, %1 stands for the package name, %2 for the complete description of the GnuPG key (multiline)
      _(
        "Package %1 from repository %2\n" \
        "%3\n" \
        "is signed with the following GnuPG key, but the integrity check failed: %4\n" \
        "\n" \
        "The package has been changed, either by accident or by an attacker,\n" \
        "since the repository creator signed it. Installing it is a big risk\n" \
        "for the integrity and security of your system.\n" \
        "\n" \
        "Install it anyway?\n"
      )
    else
      item_name = strip_download_prefix(item_name)
      # popup question, %1 stands for the filename, %2 for the complete description of the GnuPG key (multiline)
      _(
        "File %1 from repository %2\n" \
        "%3\n" \
        "is signed with the following GnuPG key, but the integrity check failed: %4\n" \
        "\n" \
        "The file has been changed, either by accident or by an attacker,\n" \
        "since the repository creator signed it. Using it is a big risk\n" \
        "for the integrity and security of your system.\n" \
        "\n" \
        "Use it anyway?\n"
      )
    end,
    item_name,
    Ops.get_locale(repo, "name", _("Unknown")),
    Ops.get_locale(repo, "url", _("Unknown")),
    Ops.add("\n\n", GPGKeyAsString(key))
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      # popup heading
      Heading(_("Validation Check Failed")),
      MarginBox(0.5, 0.5, Label(description_text)),
      YesNoButtons(:no)
    )
  )

  ret = WaitForYesNoCancelUserInput()
  # default value
  ret = false if ret.nil?

  UI.CloseDialog
  ret
end

#UseFileWithUnknownDigest(filename, digest, dont_show_dialog_ident) ⇒ Boolean

Ask user to accept a file with unknown checksum

Parameters:

  • filename (String)

    Name of the file

  • digest (String)

    Current checksum

  • dont_show_dialog_ident (String)

    Uniq ID for "don't show again"

Returns:

  • (Boolean)

    true when user accepts the file



788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 788

def UseFileWithUnknownDigest(filename, digest, dont_show_dialog_ident)
  filename = strip_download_prefix(filename)
  description_text =
    # popup question, %1 stands for the filename, %2 is expected digest, %3 is the current digest
    Builtins.sformat(
      _(
        "The checksum of file %1\n" \
        "is %2,\n" \
        "but the expected checksum is not known.\n" \
        "\n" \
        "This means that the origin and integrity of the file\n" \
        "cannot be verified. Using the file puts the integrity of your system at risk.\n" \
        "\n" \
        "Use it anyway?\n"
      ),
      filename,
      digest
    )
  # dialog heading - displayed in a big bold font
  heading = _("Unknown Digest")

  RunSimpleErrorPopup(
    heading,
    description_text,
    dont_show_dialog_ident,
    filename
  )
end

#UseFileWithWrongDigest(filename, requested_digest, found_digest, dont_show_dialog_ident) ⇒ Boolean

Ask user to accept wrong digest

Parameters:

  • filename (String)

    Name of the file

  • requested_digest (String)

    Expected checksum

  • found_digest (String)

    Current checksum

  • dont_show_dialog_ident (String)

    Uniq ID for "don't show again"

Returns:

  • (Boolean)

    true when user accepts the file



750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 750

def UseFileWithWrongDigest(filename, requested_digest, found_digest, dont_show_dialog_ident)
  filename = strip_download_prefix(filename)
  description_text =
    # popup question, %1 stands for the filename, %2 is expected checksum
    # %3 is the current checksum (e.g. "803a8ff00d00c9075a1bd223a480bcf92d2481c1")
    Builtins.sformat(
      _(
        "The expected checksum of file %1\n" \
        "is %2,\n" \
        "but the current checksum is %3.\n" \
        "\n" \
        "The file has been changed by accident or by an attacker\n" \
        "since the repository creator signed it. Using it is a big risk\n" \
        "for the integrity and security of your system.\n" \
        "\n" \
        "Use it anyway?\n"
      ),
      filename,
      requested_digest,
      found_digest
    )

  # dialog heading - displayed in a big bold font
  heading = _("Wrong Digest")

  RunSimpleErrorPopup(
    heading,
    description_text,
    dont_show_dialog_ident,
    filename
  )
end

#UseItemWithNoChecksum(item_type, item_name, dont_show_dialog_ident) ⇒ Boolean

Used for file or package on signed repository but without any checksum. Opens dialog asking whether user wants to use this item.

Parameters:

  • item_type (Symbol)

    file orpackage

  • item_name (String)

    file name or package name

  • dont_show_dialog_ident (String)

    for the identification in magic "don't show" functions

Returns:

  • (Boolean)

    use or don't use ('true' if 'yes')



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 338

def UseItemWithNoChecksum(item_type, item_name, dont_show_dialog_ident)
  description_text = Builtins.sformat(
    if item_type == :package
      # popup question, %1 stands for the package name
      _(
        "No checksum for package %1 was found in the repository.\n" \
        "While the package is part of the signed repository, it is not contained \n" \
        "in the list of checksums in this repository. Installing the package puts \n" \
        "the integrity of your system at risk.\n" \
        "\n" \
        "Install it anyway?\n"
      )
    else
      item_name = strip_download_prefix(item_name)
      # popup question, %1 stands for the filename
      _(
        "No checksum for file %1 was found in the repository.\n" \
        "This means that the file is part of the signed repository,\n" \
        "but the list of checksums in this repository does not mention this file. Using the file\n" \
        "may put the integrity of your system at risk.\n" \
        "\n" \
        "Use it anyway?"
      )
    end,
    item_name
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      # popup heading
      Heading(_("No Checksum Found")),
      MarginBox(0.5, 0.5, Label(description_text)),
      Left(
        MarginBox(
          0,
          1.2,
          CheckBox(
            Id(:dont_show_again),
            Message.DoNotShowMessageAgain,
            GetShowThisPopup(dont_show_dialog_ident, item_name) ? false : true
          )
        )
      ),
      YesNoButtons(:no)
    )
  )

  ret = WaitForYesNoCancelUserInput()
  # default value
  ret = false if ret.nil?

  # Store the don't show value, store the default return value
  HandleDoNotShowDialogAgain(
    ret,
    dont_show_dialog_ident,
    :dont_show_again,
    item_name
  )

  UI.CloseDialog
  ret
end

#UseUnsignedItem(item_type, item_name, dont_show_dialog_ident, repository) ⇒ Boolean

Used for unsiged file or package. Opens dialog asking whether user wants to use this unsigned item.

Parameters:

  • item_type (Symbol)

    file orpackage

  • item_name (String)

    file name or package name

  • dont_show_dialog_ident (String)

    for the identification in magic "don't show" functions

Returns:

  • (Boolean)

    use or don't use ('true' if 'yes')



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'library/packages/src/modules/SignatureCheckDialogs.rb', line 244

def UseUnsignedItem(item_type, item_name, dont_show_dialog_ident, repository)
  Builtins.y2milestone(
    "UseUnsignedItem: type: %1, name: %2, dontshowid: %3, repo: %4",
    item_type,
    item_name,
    dont_show_dialog_ident,
    repository
  )

  repo = Pkg.SourceGeneralData(repository)

  description_text = Builtins.sformat(
    if item_type == :package
      # popup question, %1 stands for the package name
      # %2 is a repository name
      # %3 is URL of the repository
      _(
        "The package %1 from repository %2\n" \
        "%3\n" \
        "is not digitally signed. This means that the origin\n" \
        "and integrity of the package cannot be verified. Installing the package\n" \
        "may put the integrity of your system at risk.\n" \
        "\n" \
        "Install it anyway?"
      )
    else
      item_name = strip_download_prefix(item_name)
      # popup question, %1 stands for the filename
      # %2 is a repository name
      # %3 is URL of the repository
      _(
        "The file %1 from repository %2\n" \
        "%3\n" \
        "is not digitally signed. The origin and integrity of the file\n" \
        "cannot be verified. Using the file anyway puts the integrity of your \n" \
        "system at risk.\n" \
        "\n" \
        "Use it anyway?\n"
      )
    end,
    item_name,
    Ops.get_locale(repo, "name", _("Unknown")),
    Ops.get_locale(repo, "url", _("Unknown"))
  )

  UI.OpenDialog(
    Opt(:decorated),
    VBox(
      Heading(
        if item_type == :package
          _("Unsigned Package")
        else
          _("Unsigned File")
        end
      ),
      MarginBox(0.5, 0.5, Label(description_text)),
      Left(
        MarginBox(
          0,
          1.2,
          CheckBox(
            Id(:dont_show_again),
            Message.DoNotShowMessageAgain,
            GetShowThisPopup(dont_show_dialog_ident, item_name) ? false : true
          )
        )
      ),
      YesNoButtons(:no)
    )
  )

  ret = WaitForYesNoCancelUserInput()
  # default value
  ret = false if ret.nil?

  # Store the don't show value, store the default return value
  HandleDoNotShowDialogAgain(
    ret,
    dont_show_dialog_ident,
    :dont_show_again,
    item_name
  )

  UI.CloseDialog
  ret
end