This file is indexed.

/usr/share/gocode/src/github.com/opencontainers/runc/libcontainer/xattr/xattr_test.go is in golang-github-opencontainers-runc-dev 0.0.8+dfsg-2.

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
66
67
68
69
70
71
72
73
74
75
76
77
78
// +build linux

package xattr_test

import (
	"os"
	"testing"

	"github.com/opencontainers/runc/libcontainer/xattr"
)

func TestXattr(t *testing.T) {
	tmp := "xattr_test"
	out, err := os.OpenFile(tmp, os.O_WRONLY|os.O_CREATE, 0)
	if err != nil {
		t.Fatal("failed")
	}
	defer os.Remove(tmp)
	attr := "user.test"
	out.Close()

	if !xattr.XattrEnabled(tmp) {
		t.Log("Disabled")
		t.Fatal("failed")
	}
	t.Log("Success")

	err = xattr.Setxattr(tmp, attr, "test")
	if err != nil {
		t.Fatal("failed")
	}

	var value string
	value, err = xattr.Getxattr(tmp, attr)
	if err != nil {
		t.Fatal("failed")
	}
	if value != "test" {
		t.Fatal("failed")
	}
	t.Log("Success")

	var names []string
	names, err = xattr.Listxattr(tmp)
	if err != nil {
		t.Fatal("failed")
	}

	var found int
	for _, name := range names {
		if name == attr {
			found = 1
		}
	}
	// Listxattr doesn't return trusted.* and system.* namespace
	// attrs when run in unprevileged mode.
	if found != 1 {
		t.Fatal("failed")
	}
	t.Log("Success")

	big := "0000000000000000000000000000000000000000000000000000000000000000000008c6419ad822dfe29283fb3ac98dcc5908810cb31f4cfe690040c42c144b7492eicompslf20dxmlpgz"
	// Test for long xattrs larger than 128 bytes
	err = xattr.Setxattr(tmp, attr, big)
	if err != nil {
		t.Fatal("failed to add long value")
	}
	value, err = xattr.Getxattr(tmp, attr)
	if err != nil {
		t.Fatal("failed to get long value")
	}
	t.Log("Success")

	if value != big {
		t.Fatal("failed, value doesn't match")
	}
	t.Log("Success")
}