mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 09:46:29 +00:00
Fix's & cleanup
This commit is contained in:
parent
fddd5b8860
commit
ee4b28a490
4
API.md
4
API.md
@ -427,8 +427,8 @@ Get all available addons.
|
||||
"host_ipc": "bool",
|
||||
"host_dbus": "bool",
|
||||
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
|
||||
"seccomp": "disable|default|custom",
|
||||
"apparmor": "disable|default|custom",
|
||||
"seccomp": "disable|default|profile",
|
||||
"apparmor": "disable|default|profile",
|
||||
"devices": ["/dev/xy"],
|
||||
"auto_uart": "bool",
|
||||
"icon": "bool",
|
||||
|
@ -24,7 +24,7 @@ from ..const import (
|
||||
ATTR_HASSIO_API, ATTR_AUDIO, ATTR_AUDIO_OUTPUT, ATTR_AUDIO_INPUT,
|
||||
ATTR_GPIO, ATTR_HOMEASSISTANT_API, ATTR_STDIN, ATTR_LEGACY, ATTR_HOST_IPC,
|
||||
ATTR_HOST_DBUS, ATTR_AUTO_UART, ATTR_DISCOVERY, ATTR_SERVICES,
|
||||
ATTR_SECCOMP, ATTR_APPARMOR, SECURITY_CUSTOM, SECURITY_DISABLE,
|
||||
ATTR_SECCOMP, ATTR_APPARMOR, SECURITY_PROFILE, SECURITY_DISABLE,
|
||||
SECURITY_DEFAULT)
|
||||
from ..coresys import CoreSysAttributes
|
||||
from ..docker.addon import DockerAddon
|
||||
@ -324,23 +324,18 @@ class Addon(CoreSysAttributes):
|
||||
if not self._mesh.get(ATTR_SECCOMP):
|
||||
return SECURITY_DISABLE
|
||||
elif self.path_seccomp.exists():
|
||||
return SECURITY_CUSTOM
|
||||
return SECURITY_PROFILE
|
||||
return SECURITY_DEFAULT
|
||||
|
||||
@property
|
||||
def apparmor(self):
|
||||
"""Return True if seccomp is enabled."""
|
||||
if not self._mesh.get(ATTR_SECCOMP):
|
||||
if not self._mesh.get(ATTR_APPARMOR):
|
||||
return SECURITY_DISABLE
|
||||
elif self.path_apparmor.exists():
|
||||
return SECURITY_CUSTOM
|
||||
return SECURITY_PROFILE
|
||||
return SECURITY_DEFAULT
|
||||
|
||||
@property
|
||||
def seccomp_profile(self):
|
||||
"""Return True if it not use the default profile."""
|
||||
return Path(self.path_location, f"{ATTR_SECCOMP}.json").exists()
|
||||
|
||||
@property
|
||||
def legacy(self):
|
||||
"""Return if the add-on don't support hass labels."""
|
||||
|
@ -205,6 +205,6 @@ SNAPSHOT_PARTIAL = 'partial'
|
||||
|
||||
CRYPTO_AES128 = 'aes128'
|
||||
|
||||
SECURITY_CUSTOM = 'custom'
|
||||
SECURITY_PROFILE = 'profile'
|
||||
SECURITY_DEFAULT = 'default'
|
||||
SECURITY_DISABLE = 'disable'
|
||||
|
@ -9,7 +9,7 @@ from .interface import DockerInterface
|
||||
from ..addons.build import AddonBuild
|
||||
from ..const import (
|
||||
MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP, MAP_SHARE, ENV_TOKEN,
|
||||
ENV_TIME, SECURITY_CUSTOM, SECURITY_DISABLE)
|
||||
ENV_TIME, SECURITY_PROFILE, SECURITY_DISABLE)
|
||||
from ..utils import process_lock
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -126,13 +126,13 @@ class DockerAddon(DockerInterface):
|
||||
# AppArmor
|
||||
if self.addon.apparmor == SECURITY_DISABLE:
|
||||
security.append("apparmor:unconfined")
|
||||
elif self.addon.apparmor == SECURITY_CUSTOM:
|
||||
elif self.addon.apparmor == SECURITY_PROFILE:
|
||||
security.append(f"apparmor={self.addon.slug}")
|
||||
|
||||
# Seccomp
|
||||
if self.addon.seccomp == SECURITY_DISABLE:
|
||||
security.append("seccomp=unconfined")
|
||||
elif self.addon.seccomp == SECURITY_CUSTOM:
|
||||
elif self.addon.seccomp == SECURITY_PROFILE:
|
||||
security.append(f"seccomp={self.addon.path_seccomp}")
|
||||
|
||||
return security or None
|
||||
|
Loading…
x
Reference in New Issue
Block a user