137 Commits

Author SHA1 Message Date
Sergio Cazzolato
f40b9595a1 tests: remove centos 7 support (#14147)
* tets: remove support for centos-7

Centos-7 is EOL since June-30

Signed-off-by: Sergio Cazzolato <sergio.cazzolato@canonical.com>

* update the release_tst.go with the real centos 9 info

---------

Signed-off-by: Sergio Cazzolato <sergio.cazzolato@canonical.com>
2024-07-04 11:28:21 -03:00
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
Robert Ancell
cea2be5132 release: detect if we're running on core desktop 2023-08-14 08:53:49 +02:00
Edu Gómez Escandell
fc0d3951e0 release: Fix WSL detection in LXD
* release: Defaulted WSL version to WSL2 (LP1995083)

* release: added lxfs as WSL1 filesystem (LP1995083)

* release: FStype obtained via /proc/mounts (LP1995083)

* Update release/release.go

Co-authored-by: Alberto Mardegan <mardy@users.sourceforge.net>

* Added dependency cycle comment

* Added scanner error

* Update release/release.go

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

* release: Added error log TODO comment

* Removed TestFilesystemRootType

* release: Made mockWSLsetup API more readable

* release: Changed FsType mock to prevent reading /

* release: added error check in MockFilesystemRootType

Co-authored-by: Alberto Mardegan <mardy@users.sourceforge.net>
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2022-11-16 15:57:39 +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
Edu Gómez Escandell
5545f79af9 release, snapd-apparmor: fixed outdated WSL detection (#12135)
* Chenged bad kernel check in favour of WSLInterop

* Fixed bug in unit tests

* Added cyclic import loop comment

* Removed redundant isWSL from main

* Fixed tests broken by prev commit

* Adhering to code style (thanks @MiguelPires)

* cmd/snapd-apparmor: Niche bugfix in container detection

* snapd-apparmor: Simplified tests

* snapd-apparmor: Fixed MockWSL calls

* Removed nonsense comment

* snapd-apparamor: Fixed WSL2 IsContainer test

* Update cmd/snapd-apparmor/main_test.go

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

* Update cmd/snapd-apparmor/export_test.go

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

* snapd-apparmor: moved MockWSL into main_test

* snapd-apparmor: Redundant detectCmd.Restore()

* MockWSL -> testutil.Backup

* Revert "MockWSL -> testutil.Backup"

This reverts commit 36af38165d558cac493cf661c6fc313f1cb14a40.

* Using testutil.Backup

* snapd-apparmor: Fixed MockWSL

* MockWSL -> mockWSL

* snpad-apparmor: Fixed WSL2 custom kernel test

* snapd-apparmor: Added comment explaining test

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2022-09-27 18:24:44 +02:00
James Henstridge
0af16827c1 release: refactor test to check a few more Ubuntu version variants 2020-06-26 08:21:17 +08:00
James Henstridge
6b4b979ab2 release, overlord/snapstate: move user daemons support logic to release package 2020-06-23 19:27:41 +08:00
Zygmunt Krynicki
455bfa34ab many: move IsForcedDevMode to sandbox/misc, move UA to snapdenv/useragent
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2020-04-02 18:35:50 +02:00
Samuele Pedroni
2b76ee5e5b many: introduce snapdenv.Preseeding instead of release.PreseedMode 2020-03-16 21:33:56 +01:00
Pawel Stolowski
2213690bc7 Change PreseedMode into a function. Updated the docstring. 2019-11-01 10:38:06 +01:00
Pawel Stolowski
2a45dde3cc Move PreseedMode to release package. 2019-10-29 10:49:23 +01:00
Maciej Borzecki
7c616c7f69 release: more explicit restore in the unit tests
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-10-07 10:12:13 +02:00
Maciej Borzecki
9a34a5abb5 release: make forced dev mode look at cgroupv2 support
Not all security backends are fully supported on a system using unified cgroup
hierarchy. Make sure this is reflected in the release package.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-10-01 14:11:01 +02:00
Maciej Borzecki
a590e4fe79 sandbox/seccomp: move remaining seccomp bits from release
The patch moves seccomp related APIs from the release pacakge into the
sandbox/seccomp one.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-30 14:57:59 +02:00
Maciej Borzecki
64be28bdbd sandbox/selinux: move selinux related APIs from release package
As part of the work to collect all of sandbox related pieces under the sandbox
pacakge, the patch moves the SELinux APIs from release under sandbox/selinux.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-27 11:41:28 +02:00
Maciej Borzecki
6431d40710 many: tweak AppArmor level indicator naming
Shorten the name, do not repeat AppArmor in the name needlessly.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-25 09:34:12 +02:00
Maciej Borzecki
7a638de95d many: use sandbox/apparmor package for poking the AppArmor support status
The AppArmor related code was moved to
github.com/snapcore/snapd/sandbox/apparmor package. Update the remaining code to
use the package.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-24 14:01:31 +02:00
Maciej Borzecki
ddebe16c7f sandbox/apparmor: split AppArmor detection into a separate package
Move the AppArmor related code into a separate package under sandbox/apparmor.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-24 14:01:31 +02:00
Maciej Borzecki
156e945e77 selinux: move the package under sandbox/selinux
Move the selinux package to be under sandbox, where other sandbox related pieces
live.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-09-20 11:38:21 +02:00
Maciej Borzecki
c04deb174b release: tweak SELinux summary info text
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-01-08 12:55:20 +01:00
Maciej Borzecki
d150e9a690 release: allow mocking SELinux state from external packages
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2019-01-07 09:55:55 +01:00
Maciej Borzecki
72e0954bf5 Merge remote-tracking branch 'origin/master' into bboozzoo/selinux-release-info 2019-01-07 09:34:28 +01:00
Maciej Borzecki
318896ad6b release: use sync.Once around lazy intialized state (#6306)
Some state data in the release package, namely AppArmor level/summary &
kernel/parser features as well as Seccomp feature set, is only initialized when
needed. Since there is a chance, this information could be accessed in
concurrently, we need to add some locking around the code that mutates the data.

This also shrinks the number of globals used to keep the state
and uses pointers to structs instead. This makes the Mock*
methods for the state a little bit clearer.
2018-12-20 14:48:04 +01:00