File: socket_others.go

package info (click to toggle)
golang-github-smallstep-crypto 0.57.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,284 kB
  • sloc: sh: 53; makefile: 36
file content (25 lines) | stat: -rw-r--r-- 455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//go:build !windows
// +build !windows

package socket

import (
	"io"
	"os"

	"github.com/google/go-tpm/tpmutil"
)

func newSocket(path string) (io.ReadWriteCloser, error) {
	if path == "" {
		return nil, ErrNotAvailable
	}
	fi, err := os.Stat(path)
	if err != nil { // TODO(hs): handle specific errors here?
		return nil, err
	}
	if fi.Mode()&os.ModeSocket != 0 {
		return tpmutil.NewEmulatorReadWriteCloser(path), nil
	}
	return nil, ErrNotAvailable
}