2016-01-19 16:54:42 -05:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package apparmor
|
|
|
|
|
|
|
|
// baseTemplate defines the default apparmor profile for containers.
|
|
|
|
const baseTemplate = `
|
|
|
|
{{range $value := .Imports}}
|
|
|
|
{{$value}}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
|
|
|
|
{{range $value := .InnerImports}}
|
|
|
|
{{$value}}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
network,
|
|
|
|
capability,
|
|
|
|
file,
|
|
|
|
umount,
|
|
|
|
|
|
|
|
deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
|
|
|
|
# deny write to files not in /proc/<number>/** or /proc/sys/**
|
|
|
|
deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
|
|
|
|
deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
|
|
|
|
deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/
|
|
|
|
deny @{PROC}/sysrq-trigger rwklx,
|
|
|
|
deny @{PROC}/mem rwklx,
|
|
|
|
deny @{PROC}/kmem rwklx,
|
|
|
|
deny @{PROC}/kcore rwklx,
|
|
|
|
|
|
|
|
deny mount,
|
|
|
|
|
|
|
|
deny /sys/[^f]*/** wklx,
|
|
|
|
deny /sys/f[^s]*/** wklx,
|
|
|
|
deny /sys/fs/[^c]*/** wklx,
|
|
|
|
deny /sys/fs/c[^g]*/** wklx,
|
|
|
|
deny /sys/fs/cg[^r]*/** wklx,
|
2016-09-15 22:21:31 -04:00
|
|
|
deny /sys/firmware/** rwklx,
|
2016-01-19 16:54:42 -05:00
|
|
|
deny /sys/kernel/security/** rwklx,
|
|
|
|
|
2016-02-14 02:06:31 -05:00
|
|
|
{{if ge .Version 208095}}
|
2016-01-19 16:54:42 -05:00
|
|
|
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
|
2016-11-29 02:48:38 -05:00
|
|
|
ptrace (trace,read) peer={{.Name}},
|
2016-02-14 02:04:16 -05:00
|
|
|
{{end}}
|
2016-01-19 16:54:42 -05:00
|
|
|
}
|
|
|
|
`
|