Bug 1165388

Summary: YaST2 Services Manager on console displays false row to be changed
Product: [openSUSE] openSUSE Distribution Reporter: Mészáros Gyula <meszaros.gyula>
Component: YaST2Assignee: Martin Vidner <mvidner>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P3 - Medium CC: igonzalezsosa, jlopez, lubos.kocman, meszaros.gyula, mvidner, walter.laub
Version: Leap 15.2   
Target Milestone: ---   
Hardware: x86-64   
OS: Other   
URL: https://trello.com/c/FHZyHFj5
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: YaST2 Services Manager on console displays false row to be changed
yast2 debug log
table-cell.rb

Description Mészáros Gyula 2020-03-02 06:32:02 UTC
Created attachment 831656 [details]
YaST2 Services Manager on console displays false row to be changed

In console start YaST2, and enter System / Services Manager.
Change e.g. Start Mode of a row, e.g. firebird from On Boot to Manually.
YaST2 mark the incorrect row (6 above, the dracut-pre-trigger) to be changed. However, when you press Apply you can see that YaST2 really changes the row you have selected (firebird). So the operation is performed well, but the display is frightening.
It works well in 15.1.
Comment 1 Imobach Gonzalez Sosa 2020-03-09 16:54:54 UTC
I was able to reproduce the problem using a QEMU virtual machine. However, if I login through SSH into the system, it works just fine.
Comment 2 Mészáros Gyula 2020-03-09 20:25:13 UTC
It works from graphical interface, but does not work from console and also not from SSH for me. (Before the tests I have made a system update.)
Comment 3 Martin Vidner 2020-03-10 11:08:29 UTC
Thanks for the report!

