mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 17:56:33 +00:00
Some bugfix (#516)
* Some bugfix * Update apparmor.py * Update apparmor.py * Update apparmor.py * Update apparmor.py
This commit is contained in:
parent
f48182a69c
commit
9aa5eda2c8
@ -554,7 +554,7 @@ class Addon(CoreSysAttributes):
|
|||||||
with TemporaryDirectory(dir=self.sys_config.path_tmp) as tmp_folder:
|
with TemporaryDirectory(dir=self.sys_config.path_tmp) as tmp_folder:
|
||||||
profile_file = Path(tmp_folder, 'apparmor.txt')
|
profile_file = Path(tmp_folder, 'apparmor.txt')
|
||||||
|
|
||||||
adjust_profile(self.slug, self.path_apparmor, self.profile_file)
|
adjust_profile(self.slug, self.path_apparmor, profile_file)
|
||||||
await self.sys_host.apparmor.load_profile(self.slug, profile_file)
|
await self.sys_host.apparmor.load_profile(self.slug, profile_file)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -66,7 +66,7 @@ class AppArmorControl(CoreSysAttributes):
|
|||||||
|
|
||||||
async def load_profile(self, profile_name, profile_file):
|
async def load_profile(self, profile_name, profile_file):
|
||||||
"""Load/Update a new/exists profile into AppArmor."""
|
"""Load/Update a new/exists profile into AppArmor."""
|
||||||
if not validate_profile(profile_file, profile_name):
|
if not validate_profile(profile_name, profile_file):
|
||||||
_LOGGER.error("profile is not valid with name %s", profile_name)
|
_LOGGER.error("profile is not valid with name %s", profile_name)
|
||||||
raise HostAppArmorError()
|
raise HostAppArmorError()
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ def get_profile_name(profile_file):
|
|||||||
profiles = set()
|
profiles = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with profile_file.open('r') as profile:
|
with profile_file.open('r') as profile_data:
|
||||||
for line in profile:
|
for line in profile_data:
|
||||||
match = RE_PROFILE.match(line)
|
match = RE_PROFILE.match(line)
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
@ -31,14 +31,14 @@ def get_profile_name(profile_file):
|
|||||||
return profiles.pop()
|
return profiles.pop()
|
||||||
|
|
||||||
|
|
||||||
def validate_profile(profile_file, profile_name):
|
def validate_profile(profile_name, profile_file):
|
||||||
"""Check if profile from file is valid with profile name."""
|
"""Check if profile from file is valid with profile name."""
|
||||||
if profile_name == get_profile_name(profile_file):
|
if profile_name == get_profile_name(profile_file):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def adjust_profile(profile_file, profile_name, profile_new):
|
def adjust_profile(profile_name, profile_file, profile_new):
|
||||||
"""Fix the profile name."""
|
"""Fix the profile name."""
|
||||||
org_profile = get_profile_name(profile_file)
|
org_profile = get_profile_name(profile_file)
|
||||||
profile_data = []
|
profile_data = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user