Add device agent library

Provide enrollment, elevated install, posture checks, keystore, and
system-tray helpers shared by the probo-agent binary.

Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
Ludovic Vielle
2026-07-14 20:40:05 +02:00
parent e767dd8377
commit b442e1ed76
44 changed files with 2814 additions and 88 deletions

View File

@@ -83,6 +83,11 @@ func CommandExists(cmd string) bool {
return exists
}
// CommandCandidates returns absolute paths for known commands on the current platform.
func CommandCandidates(cmd string) []string {
return commandCandidates(cmd)
}
func resolveCommandPath(cmd string) (string, bool) {
if filepath.IsAbs(cmd) {
return cmd, isExecutableFile(cmd)

View File

@@ -23,6 +23,7 @@ package checks
var darwinCommandPaths = map[string][]string{
"defaults": {"/usr/bin/defaults"},
"fdesetup": {"/usr/bin/fdesetup"},
"osascript": {"/usr/bin/osascript"},
"pwpolicy": {"/usr/bin/pwpolicy"},
"softwareupdate": {"/usr/sbin/softwareupdate"},
"stat": {"/usr/bin/stat"},

View File

@@ -21,35 +21,41 @@
package checks
import (
"fmt"
"os"
"path/filepath"
"strings"
)
var windowsCommandPaths = map[string][]string{
"manage-bde": {`%s\System32\manage-bde.exe`},
"net": {`%s\System32\net.exe`},
"netsh": {`%s\System32\netsh.exe`},
"powershell": {`%s\System32\WindowsPowerShell\v1.0\powershell.exe`},
"sc": {`%s\System32\sc.exe`},
"w32tm": {`%s\System32\w32tm.exe`},
}
func commandCandidates(cmd string) []string {
templates := windowsCommandPaths[normalizeWindowsCommand(cmd)]
if len(templates) == 0 {
return nil
}
systemRoot := os.Getenv("SystemRoot")
if systemRoot == "" {
systemRoot = `C:\Windows`
}
system32 := filepath.Join(systemRoot, "System32")
switch strings.ToLower(cmd) {
case "powershell", "powershell.exe":
return []string{
filepath.Join(system32, "WindowsPowerShell", "v1.0", "powershell.exe"),
}
case "manage-bde", "manage-bde.exe":
return []string{filepath.Join(system32, "manage-bde.exe")}
case "netsh", "netsh.exe":
return []string{filepath.Join(system32, "netsh.exe")}
case "w32tm", "w32tm.exe":
return []string{filepath.Join(system32, "w32tm.exe")}
case "sc", "sc.exe":
return []string{filepath.Join(system32, "sc.exe")}
case "net", "net.exe":
return []string{filepath.Join(system32, "net.exe")}
default:
return nil
paths := make([]string, len(templates))
for i, template := range templates {
paths[i] = fmt.Sprintf(template, systemRoot)
}
return paths
}
func normalizeWindowsCommand(name string) string {
name = strings.ToLower(strings.TrimSpace(name))
return strings.TrimSuffix(name, ".exe")
}