Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-users for openSUSE:Factory checked in at 2022-08-23 14:25:59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-users (Old) and /work/SRC/openSUSE:Factory/.yast2-users.new.2083 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-users" Tue Aug 23 14:25:59 2022 rev:252 rq:998665 version:4.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-users/yast2-users.changes 2022-04-10 19:05:23.678506104 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-users.new.2083/yast2-users.changes 2022-08-23 14:26:51.847254831 +0200 @@ -1,0 +2,7 @@ +Fri Aug 19 08:37:53 UTC 2022 - Josef Reidinger <jreidin...@suse.com> + +- AY: Fix writing ssh keys for user without specified home + (bsc#1201185) +- 4.5.2 + +------------------------------------------------------------------- @@ -11 +18 @@ -- Bump version to 4.5.0 (#bsc1198109) +- Bump version to 4.5.0 (bsc#1198109) Old: ---- yast2-users-4.5.1.tar.bz2 New: ---- yast2-users-4.5.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-users.spec ++++++ --- /var/tmp/diff_new_pack.870Z0O/_old 2022-08-23 14:26:53.315258062 +0200 +++ /var/tmp/diff_new_pack.870Z0O/_new 2022-08-23 14:26:53.319258071 +0200 @@ -17,7 +17,7 @@ Name: yast2-users -Version: 4.5.1 +Version: 4.5.2 Release: 0 Summary: YaST2 - User and Group Configuration License: GPL-2.0-only ++++++ yast2-users-4.5.1.tar.bz2 -> yast2-users-4.5.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.5.1/package/yast2-users.changes new/yast2-users-4.5.2/package/yast2-users.changes --- old/yast2-users-4.5.1/package/yast2-users.changes 2022-04-08 13:36:31.000000000 +0200 +++ new/yast2-users-4.5.2/package/yast2-users.changes 2022-08-22 16:05:56.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Aug 19 08:37:53 UTC 2022 - Josef Reidinger <jreidin...@suse.com> + +- AY: Fix writing ssh keys for user without specified home + (bsc#1201185) +- 4.5.2 + +------------------------------------------------------------------- Fri Apr 8 11:27:57 UTC 2022 - Jos?? Iv??n L??pez Gonz??lez <jlo...@suse.com> - Fix import users: do not fail if the group does not exist @@ -8,7 +15,7 @@ ------------------------------------------------------------------- Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> -- Bump version to 4.5.0 (#bsc1198109) +- Bump version to 4.5.0 (bsc#1198109) ------------------------------------------------------------------- Mon Dec 6 13:43:07 UTC 2021 - Josef Reidinger <jreidin...@suse.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.5.1/package/yast2-users.spec new/yast2-users-4.5.2/package/yast2-users.spec --- old/yast2-users-4.5.1/package/yast2-users.spec 2022-04-08 13:36:31.000000000 +0200 +++ new/yast2-users-4.5.2/package/yast2-users.spec 2022-08-22 16:05:56.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-users -Version: 4.5.1 +Version: 4.5.2 Release: 0 Summary: YaST2 - User and Group Configuration License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.5.1/src/lib/y2users/linux/users_writer.rb new/yast2-users-4.5.2/src/lib/y2users/linux/users_writer.rb --- old/yast2-users-4.5.1/src/lib/y2users/linux/users_writer.rb 2022-04-08 13:36:31.000000000 +0200 +++ new/yast2-users-4.5.2/src/lib/y2users/linux/users_writer.rb 2022-08-22 16:05:56.000000000 +0200 @@ -30,6 +30,7 @@ require "y2users/linux/set_home_ownership_action" require "y2users/linux/set_auth_keys_action" require "y2users/linux/delete_user_action" +require "y2users/linux/reader" Yast.import "MailAliases" @@ -54,6 +55,7 @@ @initial_config = initial_config @target_config = target_config @commit_configs = commit_configs + @users_to_write_ssh_keys = {} end private @@ -89,6 +91,7 @@ edit_users add_users write_root_aliases + write_ssh_auth_keys end # Deletes users @@ -104,6 +107,27 @@ new_users.each { |u| add_user(u) } end + def write_ssh_auth_keys + # we need to re-read system users as for some newly created users + # the default home can be used and it depends on useradd and login + # defaults. So instead of mimic useradd behavior just read what + # useradd creates. (bsc#1201185) + system_users = Reader.new.read.users + @users_to_write_ssh_keys.each_pair do |user, old_keys| + system_user = system_users.by_name(user.name) + if !system_user + issues << Y2Issues::Issue.new( + format(_("Failed to find user with name '%s'"), user.name) + ) + log.error("Failed to find user with name #{user.name}") + next + end + + system_user.authorized_keys = user.authorized_keys + write_user_auth_keys(system_user, old_keys) + end + end + # Performs all needed actions in order to create and configure a new user (create user, set # password, etc). # @@ -119,7 +143,7 @@ remove_home_content(user) if !reusing_home && commit_config.home_without_skel? adapt_home_ownership(user) if commit_config.adapt_home_ownership? write_password(user) if user.password - write_auth_keys(user) + @users_to_write_ssh_keys[user] = [] end # Edits users @@ -147,7 +171,9 @@ edit_password(target_user) if initial_user.password != target_user.password previous_keys = initial_user.authorized_keys || [] - write_auth_keys(target_user, previous_keys) if previous_keys != target_user.authorized_keys + return if previous_keys == target_user.authorized_keys + + @users_to_write_ssh_keys[target_user] = previous_keys end # Updates root aliases @@ -293,9 +319,7 @@ # @param user [User] # @param previous_keys [Array<String>] previous auth keys for given user, if any # @return [Boolean] true on success - def write_auth_keys(user, previous_keys = []) - return true unless exist_user_home?(user) - + def write_user_auth_keys(user, previous_keys = []) action = SetAuthKeysAction.new(user, commit_config(user), previous_keys) perform_action(action) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-users-4.5.1/test/lib/y2users/linux/users_writer_test.rb new/yast2-users-4.5.2/test/lib/y2users/linux/users_writer_test.rb --- old/yast2-users-4.5.1/test/lib/y2users/linux/users_writer_test.rb 2022-04-08 13:36:31.000000000 +0200 +++ new/yast2-users-4.5.2/test/lib/y2users/linux/users_writer_test.rb 2022-08-22 16:05:56.000000000 +0200 @@ -53,6 +53,13 @@ let(:commit_config) { Y2Users::CommitConfig.new } + let(:system_config) { initial_config } + + before do + allow(Y2Users::Linux::Reader).to receive(:new) + .and_return(instance_double(Y2Users::Linux::Reader, read: system_config)) + end + describe "#write" do let(:create_user_action) { Y2Users::Linux::CreateUserAction } @@ -331,56 +338,45 @@ end context "and the authorized keys has changed" do + let(:system_user) { target_user.copy } + before do target_user.authorized_keys = ["new-key"] + # cannot overwrite here system_config as we need to have there recent + # target user which is modified in `before` code + system_config = Y2Users::Config.new.tap { |c| c.attach(system_user) } + allow(Y2Users::Linux::Reader).to receive(:new) + .and_return(instance_double(Y2Users::Linux::Reader, read: system_config)) + allow(Yast::FileUtils).to receive(:IsDirectory).with(target_user.home.path) + .and_return(true) end - context "and the user home exists" do - before do - allow(Yast::FileUtils).to receive(:IsDirectory).with(target_user.home.path) - .and_return(true) - end - - it "performs the action for setting the authorized keys" do - action = mock_action(set_auth_keys_action, success, target_user) + it "performs the action for setting the authorized keys" do + action = mock_action(set_auth_keys_action, success, system_user) - expect(action).to receive(:perform) - - subject.write - end - - it "provides previous keys to the action for setting authorized keys" do - action = instance_double(set_auth_keys_action, perform: success) - - expect(set_auth_keys_action) - .to receive(:new).with(target_user, any_args) do |*args| - previous_keys = args.last - expect(previous_keys).to eq(initial_user.authorized_keys) - end.and_return(action) + expect(action).to receive(:perform) - subject.write - end + subject.write + end - it "returns the generated issues" do - mock_action(set_auth_keys_action, success("issue auth keys"), target_user) + it "provides previous keys to the action for setting authorized keys" do + action = instance_double(set_auth_keys_action, perform: success) - issues = subject.write + expect(set_auth_keys_action) + .to receive(:new).with(target_user, any_args) do |*args| + previous_keys = args.last + expect(previous_keys).to eq(initial_user.authorized_keys) + end.and_return(action) - expect(issues.map(&:message)).to include(/issue auth keys/) - end + subject.write end - context "and the user home does not exist" do - before do - allow(Yast::FileUtils).to receive(:IsDirectory).with(target_user.home.path) - .and_return(false) - end + it "returns the generated issues" do + mock_action(set_auth_keys_action, success("issue auth keys"), target_user) - it "does not perform the action for setting the authorized keys" do - expect_any_instance_of(set_auth_keys_action).to_not receive(:perform) + issues = subject.write - subject.write - end + expect(issues.map(&:message)).to include(/issue auth keys/) end end @@ -690,6 +686,9 @@ end context "and the user home exists" do + let(:system_user) { test3.copy } + let(:system_config) { Y2Users::Config.new.tap { |c| c.attach([system_user]) } } + before do allow(Yast::FileUtils).to receive(:IsDirectory).with(test3.home.path).and_return(true) end