mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-18 09:23:10 +00:00
Merge pull request #2744 from fengwang666/nil-bug
runtime: fix nil reference in cleanup rootless user
This commit is contained in:
commit
823818cfbc
@ -1024,10 +1024,12 @@ func (q *qemu) cleanupVM() error {
|
|||||||
u, err := user.LookupId(strconv.Itoa(int(q.config.Uid)))
|
u, err := user.LookupId(strconv.Itoa(int(q.config.Uid)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.Logger().WithError(err).WithField("uid", q.config.Uid).Warn("failed to find the user")
|
q.Logger().WithError(err).WithField("uid", q.config.Uid).Warn("failed to find the user")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
userdelPath, err := pkgUtils.FirstValidExecutable([]string{"/usr/sbin/userdel", "/sbin/userdel", "/bin/userdel"})
|
userdelPath, err := pkgUtils.FirstValidExecutable([]string{"/usr/sbin/userdel", "/sbin/userdel", "/bin/userdel"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
q.Logger().WithError(err).WithField("user", u.Username).Warn("failed to delete the user")
|
q.Logger().WithError(err).WithField("user", u.Username).Warn("failed to delete the user")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
_, err = pkgUtils.RunCommand([]string{userdelPath, "-f", u.Username})
|
_, err = pkgUtils.RunCommand([]string{userdelPath, "-f", u.Username})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user