Commit Graph

42 Commits

Author SHA1 Message Date
Stéphane Graber
5a4709d663
incusd: Document baseline error codes for endpoints using SmartError
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-07-28 18:32:51 -04:00
Stéphane Graber
ee81502afe
incusd: Limit websocket control message size
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-07-04 23:10:23 -04:00
Stéphane Graber
a00ce990dd
incusd/console: Read the container console without resetting it
Align the container behavior with VMs by reading the console ringbuffer
without resetting it, so the log can be fetched more than once.

Closes #3467

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-06-10 11:25:44 -04:00
Stéphane Graber
65eb825b19
incusd: Replace gorilla/mux with http.ServeMux
Apply what we did to incus-agent but to incusd.

Closes #2451

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-06-05 08:10:57 -04:00
Stéphane Graber
cedd8ffdf2
internal/linux: Return error last from GetErrno (revive:error-return)
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-26 18:08:25 -04:00
Stéphane Graber
9a8dcf5e98
incusd: Rename locals that shadow imports (revive:import-shadowing)
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-26 18:07:54 -04:00
Stéphane Graber
40dd4f151d
Rewrite Go import path to v7
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-02 01:18:25 +02:00
Stéphane Graber
157465d653
incusd/instance/console: Emit a single instance-console event on SPICE
SPICE uses multiple connections, instead of triggering an event on each
of them, we only want to trigger it once at the beginning.

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-01 17:31:41 +02:00
Stéphane Graber
b69464a8e3
incusd: Add missing path parameters
Closes #3170

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-05-01 00:54:26 +02:00
Stéphane Graber
ef006240ac
incusd/instance_console: Prevent symlink attacks
This fixes an issue when running on systems without the protect_symlinks
kernel protection enabled (introduced in 2012).

On such systems, a user could pre-create symlinks to sensitive files on
the system and trick Incus into truncating them and altering their file
mode and ownership.

This addresses CVE-2026-33711

Reported-by: https://7asecurity.com
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-03-24 16:58:10 -04:00
Stéphane Graber
c1d90bd34a
incusd/instance/lxc: Restrict path of template files and targets
This fixes three security issues related to file templates:

 - The template target path could be made to be relative or gothrough
   symlinks in a way that could lead to arbitrary write to the host
   filesystem.

 - The template directory could be relative, allowing for arbitrary read
   from the host filesystem.

 - The template file itself could be made relative, allowing for
   arbitrary reads from the host filesystem.

In the case of the template target path, the new logic makes use of the
kernel's openat2 system call which brings a variety of flags that can be
used to restrict path resolution and detect potential issues.

For the template path itself, we now validate that it is a simple local
file and that the template directory isn't a symlink.

This fixes CVE-2026-23954

Reported-by: Rory McNamara <rory.mcnamara@snyk.io>
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-01-22 16:55:54 -05:00
Stéphane Graber
85402757af
incusd/instance_console: Align cleanup logic with exec
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2026-01-18 17:49:13 -05:00
Stéphane Graber
696bc3943a
incusd/instances: Use /tmp for temporary screenshot storage
With the recent tightening of permissions on the instance folders, QEMU
is no longer able to directly write to the instance's folder.

We instead need a world writable location for those files to go.

Use /tmp and put a predictable pattern, restricted file permissions and
update the AppArmor policy for it.

Closes #2708

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-11-28 14:32:00 -05:00
Stéphane Graber
6048177c26
incusd: Remove remaining project remnants from operations
Follow-up on https://github.com/lxc/incus/pull/2588

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-10-28 09:49:26 -04:00
Stéphane Graber
a37f1eb2b0
incusd/console: Close remote connection on console disconnect
This will cause the remote client to get disconnected immediately rather
than on the next websocket message exchange.

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sponsored-by: https://webdock.io
2025-10-07 18:10:17 -04:00
Stéphane Graber
de7e28a3dc
incusd/instance_console: Ensure requestor match
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-07-25 17:41:07 -04:00
Nathan Chase
bf0b67dda2
incusd: Don't needlessly use format string functions
Signed-off-by: Nathan Chase <ntc477@utexas.edu>
2025-05-23 01:46:13 -04:00
Stéphane Graber
1ff7f6cb7b
incusd: Don't export internal websocket struct functions
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-04-27 20:28:28 -04:00
karo
14eca14a34
incusd: Remove unused parameters or rename unused parameters to _
Signed-off-by: karo <karolin.kostial@gmail.com>
2025-04-27 20:27:34 -04:00
karo
79ee9be3a1 incusd: Use errors.Is instead of direct error comparison
Replace direct error comparison with errors.Is checks to avoid potential bugs with wrapped errors.

