This file is indexed.

/usr/share/gocode/src/github.com/hashicorp/serf/vendor/github.com/sean-/seed/init.go is in golang-github-hashicorp-serf-dev 0.8.1+git20171021.c20a0b1~ds1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package seed

import (
	crand "crypto/rand"
	"fmt"
	"math"
	"math/big"
	"math/rand"
	"sync"
	"time"
)

var (
	once   sync.Once
	secure bool
	seeded bool
)

// Init provides best-effort seeding (which is better than running with Go's
// default seed of 1).  If `/dev/urandom` is available, Init() will seed Go's
// runtime with entropy from `/dev/urandom` and return true because the runtime
// was securely seeded.  If Init() has already initialized the random number or
// it had failed to securely initialize the random number generation, Init()
// will return false.  See MustInit().
func Init() (bool, error) {
	var err error
	once.Do(func() {
		var n *big.Int
		n, err = crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
		if err != nil {
			rand.Seed(time.Now().UTC().UnixNano())
			return
		}
		rand.Seed(n.Int64())
		secure = true
		seeded = true
	})
	return seeded && secure, err
}

// MustInit provides guaranteed seeding.  If `/dev/urandom` is not available,
// MustInit will panic() with an error indicating why reading from
// `/dev/urandom` failed.  See Init()
func MustInit() {
	once.Do(func() {
		n, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
		if err != nil {
			panic(fmt.Sprintf("Unable to seed the random number generator: %v", err))
		}
		rand.Seed(n.Int64())
		secure = true
		seeded = true
	})
}

// Secure returns true if a cryptographically secure seed was used to
// initialize rand.
func Secure() bool {
	return secure
}

// Seeded returns true if Init has seeded the random number generator.
func Seeded() bool {
	return seeded
}