mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 11:09:22 +08:00
fix: 不使用环境变量获取shell
This commit is contained in:
@@ -13,10 +13,8 @@ import (
|
||||
)
|
||||
|
||||
func newTerminalImpl() (*terminalImpl, error) {
|
||||
// 优先获取用户默认 shell
|
||||
shell := os.Getenv("SHELL")
|
||||
if shell == "" {
|
||||
// 如果 SHELL 环境变量为空,尝试从 /etc/passwd 获取
|
||||
shell := ""
|
||||
// 从 /etc/passwd 获取
|
||||
user, err := os.UserHomeDir() // 当前用户
|
||||
if err == nil {
|
||||
passwd, err := os.ReadFile("/etc/passwd")
|
||||
@@ -32,7 +30,6 @@ func newTerminalImpl() (*terminalImpl, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 验证 shell 是否可用
|
||||
if shell != "" {
|
||||
|
Reference in New Issue
Block a user