mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Refactor external and pro jobs permissions fixing in scheduler
This commit is contained in:
parent
d258f13676
commit
873dbdc014
2 changed files with 5 additions and 11 deletions
|
|
@ -5,8 +5,7 @@ from functools import partial
|
|||
from glob import glob
|
||||
from json import loads
|
||||
from logging import Logger
|
||||
from os import cpu_count, environ, getenv, sep, chmod
|
||||
from stat import S_IEXEC
|
||||
from os import cpu_count, environ, getenv, sep
|
||||
from os.path import basename, dirname, join
|
||||
from pathlib import Path
|
||||
from re import match
|
||||
|
|
@ -181,11 +180,7 @@ class JobScheduler(ApiCaller):
|
|||
success = True
|
||||
ret = -1
|
||||
try:
|
||||
file_path = join(path, "jobs", file)
|
||||
if file_path.startswith("/etc/bunkerweb/plugins") or file_path.startswith("/etc/bunkerweb/pro/plugins"):
|
||||
st = Path(file_path).stat()
|
||||
chmod(file_path, st.st_mode | S_IEXEC)
|
||||
proc = run(file_path, stdin=DEVNULL, stderr=STDOUT, env=self.__env, check=False)
|
||||
proc = run(join(path, "jobs", file), stdin=DEVNULL, stderr=STDOUT, env=self.__env, check=False)
|
||||
ret = proc.returncode
|
||||
except BaseException:
|
||||
success = False
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from glob import glob
|
|||
from hashlib import sha256
|
||||
from io import BytesIO
|
||||
from json import load as json_load
|
||||
from os import _exit, chmod, environ, getenv, getpid, listdir, sep, walk
|
||||
from os import _exit, environ, getenv, getpid, listdir, sep, walk
|
||||
from os.path import basename, dirname, join, normpath
|
||||
from pathlib import Path
|
||||
from shutil import copy, rmtree
|
||||
|
|
@ -148,9 +148,8 @@ def generate_external_plugins(plugins: List[Dict[str, Any]], *, original_path: U
|
|||
tar.extractall(original_path)
|
||||
tmp_path.unlink(missing_ok=True)
|
||||
|
||||
for job_file in glob(join(str(tmp_path.parent), "jobs", "*")):
|
||||
st = Path(job_file).stat()
|
||||
chmod(job_file, st.st_mode | S_IEXEC)
|
||||
for job_file in original_path.joinpath(plugin["id"], "jobs").glob("*"):
|
||||
job_file.chmod(job_file.stat().st_mode | S_IEXEC)
|
||||
except BaseException as e:
|
||||
logger.error(f"Error while generating {'pro ' if pro else ''}external plugins \"{plugin['name']}\": {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue