only check for ancestor if the session is not a ssh session

Signed-off-by: Tin Lai <tin@tinyiu.com>
This commit is contained in:
Tin Lai 2024-11-01 09:57:59 +10:00
parent 49ee2cbe29
commit cffa650124

View File

@ -56,11 +56,14 @@ func (s *SessionStore) CreateSession(pid int, parentpid int, grandparentpid int,
func (s *SessionStore) verifySession(ctx sockets.CallingContext, sessionType SessionType) bool { func (s *SessionStore) verifySession(ctx sockets.CallingContext, sessionType SessionType) bool {
for _, session := range s.Store { for _, session := range s.Store {
if session.sessionType == sessionType { if session.sessionType == sessionType {
// only check for ancestor if the session is not a ssh session
if sessionType == SSHKey || (session.ParentPid == ctx.ParentProcessPid && session.GrandParentPid == ctx.GrandParentProcessPid) {
if session.Expires.After(time.Now()) { if session.Expires.After(time.Now()) {
return true return true
} }
} }
} }
}
return false return false
} }