Fix/8544 mac linux unprivileged reenroll#9604
Conversation
|
This pull request does not have a backport label. Could you fix it @kaanyalti? 🙏
|
cfe42f7 to
f612dc5
Compare
…t tests fix(8544): added empty owner check in enroll unix tests
127f60e to
e27504c
Compare
8cc7a4d to
e15b90e
Compare
fix(8544): refactored fix permission computation, and added tests
fix(8544): ran mage check
e15b90e to
84d2dd7
Compare
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
|
Buildkite test this |
|
💛 Build succeeded, but was flaky
Failed CI StepsHistory
cc @kaanyalti |
|
Code looks good. I am building it now, and will run it before +1. |
|
as blake seems to be testing it as well please wait for him to get back to you |
|
I was able to test this on Linux arm64 and it is working as expected. After re-enrollment as root on an unprivileged installation all files written to disk have the correct permissions and the service is running successfully. |
|
@Mergifyio backport 8.18 8.19 9.0 9.1 |
✅ Backports have been createdDetails
|
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go
* Fix/8544 mac linux unprivileged reenroll (#9604) * fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go * fix(8544): resolve merge conflicts --------- Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
* Fix/8544 mac linux unprivileged reenroll (#9604) * fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go * fix(8544): resolve merge conflicts --------- Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
* Fix/8544 mac linux unprivileged reenroll (#9604) * fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go * fix(8544): resolve merge conflicts --------- Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co>
* Fix/8544 mac linux unprivileged reenroll (#9604) * fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block (cherry picked from commit 08444d4) # Conflicts: # internal/pkg/agent/cmd/enroll.go * fix(8544): resolve merge conflicts --------- Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co> Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
* fix(8544): remove unused files * fix(8544): remove file ownership check in enroll command * fix(8544): added getOwnerFromPath for mac and linux and added relevant tests fix(8544): added empty owner check in enroll unix tests * fix(8544): added fileownership and permission fix in enroll command fix(8544): refactored fix permission computation, and added tests * fix(8544): added noop getOwnerFromPath for windows * fix(8544): updated re-enroll test * fix(8544): added changelog fragment * fix(8544): ran mage check fix(8544): ran mage check * fix(8544): refactored computeFixPermissions and updated relevant test cases * fix(8544): refactor computeFixPermissions if block




What does this PR do?
Updates the enroll command so that the file permissions are fixed when a privileged user executes enroll. Implemented only for mac/linux. Permission fix is executed every time root executes enroll and enroll is not triggered by install. Windows implementation will be in a follow up pr. Split the PRs as windows implementation may end up being more involved.
Why is it important?
Currently a root user needs to run
sudo -u elastic-agent-user elastic-agent enroll ...in order to re-enroll an unprivileged agent.Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files./changelog/fragmentsusing the changelog toolDisruptive User Impact
None
How to test this PR locally
--unprivilegedflagRelated issues