Please reproduce the bug with Y2DEBUG:
https://en.opensuse.org/openSUSE:Report_a_YaST_bug#The_y2logs_don.27t_seem_to_show_my_problem._Can_that_logging_be_made_any_more_verbose.3F
and attach the logs. The logs will likely reveal a problem with the UI.
Comment 4 Mészáros Gyula 2020-03-10 19:17:37 UTC
Created attachment 832454 [details]
yast2 debug log
Comment 5 Lubos Kocman 2020-03-19 15:35:59 UTC
(In reply to Imobach Gonzalez Sosa from comment #1)
> I was able to reproduce the problem using a QEMU virtual machine. However,
> if I login through SSH into the system, it works just fine.
Comment 6 Michal Filka 2020-06-02 19:21:34 UTC
I wasn't able to reproduce it

@Martin:
debug logs were provided. Could you pls check whether you can find a UI issue? Thanks
Comment 7 Stefan Hundhammer 2020-06-16 09:42:48 UTC
Martin, this is waiting for input from your side. Please check.
Comment 8 José Iván López González 2020-06-25 09:43:24 UTC
I have debugged it, and it seems to be a problem with libyui and n-curses.

[327, 336] in /home/ivan/projects/yast/repos/services-manager/src/lib/services-manager/widgets/services_table.rb
   327:       # Updates the value for the start_mode column of a service
   328:       #
   329:       # @param service_name [String]
   330:       def refresh_start_mode_value(service_name)
   331:         byebug
=> 332:         UI.ChangeWidget(id, Cell(service_name, 1), start_mode_value(service_name))
   333:       end
(byebug) id
#<Yast::Term:0x0000563a60d24718 @value=:id, @params=[:services_table]>
(byebug) Cell(service_name, 1)
#<Yast::Term:0x0000563a60d36508 @value=:Cell, @params=["apparmor", 1]>

In both cases (graphical interface and text mode) the UI.ChangeWidget method is call with the same values, but the result is different. In graphical mode, the current row is updated. In text mode, the sixth row before is modified.

Tracking in trello.
Comment 9 Martin Vidner 2020-08-05 09:11:58 UTC
Created attachment 840354 [details]
table-cell.rb

I have reproduced and minimized the problem. Attaching a reproducing script.
I haven't traced down the exact cause but the bug is linked to table sorting.

A libyui table is by default sorted by its first column.
In TUI (libyui-ncurses) you can also press Ctrl-O to change the sorting column
(re*o*rder).

With sorting disabled, there is no bug: selecting an item uppercases its value:

    /usr/sbin/yast ./table-cell.rb no-sort 

With sorting enabled, the uppercased value appears elsewhere (but the internal
values are correct, as shown in y2log)

    /usr/sbin/yast ./table-cell.rb
Comment 10 Martin Vidner 2020-08-05 09:12:55 UTC
In the service manager the bug is only apparent when you have services starting
with a capital letter, like NetworkManager. If you only have lowercase services,
like in a JEOS, the bug is hidden.
Comment 12 Martin Vidner 2020-08-13 08:09:22 UTC
Copying an explanation from https://github.com/yast/yast-services-manager/pull/206 , which is a workaround.

Cause:

There is a long-standing bug in libyui-ncurses that is mostly hidden by
circumstances. This commit does not fix that bug, only works around it.

Services Manager does something other YaST modules don't do: it changes
table contents cell by cell instead of wholesale.

The ncurses (TUI) version of the table widget has a bug where this
individual cell change ignores table sorting that may be set up.

The bug seems to be old but it was masked by sorting being initially
disabled for all tables. You had to press Ctrl-O to reorder the table.
Since SLE/Leap 15.2 tables are initially sorted so the bug triggers. The
workaround is to add the :keepSorting option which disables both the
initial sorting and the user-triggered one.

Another factor masking the bug is the fact that application code, aware
that tables will not sort, was sorting the items before inserting them
in tables. So in many cases the application order and the table order
are the same and the bug is hidden. But if there are items in lowercase
as well as Uppercase the two sort algorithms disagree and the bug
becomes apparent.

SP2:

- Git: https://github.com/yast/yast-services-manager/pull/206
- RPM: yast2-services-manager-4.2.7
- IBS: https://build.suse.de/request/show/224203

master:

- Git: https://github.com/yast/yast-services-manager/pull/207
- RPM: yast2-services-manager-4.3.3
- OBS: https://build.opensuse.org/request/show/825927

A proper fix is still Work In Progress:

- https://github.com/libyui/libyui-ncurses/pull/98 (documentation only so far)
Comment 13 Martin Vidner 2020-08-27 11:25:16 UTC
The SP2/Leap 15.2 fix is a workaround by disabling re-sorting the table contents.

For master I made a better fix in libyui-ncurses so the yast2-services-manager workaround will be reverted there:

l-n:
- Git: https://github.com/libyui/libyui-ncurses/pull/100
- RPM: libyui-ncurses13-2.56.2
- OBS:  https://build.opensuse.org/request/show/829931

y-s-m:
- Git: https://github.com/yast/yast-services-manager/pull/208
- RPM: yast2-services-manager-4.3.5
- OBS: (pending, blocked by an unrelated build glitch)
Comment 14 Martin Vidner 2020-08-28 06:36:34 UTC
yast2-services-manager:
- OBS: https://build.opensuse.org/request/show/830189
Comment 15 Swamp Workflow Management 2020-09-10 01:16:28 UTC
SUSE-RU-2020:2589-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1165388,1173408,1174615
CVE References: 
JIRA References: 
Sources used:
SUSE Linux Enterprise Module for Basesystem 15-SP2 (src):    yast2-services-manager-4.2.7-3.3.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 16 Swamp Workflow Management 2020-09-19 16:29:32 UTC
openSUSE-RU-2020:1460-1: An update that has three recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1165388,1173408,1174615
CVE References: 
JIRA References: 
Sources used:
openSUSE Leap 15.2 (src):    yast2-services-manager-4.2.7-lp152.2.3.1
Comment 23 Ladislav Slezák 2021-04-21 16:15:49 UTC
*** Bug 1185025 has been marked as a duplicate of this bug. ***