add a pill to show if a user is admin or not

This commit is contained in:
KingKDot
2026-04-07 10:36:29 -05:00
parent 604803b5ee
commit ff9fda24af
11 changed files with 56 additions and 8 deletions
+1
View File
@@ -612,6 +612,7 @@ func runSession(ctx context.Context, cancel context.CancelFunc, conn *websocket.
hello.CPU = hw.CPU
hello.GPU = hw.GPU
hello.RAM = hw.RAM
hello.IsAdmin = sysinfo.IsAdmin()
if err := wire.WriteMsg(ctx, env.Conn, hello); err != nil {
return fmt.Errorf("send hello: %w", err)
@@ -0,0 +1,10 @@
//go:build !windows
package sysinfo
import "os"
// root == admin
func IsAdmin() bool {
return os.Getuid() == 0
}
@@ -0,0 +1,11 @@
//go:build windows
package sysinfo
import "golang.org/x/sys/windows"
// check current process token to see if we're admin asf
func IsAdmin() bool {
token := windows.GetCurrentProcessToken()
return token.IsElevated()
}
@@ -19,6 +19,7 @@ type Hello struct {
CPU string `msgpack:"cpu,omitempty"`
GPU string `msgpack:"gpu,omitempty"`
RAM string `msgpack:"ram,omitempty"`
IsAdmin bool `msgpack:"isAdmin,omitempty"`
}
type EnrollmentChallenge struct {