Skip to content

Commit 66cb9db

Browse files
author
masm
committed
generate: fix capability.List() for cap_last_cap not exist
Signed-off-by: masm <mashimiao.fnst@cn.fujitsu.com>
1 parent 3334d03 commit 66cb9db

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

generate/generate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,17 @@ func (g *Generator) AddBindMount(bind string) error {
950950
// SetupPrivileged sets up the priviledge-related fields inside g.spec.
951951
func (g *Generator) SetupPrivileged(privileged bool) {
952952
if privileged {
953+
last := capability.CAP_LAST_CAP
954+
// hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap
955+
if last == capability.Cap(63) {
956+
last = capability.CAP_BLOCK_SUSPEND
957+
}
953958
// Add all capabilities in privileged mode.
954959
var finalCapList []string
955960
for _, cap := range capability.List() {
961+
if cap > last {
962+
continue
963+
}
956964
finalCapList = append(finalCapList, fmt.Sprintf("CAP_%s", strings.ToUpper(cap.String())))
957965
}
958966
g.initSpecLinux()

0 commit comments

Comments
 (0)