Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incus-user: keep track of socket path used to connect to the server #1607

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/incus-user/main_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Unable to connect to the daemon: %w", err)
}

cinfo, err := client.GetConnectionInfo()
if err != nil {
return fmt.Errorf("Failed to obtain connection info: %w", err)
}

// Keep track of the socket path we used to succefully connect to the server
serverUnixPath := cinfo.SocketPath

// Validate the configuration.
ok, err := serverIsConfigured(client)
if err != nil {
Expand Down Expand Up @@ -187,6 +195,6 @@ func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
continue
}

go proxyConnection(conn)
go proxyConnection(conn, serverUnixPath)
}
}
4 changes: 2 additions & 2 deletions cmd/incus-user/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func tlsConfig(uid uint32) (*tls.Config, error) {
return localtls.GetTLSConfigMem(tlsClientCert, tlsClientKey, "", tlsServerCert, false)
}

func proxyConnection(conn *net.UnixConn) {
func proxyConnection(conn *net.UnixConn, serverUnixPath string) {
defer func() {
_ = conn.Close()

Expand Down Expand Up @@ -92,7 +92,7 @@ func proxyConnection(conn *net.UnixConn) {
}

// Connect to the daemon.
unixAddr, err := net.ResolveUnixAddr("unix", internalUtil.VarPath("unix.socket"))
unixAddr, err := net.ResolveUnixAddr("unix", serverUnixPath)
if err != nil {
log.Errorf("Unable to resolve the target server: %v", err)
return
Expand Down
Loading