Bug 1205783

Summary: YaST:Head/yast2-users: Cannot create new user groups via YaST on new installations
Product: [openSUSE] openSUSE Tumbleweed Reporter: B <reiokorn>
Component: YaST2Assignee: YaST Team <yast-internal>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Major    
Priority: P3 - Medium CC: reiokorn
Version: Current   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE Tumbleweed   
URL: https://trello.com/c/IEHa2Ffx
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: y2log
logs
hwinfo
login.defs

Description B 2022-11-26 16:51:57 UTC
When trying to create a new usergroup via Yast I always get the following error message

"Error

The name of the group may only contain
letters, digits, "-", ".", and "_" and must
and must start with a letter.
Please try again."

Screenshot: https://ibb.co/hycJHgK

the name of the group I was trying to create was in this case just "testgroup"

I can create user groups via terminal just fine, so this looks like a bug to me.
Comment 1 Stefan Hundhammer 2022-11-27 19:55:34 UTC
I just checked, and it works absolutely fine for me.

Please attach y2logs; see 

https://en.opensuse.org/openSUSE:Report_a_YaST_bug#I_reported_a_YaST2_bug,_and_now_I_am_asked_to_"attach_y2logs"_(for_package_installation_also_"libzypp_logging")._What_does_that_mean,_and_how_do_I_do_that?
Comment 2 Stefan Hundhammer 2022-11-27 19:57:34 UTC
Also, are you using Wayland or X11?
Comment 3 B 2022-11-28 14:52:03 UTC
(In reply to Stefan Hundhammer from comment #2)
> Also, are you using Wayland or X11?

Wayland

I fixed it by reinstalling the yast2 packages - looks like the issue was on my side.
Comment 4 B 2022-11-29 13:42:41 UTC
I was wrong, reinstalling the packages did not solve the problem. 
But like you, my old installation does not seem to have the problem, and only new installations are affected, this I have now been able to confirm when I just quickly booted into one.
Comment 5 B 2022-11-29 13:44:57 UTC
Created attachment 863173 [details]
y2log
Comment 6 Stefan Hundhammer 2022-11-30 08:54:51 UTC
Please add y2logs as described in the FAQ.

https://en.opensuse.org/openSUSE:Report_a_YaST_bug#Attachments_-_y2logs,_hwinfo_etc.

That's why I (!) wrote that FAQ 20 years ago.
Comment 7 B 2022-11-30 13:13:34 UTC
Created attachment 863208 [details]
logs

OK!
Comment 8 B 2022-11-30 13:14:18 UTC
Created attachment 863209 [details]
hwinfo
Comment 9 Stefan Hundhammer 2022-11-30 15:56:01 UTC
OK, this is weird:

2022-11-30 13:45:29 <2> tumbleweed-pc(3913) [Perl] 
  modules/Users.pm(Users::CheckGroupname):5027 
  groupname testgroup doesn't match to
 
2022-11-30 13:45:31 <2> tumbleweed-pc(3913) [Perl] 
  modules/Users.pm(Users::CheckGroupname):5027
  groupname testgroup doesn't match to 

2022-11-30 13:45:33 <2> tumbleweed-pc(3913) [Perl] 
  modules/Users.pm(Users::CheckGroupname):5027 
  groupname testgroup doesn't match to 



Where it SHOULD also log the character class:

https://github.com/yast/yast-users/blob/master/src/modules/Users.pm#L5027

  y2warning ("groupname $groupname doesn't match to $character_class");

i.e. that $character_class is empty (!), so of course it doesn't match.

It's defined here:

https://github.com/yast/yast-users/blob/master/src/modules/Users.pm#L172

  my $character_class = "[[:alpha:]_][[:alnum:]_.-]*[[:alnum:]_.\$-]\\?";

which *might* be influenced by the current locale settings; or if that locale isn't installed at all or not correctly, it might possibly be empty.

That initial value is overwritten later with data from (AFAICS) /etc/login.defs:

https://github.com/yast/yast-users/blob/master/src/modules/Users.pm#L1345-L1348

  $character_class = ShadowConfig->fetch("CHARACTER_CLASS");
  if ($character_class) {
      UsersSimple->SetCharacterClass ($character_class);
  }

which look OK on my system:

% grep '^CHARACTER_CLASS' /etc/login.defs
CHARACTER_CLASS         [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_][ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-]*[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.$-]\?


How about your system? Is that file there? Does that CHARACTER_CLASS entry look OK?
Comment 10 Stefan Hundhammer 2022-11-30 16:15:58 UTC
The file might also be /usr/etc/login.defs, or there might be a directory /usr/etc/login.defs.d .
Comment 11 B 2022-11-30 16:16:03 UTC
Created attachment 863224 [details]
login.defs

The file /etc/login.defs is there, however it doesn't include any type of CHARACTER_CLASS

I would like to point out again that this is the default file after a new installation.
Comment 12 B 2022-11-30 16:17:55 UTC
(In reply to Stefan Hundhammer from comment #10)
> The file might also be /usr/etc/login.defs, or there might be a directory
> /usr/etc/login.defs.d .

Yes, it was under /usr/etc
login.defs.d was empty
Comment 13 Stefan Hundhammer 2022-11-30 16:33:45 UTC
OK, thank you.

So we need to find out why the entry is no longer there, and why we don't have a fallback in just that case. The code from comment #9 looks fishy anyway:

  $character_class = ShadowConfig->fetch("CHARACTER_CLASS");
  if ($character_class) {
      UsersSimple->SetCharacterClass ($character_class);
  }

What if $character_class is empty? Then it remains empty, and the result is what we ear seeing in this bug.
Comment 14 Stefan Hundhammer 2022-11-30 16:34:30 UTC
(In reply to Stefan Hundhammer from comment #13)
> what we ear seeing in this bug.
          ^^^
          are

Fingers faster than brain make for bad typing... ;-(
Comment 15 Stefan Hundhammer 2022-11-30 16:35:19 UTC
Moving to our Trello task queue.
Comment 16 Stefan Hundhammer 2022-11-30 16:41:39 UTC
Now that the problem is identified, it should be easy enough to fix.

Thank you for your contribution!
Comment 17 Stefan Hundhammer 2022-12-08 16:06:17 UTC
Pull request with a fix:

  https://github.com/yast/yast-users/pull/371

This will become available with yast2-users-4.5.3.
Comment 19 B 2022-12-08 19:02:24 UTC
(In reply to Stefan Hundhammer from comment #17)
> Pull request with a fix:
> 
>   https://github.com/yast/yast-users/pull/371
> 
> This will become available with yast2-users-4.5.3.

Thank you!