Path: blob/main/components/ws-daemon/seccomp-profile-installer/main.go
2498 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package main56import (7"encoding/json"8"log"9"os"1011"github.com/containerd/containerd/contrib/seccomp"12"github.com/opencontainers/runtime-spec/specs-go"13)1415func main() {16enc := json.NewEncoder(os.Stdout)17enc.SetIndent("", " ")18enc.SetEscapeHTML(false)1920spec := specs.Spec{21Process: &specs.Process{22Capabilities: &specs.LinuxCapabilities{23Bounding: os.Args[1:],24},25},26}2728s := seccomp.DefaultProfile(&spec)29s.Syscalls = append(s.Syscalls,30specs.LinuxSyscall{31Names: []string{32"clone",33"clone3",34"mount",35"umount2",36"chroot",37"pivot_root",38"setdomainname",39"sethostname",40"unshare",41"keyctl",42"add_key",43"request_key",44},45Action: specs.ActAllow,46},4748// Running docker on a workspace requires setns49// TODO(cw): find means to make this more precise, maybe an eBPF program that checks if50// arg zero is a child of this netns. The kernel already does that (from the setns(2) man page):51// In order to reassociate itself with a new network, IPC, time,52// or UTS namespace, the caller must have the CAP_SYS_ADMIN capa‐53// bility both in its own user namespace and in the user names‐54// pace that owns the target namespace.55specs.LinuxSyscall{56Names: []string{"setns"},57Action: specs.ActAllow,58},59)6061err := enc.Encode(s)62if err != nil {63log.Fatalf("cannot marshal seccomp profile: %q", err)64}65}666768