Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-firstboot for openSUSE:Factory checked in at 2021-07-02 13:26:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-firstboot (Old) and /work/SRC/openSUSE:Factory/.yast2-firstboot.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-firstboot" Fri Jul 2 13:26:32 2021 rev:105 rq:903243 version:4.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-firstboot/yast2-firstboot.changes 2021-05-20 19:23:15.538394182 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-firstboot.new.2625/yast2-firstboot.changes 2021-07-02 13:26:48.101070357 +0200 @@ -1,0 +2,6 @@ +Thu Jun 17 07:43:12 UTC 2021 - David Diaz <dgonzalez@suse.com> + +- Adapt code to Y2Users (part of jsc#PM-2620). +- 4.4.2 + +------------------------------------------------------------------- Old: ---- yast2-firstboot-4.4.1.tar.bz2 New: ---- yast2-firstboot-4.4.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-firstboot.spec ++++++ --- /var/tmp/diff_new_pack.fn1gha/_old 2021-07-02 13:26:48.577066664 +0200 +++ /var/tmp/diff_new_pack.fn1gha/_new 2021-07-02 13:26:48.581066633 +0200 @@ -17,7 +17,7 @@ Name: yast2-firstboot -Version: 4.4.1 +Version: 4.4.2 Release: 0 Summary: YaST2 - Initial System Configuration License: GPL-2.0-only ++++++ yast2-firstboot-4.4.1.tar.bz2 -> yast2-firstboot-4.4.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/README.md new/yast2-firstboot-4.4.2/README.md --- old/yast2-firstboot-4.4.1/README.md 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/README.md 2021-06-30 15:47:16.000000000 +0200 @@ -60,4 +60,4 @@ If you have any question, feel free to ask at the [development mailing list](http://lists.opensuse.org/yast-devel/) or at the -[#yast](https://webchat.freenode.net/?channels=%23yast) IRC channel on freenode. +[#yast](https://web.libera.chat/#yast) IRC channel on libera.chat. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/package/yast2-firstboot.changes new/yast2-firstboot-4.4.2/package/yast2-firstboot.changes --- old/yast2-firstboot-4.4.1/package/yast2-firstboot.changes 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/package/yast2-firstboot.changes 2021-06-30 15:47:16.000000000 +0200 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Thu Jun 17 07:43:12 UTC 2021 - David Diaz <dgonzalez@suse.com> + +- Adapt code to Y2Users (part of jsc#PM-2620). +- 4.4.2 + +------------------------------------------------------------------- Sun May 16 08:11:46 UTC 2021 - Dirk M��ller <dmueller@suse.com> - only list specific files installed in common directories (metainfo, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/package/yast2-firstboot.spec new/yast2-firstboot-4.4.2/package/yast2-firstboot.spec --- old/yast2-firstboot-4.4.1/package/yast2-firstboot.spec 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/package/yast2-firstboot.spec 2021-06-30 15:47:16.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-firstboot -Version: 4.4.1 +Version: 4.4.2 Release: 0 Summary: YaST2 - Initial System Configuration License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/hostname.rb new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/hostname.rb --- old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/hostname.rb 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/hostname.rb 2021-06-30 15:47:16.000000000 +0200 @@ -88,13 +88,17 @@ private + def really_abort_inst + Popup.ConfirmAbort(:incomplete) + end + def hostname_dialog @hn_settings = InitSettings() functions = { "init" => fun_ref(method(:InitHnWidget), "void (string)"), "store" => fun_ref(method(:StoreHnWidget), "void (string, map)"), - :abort => fun_ref(method(:ReallyAbortInst), "boolean ()") + :abort => fun_ref(method(:really_abort_inst), "boolean ()") } contents = HSquash( # Frame label diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/root.rb new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/root.rb --- old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/root.rb 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/root.rb 2021-06-30 15:47:16.000000000 +0200 @@ -21,17 +21,56 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require "users/dialogs/inst_root_first" -Yast.import "UsersSimple" +require "y2users/password" +require "y2users/linux/writer" +require "y2users/config_manager" +require "y2users/clients/inst_root_first" module Y2Firstboot module Clients - # Client to set the root password - class Root < Yast::Client + # Client for setting the root password + class Root < Y2Users::Clients::InstRootFirst + # Overload Y2Users::Clients::InstRootFirst#run to wipe the encrypted password + # @see #reset_password def run - dialog_result = Yast::InstRootFirstDialog.new.run - Yast::UsersSimple.Write if dialog_result == :next - dialog_result + reset_password + + super + end + + private + + # Wipes encrypted password + # + # @note This method can be considered a sort of workaround for supporting + # as much as possible a "clean" navigation through the Firstboot dialogs + # when going back and forward (just in case the admin decides to offer + # such a feature), EVEN THOUGH is not the intended behavior since + # Firstboot clients perform changes in the running system right away. + def reset_password + return unless root_user.password&.value&.encrypted? + + root_user.password = Y2Users::Password.create_plain("") + end + + # Updates the target configuration and writes it to the system + # + # @see Y2Users::Clients::InstRootFirst#update_target_config + def update_target_config + super + + writer = Y2Users::Linux::Writer.new( + Y2Users::ConfigManager.instance.target, + Y2Users::ConfigManager.instance.system + ) + writer.write + end + + # System config, which contains all the current users on the system + # + # @return [Y2Users::Config] + def config + @config ||= Y2Users::ConfigManager.instance.system(force_read: true).copy end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/user.rb new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/user.rb --- old/yast2-firstboot-4.4.1/src/lib/y2firstboot/clients/user.rb 2021-05-19 17:22:27.000000000 +0200 +++ new/yast2-firstboot-4.4.2/src/lib/y2firstboot/clients/user.rb 2021-06-30 15:47:16.000000000 +0200 @@ -21,34 +21,76 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. +require "y2users/password" +require "y2users/linux/writer" +require "y2users/config_manager" require "users/dialogs/inst_user_first" + Yast.import "Users" -Yast.import "UsersSimple" Yast.import "Progress" module Y2Firstboot module Clients - # Client to set up the first user + # Client to set up the first user during the firstboot mode class User < Yast::Client - def initialize - Yast.include self, "users/routines.rb" + class << self + # @return [String, nil] the username of the created/edited user as a + # result of the execution of this client, if any. Needed for retrieving + # the user when going back and forward. See {#user} + attr_accessor :username end def run - dialog = Yast::InstUserFirstDialog.new - dialog_result = dialog.run - if dialog_result == :next && dialog.action == :new_user - # Change root password if needed - Yast::UsersSimple.Write - # Create user - if setup_all_users - # Do not mess with the progress indicator - orig = Yast::Progress.set(false) - Yast::Users.Write - Yast::Progress.set(orig) - end - end - dialog_result + reset_password + + result = Yast::InstUserFirstDialog.new(config, user: user).run + + write_config if result == :next + + # Updates the username reference. See {#user} + self.class.username = user.attached? ? user.name : nil + + result + end + + private + + # Wipes encrypted password + # + # @note This method can be considered a sort of workaround for supporting + # as much as possible a "clean" navigation through the Firstboot dialogs + # when going back and forward (just in case the admin decides to offer + # such a feature), EVEN THOUGH is not the intended behavior since + # Firstboot clients perform changes in the running system right away. + def reset_password + return unless user.password&.value&.encrypted? + + user.password = Y2Users::Password.create_plain("") + end + + # Writes config to the system + def write_config + writer = Y2Users::Linux::Writer.new( + config, + Y2Users::ConfigManager.instance.system + ) + + writer.write + end + + # A copy of config holding all the users on the system + # + # @return [Y2Users::Config] + def config + @config ||= Y2Users::ConfigManager.instance.system(force_read: true).copy + end + + # The user to be created/edited + # + # @return [Y2Users::User] + def user + @user ||= config.users.by_name(self.class.username) if self.class.username + @user ||= Y2Users::User.new("") end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/test/y2firstboot/clients/root_test.rb new/yast2-firstboot-4.4.2/test/y2firstboot/clients/root_test.rb --- old/yast2-firstboot-4.4.1/test/y2firstboot/clients/root_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-firstboot-4.4.2/test/y2firstboot/clients/root_test.rb 2021-06-30 15:47:16.000000000 +0200 @@ -0,0 +1,111 @@ +#!/usr/bin/env rspec +# Copyright (c) [2018] 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 "y2firstboot/clients/root" + +describe Y2Firstboot::Clients::Root do + subject(:client) { described_class.new } + + let(:inst_root_dialog) { instance_double(Yast::InstRootFirstDialog, run: result) } + let(:result) { :next } + + let(:writer) { instance_double(Y2Users::Linux::Writer, write: []) } + + let(:target_config) { Y2Users::Config.new } + let(:system_config) { Y2Users::Config.new } + let(:system_config_copy) { Y2Users::Config.new } + let(:config_manager) { Y2Users::ConfigManager.instance } + let(:root_user) { Y2Users::User.create_root } + let(:root_password) { nil } + + before do + root_user.password = root_password + allow(Yast::InstRootFirstDialog).to receive(:new).and_return(inst_root_dialog) + + allow(Y2Users::Linux::Writer).to receive(:new).and_return(writer) + + system_config_copy.attach([root_user]) + allow(system_config).to receive(:copy).and_return(system_config_copy) + allow(config_manager).to receive(:target).and_return(target_config) + allow(config_manager).to receive(:system).and_return(system_config) + end + + describe "#run" do + context "when root user has an encrypted password" do + let(:root_password) { Y2Users::Password.create_encrypted("s3cr3t") } + + it "resets the root password" do + expect(root_user.password.value).to be_encrypted + + subject.run + + expect(root_user.password.value).to_not be_encrypted + expect(root_user.password_content).to be_empty + end + end + + context "when root user has a plain password" do + let(:root_password) { Y2Users::Password.create_plain("s3cr3t") } + + it "does not reset the root password" do + expect(root_user.password_content).to eq("s3cr3t") + + subject.run + + expect(root_user.password_content).to eq("s3cr3t") + end + end + + context "when inst_root_dialog result is :next" do + let(:result) { :next } + + it "updates users target configuration" do + expect(config_manager).to receive(:target=).with(system_config_copy) + + subject.run + end + + it "writes the target users configuration" do + expect(Y2Users::Linux::Writer).to receive(:new).with(target_config, system_config) + expect(writer).to receive(:write) + + subject.run + end + end + + context "when inst_root_dialog result is not :next" do + let(:result) { :back } + + it "does not update users target configuration" do + expect(config_manager).to_not receive(:target=) + + subject.run + end + + it "does not write users configuration" do + expect(Y2Users::Linux::Writer).to_not receive(:new) + expect(writer).to_not receive(:write) + + subject.run + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-firstboot-4.4.1/test/y2firstboot/clients/user_test.rb new/yast2-firstboot-4.4.2/test/y2firstboot/clients/user_test.rb --- old/yast2-firstboot-4.4.1/test/y2firstboot/clients/user_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-firstboot-4.4.2/test/y2firstboot/clients/user_test.rb 2021-06-30 15:47:16.000000000 +0200 @@ -0,0 +1,133 @@ +#!/usr/bin/env rspec +# Copyright (c) [2018] 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 "y2firstboot/clients/user" + +describe Y2Firstboot::Clients::User do + subject(:client) { described_class.new } + + describe "#run" do + let(:dialog) { instance_double(Yast::InstUserFirstDialog, run: result) } + let(:result) { :next } + + let(:user) { Y2Users::User.new(username) } + let(:username) { "chamaleon" } + let(:password) { nil } + let(:attached) { false } + + let(:system_config) { Y2Users::Config.new } + let(:system_config_copy) { Y2Users::Config.new } + let(:config_manager) { Y2Users::ConfigManager.instance } + + let(:writer) { instance_double(Y2Users::Linux::Writer, write: []) } + + before do + user.password = password + system_config_copy.attach([user]) + + allow(Yast::InstUserFirstDialog).to receive(:new).and_return(dialog) + + allow(Y2Users::Linux::Writer).to receive(:new).and_return(writer) + + allow(subject).to receive(:user).and_return(user) + allow(user).to receive(:attached?).and_return(attached) + + allow(system_config).to receive(:copy).and_return(system_config_copy) + allow(config_manager).to receive(:system).and_return(system_config) + end + + context "when user has an encrypted password" do + let(:password) { Y2Users::Password.create_encrypted("s3cr3t") } + + it "resets the user password" do + expect(user.password.value).to be_encrypted + + subject.run + + expect(user.password.value).to_not be_encrypted + expect(user.password_content).to be_empty + end + end + + context "when user has a plain password" do + let(:password) { Y2Users::Password.create_plain("s3cr3t") } + + it "does not reset the user password" do + expect(user.password_content).to eq("s3cr3t") + + subject.run + + expect(user.password_content).to eq("s3cr3t") + end + end + + it "executes the inst_user_first dialog" do + expect(Yast::InstUserFirstDialog).to receive(:new).with(system_config_copy, user: user) + expect(dialog).to receive(:run) + + subject.run + end + + it "returns the dialog result" do + expect(subject.run).to eq(result) + end + + context "when dialog result is :next" do + it "writes the users configuration" do + expect(Y2Users::Linux::Writer).to receive(:new).with(system_config_copy, system_config) + expect(writer).to receive(:write) + + subject.run + end + end + + context "when dialog result is not :next" do + let(:result) { :back } + + it "does not write the users configuration" do + expect(Y2Users::Linux::Writer).to_not receive(:new) + expect(writer).to_not receive(:write) + + subject.run + end + end + + context "if user is attached" do + let(:attached) { true } + + it "saves the username for future reference" do + expect(described_class).to receive(:username=).with(username) + + subject.run + end + end + + context "if user is not attached" do + let(:attached) { false } + + it "deletes username reference" do + expect(described_class).to receive(:username=).with(nil) + + subject.run + end + end + end +end
participants (1)
-
Source-Sync