portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
29.59k stars 2.38k forks source link

[BUG] Attaching a console always sends 'export LANG=C.UTF-8' even when target console is not sh #11968

Open jogerj opened 1 week ago

jogerj commented 1 week ago

Before you start please confirm the following.

Problem Description

https://github.com/portainer/portainer/blob/607feb183e6255bb24c2530d440c5d997d86b301/app/react/kubernetes/applications/ConsoleView/ConsoleView.tsx#L79-L81

The following lines cannot be disabled and is forced to be sent, even when the target attached console is not necessarily sh compliant

Expected Behavior

>

Attaches to console without side effects. The sent commands should be optional.

Actual Behavior

export LANG=C.UTF-8
> export LC_ALL=C.UTF-8
> clear
[12:47:18 INFO]: Unknown command. Type "/help" for help.
[12:47:18 INFO]: Unknown command. Type "/help" for help.
[12:47:18 INFO]: [Essentials] CONSOLE issued server command: /clear 
[12:47:18 INFO]: Error: Player not found.
> 

Attaches to console and sends the command always

Steps to Reproduce

  1. Compose a stack with tty and stdin_open set to true

e.g.

services:
  paper:
    image: itzg/minecraft-server
    tty: true
    stdin_open: true
    restart: unless-stopped
    environment:
      EULA: "TRUE"
      TYPE: PAPER
      VERSION: "1.20.4"
      USE_AIKAR_FLAGS: true
  1. When attaching to the console, it always sends unwanted commands

Portainer logs or screenshots

image

Portainer version

2.20.3

Portainer Edition

Community Edition (CE)

Platform and Version

Docker 26.1.4

OS and Architecture

Ubuntu 22.04 LTS, ARM64

Browser

No response

What command did you use to deploy Portainer?

.env:

PORTAINER_VERSION=2.20.3

docker-compose.yml:

services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:${PORTAINER_VERSION}
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    networks:
      - caddy

networks:
  caddy:
     external: true

volumes:
  portainer_data:

Additional Information

I thought of submitting this under feature request (to make the extra commands optional), but I'd argue it's a bug because it causes unintended behavior.

Also in other parts of code, there seems to be a check before sending the commands whether target is a linux terminal or not. https://github.com/portainer/portainer/blob/607feb183e6255bb24c2530d440c5d997d86b301/app/docker/views/containers/console/containerConsoleController.js#L179-L186

Nick-Portainer commented 1 week ago

Hi @jogerj Thank you for reporting this, I confirmed this with the compose you provided. I am raising this internally

internal: EE-7293