2024-03-26 19:05:55 +01:00
|
|
|
// apparmor.d - Full set of apparmor profiles
|
|
|
|
// Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
package prebuild
|
2024-03-26 19:05:55 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2024-06-04 20:55:53 +02:00
|
|
|
"github.com/roddhjav/apparmor.d/pkg/paths"
|
2024-04-02 18:48:03 +02:00
|
|
|
)
|
2024-03-26 19:05:55 +01:00
|
|
|
|
2024-06-04 20:55:53 +02:00
|
|
|
// Default content of debian/apparmor.d.hide. Whonix has special addition.
|
2024-04-03 22:05:24 +02:00
|
|
|
var Hide = `# This file is generated by "make", all edit will be lost.
|
|
|
|
|
|
|
|
/etc/apparmor.d/usr.bin.firefox
|
|
|
|
/etc/apparmor.d/usr.sbin.cups-browsed
|
|
|
|
/etc/apparmor.d/usr.sbin.cupsd
|
|
|
|
/etc/apparmor.d/usr.sbin.rsyslogd
|
|
|
|
`
|
|
|
|
|
2024-03-26 19:05:55 +01:00
|
|
|
type Flagger struct{}
|
|
|
|
|
|
|
|
func (f Flagger) Read(name string) map[string][]string {
|
|
|
|
res := map[string][]string{}
|
|
|
|
path := FlagDir.Join(name + ".flags")
|
|
|
|
if !path.Exist() {
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2024-10-12 16:31:24 +02:00
|
|
|
lines := path.MustReadFilteredFileAsLines()
|
2024-03-26 19:05:55 +01:00
|
|
|
for _, line := range lines {
|
|
|
|
manifest := strings.Split(line, " ")
|
|
|
|
profile := manifest[0]
|
|
|
|
flags := []string{}
|
|
|
|
if len(manifest) > 1 {
|
|
|
|
flags = strings.Split(manifest[1], ",")
|
|
|
|
}
|
|
|
|
res[profile] = flags
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
type Ignorer struct{}
|
|
|
|
|
|
|
|
func (i Ignorer) Read(name string) []string {
|
|
|
|
path := IgnoreDir.Join(name + ".ignore")
|
|
|
|
if !path.Exist() {
|
2024-04-02 18:48:03 +02:00
|
|
|
return []string{}
|
2024-03-26 19:05:55 +01:00
|
|
|
}
|
2024-10-12 16:31:24 +02:00
|
|
|
return path.MustReadFilteredFileAsLines()
|
2024-03-26 19:05:55 +01:00
|
|
|
}
|
|
|
|
|
2024-06-04 20:55:53 +02:00
|
|
|
type DebianHider struct {
|
|
|
|
path *paths.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the file with content from Hide
|
|
|
|
func (d DebianHider) Init() error {
|
|
|
|
return d.path.WriteFile([]byte(Hide))
|
|
|
|
}
|