7884 Commits

Author SHA1 Message Date
Philip Meulengracht
ae6489f798 golang: remove deadcode linter 2023-03-09 14:43:47 +01:00
Philip Meulengracht
291f4dd00d cmd/snap-confine: review feedback
Add convenience member "num_homedirs" to the invocation structure, and initialize it when initializing homedirs. Rename sc_invocation_check_homedirs => sc_invocation_init_homedirs. Make sure mounts are bidirectionel.
2023-03-08 12:11:00 +01:00
Philip Meulengracht
52a7c50819 cmd/snap-confine: handle NULL mounts in sc_do_mounts/sc_create_mount_points. Allow dynamic_mounts to be NULL. 2023-03-08 12:11:00 +01:00
Michael Vogt
49c582ab87 snap-confine: fix crash in legacy mode on UC16
The code in `sc_bootstrap_mount_namespace()` is not robust again
NULL values in sc_mount_config.dynamic_mounts and crashes in
`sc_create_mount_points()` and `sc_do_mounts()` when that
value is NULL.

This commit fixes the initial crash but it opens the question
if sc_create_mount_points() and sc_do_mounts() should also be
robust against NULL ?
2023-03-08 12:11:00 +01:00
Philip Meulengracht
e9ce4c3599 multiple: review feedback
fix weird indentation and clarify comment
2023-03-08 12:11:00 +01:00
Philip Meulengracht
b26ea24eff cmd/snap-confine: cast to void* when freeing 2023-03-08 12:11:00 +01:00
Philip Meulengracht
7a69d4ef49 cmd/snap-confine*: review feedback
fix relative path, improvements to how we allocate and free the dynamic mounts
2023-03-08 12:11:00 +01:00
Philip Meulengracht
fc487d1bca multiple: review comments
Instead of mocking loadHomedirs in the happy case, make sure the code is exercised by letting it read the actual file instead.
Add additional check in TestConfigureHomedirsHappy to ensure mocks are called.
Rename sc_init_homedir_mounts => sc_homedir_mounts
2023-03-08 12:11:00 +01:00
Philip Meulengracht
2e26ad5b7f cmd/snap-confine: review feedback
rename sc_create_homedir_mounts, fix missing newline in strtok, remove leftovers from rebase
2023-03-08 12:11:00 +01:00
Philip Meulengracht
7b1425e376 multiple: Add missing updating of snippets when changing the homedirs.
Move the functionality of /var/lib/snapd/system-params to its own package with unit tests, to get a more structured approach to the file.

Let SetupSnapConfineSnippets itself discover the homedirs instead of passing it as a parameter, this is also more in line with how it already functions with existing features.
2023-03-08 12:11:00 +01:00
Philip Meulengracht
08c43f5e95 cmd/snap-confine: fix missing value for return 2023-03-08 12:11:00 +01:00
Philip Meulengracht
19b6730a44 cmd/snap-confine: some cleanup in the snap-confine changes to how we check homedirs 2023-03-08 12:11:00 +01:00
Philip Meulengracht
5822b1a626 cmd/snap-confine: fix missspelling of separately 2023-03-08 12:11:00 +01:00
Philip Meulengracht
d67bc000af multiple: review feedback
clear up some doc comments, fix a bug in sc_invocation_check_homedirs, remove unused function for now, add missing docs
2023-03-08 12:11:00 +01:00
Philip Meulengracht
1cfbe4f1fd multiple: review feedback
coding style corrections, simplify empty argument
2023-03-08 12:11:00 +01:00
Michael Vogt
d37e23e55a snap-confine: tweak error message for non-home users without configuration 2023-03-08 12:11:00 +01:00
Michael Vogt
dd18dc3e02 snap-bootstrap: add missing osutil.MockMountInfo() 2023-03-08 12:11:00 +01:00
Michael Vogt
2211516c3e libsnap-confine-private: add missing #include <string.h> 2023-03-08 12:11:00 +01:00
Alberto Mardegan
7be5ba3599 cmd/snap-confine: check homedirs to see if NS is stale 2023-03-08 12:11:00 +01:00
Alberto Mardegan
45da94b5db cmd/snap-confine: mount homedirs into snap namespace 2023-03-08 12:11:00 +01:00
Alberto Mardegan
7debca10b4 cmd/snap-confine: read the homedirs configuration file
Store the list of the homedirs in the sc_invocation structure.
2023-03-08 12:11:00 +01:00
Alberto Mardegan
26350987b4 many: remove restrictions on homedir locations 2023-03-08 12:11:00 +01:00
Michael Vogt
014a791a21 snap: show log information from Wait tasks in the CLI (#12598)
* snap: show log information from Wait tasks in the CLI

This is a tiny patch to make the UX on classic+modes systems
more user friendly. Right now when running e.g.
`snap refresh pc-kernel` there is no indication that a system
reboot is required to continue, the only visible output is
that a re-refresh is attempted.

To fix this properly a bigger change is required and various
attempts in PR#12417 are all having problems. However as a
very minimal improvement this commit shows log messages from
tasks in `Wait` state without changing anything else.

This means that the UX is more like:
```
$ snap refresh pc-kernel
2023-02-24T11:2315Z INFO Task set to wait until a manual system restart allows to continue
Handling re-refresh of "pc-kernel" as needed
```
while not ideal UX it feels like a worthwhile improvement until
we find the time to fix this properly.

* snap: fix typo

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* snap: add warning about pressing ctrl-c

* snap: tweak warning message when snaps are in "wait" state (thanks Samuele)

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-03-06 16:53:20 +01:00
Miguel Pires
8ede9774ec cmd/snap: expose validate command
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-03-02 18:07:36 +01:00
Miguel Pires
32f410f4d5 cmd/snap: improve validate command's help message
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-03-02 18:07:36 +01:00