From 7c65a36441f721b63ee19251ac140c66fbe3975f Mon Sep 17 00:00:00 2001 From: hotime Date: Fri, 20 Oct 2023 15:09:33 +0800 Subject: [PATCH] fix: bash is not default SHELL for new user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在未传入shell参数,并且从/etc/adduser.conf配置文件中未获取到DSHELL配置时,将"/bin/bash"作为新建用户的默认SHELL,以确保终端中能够正常展示当前用户名、机器名称、当前路径信息。 Log: 修复新建用户默认SHELL为"/bin/sh",导致的终端中未展示当前用户名、机器名称、当前路径信息的问题, Issue: https://github.com/linuxdeepin/developer-center/issues/5744 --- accounts1/users/manager.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accounts1/users/manager.go b/accounts1/users/manager.go index 5ad852528..e89ecfc62 100644 --- a/accounts1/users/manager.go +++ b/accounts1/users/manager.go @@ -24,6 +24,7 @@ const ( cmdChAge = "chage" defaultConfigShell = "/etc/adduser.conf" + defaultShell = "/bin/bash" ) const ( @@ -38,6 +39,9 @@ func CreateUser(username, fullname, shell string) error { if len(shell) == 0 { shell, _ = getDefaultShell(defaultConfigShell) + if len(shell) == 0 { + shell = defaultShell + } } mockUserInfo := UserInfo{