2024-03-26 00:34:14 +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
|
|
|
|
|
|
|
|
package prepare
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
"github.com/roddhjav/apparmor.d/pkg/prebuild"
|
2024-03-26 00:34:14 +01:00
|
|
|
"github.com/roddhjav/apparmor.d/pkg/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Configure struct {
|
2024-10-02 17:22:46 +02:00
|
|
|
prebuild.Base
|
2024-03-26 00:34:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RegisterTask(&Configure{
|
2024-10-02 17:22:46 +02:00
|
|
|
Base: prebuild.Base{
|
2024-03-26 00:34:14 +01:00
|
|
|
Keyword: "configure",
|
|
|
|
Msg: "Set distribution specificities",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p Configure) Apply() ([]string, error) {
|
|
|
|
res := []string{}
|
2024-10-02 17:22:46 +02:00
|
|
|
|
|
|
|
switch prebuild.Distribution {
|
|
|
|
case "arch", "opensuse":
|
2024-03-26 00:34:14 +01:00
|
|
|
|
|
|
|
case "ubuntu":
|
2024-10-02 17:22:46 +02:00
|
|
|
if err := prebuild.DebianHide.Init(); err != nil {
|
2024-06-04 20:55:53 +02:00
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
if prebuild.ABI == 3 {
|
|
|
|
if err := util.CopyTo(prebuild.DistDir.Join("ubuntu"), prebuild.RootApparmord); err != nil {
|
2024-03-26 00:34:14 +01:00
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case "debian", "whonix":
|
2024-10-02 17:22:46 +02:00
|
|
|
if err := prebuild.DebianHide.Init(); err != nil {
|
2024-06-04 20:55:53 +02:00
|
|
|
return res, err
|
|
|
|
}
|
2024-03-26 00:34:14 +01:00
|
|
|
|
|
|
|
// Copy Debian specific abstractions
|
2024-10-02 17:22:46 +02:00
|
|
|
if err := util.CopyTo(prebuild.DistDir.Join("ubuntu"), prebuild.RootApparmord); err != nil {
|
2024-03-26 00:34:14 +01:00
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2024-10-02 17:22:46 +02:00
|
|
|
return []string{}, fmt.Errorf("%s is not a supported distribution", prebuild.Distribution)
|
2024-03-26 00:34:14 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
return res, nil
|
|
|
|
}
|