44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package windows
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/rvbox/rvbox/internal/client/supervisor"
|
|
)
|
|
|
|
const interactiveDesktop = `winsta0\default`
|
|
|
|
// Desktop placement follows the selected identity, never a caller-supplied
|
|
// desktop name. Session 0 contexts keep their noninteractive desktop.
|
|
func desktopForIdentity(identity supervisor.EffectiveIdentity) (string, error) {
|
|
switch ExecutionContext(identity.Context) {
|
|
case ContextActiveUser, ContextActiveUserElevated, ContextActiveSystem:
|
|
if identity.SessionID == 0 {
|
|
return "", fmt.Errorf("active execution context has no interactive session")
|
|
}
|
|
return interactiveDesktop, nil
|
|
case ContextLocalService, ContextLocalSystem:
|
|
if identity.SessionID != 0 {
|
|
return "", fmt.Errorf("local execution context unexpectedly targets session %d", identity.SessionID)
|
|
}
|
|
return "", nil
|
|
default:
|
|
return "", fmt.Errorf("unknown Windows execution context %q", identity.Context)
|
|
}
|
|
}
|
|
|
|
func validateInteractiveDesktop(desktop string) error {
|
|
if !strings.EqualFold(desktop, interactiveDesktop) {
|
|
return fmt.Errorf("interactive desktop mismatch: got %q, want %q", desktop, interactiveDesktop)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func launcherAbortError(payload []byte) error {
|
|
if len(payload) == 0 || len(payload) > 4096 {
|
|
return fmt.Errorf("launcher preparation failed without a valid diagnostic")
|
|
}
|
|
return fmt.Errorf("launcher preparation failed: %s", payload)
|
|
}
|