mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 14:38:15 +01:00
Merge pull request #134 from PiBrewing/python-systemd_test
Fix for issue #132 (CVE-2024-3955)
This commit is contained in:
commit
fe15b4c0e9
3 changed files with 28 additions and 9 deletions
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.4.1.a3"
|
||||
__version__ = "4.4.1.a6"
|
||||
__codename__ = "Yeast Starter"
|
||||
|
||||
|
|
|
@ -15,6 +15,14 @@ import zipfile
|
|||
import socket
|
||||
import importlib
|
||||
from tabulate import tabulate
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
try:
|
||||
from systemd import journal
|
||||
systemd_available=True
|
||||
except Exception:
|
||||
logger.warning("Failed to load systemd library. logfile download not available")
|
||||
systemd_available=False
|
||||
|
||||
class SystemController:
|
||||
|
||||
|
@ -77,19 +85,29 @@ class SystemController:
|
|||
fullkettlename = pathlib.Path(os.path.join(".",kettlename))
|
||||
|
||||
output_filename="cbpi4_log.zip"
|
||||
|
||||
result=[]
|
||||
if systemd_available:
|
||||
j = journal.Reader()
|
||||
if logtime == "b":
|
||||
os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname))
|
||||
j.this_boot()
|
||||
else:
|
||||
os.system('journalctl --since \"{} hours ago\" -u craftbeerpi.service --output cat > {}'.format(logtime, fullname))
|
||||
since = datetime.now() - timedelta(hours=int(logtime))
|
||||
j.seek_realtime(since)
|
||||
j.add_match(_SYSTEMD_UNIT="craftbeerpi.service")
|
||||
|
||||
for entry in j:
|
||||
result.append(entry['MESSAGE'])
|
||||
try:
|
||||
with open(fullname, 'w') as f:
|
||||
for line in result:
|
||||
f.write(f"{line}\n")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
plugins = await self.plugins_list()
|
||||
|
||||
with open(fullpluginname, 'w') as f:
|
||||
f.write(plugins)
|
||||
|
||||
#os.system('echo "{}" >> {}'.format(plugins,fullpluginname))
|
||||
|
||||
try:
|
||||
actors = self.cbpi.actor.get_state()
|
||||
json.dump(actors['data'],open(fullactorname,'w'),indent=4, sort_keys=True)
|
||||
|
|
3
setup.py
3
setup.py
|
@ -64,7 +64,8 @@ setup(name='cbpi4',
|
|||
'importlib_metadata',
|
||||
'numpy==1.26.4',
|
||||
'pandas==2.2.2'] + (
|
||||
['rpi-lgpio'] if raspberrypi else [] ),
|
||||
['rpi-lgpio'] if raspberrypi else [] ) + (
|
||||
['systemd-python'] if localsystem == "Linux" else [] ),
|
||||
|
||||
dependency_links=[
|
||||
'https://testpypi.python.org/pypi',
|
||||
|
|
Loading…
Reference in a new issue