MCPcopy
hub / github.com/moby/moby / main

Function main

contrib/apparmor/main.go:13–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11type profileData struct{}
12
13func main() {
14 if len(os.Args) < 2 {
15 log.Fatal("pass a filename to save the profile in.")
16 }
17
18 // parse the arg
19 apparmorProfilePath := os.Args[1]
20
21 // parse the template
22 compiled, err := template.New("apparmor_profile").Parse(dockerProfileTemplate)
23 if err != nil {
24 log.Fatalf("parsing template failed: %v", err)
25 }
26
27 // make sure /etc/apparmor.d exists
28 if err := os.MkdirAll(path.Dir(apparmorProfilePath), 0o755); err != nil {
29 log.Fatal(err)
30 }
31
32 f, err := os.OpenFile(apparmorProfilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
33 if err != nil {
34 log.Fatal(err)
35 }
36 defer f.Close()
37
38 data := profileData{}
39 if err := compiled.Execute(f, data); err != nil {
40 log.Fatalf("executing template failed: %v", err)
41 }
42
43 fmt.Printf("created apparmor profile for version %+v at %q\n", data, apparmorProfilePath)
44}

Callers

nothing calls this directly

Calls 3

NewMethod · 0.65
CloseMethod · 0.65
ExecuteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…