add a pill to show if a user is admin or not
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user