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 2021-08-16 10:08:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-users (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-users.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-users"

Mon Aug 16 10:08:27 2021 rev:246 rq:911853 version:4.4.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-users/yast2-users.changes  2021-07-25 
20:09:15.419444111 +0200
+++ /work/SRC/openSUSE:Factory/.yast2-users.new.1899/yast2-users.changes        
2021-08-16 10:12:53.203006935 +0200
@@ -1,0 +2,7 @@
+Thu Aug 12 14:35:20 UTC 2021 - Jos?? Iv??n L??pez Gonz??lez <jlo...@suse.com>
+
+- Allow to edit the name of an existing user (bsc#1188612).
+- Allow to remove the password of an existing user(bsc#1189402).
+- 4.4.6
+
+-------------------------------------------------------------------

Old:
----
  yast2-users-4.4.5.tar.bz2

New:
----
  yast2-users-4.4.6.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-users.spec ++++++
--- /var/tmp/diff_new_pack.9hcJQe/_old  2021-08-16 10:12:53.655006405 +0200
+++ /var/tmp/diff_new_pack.9hcJQe/_new  2021-08-16 10:12:53.659006400 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-users
-Version:        4.4.5
+Version:        4.4.6
 Release:        0
 Summary:        YaST2 - User and Group Configuration
 License:        GPL-2.0-only

++++++ yast2-users-4.4.5.tar.bz2 -> yast2-users-4.4.6.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-4.4.5/package/yast2-users.changes 
new/yast2-users-4.4.6/package/yast2-users.changes
--- old/yast2-users-4.4.5/package/yast2-users.changes   2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/package/yast2-users.changes   2021-08-12 
18:05:37.000000000 +0200
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Thu Aug 12 14:35:20 UTC 2021 - Jos?? Iv??n L??pez Gonz??lez <jlo...@suse.com>
+
+- Allow to edit the name of an existing user (bsc#1188612).
+- Allow to remove the password of an existing user(bsc#1189402).
+- 4.4.6
+
+-------------------------------------------------------------------
 Tue Jul 20 15:09:28 UTC 2021 - David Diaz <dgonza...@suse.com>
 
 - Do not rewrite authorized_keys unless it is needed (bsc#1188361).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-4.4.5/package/yast2-users.spec 
new/yast2-users-4.4.6/package/yast2-users.spec
--- old/yast2-users-4.4.5/package/yast2-users.spec      2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/package/yast2-users.spec      2021-08-12 
18:05:37.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-users
-Version:        4.4.5
+Version:        4.4.6
 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.4.5/src/lib/users/widgets.rb 
new/yast2-users-4.4.6/src/lib/users/widgets.rb
--- old/yast2-users-4.4.5/src/lib/users/widgets.rb      2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/src/lib/users/widgets.rb      2021-08-12 
18:05:37.000000000 +0200
@@ -102,11 +102,18 @@
       Yast::UI.ChangeWidget(Id(:pw2), :Value, current_password)
     end
 
+    # FIXME: Validation methods should only check values. Note that with the 
current implementation,
+    #   this method is taking care of setting/removing the user's password. 
This method should not
+    #   modify the user.
     # rubocop:disable Metrics/CyclomaticComplexity
     def validate
       password1 = Yast::UI.QueryWidget(Id(:pw1), :Value)
       password2 = Yast::UI.QueryWidget(Id(:pw2), :Value)
-      return true if allow_empty? && password1.empty?
+
+      if allow_empty? && password1.empty?
+        @user.password = nil
+        return true
+      end
 
       if password1 != password2
         # report misspellings of the password
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-users-4.4.5/src/lib/y2users/linux/users_writer.rb 
new/yast2-users-4.4.6/src/lib/y2users/linux/users_writer.rb
--- old/yast2-users-4.4.5/src/lib/y2users/linux/users_writer.rb 2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/src/lib/y2users/linux/users_writer.rb 2021-08-12 
18:05:37.000000000 +0200
@@ -105,6 +105,10 @@
       CHPASSWD = "/usr/sbin/chpasswd".freeze
       private_constant :CHPASSWD
 
+      # Command for editing a password (i.e., used for deleting the password)
+      PASSWD = "/usr/bin/passwd".freeze
+      private_constant :PASSWD
+
       # Command for configuring the attributes in /etc/shadow
       CHAGE = "/usr/bin/chage".freeze
       private_constant :CHAGE
@@ -162,6 +166,20 @@
         log.error("Error setting password for '#{user.name}' - #{e.message}")
       end
 
+      # Executes the command for deleting the password of the given user
+      #
+      # @param user [User]
+      # @param issues [Y2Issues::List] a collection for adding an issue if 
something goes wrong
+      def delete_password(user, issues)
+        Yast::Execute.on_target!(PASSWD, "--delete", user.name)
+      rescue Cheetah::ExecutionFailed => e
+        issues << Y2Issues::Issue.new(
+          # TRANSLATORS: %s is a placeholder for a username
+          format(_("The password for '%s' cannot be deleted"), user.name)
+        )
+        log.error("Error deleting password for '#{user.name}' - #{e.message}")
+      end
+
       # Writes authorized keys for given user
       #
       # @see Yast::Users::SSHAuthorizedKeyring#write_keys
@@ -217,7 +235,7 @@
       end
 
       # Attributes to modify using `usermod`
-      USERMOD_ATTRS = [:gid, :home, :shell, :gecos].freeze
+      USERMOD_ATTRS = [:name, :gid, :home, :shell, :gecos].freeze
 
       # Edits the user
       #
@@ -232,7 +250,8 @@
         usermod_changes ||= different_groups?(new_user, old_user)
 
         Yast::Execute.on_target!(USERMOD, *usermod_options(new_user, 
old_user)) if usermod_changes
-        change_password(new_user, issues) if old_user.password != 
new_user.password
+
+        edit_password(new_user, old_user, issues)
         write_auth_keys(new_user, issues) if old_user.authorized_keys != 
new_user.authorized_keys
       rescue Cheetah::ExecutionFailed => e
         issues << Y2Issues::Issue.new(
@@ -241,6 +260,17 @@
         log.error("Error modifying user '#{new_user.name}' - #{e.message}")
       end
 
+      # Edits the user's password
+      #
+      # @param new_user [User] User containing the updated information
+      # @param old_user [User] Original user
+      # @param issues [Y2Issues::List] a collection for adding an issue if 
something goes wrong
+      def edit_password(new_user, old_user, issues)
+        return if old_user.password == new_user.password
+
+        new_user.password ? change_password(new_user, issues) : 
delete_password(new_user, issues)
+      end
+
       # Generates and returns the options expected by `useradd` for given user
       #
       # @param user [User]
@@ -282,8 +312,21 @@
       # rubocop:disable Metrics/PerceivedComplexity
       def usermod_options(new_user, old_user)
         args = []
+        args << "--login" << new_user.name if new_user.name != old_user.name 
&& new_user.name
         args << "--gid" << new_user.gid if new_user.gid != old_user.gid && 
new_user.gid
         args << "--comment" << new_user.gecos.join(",") if new_user.gecos != 
old_user.gecos
+        # With the --move-home option, all the content from the previous home 
directory is moved to
+        # the new location, and ownership is also adapted. But take into 
account that the new home
+        # will be created only if the old home directory exists. Otherwise, 
the user will continue
+        # without a home directory.
+        #
+        # For now, this code only supports to move an existing home 
directory/subvolume. Creating
+        # or deleting the home directory/subvolume of an existing user is not 
implemented yet.
+        #
+        # For creating the home directory of an existing user, see 
mkhomedir_helper.
+        #
+        # For deleting the home directory of an existing user, use --home "", 
and then manually
+        # remove the directory with rm -rf.
         if new_user.home != old_user.home && new_user.home
           args << "--home" << new_user.home << "--move-home"
         end
@@ -291,7 +334,7 @@
         if different_groups?(new_user, old_user)
           args << "--groups" << new_user.secondary_groups_name.join(",")
         end
-        args << new_user.name
+        args << old_user.name
         args
       end
       # rubocop:enable Metrics/CyclomaticComplexity
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-4.4.5/src/lib/y2users/linux/writer.rb 
new/yast2-users-4.4.6/src/lib/y2users/linux/writer.rb
--- old/yast2-users-4.4.5/src/lib/y2users/linux/writer.rb       2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/src/lib/y2users/linux/writer.rb       2021-08-12 
18:05:37.000000000 +0200
@@ -29,9 +29,7 @@
     # Writes users and groups to the system using Yast2::Execute and standard
     # linux tools.
     #
-    # NOTE: currently it only creates new users or modifies the password value
-    # of existing ones.  Removing or fully modifying users is still not 
covered.
-    # No group management or passowrd configuration either.
+    # NOTE: Removing or fully modifying users is still not covered.
     #
     # A brief history of the differences with the Yast::Users (perl) module:
     #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-users-4.4.5/test/lib/y2users/linux/writer_test.rb 
new/yast2-users-4.4.6/test/lib/y2users/linux/writer_test.rb
--- old/yast2-users-4.4.5/test/lib/y2users/linux/writer_test.rb 2021-07-22 
14:27:47.000000000 +0200
+++ new/yast2-users-4.4.6/test/lib/y2users/linux/writer_test.rb 2021-08-12 
18:05:37.000000000 +0200
@@ -286,6 +286,21 @@
         writer.write
       end
 
+      context "whose name has changed" do
+        before do
+          current_user = config.users.by_id(user.id)
+          current_user.name = "test2"
+        end
+
+        it "executes usermod with --login option" do
+          expect(Yast::Execute).to receive(:on_target!).with(
+            /usermod/, "--login", "test2", user.name
+          )
+
+          writer.write
+        end
+      end
+
       context "whose gid was changed" do
         before do
           current_user = config.users.by_id(user.id)
@@ -448,6 +463,19 @@
         end
       end
 
+      context "whose password was removed" do
+        before do
+          current_user = config.users.by_id(user.id)
+          current_user.password = nil
+        end
+
+        it "executes passwd with --delete option" do
+          expect(Yast::Execute).to receive(:on_target!).with(/passwd/, 
"--delete", user.name)
+
+          writer.write
+        end
+      end
+
       context "whose password was not edited" do
         it "does not execute chpasswd" do
           expect(Yast::Execute).to_not receive(:on_target!).with(/chpasswd/, 
any_args)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-users-4.4.5/test/widgets_test.rb 
new/yast2-users-4.4.6/test/widgets_test.rb
--- old/yast2-users-4.4.5/test/widgets_test.rb  2021-07-22 14:27:47.000000000 
+0200
+++ new/yast2-users-4.4.6/test/widgets_test.rb  2021-08-12 18:05:37.000000000 
+0200
@@ -126,15 +126,49 @@
       expect(subject.validate).to eq true
     end
 
-    context "when the widget is allowed to be empty" do
-      subject { described_class.new(root_user, allow_empty: true) }
+    context "when no password was entered" do
+      subject { described_class.new(root_user, allow_empty: allow_empty) }
 
-      it "does not validate the password" do
+      before do
         stub_widget_value(:pw1, "")
         stub_widget_value(:pw2, "")
 
-        expect(Y2Users::Password).to_not receive(:create_plain)
-        expect(subject.validate).to eq(true)
+        root_user.password = Y2Users::Password.create_plain("S3cr3T")
+      end
+
+      context "when the widget is allowed to be empty" do
+        let(:allow_empty) { true }
+
+        it "removes the current password" do
+          subject.validate
+
+          expect(root_user.password).to be_nil
+        end
+
+        it "returns true" do
+          expect(subject.validate).to eq(true)
+        end
+      end
+
+      context "when the widget is not allowed to be empty" do
+        let(:allow_empty) { false }
+
+        it "does not remove the current password" do
+          subject.validate
+
+          expect(root_user.password).to_not be_nil
+        end
+
+        it "reports an error" do
+          expect(Yast::Popup).to receive(:Error).with(/No password entered/)
+
+          subject.validate
+        end
+
+        it "returns false" do
+          expect(subject.validate).to eq(false)
+        end
+
       end
     end
   end

Reply via email to