Skip to content

Conversation

@michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Oct 1, 2025

to test this you need a 9.2 kibana with FF config:

xpack.fleet.enableExperimental: ["enableAgentPrivilegeLevelChange"]

This PR adds a handler for PRIVILEGE_LEVEL_CHANGE action.
Once action comes and permissions are fixed we call the code identical to privilege or unprivilege CLI commands.

Service manager handles user changes differently Windows being least problematic.
Systemd could do daemon-reload but for consistency MacOS and Linux are handled in a same way:

  • change to service file is made
  • agent is rebooted
  • desired user is detecting by reading a service definition file
  • permissions are fixed if needed
  • if it is non-root, setgid,setuid calls are made to drop privileges
  • we continue running.
    This is not performed if we are running using proper user

Test steps:

  • run kibana instance local or cloud >=9.2-SNAPSHOT
  • set config value xpack.fleet.enableExperimental: ["enableAgentPrivilegeLevelChange"]
  • enroll agent to fleet, make sure you don't have system integration enabled (system requires root)
  • dev tools: POST kbn:api/fleet/agents/{agent_id}/privilege_level_change
  • check file system permissions are correct
  • check process is using proper user/group
  • check service file is updated
  • restart machine recheck everything

Fixes: #4973

@michalpristas michalpristas self-assigned this Oct 1, 2025
@michalpristas michalpristas requested a review from a team as a code owner October 1, 2025 11:37
@michalpristas michalpristas added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-skip labels Oct 1, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalpristas Would it be possible to add some integration/E2E tests in this PR? Failing that, could you add some manual testing steps to the PR description? Thanks.

@michalpristas
Copy link
Contributor Author

added testing steps to description

@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feat/switch-action upstream/feat/switch-action
git merge upstream/main
git push upstream feat/switch-action

@mergify
Copy link
Contributor

mergify bot commented Oct 24, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feat/switch-action upstream/feat/switch-action
git merge upstream/main
git push upstream feat/switch-action

@mergify
Copy link
Contributor

mergify bot commented Oct 30, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feat/switch-action upstream/feat/switch-action
git merge upstream/main
git push upstream feat/switch-action

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @michalpristas

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks for working on it and iterating to get it into a good state.

@michalpristas michalpristas merged commit ac2e9f8 into elastic:main Nov 5, 2025
21 checks passed
hayotbisonai pushed a commit to hayotbisonai/elastic-agent that referenced this pull request Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle new action for switching Agent from privileged to unprivileged mode

5 participants