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