Skip to content

Commit

Permalink
shared/cliconfig: Remove incus-user support
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Oct 7, 2023
1 parent 593e3a2 commit e2a5052
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions shared/cliconfig/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/pem"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

Expand Down Expand Up @@ -73,40 +72,7 @@ func (c *Config) GetInstanceServer(name string) (incus.InstanceServer, error) {

// Unix socket
if strings.HasPrefix(remote.Addr, "unix:") {
unixPath := remote.Addr
if unixPath == "unix://" {
// Handle unix socket path overrides.
unixPath = os.Getenv("INCUS_SOCKET")
if unixPath == "" {
incusDir := os.Getenv("INCUS_DIR")
if incusDir == "" {
incusDir = "/var/lib/incus/"
}

newUnixPath := filepath.Join(incusDir, "unix.socket")
userUnixPath := filepath.Join(incusDir, "unix.socket.user")
if util.PathIsWritable(unixPath) {
// Use the new computed path.
unixPath = newUnixPath
} else if util.PathIsWritable(userUnixPath) {
// Handle the use of incus-user.
unixPath = userUnixPath

// When using incus-user, the project list is typically restricted.
// So let's try to be smart about the project we're using.
if remote.Project == "" {
remote.Project = fmt.Sprintf("user-%d", os.Geteuid())
}
} else {
// Fallback to path as provided by user.
unixPath = strings.TrimPrefix(strings.TrimPrefix(remote.Addr, "unix:"), "//")
}
}
} else {
unixPath = strings.TrimPrefix(strings.TrimPrefix(remote.Addr, "unix:"), "//")
}

d, err := incus.ConnectIncusUnix(unixPath, args)
d, err := incus.ConnectIncusUnix(strings.TrimPrefix(strings.TrimPrefix(remote.Addr, "unix:"), "//"), args)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e2a5052

Please sign in to comment.