KatharaFramework / Kathara

A lightweight container-based network emulation system.
https://www.kathara.org/
GNU General Public License v3.0
452 stars 63 forks source link

Terminal crashes if startup script output contains text that cannot be parsed as UTF-8 #208

Closed fstachura closed 1 year ago

fstachura commented 1 year ago

Describe the bug Kathara terminal crashes if startup script output contains text that cannot be parsed as UTF-8

To Reproduce Steps to reproduce the behavior:

  1. Create directory structure as shown in below
  2. Run kathara lstart
  3. pc1 terminal should show up and immediately crash with an error shown on screenshot below.

$ tree:

.
├── lab.conf
├── pc1/
│   └── a
├── pc1.startup
└── shared/

pc1/a:

test ó

lab.conf:

pc1[0]=A

pc1.startup:

cat /hostlab/pc1/a

Note that contents of pc1/a are not valid UTF-8:

cat pc1/a | xxd:

00000000: 7465 7374 20f3 0a                        test ..

file -i pc1/a

pc1/a: text/plain; charset=iso-8859-1

iconv -t utf-8 pc1/a

test iconv: illegal input sequence at position 5

Expected behavior Kathara terminal renders text from pc1/a, starts the shell and stays open.

Screenshots

Error (visible for <1 second):

error windows-error

"check" Command Output ``` * Current Manager is: Docker (Kathara) * Manager version is: 23.0.1 * Python version is: 3.10.7 (main, Dec 28 2022, 15:08:11) [GCC 12.2.0] * Kathara version is: 3.5.5 * Operating System version is: Linux-6.1.15-1-lts-x86_64 * Trying to run `Hello World` container... Deploying devices...|###################################################################################################################################################################################################################################################| 1/1 * Container run successfully. Deleting devices...|####################################################################################################################################################################################################################################################| 1/1 ```

Tested on Arch Linux (updated today) and Windows 10

tcaiazzi commented 1 year ago

Hello @fstachura,

Sorry for the late reply and thanks for opening the issue. I'm happy to help you!

However, I tried to run a lab like the one you suggest, but I didn't receive any error.

image

Can you please attach a copy of your lab so that I can investigate further?

Many thanks, Tommaso

fstachura commented 1 year ago

Hello, here is a copy of the lab:

lab.zip

tcaiazzi commented 1 year ago

Hi @fstachura,

Thanks for the lab. I stared to fix the problem on this branch: 209-waiting-startup-on-connect.

We have this error since the current version of Kathará manages the print of the startup logs on the terminal directly in Python and using the 'utf-8' encoding.

The new version will manage the print on the container, using its locale and preventing the terminal emulator from crashing.

Thanks for the help, Tommaso