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

snapdtool: check for binary existence in InternalToolPath() #13227

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Sep 27, 2023

The current version of InternalToolPath() does not actually checks in all cases if the binary is actually there. Historically this was not a problem but with recent snapd releases we have the internal tool apparmor_parser that is only available in the snapd snap but not in the core snap. This means that on systems that have the snapd deb and only core InternalToolPath may return /snap/core/123/usr/lib/snapd/apparmor_parser even if this tool in not available inside the core snap.

This commit fixes this by checking if the actual executable is available.

The current version of `InternalToolPath()` does not actually
checks in all cases if the binary is actually there. Historically
this was not a problem but with recent snapd releases we have
the internal tool `apparmor_parser` that is only available in
the `snapd` snap but not in the `core` snap. This means that
on systems that have the snapd deb and only core `InternalToolPath`
may return `/snap/core/123/usr/lib/snapd/apparmor_parser` even
if this tool in not available inside the core snap.

This commit fixes this by checking if the actual executable
is available.
@codecov-commenter
Copy link

Codecov Report

Merging #13227 (da91a24) into master (8b353cc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@           Coverage Diff           @@
##           master   #13227   +/-   ##
=======================================
  Coverage   78.81%   78.81%           
=======================================
  Files        1014     1014           
  Lines      126399   126401    +2     
=======================================
+ Hits        99621    99623    +2     
  Misses      20539    20539           
  Partials     6239     6239           
Flag Coverage Δ
unittests 78.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
snapdtool/tool_linux.go 90.17% <100.00%> (+0.17%) ⬆️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pedronis pedronis self-requested a review October 4, 2023 13:00
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thanks, did a pass

snapdtool/tool_linux.go Outdated Show resolved Hide resolved
snapdtool/tool_linux.go Show resolved Hide resolved
@pedronis pedronis self-requested a review October 12, 2023 11:39
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thank you

Copy link
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ernestl ernestl changed the title snaptool: check for binary existance in InternalToolPath() snaptool: check for binary existence in InternalToolPath() Oct 18, 2023
@pedronis pedronis changed the title snaptool: check for binary existence in InternalToolPath() snapdtool: check for binary existence in InternalToolPath() Oct 24, 2023
@pedronis pedronis merged commit 1f621a9 into canonical:master Oct 24, 2023
fredldotme pushed a commit to fredldotme/snapd that referenced this pull request Mar 2, 2024
…l#13227)

* snapdtool: check for binary existance in InternalToolPath()

The current version of `InternalToolPath()` does not actually
checks in all cases if the binary is actually there. Historically
this was not a problem but with recent snapd releases we have
the internal tool `apparmor_parser` that is only available in
the `snapd` snap but not in the `core` snap. This means that
on systems that have the snapd deb and only core `InternalToolPath`
may return `/snap/core/123/usr/lib/snapd/apparmor_parser` even
if this tool in not available inside the core snap.

This commit fixes this by checking if the actual executable
is available.

* snapdtool: add test for non-executable internal tool path

* snapdtool: simplify InternalToolPath() (thanks to Samuele)
fredldotme pushed a commit to fredldotme/snapd that referenced this pull request Jun 4, 2024
…l#13227)

* snapdtool: check for binary existance in InternalToolPath()

The current version of `InternalToolPath()` does not actually
checks in all cases if the binary is actually there. Historically
this was not a problem but with recent snapd releases we have
the internal tool `apparmor_parser` that is only available in
the `snapd` snap but not in the `core` snap. This means that
on systems that have the snapd deb and only core `InternalToolPath`
may return `/snap/core/123/usr/lib/snapd/apparmor_parser` even
if this tool in not available inside the core snap.

This commit fixes this by checking if the actual executable
is available.

* snapdtool: add test for non-executable internal tool path

* snapdtool: simplify InternalToolPath() (thanks to Samuele)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants