7951 Commits

Author SHA1 Message Date
Andrew Phelps
1d3a407dea c/snap-repair,o/hookstate,o/snapstate: replace errtracker usage with TODO comments 2023-10-09 16:00:35 +02:00
Andrew Phelps
a74c539a9c many: remove usage of the error tracker 2023-10-09 16:00:35 +02:00
Andrew Phelps
387d297407 c/snap-repair: make snap-repair respect store.offline configurable 2023-10-09 15:55:42 +02:00
Daniel Dadap
126029f5b2 Add libnvidia-gpucomp to the list of NVIDIA driver libraries
Upcoming versions of the NVIDIA driver will include a new component:

https://forums.developer.nvidia.com/t/new-driver-component-libnvidia-gpucomp/267060

Update the list of NVIDIA driver libraries so that it can be included
in the runtime environment along with the others.

Signed-off-by: Daniel Dadap <ddadap@nvidia.com>
2023-10-06 11:43:01 +02:00
Alfonso Sánchez-Beato
b4f263bba8 many: replace exec.CombinedOutput when output is parsed
Some invocations to external programs used exec.CombinedOutput, that
combines stdout and strerr into a single byte array. This can be an
issue if this output is parsed, as many programs print debug output or
warnings to stderr and that data is unexpected by the parsers. This
patch changes to using osutil.RunSplitOutput or osutil.RunCmd (that
return separately stdout and stderr) when we need to parse stdout, and
also in some other cases when printing separately both streams could
be helpful. Fixes LP #1885597.
2023-10-05 14:14:28 +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
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Valentin David
b133916fd7 cmd/Makefile.am: add warning to all CFLAGS (#13133)
Some target were not having warnings, for instance snap-generator,
because they did not have explicit CFLAGS, and AM_CFLAGS did
not contain CHECK_CFLAGS.
2023-09-19 14:10:38 +02:00
Valentin David
ce727afebf cmd/snap-device-helper: handle bind and unbind commands
When a device is bound unound to/from a driver, BIND/UNBIND events are
sent. We have been generating error as "unknown action", which
pollutes the logs and confuse users.

While a device node should be present in theory already from the ADD
event, we still ensure the device is added to the cgroup on BIND
events. Like we do with CHANGE events.
2023-09-19 13:41:29 +02:00
Samuele Pedroni
eab4494810 cmd/snap: optional cross-checking with the account-key when signing
this is done by passing the account-key if it could be retrieved
to signtool that has added support for cross-checking now
2023-08-31 13:06:49 +02:00
Michael Vogt
749b6ca910 snap: fix TestParseQuotas when no snapd.socket is avilable
The TestParseQuotas was hitting the /v2/quota/<group> endpoint
and with no snapd available it would hang forever. This commit
fixes this by adding the missing fake handler.
2023-08-30 15:43:22 +02:00
Valentin David
a6e7fa93de cmd/snapd-generator: read mountinfo for pid 1
Systemd now runs generators in a sandbox. That means
`/proc/self/mountinfo` does not represent correctly the mounts of the
system.
2023-08-30 15:43:09 +02:00
Valentin David
70f72f7643 cmd/snapd-generator: remove useless install section to snap.mount
No "enable" will happen for generated mounts. `snap.mount` is
started because of implicit dependency from snap mounts.
2023-08-30 15:43:09 +02:00
Valentin David
c7e748b340 cmd/configure.ac: remove defines in test programs that are already defined by prior macros 2023-08-29 17:50:35 +02:00
Valentin David
3bf4f7c206 cmd/configure.ac: use AX_APPEND_COMPILE_FLAGS 2023-08-29 17:50:35 +02:00
Valentin David
fbde190070 cmd/configure.ac: cache result of checking for -Wmissing-field-initializers 2023-08-29 17:50:35 +02:00
Valentin David
21381fcb24 cmd/configure.ac: cache result of checking for bpf headers 2023-08-29 17:50:35 +02:00
Philip Meulengracht
c9e7839e35 cmd/snap: more robust restart handling 2023-08-28 16:01:09 +02:00
Michael Vogt
0c571d803c cmd: detect if -Wno-missing-field-initializers is needed
Older versions of gcc are buggy and will give incorrect errors when
using `-Wmissing-field-initializers`. This is true on e.g. 14.04
and 16.04. However this is relatively straightforward to detect
and the configure.ac snippet in this commit will take care of it.
2023-08-17 14:56:24 +02:00
Michael Vogt
83c28eea71 many: add _daemon_ as valid system username (#13052)
* many: add `_daemon_` as valid system username

With the recent adoption of the `_daemon_` user in the spec RK011
by the rocks team we should follow suite and also support the
new `_daemon_` user for snaps.

This commit implements this support.

* osutil: improve comments

* tests: improve system-users-are-created spread test

* many: tweak function naming/comment (thanks to Samuele)

* osutil: rename EnsureUserGroup->EnsureSnapUserGroup
2023-08-15 18:00:00 +02:00
Michael Vogt
2d697eef13 cmd: remove -W{no-,}missing-field-initializers
With `-Wextra` the `-Wmissing-field-initializers` is already included
so removing `-Wno-missing-field-initializers` is enough.
2023-08-15 17:59:37 +02:00
Michael Vogt
6db39cb4d0 snap-confine: build with -Wmissing-field-initializers
The tiobe software quality checker flaged this and while it's a bit
debatable it adds some clarity around the booleans in the `sc_mount`
struct so I think it's overall worth it.
2023-08-15 17:59:37 +02:00
Zeyad Gouda
8825a2bc58 cmd/snap: prevent passing --prefer in multi-snap installs
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2023-08-04 11:24:58 +02:00
Michael Vogt
868459b938 snap-confine: tweak naming/comments
* rename "last"->"allow_spaces_in_field" in parse_next_string_field_ex()
* add comments to `parse_{next,last}_string_field()`
2023-08-03 09:14:04 +02:00
Zygmunt Krynicki
adf5090a5e osutil,cmd/libsnap: fix parsing super-block options with spaces
On any Windows + WSL 2 + Docker system, running any snap command is immediately
preceded by the two errors:

  2023/06/17 23:59:52.071511 system_key.go:129: cannot determine nfs usage in
  generateSystemKey: cannot parse mountinfo: incorrect number of tail fields,
  expected 3 but found 4
  2023/06/17 23:59:52.080033 cmd_run.go:1046: WARNING: cannot create user data
  directory: cannot determine SELinux status: failed to obtain SELinux mount
  path: incorrect number of tail fields, expected 3 but found 4

Those errors confuse tools that parse program output and generally cause a lot of havoc.

The root of the issue is caused by this specific entry in /proc/self/mountinfo
(not wrapped to preserve the problematic part more prominently):

  1146 77 0:149 / /Docker/host rw,noatime - 9p drvfs rw,dirsync,aname=drvfs;path=C:\Program Files\Docker\Docker\resources;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio

Note that the super-block mount option contains a key=value pair where the
value contains un-escaped spaces. Historically mountinfo has been an utter mess
to parse, with several bugs in both the userspace parsing and several bugs in
the fragile kernel interface generating the contents of said file.

To work around this problem allow spaces in the super-block options and
silently parse them as if they had been escaped correctly.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2023-08-03 09:14:04 +02:00