Skip to content

Commit 9235b26

Browse files
committed
refactor(accounts1): remove guest user functionality
Remove guest user feature to address security vulnerability identified in security report. The CreateGuestUser() function had a race condition when creating home directories in /tmp, which could allow other users to pre-create directories under their control. Since guest user functionality is no longer needed, it has been completely removed. Pms: BUG-349985 Signed-off-by: ComixHe <heyuming@deepin.org>
1 parent 1bbd70b commit 9235b26

5 files changed

Lines changed: 2 additions & 136 deletions

File tree

accounts1/accounts_dbusutil.go

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts1/exported_methods_auto.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts1/manager.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -38,7 +38,6 @@ const (
3838

3939
actConfigFile = actConfigDir + "/accounts.ini"
4040
actConfigGroupGroup = "Accounts"
41-
actConfigKeyGuest = "AllowGuest"
4241

4342
interfacesFile = "/usr/share/dde-daemon/accounts/dbus-udcp.json"
4443
)
@@ -80,9 +79,6 @@ type Manager struct {
8079
UserList []string
8180
UserListMu sync.RWMutex
8281

83-
// dbusutil-gen: ignore
84-
GuestIcon string
85-
AllowGuest bool
8682
// dbusutil-gen: equal=isStrvEqual
8783
GroupList []string
8884

@@ -138,9 +134,6 @@ func NewManager(service *dbusutil.Service) *Manager {
138134
m.usersMap = make(map[string]*User)
139135
m.userAddedChanMap = make(map[string]chan string)
140136

141-
m.GuestIcon = getRandomIcon()
142-
m.AllowGuest = isGuestUserEnabled()
143-
144137
m.initUsers(getUserPaths())
145138
m.initUdcpUsers()
146139
m.initAccountDSettings()
@@ -539,21 +532,6 @@ func getUserPaths() []string {
539532
return paths
540533
}
541534

542-
func isGuestUserEnabled() bool {
543-
v, exist := dutils.ReadKeyFromKeyFile(actConfigFile,
544-
actConfigGroupGroup, actConfigKeyGuest, true)
545-
if !exist {
546-
return false
547-
}
548-
549-
ret, ok := v.(bool)
550-
if !ok {
551-
return false
552-
}
553-
554-
return ret
555-
}
556-
557535
func (m *Manager) checkAuth(sender dbus.Sender) error {
558536
return checkAuth(polkitActionUserAdministration, string(sender))
559537
}

accounts1/manager_ifc.go

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -21,7 +21,6 @@ import (
2121
login1 "github.com/linuxdeepin/go-dbus-factory/system/org.freedesktop.login1"
2222
"github.com/linuxdeepin/go-lib/dbusutil"
2323
"github.com/linuxdeepin/go-lib/users/passwd"
24-
dutils "github.com/linuxdeepin/go-lib/utils"
2524
)
2625

2726
const (
@@ -340,49 +339,6 @@ func (m *Manager) IsPasswordValid(password string) (valid bool, msg string, code
340339
return errCode.IsOk(), errCode.Prompt(), int32(errCode), nil
341340
}
342341

343-
func (m *Manager) AllowGuestAccount(sender dbus.Sender, allow bool) *dbus.Error {
344-
err := m.checkAuth(sender)
345-
if err != nil {
346-
return dbusutil.ToError(err)
347-
}
348-
349-
m.PropsMu.Lock()
350-
defer m.PropsMu.Unlock()
351-
352-
if m.AllowGuest == allow {
353-
return nil
354-
}
355-
356-
success := dutils.WriteKeyToKeyFile(actConfigFile,
357-
actConfigGroupGroup, actConfigKeyGuest, allow)
358-
if !success {
359-
return dbusutil.ToError(errors.New("enable guest user failed"))
360-
}
361-
362-
m.AllowGuest = allow
363-
_ = m.emitPropChangedAllowGuest(allow)
364-
return nil
365-
}
366-
367-
func (m *Manager) CreateGuestAccount(sender dbus.Sender) (user string, busErr *dbus.Error) {
368-
err := m.checkAuth(sender)
369-
if err != nil {
370-
return "", dbusutil.ToError(err)
371-
}
372-
373-
name, err := users.CreateGuestUser()
374-
if err != nil {
375-
return "", dbusutil.ToError(err)
376-
}
377-
378-
info, err := users.GetUserInfoByName(name)
379-
if err != nil {
380-
return "", dbusutil.ToError(err)
381-
}
382-
383-
return userDBusPathPrefix + info.Uid, nil
384-
}
385-
386342
func (m *Manager) GetGroups() (groups []string, busErr *dbus.Error) {
387343
groups, err := users.GetAllGroups()
388344
return groups, dbusutil.ToError(err)

accounts1/users/guest.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)