podman-py icon indicating copy to clipboard operation
podman-py copied to clipboard

Error if URI exceeds 64 characters

Open muzammil786 opened this issue 1 year ago • 3 comments

I have a uri like this

uri = "unix:///Users/muzammil.shahbaz/.local/share/containers/podman/machine/podman-machine-default/podman.sock" This exceeds the standard 64 characters.

On execution, I get the following error:

Exception has occurred: UnicodeError
encoding with 'idna' codec failed (UnicodeError: label empty or too long)

The above exception was the direct cause of the following exception:

  File "../podmanclient.py", line 12, in <module>
    version = client.version()

A potential fix would be to encode the URL to base64 and handle decoding in the code.

I am using podman version 4.1.1 on OSX using qemu virtual machine.

muzammil786 avatar Jul 30 '22 12:07 muzammil786

You can open the file and then use the path to the fd. In Go we do this with.

	fd, err := unix.Open(path, unix.O_PATH, 0)
	if err != nil {
		return nil, err
	}
	defer unix.Close(fd)
	return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"})
}

rhatdan avatar Jul 30 '22 14:07 rhatdan

You can open the file and then use the path to the fd. In Go we do this with.

	fd, err := unix.Open(path, unix.O_PATH, 0)
	if err != nil {
		return nil, err
	}
	defer unix.Close(fd)
	return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"})
}

Any idea how to do in python pls?

muzammil786 avatar Aug 01 '22 09:08 muzammil786

I couldn't quite figure out how to get the path to the file descriptor the way that they do with Go, but I found a different (albeit clunky) workaround here. It creates an SSH tunnel to a socket in a much easier to access (and shorter path) location: /tmp/podman.sock. Its neither ideal nor pretty, but it gets the job done.

  > podman system connection ls

  # Create tunnel
  > ssh -nNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:[PORT]

  # Export socket location
  > export DOCKER_HOST='unix:///tmp/podman.sock'```

WisdomWolf avatar Aug 25 '22 21:08 WisdomWolf