fix(terminal): authenticate host shell sessions
Build and publish Docker image / build-and-publish (push) Successful in 7s
Build and publish Docker image / build-and-publish (push) Successful in 7s
This commit is contained in:
1 parent
91d7c78392
commit
82fa50e9d5
2 files changed
+7
-18
No files matched your search
+6
-18
@@ -491,12 +491,6 @@ async def handle_node_terminal_connect(client_id, data):
|
||||
return
|
||||
|
||||
try:
|
||||
await send_message(client_id, {
|
||||
'type': 'node_terminal_output',
|
||||
'nodeName': node_name,
|
||||
'output': f"\r\n\x1b[32m[AnchorHost]\x1b[0m Initializing node shell on \x1b[36m{node_name}\x1b[0m...\r\n"
|
||||
})
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
pod_name = await ensure_node_shell_pod(node_name)
|
||||
|
||||
@@ -507,7 +501,7 @@ async def handle_node_terminal_connect(client_id, data):
|
||||
pod_name,
|
||||
'kube-system',
|
||||
container='shell',
|
||||
command=['nsenter', '-t', '1', '-m', '-u', '-i', '-n', '-p', '--', '/bin/sh'],
|
||||
command=['nsenter', '-t', '1', '-m', '-u', '-i', '-n', '-p', '--', '/bin/login'],
|
||||
stderr=True,
|
||||
stdin=True,
|
||||
stdout=True,
|
||||
@@ -521,7 +515,7 @@ async def handle_node_terminal_connect(client_id, data):
|
||||
pod_name,
|
||||
'kube-system',
|
||||
container='shell',
|
||||
command=['chroot', '/host', '/bin/sh'],
|
||||
command=['chroot', '/host', '/bin/login'],
|
||||
stderr=True,
|
||||
stdin=True,
|
||||
stdout=True,
|
||||
@@ -536,12 +530,6 @@ async def handle_node_terminal_connect(client_id, data):
|
||||
'nodeName': node_name
|
||||
}
|
||||
|
||||
await send_message(client_id, {
|
||||
'type': 'node_terminal_output',
|
||||
'nodeName': node_name,
|
||||
'output': f"\x1b[32m[AnchorHost]\x1b[0m Node terminal connected to \x1b[1m{node_name}\x1b[0m (host root namespace).\r\n\r\n"
|
||||
})
|
||||
|
||||
async def read_node_output():
|
||||
try:
|
||||
while client_id in node_sessions and client_id in connected_clients:
|
||||
@@ -575,9 +563,9 @@ async def handle_node_terminal_connect(client_id, data):
|
||||
except Exception as e:
|
||||
logger.error(f"Node terminal error: {e}", exc_info=True)
|
||||
await send_message(client_id, {
|
||||
'type': 'node_terminal_output',
|
||||
'type': 'node_terminal_error',
|
||||
'nodeName': node_name,
|
||||
'output': f"\x1b[31m[AnchorHost] Connection failed: {str(e)}\x1b[0m\r\n"
|
||||
'output': f"\x1b[31mHost login could not start: {str(e)}\x1b[0m\r\n"
|
||||
})
|
||||
|
||||
async def handle_node_terminal_input(client_id, data):
|
||||
@@ -604,9 +592,9 @@ async def handle_node_terminal_disconnect(client_id, data):
|
||||
ws_client.close()
|
||||
if client_id in connected_clients:
|
||||
await send_message(client_id, {
|
||||
'type': 'node_terminal_output',
|
||||
'type': 'node_terminal_disconnected',
|
||||
'nodeName': session.get('nodeName'),
|
||||
'output': "\r\n\x1b[33m[AnchorHost] Node terminal session closed.\x1b[0m\r\n"
|
||||
'output': "\r\nHost session closed.\r\n"
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"Node terminal cleanup error: {e}")
|
||||
|
||||
Reference in new issue
Block a user