Error in system information after logging in to your account

Bug #1780071 reported by Krzysztof Kolasa
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Committed
Medium
Simon Poirier
landscape-client (Ubuntu)
Fix Released
Medium
Unassigned
Bionic
In Progress
Medium
Unassigned
Cosmic
In Progress
Medium
Unassigned
Disco
Won't Fix
Medium
Unassigned
Eoan
Fix Released
Medium
Unassigned

Bug Description

[Impact]

 * An error message is included in when rendering landscape-sysinfo
   statistics through pam_motd if there are processes with a non-ascii
   command. This is due to the fact that environment is not passed
   by pam-motd.

 * As landscape-sysinfo is present on cloud-images, this bug affects
   all images since bionic.

 * This change sets locale variables in the landscape-sysinfo wrapper,
   so the python interpreter can know which locale to load.

[Test Case]

 * Make sure the system default locale is configured with a valid
   charset (e.g. /etc/default/locale contains "LANG=C.UTF-8").

 * Spawn a process with non-ascii parameters (which are part of the
   configured charset): sh -c 'sleep 60; echo holà mundo' & sudo login

 * Check the output of the motd

[Regression Potential]

 * Since this changes only alters the landscape-sysinfo wrapper script,
   its effects shouldn't alter other functionalities.

 * Although it is still possible to have a misconfigured locale file,
   and run commands, the effect would be limited to an error message
   similar to the one which is currently displayed.

[Original Description]

Exception after login:
---------------------
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-24-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Wed Jul 4 10:41:09 CEST 2018

  System load: 0.0 Swap usage: 5%
  Usage of /home: unknown Users logged in: 0
  Memory usage: 16% IP address for enp3s0: 192.168.20.12

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

 * Meltdown, Spectre and Ubuntu: What are the attack vectors,
   how the fixes work, and everything else you need to know
   - https://ubu.one/u2Know

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 pakietów może zostać zaktualizowanych.
0 aktualizacji jest aktualizacjami zabezpieczeń.
--------------------

sysinfo.log:

2018-06-19 23:19:34,877 ERROR Processes plugin raised an exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/sysinfo.py", line 99, in run
    result = plugin.run()
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/processes.py", line 18, in run
    for process_info in info.get_all_process_info():
  File "/usr/lib/python3/dist-packages/landscape/lib/process.py", line 39, in get_all_process_info
    process_info = self.get_process_info(process_id)
  File "/usr/lib/python3/dist-packages/landscape/lib/process.py", line 61, in get_process_info
    cmd_line = file.readline()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 152: ordinal not in range(128)

-----------------
the problem concerned the decoding of utf8 forms, attached patch resolve my problem, after patch my login
screen looks normal:

-----------------
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-24-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Wed Jul 4 11:10:20 CEST 2018

  System load: 0.2 Processes: 187
  Usage of /home: unknown Users logged in: 1
  Memory usage: 18% IP address for enp3s0: 192.168.20.12
  Swap usage: 5%

 * Meltdown, Spectre and Ubuntu: What are the attack vectors,
   how the fixes work, and everything else you need to know
   - https://ubu.one/u2Know

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 pakietów może zostać zaktualizowanych.
0 aktualizacji jest aktualizacjami zabezpieczeń.

Tags: patch sysinfo
Revision history for this message
Krzysztof Kolasa (kkolasa) wrote :
Simon Poirier (simpoir)
Changed in landscape-client:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Simon Poirier (simpoir) wrote :

Thank you for reporting this bug. We believe it is an actual issue and will look into having it fixed.

For the record, I've been able to reproduce it easily on a pristine bionic container, by spawning a command and launching a login shell, which empties the environment and calls pam_motd:

simpoir@qs:~$ sh -c 'sleep 60; echo ಠ_ಠ' &
[1] 2514
simpoir@qs:~$ sudo login
qs login: simpoir
Password:
Last login: Wed Jul 4 12:31:15 UTC 2018 on pts/0
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-15-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage
(None, None)

  System information as of Wed Jul 4 12:38:14 UTC 2018

  System load: 0.75 Memory usage: 0% Users logged in: 1
  Usage of /home: unknown Swap usage: 0% IP address for eth0: 10.4.50.157

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

Simon Poirier (simpoir)
Changed in landscape-client:
assignee: nobody → Simon Poirier (simpoir)
Revision history for this message
Simon Poirier (simpoir) wrote :
Changed in landscape-client:
status: Triaged → In Progress
Revision history for this message
Krzysztof Kolasa (kkolasa) wrote :

I tested and the patch #3 works correctly, thanks.

Simon Poirier (simpoir)
Changed in landscape-client:
status: In Progress → Fix Committed
Revision history for this message
Simon Poirier (simpoir) wrote :
Revision history for this message
Simon Poirier (simpoir) wrote :
Simon Poirier (simpoir)
description: updated
Mathew Hodson (mhodson)
Changed in landscape-client (Ubuntu):
importance: Undecided → Medium
tags: added: patch
Revision history for this message
Simon Quigley (tsimonq2) wrote :

Uploaded to Bionic, Cosmic, Disco, Eoan. Unsubscribing sponsors.

Changed in landscape-client (Ubuntu Disco):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Bionic):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Cosmic):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Bionic):
status: New → In Progress
Changed in landscape-client (Ubuntu Cosmic):
status: New → In Progress
Changed in landscape-client (Ubuntu Disco):
status: New → In Progress
Changed in landscape-client (Ubuntu Eoan):
status: New → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package landscape-client - 18.01-0ubuntu8

---------------
landscape-client (18.01-0ubuntu8) eoan; urgency=medium

  * Set LANG in sysinfo wrapper. (LP: #1780071)

 -- Simon Poirier <email address hidden> Mon, 16 Jul 2018 13:47:29 -0400

Changed in landscape-client (Ubuntu Eoan):
status: In Progress → Fix Released
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Garbage in, barbage out. I think opening things and reading as utf-8 is good. For added resilience, one has to also espace unicode encoding errors too, and replace them with anything readable. I.e. one may choose to read in binary, and then decode as utf-8 with any errors replaced, ie.:

b'somebinary string'.decode('utf-8', 'replace')

Revision history for this message
Steve Langasek (vorlon) wrote : Proposed package upload rejected

An upload of landscape-client to disco-proposed has been rejected from the upload queue for the following reason: "Wrong solution for the reported symptom. locale should be set globally in update-motd.".

Revision history for this message
Stefan Pappalardo (sjuk) wrote :

I can confirm that the issue is still there in Ubuntu 18.04.4 LTS.

I'm not sure if it counts, but landscape-client is not installed on the affected system.
Instead there is landscape-common installed. I tried to add the package to the affected packages list of the bug, but without any success. Launchpad does simply not find landscape-common in project Ubuntu.

Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-96-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Wed Apr 29 13:19:28 UTC 2020

  System load: 1.14 Swap usage: 0%
  Usage of /: 6.8% of 228.23GB Users logged in: 0
  Memory usage: 9% IP address for enp3s0: 192.168.0.3

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

Steve Langasek (vorlon)
Changed in landscape-client (Ubuntu Disco):
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.