-
Notifications
You must be signed in to change notification settings - Fork 543
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
[collect] update for strict confinement for juju #3422
Closed
arif-ali
wants to merge
1
commit into
sosreport:main
from
arif-ali:sos-arif-collect-juju-snap-strict
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really not a fan of embedding
sudo
into a flow here, or shelling out to mess with the permissions and directory structure.Let's take a step back and review. What does "strict confinement" mean for juju? As a regular user running, what causes the
juju
commands I run to pull data to write as root? If I, as a regular user, can leveragejuju
commands to execute within a machine, why do I need to do special steps to access certain data within that machine? I.E. why does "juju-root" matter when pulling the data but not when executing the commands on behalf of the local user?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can totally understand, and this is nothing to do with
juju
itself, but how juju is installed.juju
is installed as asnap
, andsnaps
are either classic confinement or strict confinement.juju 2.9 and below were classic confinement, and hence it had the capability of writing to the classic
/tmp
. As soon as an application is strictly confined (and is the case for juju >=3), and you specify/tmp
, this will automatically expand to/tmp/snap-private-tmp/snap.<snap-name>/tmp
. So, when we do ajuju scp
and bring it onto the collector machine, it will copy it to/tmp/snap-private-tmp/snap.<snap-name>/tmp/sos.XXXXX
.If, however, we were using $HOME and some directory there to copy the file to, we should be able to, due to the following connections we have. The
/tmp
is a special area, that security confinement does not allow it to access files from other snaps and applicationsBelow is a link to a similar question on this
https://askubuntu.com/questions/1227248/how-to-make-snaps-see-the-real-tmp
I hope that makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TurboTurtle thoughts on this, I am keen for this to land for 4.7.0 if possible. Unless, you can advise on a different way to handle this?
@dnegreira anything you would like to chime in on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arif-ali I'm still not keen on embedding
sudo
and the like.If we're writing to a private
/tmp
location due to it being packaged as a snap, would it suffice to have the snap packaging set sos' entire tmpdir to that private location? As in, insos.conf
overriding--tmp-dir
to/tmp/snap-private-tmp/snap.<snap-name>/
with the snap packaging, leaving deb packaging as the "normal"/tmp
?Alternatively, is
juju
non-root capable? If not, would it be acceptable to saysos collect
now requires root forjuju
collections?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a snap issue of the
sos
and hence changing the default for the snap does not make sense here. This issue would exist on any machine that even has the deb or rpm version ofsos
, and is trying to access ajuju
cluster using v3This is ultimately an issue with how
juju
is packaged and notsos
. As mentioned above, there are 2 ways to package a snap, strict and classic. strict is the recommended way, and hence juju is like this from 3 onwards. The reason whysos
is not is due to the nature that it is a debugging tool, and it doesn't make sense for it to be strictly confined.The folder
/tmp/snap-private-tmp
is only written by strictly confined snaps, in this case this is thejuju
snap that is doing this and notsos
. When we scp files from the remote host usingjuju scp< machine-id>:<source> /tmp/sos.xxxx/
. That command is actually copying the file into/tmp/snap-private-tmp/snap.juju/tmp/sos.xxxx
and not into/tmp/sos.xxxx
. This is the essence of strictly confined snaps. This folder is only accessible toroot
users unfortunately, and hence the need to usesudo
.I appreciate this is not ideal and goes against in what this is happening here, but unfortunately this would be the only way we can easily resolve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I see, instead of running sudo, which I am also not very keen on doing, is forcing the collect to run as root, as we already do for
report
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnegreira that will defeat the purpose, as juju may not be configured for the root user, and hence will not be able to actually do
sudo juju ssh
orsudo juju scp
right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default no, but one could point the env variable
JUJU_DATA
or directly point to the ssh key under ~/.local/share/juju/ and it -should- work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, we'd make this root required for the
juju
cluster profile/transport specifically withincollect
, not for the entirety ofcollect
. Unfortunately I think this is the only path forward, as I simply cannot get myself over the embedding ofsudo
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll have to re-think how we do this then, leave it with me; thanks for the inputs