lxd/endpoints/local.go
func localCreateListener(path string, group string) (net.Listener, error) {
	err := CheckAlreadyRunning(path)
	if err != nil {
		return nil, err
	}

	err = socketUnixRemoveStale(path)
	if err != nil {
		return nil, err
	}

	listener, err := socketUnixListen(path)
	if err != nil {
		return nil, err
	}

	err = localSetAccess(path, group)
	if err != nil {
		listener.Close()
		return nil, err
	}

	return listener, nil
}
func localCreateListener(path string, group string) (net.Listener, error) {
	err := CheckAlreadyRunning(path)
	if err != nil {
		return nil, err
	}

	err = socketUnixRemoveStale(path)
	if err != nil {
		return nil, err
	}

	listener, err := socketUnixListen(path)
	if err != nil {
		return nil, err
	}

	err = localSetAccess(path, group)
	if err != nil {
		listener.Close()
		return nil, err
	}

	return listener, nil
}
// Create a new net.Listener bound to the unix socket of the local endpoint.