From 2feff97a914541e2be7480be1fb36c2a949674b4 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 23 Jun 2025 09:58:12 +0200 Subject: [PATCH 1/5] refs #2278 change some labels in the windows installer --- windows/ogagent.nsi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/windows/ogagent.nsi b/windows/ogagent.nsi index 7aaf027..d496a5e 100644 --- a/windows/ogagent.nsi +++ b/windows/ogagent.nsi @@ -217,7 +217,7 @@ FunctionEnd Function GetParameters ${GetOptions} $CMDLINE "/server" $SERVERIP_VALUE ${If} $SERVERIP_VALUE == "" - StrCpy $SERVERIP_VALUE "192.168.2.10" + StrCpy $SERVERIP_VALUE "192.168.2.1:8443" ${EndIf} FunctionEnd @@ -226,10 +226,12 @@ LangString PARAMS_TITLE ${LANG_ENGLISH} "Setup parameters" LangString PARAMS_TITLE ${LANG_SPANISH} "Parametros de configuracion" LangString PARAMS_TITLE ${LANG_FRENCH} "Parametres de configuration" LangString PARAMS_TITLE ${LANG_GERMAN} "Setup-Parameter" -LangString SERVER_LABEL ${LANG_ENGLISH} "OpenGnsys Server IP Address" -LangString SERVER_LABEL ${LANG_SPANISH} "Direccion IP del Servidor OpenGnsys" -LangString SERVER_LABEL ${LANG_FRENCH} "Adresse IP du Serveur OpenGnsys" -LangString SERVER_LABEL ${LANG_GERMAN} "OpenGnsys-Server-IP-Adresse" + +LangString SERVER_LABEL ${LANG_ENGLISH} "OpenGnsys Server IP Address and port (eg. 192.168.98.99:8443)" +LangString SERVER_LABEL ${LANG_SPANISH} "Direccion IP y puerto del Servidor OpenGnsys (p. ej. 192.168.98.99:8443)" +LangString SERVER_LABEL ${LANG_FRENCH} "Adresse IP et port du Serveur OpenGnsys (ex. 192.168.98.99:8443)" +LangString SERVER_LABEL ${LANG_GERMAN} "OpenGnsys Server IP-Adresse und Port (z. B. 192.168.98.99:8443)" + LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)" LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)" LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)" -- 2.40.1 From 250de7a0705c97ecbbe867b46849f0853e3668ff Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 23 Jun 2025 12:26:20 +0200 Subject: [PATCH 2/5] refs #2285 improve failure conditions in EjecutarScript --- src/opengnsys/modules/server/OpenGnSys/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/opengnsys/modules/server/OpenGnSys/__init__.py b/src/opengnsys/modules/server/OpenGnSys/__init__.py index 438d50a..5253f3f 100644 --- a/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -358,7 +358,14 @@ class OpenGnSysWorker(ServerWorker): """ logger.debug('Processing script request') # Decoding script - script = urllib.parse.unquote(base64.b64decode(post_params.get('script')).decode('utf-8')) + param_script = post_params.get('script') + if not param_script: + return {'op': 'error', 'err': 'Required parameter "script" is missing or empty'} + try: + b64decoded = base64.b64decode (param_script) + except Exception as e: + return {'op': 'error', 'err': f'Failed to decode base64: {e}'} + script = urllib.parse.unquote (b64decoded.decode ('utf-8')) logger.debug('received script "{}"'.format(script)) if post_params.get('client', 'false') == 'false': -- 2.40.1 From 22f7ce0bb9f40fe8a01982869fdf698dd707ce96 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 23 Jun 2025 12:27:03 +0200 Subject: [PATCH 3/5] refs #2257 rename some endpoints --- src/opengnsys/modules/server/OpenGnSys/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/opengnsys/modules/server/OpenGnSys/__init__.py b/src/opengnsys/modules/server/OpenGnSys/__init__.py index 5253f3f..eb6e1a4 100644 --- a/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -112,7 +112,7 @@ class OpenGnSysWorker(ServerWorker): "iph": self.interface.ip, "timestamp": int (time.time()), } - logger.debug (f'about to send ping ({body})') + #logger.debug (f'about to send ping ({body})') self.REST.sendMessage ('clients/status/webhook', body) def onActivation(self): @@ -308,7 +308,7 @@ class OpenGnSysWorker(ServerWorker): @execution_level('halt') @check_secret - def process_reboot(self, path, get_params, post_params, server): + def process_Reiniciar(self, path, get_params, post_params, server): """ Launches a system reboot operation :param path: @@ -327,7 +327,7 @@ class OpenGnSysWorker(ServerWorker): @execution_level('halt') @check_secret - def process_poweroff(self, path, get_params, post_params, server): + def process_Apagar(self, path, get_params, post_params, server): """ Launches a system power off operation :param path: @@ -347,7 +347,7 @@ class OpenGnSysWorker(ServerWorker): @execution_level('full') @check_secret - def process_script(self, path, get_params, post_params, server): + def process_EjecutarScript(self, path, get_params, post_params, server): """ Processes an script execution (script should be encoded in base64) :param path: -- 2.40.1 From bb856e5b63afd276636e95ea05cacb51202d7578 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 23 Jun 2025 12:27:45 +0200 Subject: [PATCH 4/5] refs #2281 fix logout on windows --- CHANGELOG.md | 7 +++++++ linux/debian/changelog | 7 +++++++ src/VERSION | 2 +- src/opengnsys/RESTApi.py | 2 +- src/opengnsys/ipc.py | 3 +++ src/opengnsys/linux/OGAgentService.py | 7 +++++++ src/opengnsys/service.py | 10 ---------- src/opengnsys/windows/OGAgentService.py | 7 +++++++ 8 files changed, 33 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25638cd..fb25dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.0.0] - 2025-06-19 + +### Changed + +- Changed the names of some endpoints for consistency between oglive and OS +- Changed label in the windows installer + ## [5.9.0] - 2025-06-16 ### Added diff --git a/linux/debian/changelog b/linux/debian/changelog index cb44f78..638dee5 100644 --- a/linux/debian/changelog +++ b/linux/debian/changelog @@ -1,3 +1,10 @@ +ogagent (6.0.0-1) stable; urgency=medium + + * Unify API methods for poweroff, reboot and run script + * Change label in the windows installer + + -- OpenGnsys developers Fri, 20 Jun 2025 10:03:15 +0200 + ogagent (5.9.0-1) stable; urgency=medium * Add changes for oggit diff --git a/src/VERSION b/src/VERSION index b3d91f9..09b254e 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -5.9.0 +6.0.0 diff --git a/src/opengnsys/RESTApi.py b/src/opengnsys/RESTApi.py index 541ed49..ff21a67 100644 --- a/src/opengnsys/RESTApi.py +++ b/src/opengnsys/RESTApi.py @@ -209,7 +209,7 @@ class REST(object): r.raise_for_status() ct = r.headers['Content-Type'] - if 'application/json' != ct: + if len(ct) < 16 or 'application/json' != ct[0:16]: raise Exception (f'response content-type is not "application/json" but "{ct}"') r = json.loads(r.content) # Using instead of r.json() to make compatible with old requests lib versions except requests.exceptions.RequestException as e: diff --git a/src/opengnsys/ipc.py b/src/opengnsys/ipc.py index d1a61ea..077d6c3 100644 --- a/src/opengnsys/ipc.py +++ b/src/opengnsys/ipc.py @@ -165,6 +165,9 @@ class ClientProcessor(threading.Thread): logger.debug('Got invalid message from request: {}, state: {}'.format(buf, state)) except socket.error as e: # If no data is present, no problem at all, pass to check messages + if '[WinError 10054]' in str(e): + ## windows: client disconnected + self.running = False pass except Exception as e: tb = traceback.format_exc() diff --git a/src/opengnsys/linux/OGAgentService.py b/src/opengnsys/linux/OGAgentService.py index 76bfbb8..a9cd75c 100755 --- a/src/opengnsys/linux/OGAgentService.py +++ b/src/opengnsys/linux/OGAgentService.py @@ -71,6 +71,13 @@ class OGAgentSvc(Daemon, CommonService): # example try: while self.isAlive: + client_died=False + if os.path.exists ('/tmp/ogagentuser_died'): + os.unlink ('/tmp/ogagentuser_died') + client_died=True + if client_died: + self.notifyLogout (b'') + # In milliseconds, will break self.doWait(1000) except (KeyboardInterrupt, SystemExit) as e: diff --git a/src/opengnsys/service.py b/src/opengnsys/service.py index 7b4b969..f9b4292 100644 --- a/src/opengnsys/service.py +++ b/src/opengnsys/service.py @@ -198,16 +198,6 @@ class CommonService(object): Invoked to wait a bit CAN be OVERRIDDEN """ - client_died=False - if os.path.exists ('/windows/temp/ogagentuser_died'): - os.unlink ('/windows/temp/ogagentuser_died') - client_died=True - elif os.path.exists ('/tmp/ogagentuser_died'): - os.unlink ('/tmp/ogagentuser_died') - client_died=True - if client_died: - self.notifyLogout (b'') - time.sleep(float(miliseconds) / 1000) def notifyStop(self): diff --git a/src/opengnsys/windows/OGAgentService.py b/src/opengnsys/windows/OGAgentService.py index d42c144..7529b38 100644 --- a/src/opengnsys/windows/OGAgentService.py +++ b/src/opengnsys/windows/OGAgentService.py @@ -106,6 +106,13 @@ class OGAgentSvc(win32serviceutil.ServiceFramework, CommonService): # ********************* try: while self.isAlive: + client_died=False + if os.path.exists ('/windows/temp/ogagentuser_died'): + os.unlink ('/windows/temp/ogagentuser_died') + client_died=True + if client_died: + self.notifyLogout (b'') + # Pumps & processes any waiting messages pythoncom.PumpWaitingMessages() win32event.WaitForSingleObject(self.hWaitStop, 1000) -- 2.40.1 From 7be441ca998343f48e4821854c492639ccbe8b48 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 23 Jun 2025 12:37:42 +0200 Subject: [PATCH 5/5] refs #2281 last commit broke linux--fix --- src/cfg/ogagent.cfg | 2 +- src/opengnsys/linux/OGAgentService.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cfg/ogagent.cfg b/src/cfg/ogagent.cfg index 02ca7ca..ef64871 100644 --- a/src/cfg/ogagent.cfg +++ b/src/cfg/ogagent.cfg @@ -7,7 +7,7 @@ port=8000 #path=test_modules/server,more_modules/server # Remote OpenGnsys Service -remote=https://192.168.2.1/opengnsys/rest +remote=https://192.168.2.1:8443/opengnsys/rest # Alternate OpenGnsys Service (comment out to enable this option) #altremote=https://10.0.2.2/opengnsys/rest diff --git a/src/opengnsys/linux/OGAgentService.py b/src/opengnsys/linux/OGAgentService.py index a9cd75c..c1962a0 100755 --- a/src/opengnsys/linux/OGAgentService.py +++ b/src/opengnsys/linux/OGAgentService.py @@ -39,6 +39,7 @@ from opengnsys.log import logger from opengnsys.linux.daemon import Daemon +import os import sys import signal import json -- 2.40.1