Skip to content

Commit

Permalink
Make the updater work properly on SELinux (#518)
Browse files Browse the repository at this point in the history
* Add DECKY_SELINUX env var

* if on selinux make binary executable with chcon

* No need to recursively change one file
  • Loading branch information
PartyWumpus authored Jul 29, 2023
1 parent d4a76da commit 2ba9bce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion backend/localplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ def get_keep_systemd_service() -> bool:
def get_log_level() -> int:
return {"CRITICAL": 50, "ERROR": 40, "WARNING": 30, "INFO": 20, "DEBUG": 10}[
os.getenv("LOG_LEVEL", "INFO")
]
]

def get_selinux() -> bool:
return os.getenv("DECKY_SELINUX", "0") == "1"
5 changes: 4 additions & 1 deletion backend/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from json.decoder import JSONDecodeError
from logging import getLogger
from os import getcwd, path, remove
from localplatform import chmod, service_restart, ON_LINUX, get_keep_systemd_service
from localplatform import chmod, service_restart, ON_LINUX, get_keep_systemd_service, get_selinux

from aiohttp import ClientSession, web

Expand Down Expand Up @@ -208,6 +208,9 @@ async def do_update(self):
remove(path.join(getcwd(), download_filename))
shutil.move(path.join(getcwd(), download_temp_filename), path.join(getcwd(), download_filename))
chmod(path.join(getcwd(), download_filename), 777, False)
if get_selinux():
from subprocess import call
call(["chcon", "-t", "bin_t", path.join(getcwd(), download_filename)])

logger.info("Updated loader installation.")
await tab.evaluate_js("window.DeckyUpdater.finish()", False, False)
Expand Down

0 comments on commit 2ba9bce

Please sign in to comment.