fix: run ttyd shell as normal user (sts) instead of root
Made-with: Cursor
This commit is contained in:
@@ -119,12 +119,15 @@ async function startTtyd() {
|
||||
|
||||
try {
|
||||
const shell = fs.existsSync('/bin/bash') ? '/bin/bash' : '/bin/sh';
|
||||
const proc = spawn(TTYD_BIN, ['-p', String(TTYD_PORT), '-i', '127.0.0.1', '-W', '-t', 'cursorBlink=true', shell], {
|
||||
// 以普通用户身份启动 shell(与 SSH 登录一致)
|
||||
const ttydUser = process.env.CLAWD_TTY_USER || 'sts';
|
||||
const loginCmd = `/bin/su - ${ttydUser}`;
|
||||
const proc = spawn(TTYD_BIN, ['-p', String(TTYD_PORT), '-i', '127.0.0.1', '-W', '-t', 'cursorBlink=true', loginCmd], {
|
||||
stdio: 'ignore',
|
||||
detached: true,
|
||||
});
|
||||
proc.unref();
|
||||
log.info('ttyd', `已启动,端口 ${TTYD_PORT},shell=${shell}`);
|
||||
log.info('ttyd', `已启动,端口 ${TTYD_PORT},用户=${ttydUser}`);
|
||||
return true;
|
||||
} catch (e) {
|
||||
log.warn('ttyd', '启动失败:', e.message);
|
||||
|
||||
Reference in New Issue
Block a user