-
Notifications
You must be signed in to change notification settings - Fork 670
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
Change file permissions on instances #3715
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3715 +/- ##
==========================================
- Coverage 89.11% 89.11% -0.01%
==========================================
Files 255 256 +1
Lines 14603 14643 +40
==========================================
+ Hits 13014 13049 +35
- Misses 1589 1594 +5 ☔ View full report in Codecov by Sentry. |
5a257a8
to
1e245a5
Compare
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.
Looks good, it seems that codecov wants to see test coverage for some lines:
- if (!MP_PLATFORM.set_root_as_owner(path)) in
write_to
extract_image
doesn't seem to have tests for it at all?
I have decided that the vm_image_vault tests are out of the scope of this PR. This is because writing tests would require a significant refactor of unrelated code (see 1653 in Jira). |
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.
Thanks for your work on this @Sploder12! Tackling these parts of the code can be tricky :)
Since this PR is closely related with #3782, there might be some overlap. But, here are some thoughts I had reviewing this:
- Existing instance directories/files do not have their permissions changed, only new instances.
- Is there a reason to apply permissions specifically to
cloud_init_iso
and instance directories and not to the other files stored within thedata_directory
andcache_directory
? - Would it be better/easier to apply blanket permissions on the
storage_directory
/cache_directory
/data_directory
indaemon_config
? That would solve 1 if it doesn't interfere with 2. - Instead of the name
set_root_as_owner()
, how abouttakeown()
? If need be, it could default to root/admin with an option to set ownership to the current user. That would follow pretty closely the Windows definition oftakeown
.
|
I guess covering the whole directory would be safer for the future and agree with principle of least privilege better. We can always expose any thing we need on a case by case basis. |
3af663c
to
bafbd01
Compare
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.
Initial review pass and I noticed some things that I think could be improved. Will make a more detailed review afterwards.
By setting permissions on the top level data/cache directories, all sub-directories should inherit those permissions, correct? If so, some of the code could be cleaned up.
d97135f
to
36e630f
Compare
5b088d8
to
d50d4e4
Compare
2d9bed1
to
477d0b9
Compare
I meant to review this but I am a little bogged down with reviews right now. This has 2 reviewers already, so I'll leave it up to them. |
024baf7
to
48de023
Compare
477d0b9
to
4a1b649
Compare
4a1b649
to
ad94156
Compare
f401971
to
ab13596
Compare
ad94156
to
ad5d54e
Compare
# Conflicts: # src/utils/vm_image_vault_utils.cpp
# Conflicts: # tests/linux/test_platform_linux.cpp
8da9d37
to
e6fee0a
Compare
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.
Well done with these changes! Tests pass including new ones, and I can see the permissions are changed for the cache and data folders with no loss in functionality to multipass:
this PR:
/var/snap/multipass/common/cache/multipassd# ls -l
total 40
-rwx------ 1 root root 32287 Feb 21 10:11 multipass-blueprints.zip
drwx------ 4 root root 4096 Feb 12 10:30 network-cache
drwx------ 3 root root 4096 Feb 21 10:11 vault
/var/snap/multipass/common/data/multipassd# ls -l
total 28
drwx------ 2 root root 4096 Feb 12 10:30 authenticated-certs
drwx------ 2 root root 4096 Feb 12 10:30 certificates
-rwx------ 1 root root 5142 Feb 21 10:13 multipassd-vm-instances.json
drwx------ 2 root root 4096 Feb 21 10:11 network
drwx------ 2 root root 4096 Feb 12 10:30 ssh-keys
drwx------ 3 root root 4096 Feb 19 22:21 vault
current main:
/var/snap/multipass/common/data/multipassd# ls -l
total 24
drwxr-xr-x 2 root root 4096 Feb 21 10:25 authenticated-certs
drwxr-xr-x 2 root root 4096 Feb 21 10:25 certificates
-rw-r--r-- 1 root root 1567 Feb 21 10:30 multipassd-vm-instances.json
drwxr-xr-x 2 root root 4096 Feb 21 10:25 network
drwxr-xr-x 2 root root 4096 Feb 21 10:25 ssh-keys
drwxr-xr-x 3 root root 4096 Feb 21 10:26 vault
/var/snap/multipass/common/cache/multipassd# ls -l
total 40
-rw-r--r-- 1 root root 32287 Feb 21 10:25 multipass-blueprints.zip
drwxr-xr-x 4 root root 4096 Feb 21 10:25 network-cache
drwxr-xr-x 3 root root 4096 Feb 21 10:26 vault
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.
Looks much better now. Thanks @Sploder12!
This PR changes file permissions on Multipass cache and data directories to be read/write only by root. Previously the files could be read by all.
Fixes #3866
MULTI-1403
MULTI-1723