~mvo/snapd/+git/snapd-mvo:internal-tool-path-smartz

Last commit made on 2023-10-12
Get this branch:
git clone -b internal-tool-path-smartz https://git.launchpad.net/~mvo/snapd/+git/snapd-mvo

Branch merges

Branch information

Name:
internal-tool-path-smartz
Repository:
lp:~mvo/snapd/+git/snapd-mvo

Recent commits

04086a6... by Michael Vogt

snapdtool: simplify InternalToolPath() (thanks to Samuele)

9b92d7b... by Michael Vogt

snapdtool: add test for non-executable internal tool path

da91a24... by Michael Vogt

snaptool: check for binary existance in InternalToolPath()

The current version of `InternalToolPath()` does not actually
checks in all cases if the binary is actually there. Historically
this was not a problem but with recent snapd releases we have
the internal tool `apparmor_parser` that is only available in
the `snapd` snap but not in the `core` snap. This means that
on systems that have the snapd deb and only core `InternalToolPath`
may return `/snap/core/123/usr/lib/snapd/apparmor_parser` even
if this tool in not available inside the core snap.

This commit fixes this by checking if the actual executable
is available.

8b353cc... by Alfonso Sanchez-Beato

gadget,osutil: add support for fat16 partitions (#13123)

* gadget,osutil: support FAT16 as filesystem

Add additional filesystem fat16 in the gadget specification.

* gadget: add method to check if filesystem identified by linux

matches the one in the gadget. This is not an exact match anymore
because of the introduction of fat16 as filesystem in gadget, which is
still seen as vfat by linux (udev shows fat bits in ID_FS_VERSION
while keeping ID_FS_TYPE=vfat).

* gadget,osutil: use vfat-16 instead of fat16, and vfat-32 as

alternative to vfat.

* gadget: add method to convert gadget to linux filesystem

Now the filesystem field in the gadget is not exactly the same as the
string used in Linux, so we need conversions in differente places.

* gadget: replace some simple methods with calls to LinuxFilesystem()

5bae3c1... by Andrew Phelps <email address hidden>

snap/squashfs: enforce a minimum snap size to eliminate some kernel log noise (#13191)

* squashfs: enforce a minimum snap size to eliminate kernel log noise

* integrity: update tests to account for new minimum snap size

* pack: update tests to account for new minimum snap size

* squashfs: rename truncate functions for clarity

* squashfs: make comment explaining growing a snap more clear

Co-authored-by: Miguel Pires <email address hidden>

* squashfs: add better context to truncation error

Co-authored-by: Miguel Pires <email address hidden>

* squashfs: split error if check onto multiple lines

* snap/pack: make test data consistent with new snap size

* snap/pack: update comment to be consistent with new snap size

* snap/squashfs: use more suited check comparator

* snap/integrity: add comment explaining calculation of verityHashSize

* pack: add comment explaining verityHashSize

* s/squashfs: log random snap data in test failure to enable reproduction

* s/squashfs: reduce mocking needed by calling actual mksquashfs command

---------

Co-authored-by: Miguel Pires <email address hidden>

402fdde... by Oliver Calder

osutil/epoll: make `e.Wait{,Timeout}()` return immediately when `e.Close()` is called (#13204)

* osutil/epoll: make `e.Wait{,Timeout}()` return immediately when `e.Close()` is called

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: make `WaitTimeout()` reference initial time

Previously, the elapsed time was computed as the total time spent
waiting on the `epoll_wait` syscall, but when waiting for a timeout, one
is generally more concerned with the time which has elapsed since
initiating the call, rather than the total time internally spent waiting
on the syscall (to the extent that can even be accurately measured).

This commit ensures that the function returns once the time since the
start of the call exceeds the given duration.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: added explicit `IsClosed()` function

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: made epoll file descriptor thread safe

Importantly, this change also makes `Close()` thread safe, eliminating
the previous risk that `close(e.closed)` could be called more than once,
thus causing a panic.

Additionally, the `zeroRegisteredFdCount()` function has been removed,
since guaranteeing that `e.registeredFdCount` is `0` after `Close()`
while other threads may be about to increment/decrement the count
requires additional overhead. It may also be useful to query the number
of registered file descriptors at time of close, and the function
otherwise served no purpose.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: use `chan struct{}` instead of `chan interface{}`

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: make `IsClosed()` atomic

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: make `IsClosed()` use `closed` channel

Thus, it is not necessary to set `e.fd = -1` when the channel is closed,
which is redundant information with the `closed` channel and meant that
reads and writes of `e.fd` needed to be atomic. Now, `e.fd` is never
changed after the epoll instance is created, so there is no need for
atomic reads/writes of `e.fd`.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: remove public `Fd()` method

Since `e.fd` is no longer modified, there is no need to internally
control reads of it in any special way, and thus no internal need for a
helper function.

Additionally, we very much do not want outside callers to close the
epoll file descriptor directly, as this should always be done via the
`Close()` method. Therefore, by unexporting access to internal `e.fd`,
this discourages users from closing `e.fd` directly.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: improved race condition checks in tests

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: added doc comment to `IsClosed()`

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: adjusted file header

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: added `IsClosed()` checks after syscalls

If the epoll instance is closed during a syscall, this could cause the
syscall to return EBADF. However, since closing the epoll instance is
the cause of this, we want to return `ErrEpollClosed` instead of
`EBADF`.

By checking `IsClosed()` immediately after the syscall returns (and
before checking the error returned by the syscall), we are guaranteed to
return `ErrEpollClosed` if the epoll instance was closed during a
syscall, regardless of whether closing the instance was the cause of an
error during the syscall.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: Only return ErrEpollClosed if error occurred

For methods which invoke syscalls, the epoll instance may be closed
during the syscall, which may cause the syscall to return an error.

Previously, we checked (after the syscall returned) if the epoll
instance was now closed, and if so, returned ErrEpollClosed. However,
there is a race between the end of the syscall and the check for whether
the epoll instance has been closed, so it may be that the syscall
completed successfully, either because the close occurred after the
syscall completed, or because the close did not trigger an error in the
syscall. Regardless, we should not return an error if no error actually
occurred.

Signed-off-by: Oliver Calder <email address hidden>

* osutil/epoll: remove unnecessary type from error variable

Signed-off-by: Oliver Calder <email address hidden>

---------

Signed-off-by: Oliver Calder <email address hidden>

29c9752... by Miguel Pires

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 <email address hidden>

bbcde77... by Philip Meulengracht

many: switch to new restart logic

Remodelling code had to be handled after the change of how restarts are now done. By default restarts only happen once a Change enters Done/Undone/Error/Wait, and thus a lot of changes were necessary to how some unit tests test their code.

97311ef... by Miguel Pires

o/servicestate: remove unused test struct

The build was failing on master because golangci was picking up this
unused struct and methods.

Signed-off-by: Miguel Pires <email address hidden>

d55f312... by Dimitri John Ledkov

go: go fix with 1.18

Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.