fix(mdm): detect logged-in console user when running as root#20
Merged
ashishkurmi merged 3 commits intostep-security:mainfrom Apr 15, 2026
Merged
Conversation
efb7ea8 to
7a35d5c
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves macOS behavior when the agent runs as root (e.g., via LaunchDaemon) by detecting the logged-in console user and using that identity/home directory for scans and configuration.
Changes:
- Add
Executor.LoggedInUser()(console user detection via/dev/consoleon macOS when root) and use it to resolve$HOMEand developer identity. - Update enterprise Node scanning to optionally delegate package-manager commands to the logged-in user.
- Update launchd installation to bake
HOMEinto the generated plist when running as root; also adds timestamps to progress/error log lines.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/executor/executor.go | Adds LoggedInUser() implementation for macOS root console-user detection. |
| internal/executor/mock.go | Adds mock LoggedInUser() implementation. |
| internal/telemetry/telemetry.go | Uses LoggedInUser() for $HOME resolution and passes logged-in username into Node scanner. |
| internal/scan/scanner.go | Uses LoggedInUser() for $HOME resolution in community scans. |
| internal/device/device.go | Uses LoggedInUser() for developer identity fallback. |
| internal/detector/aicli.go | Uses LoggedInUser() for tilde expansion home directory. |
| internal/detector/nodescan.go | Adds user-delegated execution path for Node package manager commands. |
| internal/launchd/launchd.go | Injects HOME env var into LaunchDaemon plist when a user home is resolved. |
| internal/progress/progress.go | Prepends timestamps to progress/error log lines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e3148f7 to
78037b8
Compare
78037b8 to
cf90d50
Compare
ashishkurmi
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Type of change
Testing
./stepsecurity-dev-machine-guard --verbose./stepsecurity-dev-machine-guard --json | python3 -m json.toolmake lintmake testRelated Issues