mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 11:36:29 +00:00
75513575be
* store dependency's in git * since we vendor ... rm tech-depts * aad make target 'vendor' to update vendor folder (manual task)
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
|
|
}
|