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
@@ -335,6 +335,7 @@ def admin_get_all_servers():
|
|||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
SELECT s.id, s.name, s.cpu, s.ram, s.storage, s.image, s.type, s.version, s.loader, s.java_version,
|
SELECT s.id, s.name, s.cpu, s.ram, s.storage, s.image, s.type, s.version, s.loader, s.java_version,
|
||||||
|
s.is_demo, s.demo_expires_at,
|
||||||
s.status, s.ports, s.created_at, u.username as owner, u.id as owner_id,
|
s.status, s.ports, s.created_at, u.username as owner, u.id as owner_id,
|
||||||
s.sftp_username, s.sftp_port
|
s.sftp_username, s.sftp_port
|
||||||
FROM servers s
|
FROM servers s
|
||||||
|
|||||||
+6
-18
@@ -491,12 +491,6 @@ async def handle_node_terminal_connect(client_id, data):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
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()
|
loop = asyncio.get_event_loop()
|
||||||
pod_name = await ensure_node_shell_pod(node_name)
|
pod_name = await ensure_node_shell_pod(node_name)
|
||||||
|
|
||||||
@@ -507,7 +501,7 @@ async def handle_node_terminal_connect(client_id, data):
|
|||||||
pod_name,
|
pod_name,
|
||||||
'kube-system',
|
'kube-system',
|
||||||
container='shell',
|
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,
|
stderr=True,
|
||||||
stdin=True,
|
stdin=True,
|
||||||
stdout=True,
|
stdout=True,
|
||||||
@@ -521,7 +515,7 @@ async def handle_node_terminal_connect(client_id, data):
|
|||||||
pod_name,
|
pod_name,
|
||||||
'kube-system',
|
'kube-system',
|
||||||
container='shell',
|
container='shell',
|
||||||
command=['chroot', '/host', '/bin/sh'],
|
command=['chroot', '/host', '/bin/login'],
|
||||||
stderr=True,
|
stderr=True,
|
||||||
stdin=True,
|
stdin=True,
|
||||||
stdout=True,
|
stdout=True,
|
||||||
@@ -536,12 +530,6 @@ async def handle_node_terminal_connect(client_id, data):
|
|||||||
'nodeName': node_name
|
'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():
|
async def read_node_output():
|
||||||
try:
|
try:
|
||||||
while client_id in node_sessions and client_id in connected_clients:
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Node terminal error: {e}", exc_info=True)
|
logger.error(f"Node terminal error: {e}", exc_info=True)
|
||||||
await send_message(client_id, {
|
await send_message(client_id, {
|
||||||
'type': 'node_terminal_output',
|
'type': 'node_terminal_error',
|
||||||
'nodeName': node_name,
|
'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):
|
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()
|
ws_client.close()
|
||||||
if client_id in connected_clients:
|
if client_id in connected_clients:
|
||||||
await send_message(client_id, {
|
await send_message(client_id, {
|
||||||
'type': 'node_terminal_output',
|
'type': 'node_terminal_disconnected',
|
||||||
'nodeName': session.get('nodeName'),
|
'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:
|
except Exception as e:
|
||||||
logger.error(f"Node terminal cleanup error: {e}")
|
logger.error(f"Node terminal cleanup error: {e}")
|
||||||
|
|||||||
Reference in new issue
Block a user