Signed-off-by: karo <karolin.kostial@gmail.com>
2025-04-27 12:51:40 +02:00
Stéphane Graber
a1b7634df8
incusd: Remove old routing logic
Incus never had the old /1.0/containers and /1.0/virtual-machines
routes, it's therefore a waste of time for every API endpoint to do
extra request parsing and pass through the result of that operation
(which will always be instancetype.Any).

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-04-17 01:04:29 -04:00
Serge Hallyn
e14ad3ece9
Merge pull request #1501 from stgraber/main
Improve console disconnections
2024-12-12 16:26:27 -06:00
Stéphane Graber
9485a99f54
incusd/instance_console: Don't fail on failure to write reset sequence
This avoids tripping on a write error every time an instance is restarted.

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-12-12 15:20:42 -05:00
Stéphane Graber
2a58e25312
incusd/instance_console: Remove redundant (and unsafe) write
The last write sequence is already handled by the ws package, this is
just duplicated logic which may cause us to race with the ws package,
crashing the daemon.

Closes #1449

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-12-12 15:05:16 -05:00
Piotr Resztak
926009fad2 inucsd: Add additional check to Cancel method for ConsoleShow operation
Signed-off-by: Piotr Resztak <piotr.resztak@futurfusion.io>
2024-12-12 20:02:29 +01:00
Piotr Resztak
3bcd5fd4cc incusd: Add support for '--force' flag
Signed-off-by: Piotr Resztak <piotr.resztak@futurfusion.io>
2024-12-11 18:45:07 +01:00
Lucas Bremgartner
270cba3260
incusd/instance_console: Add screenshot support to console API
Signed-off-by: Lucas Bremgartner <lucas.bremgartner@futurfusion.io>
2024-11-28 11:50:44 -05:00
Stéphane Graber
71fb5f4748
incusd/instance/qemu: Simplify console switching
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-10-03 00:59:07 -04:00
Stéphane Graber
1250e03494
incusd/instance_console: Check result of type assertion
The previous check should be sufficient, but let's make golang-ci happy.

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-09-24 15:58:22 -04:00
Mathias Gibbens
ded249a081
cmd/incusd: Allow VMs to pull console history similar to containers
Signed-off-by: Mathias Gibbens <mathias.gibbens@futurfusion.io>
2024-09-20 15:08:14 -06:00
Stéphane Graber
3a0c790965
incusd/instance: Track operation during exec/console
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-08-05 00:29:29 -04:00
Stéphane Graber
c250aa58ed
incusd/instance_console: Cleanup error message
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-05-30 15:11:57 -04:00
Stéphane Graber
afb2ce0b20
incusd/instance_console: Don't fail on empty logs
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-05-30 15:10:48 -04:00
Stéphane Graber
bef8925526
incusd/instance_console: Handle missing log file
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-05-30 15:10:31 -04:00
Stéphane Graber
e77024b2c1
incusd/instance_console: Remove old check
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-05-30 15:10:08 -04:00
Stéphane Graber
859030aa96
incusd: Stop mentioning containers in resources
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-04-08 16:21:19 -04:00
Stéphane Graber
09dc3e60bc
global: Update Go package to v6
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-04-05 11:11:11 -04:00
Thomas Hipp
16095c9721
Replace util.ValueInSlice with slices.Contains
Signed-off-by: Thomas Hipp <thomashipp@gmail.com>
2024-02-23 22:28:37 +01:00
Stéphane Graber
de094b24bb
incusd/cluster: Optimize ConnectIfInstanceIsRemote
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2024-01-27 00:55:07 -05:00
Mark Laing
891e24a02d
[lxd-import] lxd: Updates calls to projectParam and queryParam.
Signed-off-by: Mark Laing <mark.laing@canonical.com>
2023-10-25 15:20:12 -04:00
Thomas Parrott
625964c720
[lxd-import] lxd: ws.Mirror*() usage
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2023-10-16 18:13:19 -04:00
Stéphane Graber
1757b5d04f
cmd/incusd: Move to cmd package
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2023-09-29 23:44:34 -04:00