diff --git a/src/scheduler/JobScheduler.py b/src/scheduler/JobScheduler.py index 8a4ffc1d0..2f41f932b 100644 --- a/src/scheduler/JobScheduler.py +++ b/src/scheduler/JobScheduler.py @@ -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 diff --git a/src/scheduler/main.py b/src/scheduler/main.py index b14b8d317..7d841bd97 100644 --- a/src/scheduler/main.py +++ b/src/scheduler/main.py @@ -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}")