From afa06383f692fb5f347f895774a5cf0e2c49f53d Mon Sep 17 00:00:00 2001 From: afabiani Date: Wed, 19 Oct 2022 16:11:05 +0200 Subject: [PATCH] [Hardening] Avoid "backup.py" failing while trying to set "w" perms on the GeoServer catalog file (cherry picked from commit bc8b4323f84a488273115082e799cbbb94cafb6d) --- geonode/br/management/commands/backup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/geonode/br/management/commands/backup.py b/geonode/br/management/commands/backup.py index 29332db79a2..e36a7895867 100644 --- a/geonode/br/management/commands/backup.py +++ b/geonode/br/management/commands/backup.py @@ -378,10 +378,13 @@ def create_geoserver_backup(self, config, settings, target_folder, ignore_errors if gs_bk_exec_status == 'FAILED': raise ValueError(error_backup.format(url, r.status_code, r.text)) _permissions = 0o777 - os.chmod(geoserver_bk_file, _permissions) - status = os.stat(geoserver_bk_file) - if oct(status.st_mode & 0o777) != str(oct(_permissions)): - raise Exception(f"Could not update permissions of {geoserver_bk_file}") + try: + os.chmod(geoserver_bk_file, _permissions) + status = os.stat(geoserver_bk_file) + if oct(status.st_mode & 0o777) != str(oct(_permissions)): + raise Exception(f"Could not update permissions of {geoserver_bk_file}") + except Exception as e: + logger.warning(e) else: raise ValueError(error_backup.format(url, r.status_code, r.text))