Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unprivileged] Upgrade broken due to permission issues #4093

Closed
blakerouse opened this issue Jan 17, 2024 · 2 comments · Fixed by #4100
Closed

[Unprivileged] Upgrade broken due to permission issues #4093

blakerouse opened this issue Jan 17, 2024 · 2 comments · Fixed by #4100
Assignees
Labels
bug Something isn't working Team:Elastic-Agent Label for the Agent team

Comments

@blakerouse
Copy link
Contributor

Upgrading an Elastic Agent that is installed with unprivileged fails to perform upgrade unless the tarball is built with the correct permissions.

Failed trigger upgrade of daemon: TarInstaller: creating file /opt/Elastic/Agent/data/elastic-agent-5b3535/package.version: open /opt/Elastic/Agent/data/elastic-agent-5b3535/package.version: permission denied

root@ogc-linux-arm64-ubuntu-2204-upgrade-cb2f:/opt/Elastic/Agent/data# ls -lh
total 8.0K
-rw------- 1 elastic-agent elastic-agent    0 Jan 17 18:37 agent.lock
drw-r----- 2 elastic-agent elastic-agent 4.0K Jan 17 18:37 elastic-agent-5b3535
drwxr-x--- 5 elastic-agent elastic-agent 4.0K Jan 17 18:37 elastic-agent-666fd7

The elastic-agent-5b3535 is the extracted directory for the upgrade and it doesn't have the correct permissions. It should have the same permissions as elastic-agent-666fd7.

if err := os.MkdirAll(abs, mode.Perm()&0770); err != nil {

Only applies a bitmask for 0770 meaning that the contents of the tarball have an a effect on the extracted contents.

@blakerouse blakerouse added bug Something isn't working Team:Elastic-Agent Label for the Agent team labels Jan 17, 2024
@blakerouse blakerouse self-assigned this Jan 17, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@blakerouse
Copy link
Contributor Author

I was able to identify the issue and it is not the archive that is incorrect. The archive is actually correct. The issue is in the TarInstaller.

if err := os.MkdirAll(filepath.Dir(abs), mode.Perm()&0770); err != nil {

At this point if the directory doesn't exist it will create it, except it uses the permissions of the file for its permissions and not the permissions for the directory that are in the tarball. This causes the extraction to be incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants