mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-12 02:15:01 +00:00
* Move the reexec parts of lib/srv to session/reexec * Update references to the moved bits of lib/srv * Avoid testutils in session/reexec * Shuffle some constants around to avoid imports in session/reexec * Vendor in the relevant parts of logutils in session/reexec * Remove unnecessary symlink checks when opening files * Inline the last two things from lib/utils in session/reexec * Inline moved constants * Deprecate group name consts and fix missed inlines * Add missing session/reexec.TestMain with reexec check * Reuse existing constants from the log constants package in session * Fix broken godoc link
38 lines
1.5 KiB
Go
38 lines
1.5 KiB
Go
// Teleport
|
|
// Copyright (C) 2026 Gravitational, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package reexec
|
|
|
|
import (
|
|
"errors"
|
|
"os/user"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
// isUnknownGroupError returns whether the error from LookupGroup is an unknown group error.
|
|
//
|
|
// LookupGroup is supposed to return an UnknownGroupError, but due to an existing issue
|
|
// may instead return a generic "no such file or directory" error when sssd is installed
|
|
// or "no such process" as Go std library just forwards errors returned by getgrpnam_r.
|
|
// See github issue - https://github.com/golang/go/issues/40334
|
|
func isUnknownGroupError(err error, groupName string) bool {
|
|
return errors.Is(err, user.UnknownGroupError(groupName)) ||
|
|
errors.Is(err, user.UnknownGroupIdError(groupName)) ||
|
|
strings.HasSuffix(err.Error(), syscall.ENOENT.Error()) ||
|
|
strings.HasSuffix(err.Error(), syscall.ESRCH.Error())
|
|
}
|