Skip tray re-register on deep-link enroll
Browser enrollment succeeds once the device is ACTIVE, but the macOS URL handler failed whenever install re-bootstrapped a tray LaunchAgent the PKG had already installed. Skip registration when the plist is current, treat live bootstrap as best-effort, and exit successfully if the device is already enrolled so retries do not show "Enrollment failed". Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -48,14 +48,23 @@ func RegisterAutoStart(exePath string, runDir string) error {
|
||||
|
||||
keyPath := sid + `\` + runKeyPath
|
||||
|
||||
key, _, err := registry.CreateKey(registry.USERS, keyPath, registry.SET_VALUE)
|
||||
key, _, err := registry.CreateKey(registry.USERS, keyPath, registry.QUERY_VALUE|registry.SET_VALUE)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot open or create Run registry key for interactive user: %w", err)
|
||||
}
|
||||
|
||||
defer func() { _ = key.Close() }()
|
||||
|
||||
command := fmt.Sprintf(`"%s" tray --run-dir "%s"`, exePath, runDir)
|
||||
command := trayRunCommand(exePath, runDir)
|
||||
|
||||
existing, _, err := key.GetStringValue(runValueName)
|
||||
if err == nil && existing == command {
|
||||
return nil
|
||||
}
|
||||
if err != nil && !errors.Is(err, registry.ErrNotExist) {
|
||||
return fmt.Errorf("cannot read Run registry value: %w", err)
|
||||
}
|
||||
|
||||
if err := key.SetStringValue(runValueName, command); err != nil {
|
||||
return fmt.Errorf("cannot set Run registry value: %w", err)
|
||||
}
|
||||
@@ -63,6 +72,10 @@ func RegisterAutoStart(exePath string, runDir string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func trayRunCommand(exePath string, runDir string) string {
|
||||
return fmt.Sprintf(`"%s" tray --run-dir "%s"`, exePath, runDir)
|
||||
}
|
||||
|
||||
func UnregisterAutoStart() error {
|
||||
sid, err := currentInteractiveUserSID()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user