Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2020-09-15 16:14:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new.4249 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Tue Sep 15 16:14:39 2020 rev:493 rq:833457 version:4.3.25 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2020-09-03 01:10:27.212392973 +0200 +++ /work/SRC/openSUSE:Factory/.yast2.new.4249/yast2.changes 2020-09-15 16:14:44.821826533 +0200 @@ -1,0 +2,8 @@ +Thu Sep 10 07:30:52 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Enhance GPG module with symmetric encryption + (related to bsc#1176336) +- add new shared password dialog +- 4.3.25 + +------------------------------------------------------------------- Old: ---- yast2-4.3.24.tar.bz2 New: ---- yast2-4.3.25.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.KA8bQy/_old 2020-09-15 16:14:46.581828163 +0200 +++ /var/tmp/diff_new_pack.KA8bQy/_new 2020-09-15 16:14:46.581828163 +0200 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.3.24 +Version: 4.3.25 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only ++++++ yast2-4.3.24.tar.bz2 -> yast2-4.3.25.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/general/example/password_dialog.rb new/yast2-4.3.25/library/general/example/password_dialog.rb --- old/yast2-4.3.24/library/general/example/password_dialog.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/general/example/password_dialog.rb 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1,8 @@ +$LOAD_PATH.unshift File.expand_path("../src/lib", __dir__) + +require "yast" +require "yast2/popup" +require "ui/password_dialog" + +res = UI::PasswordDialog.new("Test").run +Yast2::Popup.show("Dialog returns #{res.inspect}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/general/example/password_dialog_confirm.rb new/yast2-4.3.25/library/general/example/password_dialog_confirm.rb --- old/yast2-4.3.24/library/general/example/password_dialog_confirm.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/general/example/password_dialog_confirm.rb 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1,8 @@ +$LOAD_PATH.unshift File.expand_path("../src/lib", __dir__) + +require "yast" +require "yast2/popup" +require "ui/password_dialog" + +res = UI::PasswordDialog.new("Test", confirm: true).run +Yast2::Popup.show("Dialog returns #{res.inspect}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/general/src/lib/ui/password_dialog.rb new/yast2-4.3.25/library/general/src/lib/ui/password_dialog.rb --- old/yast2-4.3.24/library/general/src/lib/ui/password_dialog.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/general/src/lib/ui/password_dialog.rb 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1,78 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "shellwords" + +require "ui/dialog" +require "yast2/popup" + +Yast.import "UI" +Yast.import "Label" + +module UI + # Dialog that asks for password. It returns String password or nil if aborted. + # + class PasswordDialog < UI::Dialog + extend Yast::I18n + extend Yast::UIShortcuts + + # @param label [String] intention of password e.g. "Encrypted autoyast profile." + # @param confirm [Boolean] if double password entry is required. + # Usually when new password is specified. + def initialize(label, confirm: false) + textdomain "autoinst" + @confirm = confirm + @label = label + + super() + end + + def dialog_content + res = VBox( + Left(Heading(@label)), + Password(Id(:password), Yast::Label.Password, "") + ) + res << Password(Id(:password2), Yast::Label.ConfirmPassword, "") if @confirm + + res << HBox( + PushButton(Id(:ok), Yast::Label.OKButton), + PushButton(Id(:abort), Yast::Label.AbortButton) + ) + + res + end + + def abort_handler + finish_dialog(nil) + end + + def ok_handler + password = Yast::UI.QueryWidget(:password, :Value) + if @confirm + password2 = Yast::UI.QueryWidget(:password2, :Value) + if password != password2 + Yast2::Popup.show(_("Passwords does not match."), headline: :error) + return + end + end + finish_dialog(password) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/gpg/MAINTAINER new/yast2-4.3.25/library/gpg/MAINTAINER --- old/yast2-4.3.24/library/gpg/MAINTAINER 2020-08-27 12:51:22.000000000 +0200 +++ new/yast2-4.3.25/library/gpg/MAINTAINER 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -Ladislav Slezak <lsle...@suse.cz> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/gpg/src/modules/GPG.rb new/yast2-4.3.25/library/gpg/src/modules/GPG.rb --- old/yast2-4.3.24/library/gpg/src/modules/GPG.rb 2020-08-27 12:51:22.000000000 +0200 +++ new/yast2-4.3.25/library/gpg/src/modules/GPG.rb 2020-09-10 12:53:09.000000000 +0200 @@ -401,6 +401,38 @@ Ops.get_integer(out, "exit", -1) == 0 end + # Decrypts file with symmetric cipher. + # @param [String] file encrypted file + # @param [String] password to use + # @return [String] decrypted content of file + # @raise [GPGFailed] when decryption failed + def decrypt_symmetric(file, password) + out = callGPG("--decrypt --batch --passphrase '#{String.Quote(password)}' '#{String.Quote(file)}'") + + raise GPGFailed, out["stderr"] if out["exit"] != 0 + + out["stdout"] + end + + # @return [Boolean] if file is gpg symmetric encrypted with --armor + def encrypted_symmetric?(file) + File.readlines(file).first&.strip == "-----BEGIN PGP MESSAGE-----" + end + + # Encrypts file with symmetric cipher. + # @param [String] input_file file to encrypt + # @param [String] output_file where result is written + # @param [String] password to use + # @return [void] + # @note exception is raised even if file exist + # @raise [GPGFailed] when encryption failed + def encrypt_symmetric(input_file, output_file, password) + out = callGPG("--armor --batch --symmetric --passphrase '#{String.Quote(password)}' " \ + "--output '#{String.Quote(output_file)}' '#{String.Quote(input_file)}'") + + raise GPGFailed, out["stderr"] if out["exit"] != 0 + end + publish function: :Init, type: "boolean (string, boolean)" publish function: :PublicKeys, type: "list <map> ()" publish function: :PrivateKeys, type: "list <map> ()" @@ -412,6 +444,11 @@ publish function: :ExportPublicKey, type: "boolean (string, string)" end + # Exception raised when GPG failed + # @note not all methods in GPG module use this exception + class GPGFailed < RuntimeError + end + GPG = GPGClass.new GPG.main end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/gpg/test/data/test.asc new/yast2-4.3.25/library/gpg/test/data/test.asc --- old/yast2-4.3.24/library/gpg/test/data/test.asc 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/gpg/test/data/test.asc 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1,10 @@ +-----BEGIN PGP MESSAGE----- + +jA0ECQMCcDEcLgINyN7u0sAmAVC1w1tmY2SohOmPd4ChbkpPtEzvPbVQ+0TdOnQM +Jpf3i4cPHTF0hw624N+SfIvlyAxu3VG6Ck7FDtWieBQlcSYEvZ1eIZAlD4jZIE5R +lp6JwzelfxbMvX9jmqhPpLSKYJBlbThce9Yr3MUfIrURleiD6YTCuse7YrbmmDfP +ZZzVXqyl9IzENi09awxCOVHbrz5Fn7urWFB2onM5xuyT0C82EGTfpuiPrQDo2Gfw +iEES4TGKcP0xRcXeXHaHg20ddHJvozM3RXphqfwhdJ2CylumgYnjZVkYZHM39Sdk +drSOtqVQVLM= +=xi/T +-----END PGP MESSAGE----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/gpg/test/gpg_test.rb new/yast2-4.3.25/library/gpg/test/gpg_test.rb --- old/yast2-4.3.24/library/gpg/test/gpg_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/gpg/test/gpg_test.rb 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1,94 @@ +#!/usr/bin/env rspec +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "test_helper" +require "tempfile" +require "tmpdir" +require "fileutils" + +Yast.import "GPG" + +describe Yast::GPG do + let(:file_content) do + File.read(File.join(__dir__, "data", "test.asc")) + end + + let(:label) { "test" } + + around do |t| + file = Tempfile.open + file.write file_content + file.close + + @path = file.path + + t.call + + file.unlink + end + + describe "#decrypt_symmetric" do + context "file contain gpg encrypted file" do + it "returns content if password was correct" do + expect(described_class.decrypt_symmetric(@path, "test")).to match(/<zeroOrMore>/) + end + + it "raises Yast::GPGFailed expcetion if password is not correct" do + expect { described_class.decrypt_symmetric(@path, "wrong") }.to raise_error(Yast::GPGFailed) + end + end + + context "file is not encrypted" do + let(:file_content) { "test\n" } + + it "raises Yast::GPGFailed exception" do + expect { described_class.decrypt_symmetric(@path, "test") }.to raise_error(Yast::GPGFailed) + end + end + end + + describe "#encrypted_symmetric?" do + context "file contain gpg encrypted file" do + it "returns true" do + expect(described_class.encrypted_symmetric?(@path)).to eq true + end + end + + context "file is not encrypted" do + let(:file_content) { "test\n" } + + it "returns false" do + expect(described_class.encrypted_symmetric?(@path)).to eq false + end + end + end + + describe "#encrypted_symmetric" do + let(:file_content) { "test\n" } + + it "will create output file that is encrypted" do + Dir.mktmpdir do |dir| + path = File.join(dir, "encrypted") + described_class.encrypt_symmetric(@path, path, "test") + expect(described_class.encrypted_symmetric?(path)).to eq true + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/library/gpg/test/test_helper.rb new/yast2-4.3.25/library/gpg/test/test_helper.rb --- old/yast2-4.3.24/library/gpg/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.3.25/library/gpg/test/test_helper.rb 2020-09-10 12:53:09.000000000 +0200 @@ -0,0 +1 @@ +require_relative "../../../test/test_helper.rb" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/package/yast2.changes new/yast2-4.3.25/package/yast2.changes --- old/yast2-4.3.24/package/yast2.changes 2020-08-27 12:51:22.000000000 +0200 +++ new/yast2-4.3.25/package/yast2.changes 2020-09-10 12:53:09.000000000 +0200 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Thu Sep 10 07:30:52 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Enhance GPG module with symmetric encryption + (related to bsc#1176336) +- add new shared password dialog +- 4.3.25 + +------------------------------------------------------------------- Thu Aug 27 10:37:14 UTC 2020 - Ladislav Slezák <lsle...@suse.cz> - Fixed accidentaly broken dependencies (related to bsc#1175317) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.24/package/yast2.spec new/yast2-4.3.25/package/yast2.spec --- old/yast2-4.3.24/package/yast2.spec 2020-08-27 12:51:22.000000000 +0200 +++ new/yast2-4.3.25/package/yast2.spec 2020-09-10 12:53:09.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.3.24 +Version: 4.3.25 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only