1192 Commits

Author SHA1 Message Date
Philip Meulengracht
99302b1ad3 asserts: review feedback
update maxSupportedFormat to 2, update test, add check that UserExpiration is empty by default
2022-10-19 10:38:34 +02:00
Philip Meulengracht
2afc347391 asserts: reverse logic check 2022-10-19 09:26:01 +02:00
Philip Meulengracht
957f45b5af asserts: review feedback
update doc and error text, update unit tests
2022-10-19 09:13:29 +02:00
Philip Meulengracht
30cbadccf5 asserts: require header format 2 to use the new user-presence variable 2022-10-19 09:10:36 +02:00
Philip Meulengracht
ae9eee9ee5 asserts: rename user-valid-for to user-presence, add unit test specifically to verify that the member is optional, fix current logic determining this 2022-10-18 08:29:06 +02:00
Philip Meulengracht
14d7b7fb4f asserts: move the possitive test into TestDecodeOK 2022-10-13 12:48:18 +02:00
Philip Meulengracht
a22d1b8b41 asserts: review feedback
remove the duration part of the functionality after discussions on this subject. This cleans up a bit a code. Folded all unit tests into the DecodeOK/Invalid
2022-10-13 12:47:56 +02:00
Philip Meulengracht
bc6f4eac85 asserts: corrections to error messages, and corrections to docs 2022-10-10 09:18:41 +02:00
Philip Meulengracht
b0c7ae1e69 asserts: add support in system user assertion for keyword 'user-valid-for' 2022-10-10 09:10:14 +02:00
Samuele Pedroni
fcd9668e0c asserts,o/devicestate: fix typos and clarify naming
thanks @Meulengracht and @mardy
2022-10-07 18:40:58 +02:00
Samuele Pedroni
58bb6b4f21 many: support explicitly allowing classic snaps in extended models 2022-10-06 18:05:00 +02:00
Miguel Pires
f854897ee0 Merge pull request #12203 from MiguelPires/refresh-enforce-overlord
overlord: auto-resolve validation set enforcement constraints
2022-10-03 17:14:13 +01:00
Miguel Pires
4c6fdc2164 many: add tests for error Is()
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-10-03 10:22:01 +01:00
Samuele Pedroni
9280bdc7d4 many: cleanups
thanks @alfonsosanchezbeato
2022-09-30 18:20:32 +02:00
Samuele Pedroni
4b6bc5a702 Merge remote-tracking branch 'upstream/master' into classic-with-modes-no-kernel-gadget 2022-09-30 18:20:21 +02:00
Miguel Pires
f277d90279 o/snapstate: mostly test and documentation improvements
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-30 17:13:33 +01:00
Samuele Pedroni
54d5fa832c many: support extended classic models that omit kernel/gadget
redefine IsCoreBoot as the model having a kernel

there are at least tests that show we can seed such systems

the changes ind devicemgr.go prompted fixes for some remodel tests that were
confusingly running wiht OnClassic true though they were using Core models
2022-09-29 18:34:10 +02:00
Michael Vogt
450eb45492 Merge pull request #12182 from MiguelPires/refresh-enforce-daemon
daemon: support validation set refresh+enforce in API
2022-09-29 12:33:42 +02:00
Miguel Pires
1bc20a8391 daemon: change summary message + minor changes
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-28 10:28:31 +01:00
Miguel Pires
af2750d0a4 o/assertstate: add all used sets to ValidationSetsValidationError
Include all validation sets used to check in the validation error
instead of wrapping error with additional information.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-27 17:10:18 +01:00
Miguel Pires
73484a1523 asserts: wrap validation error with new sets data
Wrap the error returned by CheckInstalledSnaps with the new sets
that are not currently tracked. The previous approach required
marking those sets as "extra" in the validation set but was out
of place since this is only required for callers of "TryEnforce" to
resolve constraints that led to the validation error

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 17:17:46 +01:00
Miguel Pires
65e5c0271b asserts: add unit test for SetExtraSets method
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 14:46:23 +01:00
Miguel Pires
3cf8a0828b asserts: rename SexExtra method
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-26 14:46:09 +01:00
Miguel Pires
5c42708c8c daemon: support validation set refresh+enforce in API
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-09-23 15:43:31 +01:00
Alberto Mardegan
c45782e846 many: don't concatenate non-constant format strings
We should be careful not to concatenate variable strings into the first
argument of Sprintf/Printf/Errorf: if these variable strings end up
containing a percent character, it will break the way that the printfs
arguments are interpreted. Luckily, golang is smarter than C and is able
to detect mismatches between the number of '%' and the number of
arguments, but it still can lead to unexpected results:

    $ sudo snap set core refresh.rate-limit='%[2]#v'
    error: cannot perform the following tasks:
    - Run configure hook of "core" snap (run hook "configure": cannot parse "%!#(BADINDEX)v": no numerical prefix)

also:

    $ sudo snap set core refresh.rate-limit='%#v'
    error: cannot perform the following tasks:
    - Run configure hook of "core" snap (run hook "configure": cannot parse "&errors.errorString{s:"no numerical prefix"}": %!s(MISSING))

Moreover, it appears that all the occurrences of such pattern in our
code are situated either on unprivileged processes (like the `snap`
client), or, when in snapd, can only be triggered by the root user
(notice the `sudo` in the commands above).

Nevertheless, let's be defensive and fix these.

There are also other occurrences of concatenations in formatting
strings, but those are only constants so they don't pose a problem. But
to avoid the risk of these strings getting updated in the future with a
mutable version, let's explicitly mark these format prefixes as `const`.
2022-09-20 17:16:22 +03:00