5 Commits

Author SHA1 Message Date
Miguel Pires
79c5ac14b2 many: remove usages of deprecated io/ioutil package (#13768)
* many: remove usages of deprecated io/ioutil package

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* .golangci.yml: remove errcheck ignore rule for io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* run-checks: prevent new usages of io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-03 23:23:24 +02:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Edu Gómez Escandell
0582fcf513 release, snapd-apparmor, syscheck: distinguish WSL1 and WSL2 (#12179)
Context
On Sept 21st, Microsoft anounced systemd support for WSL 2 ([see anouncement](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/)), and Ubuntu-Preview already ships with systemd enabled by default.

Changes
Snap now works on WSL 2. Hence some of the current system checks in snapd have to be updated in response.

Bugfixes
This PR fixes:
- [#1991823](https://bugs.launchpad.net/snapd/+bug/1991823) WSL detection is now incorrect / inappropriate
- [#1991826](https://bugs.launchpad.net/snapd/+bug/1991826) snapd is intentionally broken under WSL and shouldn't be

* release: Implemented WLS 1/2 distinction

* syscheck: enabled snapd on WSL 2

* snapd-apparmor: Applied distiction, split tests

* Made WSL1 check more robust

* release: Removed redundant isWSL

* snapd-apparmor: WSL2 has internal policy

* release: Strenghtened detection of WSL1 vs. WSL2

* cmd/snap: Allowed snap on WSL2

* release: getting filesystem type with syscal

* release: added unit test for filesystemRootType

* release: use Assert to check errors

as we usually do

Co-authored-by: Samuele Pedroni <pedronis@lucediurna.net>
2022-10-13 18:41:02 +02:00
Michael Vogt
58d9bfd21a sanity: rename "sanity.Check" to "syscheck.CheckSystem"
* sanity: rename to "validity"

* sanity: rename to syscheck.CheckSystem()

* syscheck: add doc comment for syscheck.CheckSystem()
2022-04-05 10:19:53 +02:00