Move sockets to rundir

This commit is contained in:
Neal Gompa
2024-04-27 10:14:22 -04:00
parent cea6ee0cbc
commit c84d9bec13
6 changed files with 54 additions and 4 deletions

View File

@@ -0,0 +1,44 @@
From bac712576069204618f642ef5ed3d8be942864b4 Mon Sep 17 00:00:00 2001
From: Neal Gompa <neal@gompa.dev>
Date: Sat, 27 Apr 2024 10:01:14 -0400
Subject: [PATCH] client/connection: Add support for the socket existing in
/run/incus
Transient sockets are supposed to be in /run rather than /var, so make
it possible to detect that automatically when used.
Signed-off-by: Neal Gompa <neal@gompa.dev>
---
client/connection.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/client/connection.go b/client/connection.go
index 01be07685..2792ccbe4 100644
--- a/client/connection.go
+++ b/client/connection.go
@@ -157,7 +157,8 @@ func ConnectIncusUnix(path string, args *ConnectionArgs) (InstanceServer, error)
//
// If the path argument is empty, then $INCUS_SOCKET will be used, if
// unset $INCUS_DIR/unix.socket will be used and if that one isn't set
-// either, then the path will default to /var/lib/incus/unix.socket.
+// either, then the path will default to /run/incus/unix.socket or
+// /var/lib/incus/unix.socket.
func ConnectIncusUnixWithContext(ctx context.Context, path string, args *ConnectionArgs) (InstanceServer, error) {
logger.Debug("Connecting to a local Incus over a Unix socket")
@@ -180,7 +181,11 @@ func ConnectIncusUnixWithContext(ctx context.Context, path string, args *Connect
if path == "" {
incusDir := os.Getenv("INCUS_DIR")
if incusDir == "" {
- incusDir = "/var/lib/incus"
+ if util.PathExists("/run/incus") {
+ incusDir = "/run/incus"
+ } else {
+ incusDir = "/var/lib/incus"
+ }
}
path = filepath.Join(incusDir, "unix.socket")
--
2.44.0

View File

@@ -1,3 +1,4 @@
d /var/cache/incus 0700 root root - - d /var/cache/incus 0700 root root - -
d /var/log/incus 0700 root root - - d /var/log/incus 0700 root root - -
d /var/lib/incus 0711 root root - - d /var/lib/incus 0711 root root - -
d /run/incus 0711 root root - -

View File

@@ -2,7 +2,7 @@
Description=Incus - Daemon (user unix socket) Description=Incus - Daemon (user unix socket)
[Socket] [Socket]
ListenStream=/var/lib/incus/unix.socket.user ListenStream=/run/incus/unix.socket.user
SocketGroup=incus SocketGroup=incus
SocketMode=0660 SocketMode=0660
Service=incus-user.service Service=incus-user.service

View File

@@ -3,6 +3,7 @@
/usr/libexec/incus(/.*)? gen_context(system_u:object_r:container_runtime_exec_t,s0) /usr/libexec/incus(/.*)? gen_context(system_u:object_r:container_runtime_exec_t,s0)
/usr/lib/systemd/system/incus.* gen_context(system_u:object_r:container_unit_file_t,s0) /usr/lib/systemd/system/incus.* gen_context(system_u:object_r:container_unit_file_t,s0)
/var/cache/incus(/.*)? gen_context(system_u:object_r:container_var_lib_t,s0) /var/cache/incus(/.*)? gen_context(system_u:object_r:container_var_lib_t,s0)
/var/lib/incus/unix.socket(.*)? -s gen_context(system_u:object_r:container_var_run_t,s0)
/var/lib/incus(/.*)? gen_context(system_u:object_r:container_var_lib_t,s0) /var/lib/incus(/.*)? gen_context(system_u:object_r:container_var_lib_t,s0)
/var/log/incus(/.*)? gen_context(system_u:object_r:container_log_t,s0) /var/log/incus(/.*)? gen_context(system_u:object_r:container_log_t,s0)
/run/incus/unix.socket(.*)? -s gen_context(system_u:object_r:container_var_run_t,s0)
/run/incus(/.*)? gen_context(system_u:object_r:container_var_run_t,s0)

View File

@@ -2,7 +2,7 @@
Description=Incus - Daemon (unix socket) Description=Incus - Daemon (unix socket)
[Socket] [Socket]
ListenStream=/var/lib/incus/unix.socket ListenStream=/run/incus/unix.socket
SocketGroup=incus-admin SocketGroup=incus-admin
SocketMode=0660 SocketMode=0660
Service=incus.service Service=incus.service

View File

@@ -58,10 +58,13 @@ Source203: %{swaggerui_source_baseurl}/swagger-ui.css#/swagger-ui-%{swagger
## Support correct incusd path ## Support correct incusd path
### From: https://github.com/lxc/incus/pull/799 ### From: https://github.com/lxc/incus/pull/799
Patch0001: 0001-cmd-incus-admin_cluster-Add-libexec-path-for-incusd.patch Patch0001: 0001-cmd-incus-admin_cluster-Add-libexec-path-for-incusd.patch
## Support /run/incus
### From: https://github.com/lxc/incus/pull/800
Patch0002: 0001-client-connection-Add-support-for-the-socket-existin.patch
# Downstream only patches # Downstream only patches
## Allow offline builds ## Allow offline builds
Patch1001: incus-0.2-doc-Remove-downloads-from-sphinx-build.patch Patch1001: incus-0.2-doc-Remove-downloads-from-sphinx-build.patch
%global bashcompletiondir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || :) %global bashcompletiondir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null || :)
%global selinuxtype targeted %global selinuxtype targeted
@@ -470,6 +473,7 @@ export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
* Sat Apr 27 2024 Neal Gompa <ngompa@fedoraproject.org> - 6.0.0-1 * Sat Apr 27 2024 Neal Gompa <ngompa@fedoraproject.org> - 6.0.0-1
- Update to 6.0.0 - Update to 6.0.0
- Move libexec content to libexecdir - Move libexec content to libexecdir
- Move sockets to rundir
* Wed Mar 27 2024 Neal Gompa <ngompa@fedoraproject.org> - 0.7-1 * Wed Mar 27 2024 Neal Gompa <ngompa@fedoraproject.org> - 0.7-1
- Update to 0.7 - Update to 0.7