Add a new generic container registry client via a new `container` package. Use this to create a command line utility as well as a new upload target for container registries. The code uses the github.com/containers/* project and packages to interact with container registires that is also used by skopeo, podman et al. One if the dependencies is `proglottis/gpgme` that is using cgo to bind libgpgme, so we have to add the corresponding devel package to the BuildRequires as well as installing it on CI. Checks will follow later via an integration test.
32 lines
610 B
Go
32 lines
610 B
Go
// +build !windows
|
|
|
|
package sockets
|
|
|
|
import (
|
|
"net"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// NewUnixSocket creates a unix socket with the specified path and group.
|
|
func NewUnixSocket(path string, gid int) (net.Listener, error) {
|
|
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
|
|
return nil, err
|
|
}
|
|
mask := syscall.Umask(0777)
|
|
defer syscall.Umask(mask)
|
|
|
|
l, err := net.Listen("unix", path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := os.Chown(path, 0, gid); err != nil {
|
|
l.Close()
|
|
return nil, err
|
|
}
|
|
if err := os.Chmod(path, 0660); err != nil {
|
|
l.Close()
|
|
return nil, err
|
|
}
|
|
return l, nil
|
|
}
|